aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dsa
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2016-06-20 13:14:09 -0400
committerDavid S. Miller <davem@davemloft.net>2016-06-21 03:58:30 -0400
commitcaac8545c861f2e78ae2565de31b573739b4034b (patch)
tree8cad9d51033709b6a31248074f31f1cfd85cfee2 /drivers/net/dsa
parentbc46a3d57cf7715d76eef8ea822c763cd271aacf (diff)
net: dsa: mv88e6xxx: pass compatible info
After allocating the chip structure, pass it a compatible info pointer. The compatible info structure will be used later to describe how to access the switch registers and where to read the switch ID. For the standard MDIO probe, get it from the device node data. For the legacy DSA driver probing, pass it the 88E6085 info. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa')
-rw-r--r--drivers/net/dsa/mv88e6xxx.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
index de92add7f9a6..cadd1e388836 100644
--- a/drivers/net/dsa/mv88e6xxx.c
+++ b/drivers/net/dsa/mv88e6xxx.c
@@ -21,6 +21,7 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/mdio.h> 22#include <linux/mdio.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/of_device.h>
24#include <linux/of_mdio.h> 25#include <linux/of_mdio.h>
25#include <linux/netdevice.h> 26#include <linux/netdevice.h>
26#include <linux/gpio/consumer.h> 27#include <linux/gpio/consumer.h>
@@ -3617,6 +3618,7 @@ static int mv88e6xxx_detect(struct mv88e6xxx_priv_state *ps)
3617 if (!info) 3618 if (!info)
3618 return -ENODEV; 3619 return -ENODEV;
3619 3620
3621 /* Update the compatible info with the probed one */
3620 ps->info = info; 3622 ps->info = info;
3621 3623
3622 dev_info(ps->dev, "switch 0x%x detected: %s, revision %u\n", 3624 dev_info(ps->dev, "switch 0x%x detected: %s, revision %u\n",
@@ -3669,6 +3671,9 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3669 if (!ps) 3671 if (!ps)
3670 return NULL; 3672 return NULL;
3671 3673
3674 /* Legacy SMI probing will only support chips similar to 88E6085 */
3675 ps->info = &mv88e6xxx_table[MV88E6085];
3676
3672 err = mv88e6xxx_smi_init(ps, bus, sw_addr); 3677 err = mv88e6xxx_smi_init(ps, bus, sw_addr);
3673 if (err) 3678 if (err)
3674 goto free; 3679 goto free;
@@ -3754,14 +3759,21 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
3754{ 3759{
3755 struct device *dev = &mdiodev->dev; 3760 struct device *dev = &mdiodev->dev;
3756 struct device_node *np = dev->of_node; 3761 struct device_node *np = dev->of_node;
3762 const struct mv88e6xxx_info *compat_info;
3757 struct mv88e6xxx_priv_state *ps; 3763 struct mv88e6xxx_priv_state *ps;
3758 u32 eeprom_len; 3764 u32 eeprom_len;
3759 int err; 3765 int err;
3760 3766
3767 compat_info = of_device_get_match_data(dev);
3768 if (!compat_info)
3769 return -EINVAL;
3770
3761 ps = mv88e6xxx_alloc_chip(dev); 3771 ps = mv88e6xxx_alloc_chip(dev);
3762 if (!ps) 3772 if (!ps)
3763 return -ENOMEM; 3773 return -ENOMEM;
3764 3774
3775 ps->info = compat_info;
3776
3765 err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr); 3777 err = mv88e6xxx_smi_init(ps, mdiodev->bus, mdiodev->addr);
3766 if (err) 3778 if (err)
3767 return err; 3779 return err;
@@ -3801,7 +3813,10 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
3801} 3813}
3802 3814
3803static const struct of_device_id mv88e6xxx_of_match[] = { 3815static const struct of_device_id mv88e6xxx_of_match[] = {
3804 { .compatible = "marvell,mv88e6085" }, 3816 {
3817 .compatible = "marvell,mv88e6085",
3818 .data = &mv88e6xxx_table[MV88E6085],
3819 },
3805 { /* sentinel */ }, 3820 { /* sentinel */ },
3806}; 3821};
3807 3822