Skip to content

Commit be9bd8d

Browse files
author
Paolo Abeni
committed
Merge branch 'net-dsa-mv88e6xxx-add-amethyst-specific-smi-gpio-function'
Robert Marko says: ==================== net: dsa: mv88e6xxx: add Amethyst specific SMI GPIO function Amethyst family (MV88E6191X/6193X/6393X) has a simplified SMI GPIO setting via the Scratch and Misc register so it requires family specific function. In the v1 review, Andrew pointed out that it would make sense to rename the existing mv88e6xxx_g2_scratch_gpio_set_smi as it only works on the MV6390 family. Changes in v2: * Add rename of mv88e6xxx_g2_scratch_gpio_set_smi to mv88e6390_g2_scratch_gpio_set_smi ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 67ea41d + e3ab326 commit be9bd8d

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
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 = mv88e6xxx_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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ extern const struct mv88e6xxx_avb_ops mv88e6390_avb_ops;
378378

379379
extern const struct mv88e6xxx_gpio_ops mv88e6352_gpio_ops;
380380

381-
int mv88e6xxx_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
381+
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: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,15 @@ const struct mv88e6xxx_gpio_ops mv88e6352_gpio_ops = {
240240
};
241241

242242
/**
243-
* mv88e6xxx_g2_scratch_gpio_set_smi - set gpio muxing for external smi
243+
* mv88e6390_g2_scratch_gpio_set_smi - set gpio muxing for external smi
244244
* @chip: chip private data
245245
* @external: set mux for external smi, or free for gpio usage
246246
*
247247
* Some mv88e6xxx models have GPIO pins that may be configured as
248248
* an external SMI interface, or they may be made free for other
249249
* GPIO uses.
250250
*/
251-
int mv88e6xxx_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
251+
int mv88e6390_g2_scratch_gpio_set_smi(struct mv88e6xxx_chip *chip,
252252
bool external)
253253
{
254254
int misc_cfg = MV88E6352_G2_SCRATCH_MISC_CFG;
@@ -290,6 +290,37 @@ int mv88e6xxx_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)