Commit b4d081df authored by David S. Miller's avatar David S. Miller

Merge branch 'Convert-mv88e6060-to-mdio-device'

Andrew Lunn says:

====================
Convert mv88e6060 to mdio device

This patchset builds upon the previous patches to mv88e6060. It adds
support for probing the switch as an MDIO device and then removes the
legacy probe method. Since this is the last device supporting legacy
probe, this allows legacy probe to be removed, originally planned to
be removed in 4.17, but took a bit longer.

This change to the mv88e6060 is more risky than the previous
patchset. Some attempts to test it have been made, by hacking the
driver to match on an mv88e6352 so that it probes. These changes are
all about probe, so it is a reasonable test. But testing on a real
mv88e6060 would be great.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 49259301 c1b0f9fa
Distributed Switch Architecture Device Tree Bindings Distributed Switch Architecture Device Tree Bindings
---------------------------------------------------- ----------------------------------------------------
Two bindings exist, one of which has been deprecated due to
limitations.
Current Binding
---------------
Switches are true Linux devices and can be probed by any means. Once Switches are true Linux devices and can be probed by any means. Once
probed, they register to the DSA framework, passing a node probed, they register to the DSA framework, passing a node
pointer. This node is expected to fulfil the following binding, and pointer. This node is expected to fulfil the following binding, and
...@@ -262,152 +256,3 @@ linked into one DSA cluster. ...@@ -262,152 +256,3 @@ linked into one DSA cluster.
}; };
}; };
}; };
Deprecated Binding
------------------
The deprecated binding makes use of a platform device to represent the
switches. The switches themselves are not Linux devices, and make use
of an MDIO bus for management.
Required properties:
- compatible : Should be "marvell,dsa"
- #address-cells : Must be 2, first cell is the address on the MDIO bus
and second cell is the address in the switch tree.
Second cell is used only when cascading/chaining.
- #size-cells : Must be 0
- dsa,ethernet : Should be a phandle to a valid Ethernet device node
- dsa,mii-bus : Should be a phandle to a valid MDIO bus device node
Optional properties:
- interrupts : property with a value describing the switch
interrupt number (not supported by the driver)
A DSA node can contain multiple switch chips which are therefore child nodes of
the parent DSA node. The maximum number of allowed child nodes is 4
(DSA_MAX_SWITCHES).
Each of these switch child nodes should have the following required properties:
- reg : Contains two fields. The first one describes the
address on the MII bus. The second is the switch
number that must be unique in cascaded configurations
- #address-cells : Must be 1
- #size-cells : Must be 0
A switch child node has the following optional property:
- eeprom-length : Set to the length of an EEPROM connected to the
switch. Must be set if the switch can not detect
the presence and/or size of a connected EEPROM,
otherwise optional.
A switch may have multiple "port" children nodes
Each port children node must have the following mandatory properties:
- reg : Describes the port address in the switch
- label : Describes the label associated with this port, special
labels are "cpu" to indicate a CPU port and "dsa" to
indicate an uplink/downlink port.
Note that a port labelled "dsa" will imply checking for the uplink phandle
described below.
Optional property:
- link : Should be a list of phandles to another switch's DSA port.
This property is only used when switches are being
chained/cascaded together. This port is used as outgoing port
towards the phandle port, which can be more than one hop away.
- phy-handle : Phandle to a PHY on an external MDIO bus, not the
switch internal one. See
Documentation/devicetree/bindings/net/ethernet.txt
for details.
- phy-mode : String representing the connection to the designated
PHY node specified by the 'phy-handle' property. See
Documentation/devicetree/bindings/net/ethernet.txt
for details.
- mii-bus : Should be a phandle to a valid MDIO bus device node.
This mii-bus will be used in preference to the
global dsa,mii-bus defined above, for this switch.
Optional subnodes:
- fixed-link : Fixed-link subnode describing a link to a non-MDIO
managed entity. See
Documentation/devicetree/bindings/net/fixed-link.txt
for details.
Example:
dsa@0 {
compatible = "marvell,dsa";
#address-cells = <2>;
#size-cells = <0>;
interrupts = <10>;
dsa,ethernet = <&ethernet0>;
dsa,mii-bus = <&mii_bus0>;
switch@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <16 0>; /* MDIO address 16, switch 0 in tree */
port@0 {
reg = <0>;
label = "lan1";
phy-handle = <&phy0>;
};
port@1 {
reg = <1>;
label = "lan2";
};
port@5 {
reg = <5>;
label = "cpu";
};
switch0port6: port@6 {
reg = <6>;
label = "dsa";
link = <&switch1port0
&switch2port0>;
};
};
switch@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <17 1>; /* MDIO address 17, switch 1 in tree */
mii-bus = <&mii_bus1>;
reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
switch1port0: port@0 {
reg = <0>;
label = "dsa";
link = <&switch0port6>;
};
switch1port1: port@1 {
reg = <1>;
label = "dsa";
link = <&switch2port1>;
};
};
switch@2 {
#address-cells = <1>;
#size-cells = <0>;
reg = <18 2>; /* MDIO address 18, switch 2 in tree */
mii-bus = <&mii_bus1>;
switch2port0: port@0 {
reg = <0>;
label = "dsa";
link = <&switch1port1
&switch0port6>;
};
};
};
...@@ -41,7 +41,7 @@ config NET_DSA_MT7530 ...@@ -41,7 +41,7 @@ config NET_DSA_MT7530
config NET_DSA_MV88E6060 config NET_DSA_MV88E6060
tristate "Marvell 88E6060 ethernet switch chip support" tristate "Marvell 88E6060 ethernet switch chip support"
depends on NET_DSA && NET_DSA_LEGACY depends on NET_DSA
select NET_DSA_TAG_TRAILER select NET_DSA_TAG_TRAILER
---help--- ---help---
This enables support for the Marvell 88E6060 ethernet switch This enables support for the Marvell 88E6060 ethernet switch
......
...@@ -48,27 +48,6 @@ static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds, ...@@ -48,27 +48,6 @@ static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds,
return DSA_TAG_PROTO_TRAILER; return DSA_TAG_PROTO_TRAILER;
} }
static const char *mv88e6060_drv_probe(struct device *dsa_dev,
struct device *host_dev, int sw_addr,
void **_priv)
{
struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
struct mv88e6060_priv *priv;
const char *name;
name = mv88e6060_get_name(bus, sw_addr);
if (name) {
priv = devm_kzalloc(dsa_dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return NULL;
*_priv = priv;
priv->bus = bus;
priv->sw_addr = sw_addr;
}
return name;
}
static int mv88e6060_switch_reset(struct mv88e6060_priv *priv) static int mv88e6060_switch_reset(struct mv88e6060_priv *priv)
{ {
int i; int i;
...@@ -266,28 +245,68 @@ mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val) ...@@ -266,28 +245,68 @@ mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
static const struct dsa_switch_ops mv88e6060_switch_ops = { static const struct dsa_switch_ops mv88e6060_switch_ops = {
.get_tag_protocol = mv88e6060_get_tag_protocol, .get_tag_protocol = mv88e6060_get_tag_protocol,
.probe = mv88e6060_drv_probe,
.setup = mv88e6060_setup, .setup = mv88e6060_setup,
.phy_read = mv88e6060_phy_read, .phy_read = mv88e6060_phy_read,
.phy_write = mv88e6060_phy_write, .phy_write = mv88e6060_phy_write,
}; };
static struct dsa_switch_driver mv88e6060_switch_drv = { static int mv88e6060_probe(struct mdio_device *mdiodev)
.ops = &mv88e6060_switch_ops,
};
static int __init mv88e6060_init(void)
{ {
register_switch_driver(&mv88e6060_switch_drv); struct device *dev = &mdiodev->dev;
return 0; struct mv88e6060_priv *priv;
struct dsa_switch *ds;
const char *name;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->bus = mdiodev->bus;
priv->sw_addr = mdiodev->addr;
name = mv88e6060_get_name(priv->bus, priv->sw_addr);
if (!name)
return -ENODEV;
dev_info(dev, "switch %s detected\n", name);
ds = dsa_switch_alloc(dev, MV88E6060_PORTS);
if (!ds)
return -ENOMEM;
ds->priv = priv;
ds->dev = dev;
ds->ops = &mv88e6060_switch_ops;
dev_set_drvdata(dev, ds);
return dsa_register_switch(ds);
} }
module_init(mv88e6060_init);
static void __exit mv88e6060_cleanup(void) static void mv88e6060_remove(struct mdio_device *mdiodev)
{ {
unregister_switch_driver(&mv88e6060_switch_drv); struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
dsa_unregister_switch(ds);
} }
module_exit(mv88e6060_cleanup);
static const struct of_device_id mv88e6060_of_match[] = {
{
.compatible = "marvell,mv88e6060",
},
{ /* sentinel */ },
};
static struct mdio_driver mv88e6060_driver = {
.probe = mv88e6060_probe,
.remove = mv88e6060_remove,
.mdiodrv.driver = {
.name = "mv88e6060",
.of_match_table = mv88e6060_of_match,
},
};
mdio_module_driver(mv88e6060_driver);
MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
MODULE_DESCRIPTION("Driver for Marvell 88E6060 ethernet switch chip"); MODULE_DESCRIPTION("Driver for Marvell 88E6060 ethernet switch chip");
......
...@@ -318,15 +318,6 @@ static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) ...@@ -318,15 +318,6 @@ static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data); bool is_static, void *data);
struct dsa_switch_ops { struct dsa_switch_ops {
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
/*
* Legacy probing.
*/
const char *(*probe)(struct device *dsa_dev,
struct device *host_dev, int sw_addr,
void **priv);
#endif
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds, enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
int port); int port);
...@@ -516,20 +507,6 @@ struct dsa_switch_driver { ...@@ -516,20 +507,6 @@ struct dsa_switch_driver {
const struct dsa_switch_ops *ops; const struct dsa_switch_ops *ops;
}; };
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
/* Legacy driver registration */
void register_switch_driver(struct dsa_switch_driver *type);
void unregister_switch_driver(struct dsa_switch_driver *type);
struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev);
#else
static inline void register_switch_driver(struct dsa_switch_driver *type) { }
static inline void unregister_switch_driver(struct dsa_switch_driver *type) { }
static inline struct mii_bus *dsa_host_dev_to_mii_bus(struct device *dev)
{
return NULL;
}
#endif
struct net_device *dsa_dev_to_net_device(struct device *dev); struct net_device *dsa_dev_to_net_device(struct device *dev);
/* Keep inline for faster access in hot path */ /* Keep inline for faster access in hot path */
......
...@@ -17,15 +17,6 @@ menuconfig NET_DSA ...@@ -17,15 +17,6 @@ menuconfig NET_DSA
if NET_DSA if NET_DSA
config NET_DSA_LEGACY
bool "Support for older platform device and Device Tree registration"
default y
---help---
Say Y if you want to enable support for the older platform device and
deprecated Device Tree binding registration.
This feature is scheduled for removal in 4.17.
config NET_DSA_TAG_BRCM_COMMON config NET_DSA_TAG_BRCM_COMMON
tristate tristate
default n default n
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# the core # the core
obj-$(CONFIG_NET_DSA) += dsa_core.o obj-$(CONFIG_NET_DSA) += dsa_core.o
dsa_core-y += dsa.o dsa2.o master.o port.o slave.o switch.o dsa_core-y += dsa.o dsa2.o master.o port.o slave.o switch.o
dsa_core-$(CONFIG_NET_DSA_LEGACY) += legacy.o
# tagging formats # tagging formats
obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o
......
...@@ -346,10 +346,6 @@ static int __init dsa_init_module(void) ...@@ -346,10 +346,6 @@ static int __init dsa_init_module(void)
if (rc) if (rc)
return rc; return rc;
rc = dsa_legacy_register();
if (rc)
return rc;
dev_add_pack(&dsa_pack_type); dev_add_pack(&dsa_pack_type);
dsa_tag_driver_register(&DSA_TAG_DRIVER_NAME(none_ops), dsa_tag_driver_register(&DSA_TAG_DRIVER_NAME(none_ops),
...@@ -365,7 +361,6 @@ static void __exit dsa_cleanup_module(void) ...@@ -365,7 +361,6 @@ static void __exit dsa_cleanup_module(void)
dsa_slave_unregister_notifier(); dsa_slave_unregister_notifier();
dev_remove_pack(&dsa_pack_type); dev_remove_pack(&dsa_pack_type);
dsa_legacy_unregister();
destroy_workqueue(dsa_owq); destroy_workqueue(dsa_owq);
} }
module_exit(dsa_cleanup_module); module_exit(dsa_cleanup_module);
......
...@@ -90,18 +90,6 @@ void dsa_tag_driver_put(const struct dsa_device_ops *ops); ...@@ -90,18 +90,6 @@ void dsa_tag_driver_put(const struct dsa_device_ops *ops);
bool dsa_schedule_work(struct work_struct *work); bool dsa_schedule_work(struct work_struct *work);
const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops); const char *dsa_tag_protocol_to_str(const struct dsa_device_ops *ops);
/* legacy.c */
#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
int dsa_legacy_register(void);
void dsa_legacy_unregister(void);
#else
static inline int dsa_legacy_register(void)
{
return 0;
}
static inline void dsa_legacy_unregister(void) { }
#endif
int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev, struct net_device *dev,
const unsigned char *addr, u16 vid, const unsigned char *addr, u16 vid,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment