net: dsa: mv88e6xxx: add mv88e6352_g2_scratch_port_has_serdes()
Read the hardware configuration to determine which port is attached to the serdes. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0947644332
commit
62001548a6
@ -299,6 +299,8 @@
|
||||
#define MV88E6352_G2_SCRATCH_CONFIG_DATA1_NO_CPU BIT(2)
|
||||
#define MV88E6352_G2_SCRATCH_CONFIG_DATA2 0x72
|
||||
#define MV88E6352_G2_SCRATCH_CONFIG_DATA2_P0_MODE_MASK 0x3
|
||||
#define MV88E6352_G2_SCRATCH_CONFIG_DATA3 0x73
|
||||
#define MV88E6352_G2_SCRATCH_CONFIG_DATA3_S_SEL BIT(1)
|
||||
|
||||
#define MV88E6352_G2_SCRATCH_GPIO_PCTL_GPIO 0
|
||||
#define MV88E6352_G2_SCRATCH_GPIO_PCTL_TRIG 1
|
||||
@ -370,6 +372,7 @@ extern const struct mv88e6xxx_gpio_ops mv88e6352_gpio_ops;
|
||||
|
||||
int mv88e6xxx_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
|
||||
bool external);
|
||||
int mv88e6352_g2_scratch_port_has_serdes(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6xxx_g2_atu_stats_set(struct mv88e6xxx_chip *chip, u16 kind, u16 bin);
|
||||
int mv88e6xxx_g2_atu_stats_get(struct mv88e6xxx_chip *chip, u16 *stats);
|
||||
|
||||
|
@ -289,3 +289,31 @@ int mv88e6xxx_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
|
||||
|
||||
return mv88e6xxx_g2_scratch_write(chip, misc_cfg, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
u8 config3, p;
|
||||
int err;
|
||||
|
||||
err = mv88e6xxx_g2_scratch_read(chip, MV88E6352_G2_SCRATCH_CONFIG_DATA3,
|
||||
&config3);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (config3 & MV88E6352_G2_SCRATCH_CONFIG_DATA3_S_SEL)
|
||||
p = 5;
|
||||
else
|
||||
p = 4;
|
||||
|
||||
return port == p;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user