Skip to content

Commit e3ab326

Browse files
robimarkoPaolo Abeni
authored andcommitted
net: dsa: mv88e6xxx: add Amethyst specific SMI GPIO function
The existing mv88e6390_g2_scratch_gpio_set_smi() cannot be used on the 88E6393X as it requires certain P0_MODE, it also checks the CPU mode as it impacts the bit setting value. This is all irrelevant for Amethyst (MV88E6191X/6193X/6393X) as only the default value of the SMI_PHY Config bit is set to CPU_MGD bootstrap pin value but it can be changed without restrictions so that GPIO pins 9 and 10 are used as SMI pins. So, introduce Amethyst specific function and call that if the Amethyst family wants to setup the external PHY. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Robert Marko <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 5c5b0c4 commit e3ab326

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

drivers/net/dsa/mv88e6xxx/chip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3712,7 +3712,10 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
37123712

37133713
if (external) {
37143714
mv88e6xxx_reg_lock(chip);
3715-
err = mv88e6390_g2_scratch_gpio_set_smi(chip, true);
3715+
if (chip->info->family == MV88E6XXX_FAMILY_6393)
3716+
err = mv88e6393x_g2_scratch_gpio_set_smi(chip, true);
3717+
else
3718+
err = mv88e6390_g2_scratch_gpio_set_smi(chip, true);
37163719
mv88e6xxx_reg_unlock(chip);
37173720

37183721
if (err)

drivers/net/dsa/mv88e6xxx/global2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ extern const struct mv88e6xxx_gpio_ops mv88e6352_gpio_ops;
380380

381381
int mv88e6390_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
382382
bool external);
383+
int mv88e6393x_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
384+
bool external);
383385
int mv88e6352_g2_scratch_port_has_serdes(struct mv88e6xxx_chip *chip, int port);
384386
int mv88e6xxx_g2_atu_stats_set(struct mv88e6xxx_chip *chip, u16 kind, u16 bin);
385387
int mv88e6xxx_g2_atu_stats_get(struct mv88e6xxx_chip *chip, u16 *stats);

drivers/net/dsa/mv88e6xxx/global2_scratch.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,37 @@ int mv88e6390_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
290290
return mv88e6xxx_g2_scratch_write(chip, misc_cfg, val);
291291
}
292292

293+
/**
294+
* mv88e6393x_g2_scratch_gpio_set_smi - set gpio muxing for external smi
295+
* @chip: chip private data
296+
* @external: set mux for external smi, or free for gpio usage
297+
*
298+
* MV88E6191X/6193X/6393X GPIO pins 9 and 10 can be configured as an
299+
* external SMI interface or as regular GPIO-s.
300+
*
301+
* They however have a different register layout then the existing
302+
* function.
303+
*/
304+
305+
int mv88e6393x_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
306+
bool external)
307+
{
308+
int misc_cfg = MV88E6352_G2_SCRATCH_MISC_CFG;
309+
int err;
310+
u8 val;
311+
312+
err = mv88e6xxx_g2_scratch_read(chip, misc_cfg, &val);
313+
if (err)
314+
return err;
315+
316+
if (external)
317+
val &= ~MV88E6352_G2_SCRATCH_MISC_CFG_NORMALSMI;
318+
else
319+
val |= MV88E6352_G2_SCRATCH_MISC_CFG_NORMALSMI;
320+
321+
return mv88e6xxx_g2_scratch_write(chip, misc_cfg, val);
322+
}
323+
293324
/**
294325
* mv88e6352_g2_scratch_port_has_serdes - indicate if a port can have a serdes
295326
* @chip: chip private data

0 commit comments

Comments
 (0)