// SPDX-License-Identifier: GPL-2.0-or-later /* * Marvell 88E6xxx Switch Global 2 Scratch & Misc Registers support * * Copyright (c) 2008 Marvell Semiconductor * * Copyright (c) 2017 National Instruments * Brandon Streiff <[email protected]> */ #include "chip.h" #include "global2.h" /* Offset 0x1A: Scratch and Misc. Register */ static int mv88e6xxx_g2_scratch_read(struct mv88e6xxx_chip *chip, int reg, u8 *data) { … } static int mv88e6xxx_g2_scratch_write(struct mv88e6xxx_chip *chip, int reg, u8 data) { … } /** * mv88e6xxx_g2_scratch_get_bit - get a bit * @chip: chip private data * @base_reg: base of scratch bits * @offset: index of bit within the register * @set: is bit set? */ static int mv88e6xxx_g2_scratch_get_bit(struct mv88e6xxx_chip *chip, int base_reg, unsigned int offset, int *set) { … } /** * mv88e6xxx_g2_scratch_set_bit - set (or clear) a bit * @chip: chip private data * @base_reg: base of scratch bits * @offset: index of bit within the register * @set: should this bit be set? * * Helper function for dealing with the direction and data registers. */ static int mv88e6xxx_g2_scratch_set_bit(struct mv88e6xxx_chip *chip, int base_reg, unsigned int offset, int set) { … } /** * mv88e6352_g2_scratch_gpio_get_data - get data on gpio pin * @chip: chip private data * @pin: gpio index * * Return: 0 for low, 1 for high, negative error */ static int mv88e6352_g2_scratch_gpio_get_data(struct mv88e6xxx_chip *chip, unsigned int pin) { … } /** * mv88e6352_g2_scratch_gpio_set_data - set data on gpio pin * @chip: chip private data * @pin: gpio index * @value: value to set */ static int mv88e6352_g2_scratch_gpio_set_data(struct mv88e6xxx_chip *chip, unsigned int pin, int value) { … } /** * mv88e6352_g2_scratch_gpio_get_dir - get direction of gpio pin * @chip: chip private data * @pin: gpio index * * Return: 0 for output, 1 for input. */ static int mv88e6352_g2_scratch_gpio_get_dir(struct mv88e6xxx_chip *chip, unsigned int pin) { … } /** * mv88e6352_g2_scratch_gpio_set_dir - set direction of gpio pin * @chip: chip private data * @pin: gpio index * @input: should the gpio be an input, or an output? */ static int mv88e6352_g2_scratch_gpio_set_dir(struct mv88e6xxx_chip *chip, unsigned int pin, bool input) { … } /** * mv88e6352_g2_scratch_gpio_get_pctl - get pin control setting * @chip: chip private data * @pin: gpio index * @func: function number * * Note that the function numbers themselves may vary by chipset. */ static int mv88e6352_g2_scratch_gpio_get_pctl(struct mv88e6xxx_chip *chip, unsigned int pin, int *func) { … } /** * mv88e6352_g2_scratch_gpio_set_pctl - set pin control setting * @chip: chip private data * @pin: gpio index * @func: function number */ static int mv88e6352_g2_scratch_gpio_set_pctl(struct mv88e6xxx_chip *chip, unsigned int pin, int func) { … } const struct mv88e6xxx_gpio_ops mv88e6352_gpio_ops = …; /** * mv88e6390_g2_scratch_gpio_set_smi - set gpio muxing for external smi * @chip: chip private data * @external: set mux for external smi, or free for gpio usage * * Some mv88e6xxx models have GPIO pins that may be configured as * an external SMI interface, or they may be made free for other * GPIO uses. */ int mv88e6390_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip, bool external) { … } /** * mv88e6393x_g2_scratch_gpio_set_smi - set gpio muxing for external smi * @chip: chip private data * @external: set mux for external smi, or free for gpio usage * * MV88E6191X/6193X/6393X GPIO pins 9 and 10 can be configured as an * external SMI interface or as regular GPIO-s. * * They however have a different register layout then the existing * function. */ int mv88e6393x_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip, bool external) { … } /** * mv88e6352_g2_scratch_port_has_serdes - indicate if a port can have a serdes * @chip: chip private data * @port: port number to check for serdes * * Indicates whether the port may have a serdes attached according to the * pin strapping. Returns negative error number, 0 if the port is not * configured to have a serdes, and 1 if the port is configured to have a * serdes attached. */ int mv88e6352_g2_scratch_port_has_serdes(struct mv88e6xxx_chip *chip, int port) { … }