123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- From 5313432ca1e1a0677ad7b4f17a7e0186473f47aa Mon Sep 17 00:00:00 2001
- From: Daniel Golle <[email protected]>
- Date: Mon, 3 Apr 2023 02:19:13 +0100
- Subject: [PATCH 12/48] net: dsa: mt7530: introduce separate MDIO driver
- Split MT7530 switch driver into a common part and a part specific
- for MDIO connected switches and multi-chip modules.
- Move MDIO-specific functions to newly introduced mt7530-mdio.c while
- keeping the common parts in mt7530.c.
- Introduce new Kconfig symbol CONFIG_NET_DSA_MT7530_MDIO which is
- implied by CONFIG_NET_DSA_MT7530.
- Signed-off-by: Daniel Golle <[email protected]>
- Reviewed-by: Andrew Lunn <[email protected]>
- Signed-off-by: David S. Miller <[email protected]>
- ---
- MAINTAINERS | 1 +
- drivers/net/dsa/Kconfig | 18 ++-
- drivers/net/dsa/Makefile | 1 +
- drivers/net/dsa/mt7530-mdio.c | 271 ++++++++++++++++++++++++++++++++++
- drivers/net/dsa/mt7530.c | 264 +--------------------------------
- drivers/net/dsa/mt7530.h | 6 +
- 6 files changed, 302 insertions(+), 259 deletions(-)
- create mode 100644 drivers/net/dsa/mt7530-mdio.c
- --- a/MAINTAINERS
- +++ b/MAINTAINERS
- @@ -13069,6 +13069,7 @@ M: Landen Chao <[email protected]
- M: DENG Qingfang <[email protected]>
- L: [email protected]
- S: Maintained
- +F: drivers/net/dsa/mt7530-mdio.c
- F: drivers/net/dsa/mt7530.*
- F: net/dsa/tag_mtk.c
-
- --- a/drivers/net/dsa/Kconfig
- +++ b/drivers/net/dsa/Kconfig
- @@ -34,13 +34,25 @@ config NET_DSA_LANTIQ_GSWIP
- the xrx200 / VR9 SoC.
-
- config NET_DSA_MT7530
- - tristate "MediaTek MT753x and MT7621 Ethernet switch support"
- + tristate "MediaTek MT7530 and MT7531 Ethernet switch support"
- select NET_DSA_TAG_MTK
- + imply NET_DSA_MT7530_MDIO
- + help
- + This enables support for the MediaTek MT7530 and MT7531 Ethernet
- + switch chips. Multi-chip module MT7530 in MT7621AT, MT7621DAT,
- + MT7621ST and MT7623AI SoCs, and built-in switch in MT7988 SoC are
- + supported as well.
- +
- +config NET_DSA_MT7530_MDIO
- + tristate "MediaTek MT7530 MDIO interface driver"
- + depends on NET_DSA_MT7530
- select MEDIATEK_GE_PHY
- select PCS_MTK_LYNXI
- help
- - This enables support for the MediaTek MT7530, MT7531, and MT7621
- - Ethernet switch chips.
- + This enables support for the MediaTek MT7530 and MT7531 switch
- + chips which are connected via MDIO, as well as multi-chip
- + module MT7530 which can be found in the MT7621AT, MT7621DAT,
- + MT7621ST and MT7623AI SoCs.
-
- config NET_DSA_MV88E6060
- tristate "Marvell 88E6060 ethernet switch chip support"
- --- a/drivers/net/dsa/Makefile
- +++ b/drivers/net/dsa/Makefile
- @@ -7,6 +7,7 @@ obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdi
- endif
- obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o
- obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o
- +obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
- obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
- obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o
- obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
- --- /dev/null
- +++ b/drivers/net/dsa/mt7530-mdio.c
- @@ -0,0 +1,271 @@
- +// SPDX-License-Identifier: GPL-2.0-only
- +
- +#include <linux/gpio/consumer.h>
- +#include <linux/mdio.h>
- +#include <linux/module.h>
- +#include <linux/pcs/pcs-mtk-lynxi.h>
- +#include <linux/of_irq.h>
- +#include <linux/of_mdio.h>
- +#include <linux/of_net.h>
- +#include <linux/of_platform.h>
- +#include <linux/regmap.h>
- +#include <linux/reset.h>
- +#include <linux/regulator/consumer.h>
- +#include <net/dsa.h>
- +
- +#include "mt7530.h"
- +
- +static int
- +mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
- +{
- + struct mii_bus *bus = context;
- + u16 page, r, lo, hi;
- + int ret;
- +
- + page = (reg >> 6) & 0x3ff;
- + r = (reg >> 2) & 0xf;
- + lo = val & 0xffff;
- + hi = val >> 16;
- +
- + /* MT7530 uses 31 as the pseudo port */
- + ret = bus->write(bus, 0x1f, 0x1f, page);
- + if (ret < 0)
- + return ret;
- +
- + ret = bus->write(bus, 0x1f, r, lo);
- + if (ret < 0)
- + return ret;
- +
- + ret = bus->write(bus, 0x1f, 0x10, hi);
- + return ret;
- +}
- +
- +static int
- +mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
- +{
- + struct mii_bus *bus = context;
- + u16 page, r, lo, hi;
- + int ret;
- +
- + page = (reg >> 6) & 0x3ff;
- + r = (reg >> 2) & 0xf;
- +
- + /* MT7530 uses 31 as the pseudo port */
- + ret = bus->write(bus, 0x1f, 0x1f, page);
- + if (ret < 0)
- + return ret;
- +
- + lo = bus->read(bus, 0x1f, r);
- + hi = bus->read(bus, 0x1f, 0x10);
- +
- + *val = (hi << 16) | (lo & 0xffff);
- +
- + return 0;
- +}
- +
- +static void
- +mt7530_mdio_regmap_lock(void *mdio_lock)
- +{
- + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
- +}
- +
- +static void
- +mt7530_mdio_regmap_unlock(void *mdio_lock)
- +{
- + mutex_unlock(mdio_lock);
- +}
- +
- +static const struct regmap_bus mt7530_regmap_bus = {
- + .reg_write = mt7530_regmap_write,
- + .reg_read = mt7530_regmap_read,
- +};
- +
- +static int
- +mt7531_create_sgmii(struct mt7530_priv *priv)
- +{
- + struct regmap_config *mt7531_pcs_config[2];
- + struct phylink_pcs *pcs;
- + struct regmap *regmap;
- + int i, ret = 0;
- +
- + for (i = 0; i < 2; i++) {
- + mt7531_pcs_config[i] = devm_kzalloc(priv->dev,
- + sizeof(struct regmap_config),
- + GFP_KERNEL);
- + if (!mt7531_pcs_config[i]) {
- + ret = -ENOMEM;
- + break;
- + }
- +
- + mt7531_pcs_config[i]->name = i ? "port6" : "port5";
- + mt7531_pcs_config[i]->reg_bits = 16;
- + mt7531_pcs_config[i]->val_bits = 32;
- + mt7531_pcs_config[i]->reg_stride = 4;
- + mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
- + mt7531_pcs_config[i]->max_register = 0x17c;
- + mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
- + mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
- + mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
- +
- + regmap = devm_regmap_init(priv->dev,
- + &mt7530_regmap_bus, priv->bus,
- + mt7531_pcs_config[i]);
- + if (IS_ERR(regmap)) {
- + ret = PTR_ERR(regmap);
- + break;
- + }
- + pcs = mtk_pcs_lynxi_create(priv->dev, regmap,
- + MT7531_PHYA_CTRL_SIGNAL3, 0);
- + if (!pcs) {
- + ret = -ENXIO;
- + break;
- + }
- + priv->ports[5 + i].sgmii_pcs = pcs;
- + }
- +
- + if (ret && i)
- + mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs);
- +
- + return ret;
- +}
- +
- +static const struct of_device_id mt7530_of_match[] = {
- + { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
- + { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
- + { .compatible = "mediatek,mt7531", .data = &mt753x_table[ID_MT7531], },
- + { /* sentinel */ },
- +};
- +MODULE_DEVICE_TABLE(of, mt7530_of_match);
- +
- +static int
- +mt7530_probe(struct mdio_device *mdiodev)
- +{
- + static struct regmap_config *regmap_config;
- + struct mt7530_priv *priv;
- + struct device_node *dn;
- + int ret;
- +
- + dn = mdiodev->dev.of_node;
- +
- + priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
- + if (!priv)
- + return -ENOMEM;
- +
- + priv->bus = mdiodev->bus;
- + priv->dev = &mdiodev->dev;
- +
- + ret = mt7530_probe_common(priv);
- + if (ret)
- + return ret;
- +
- + /* Use medatek,mcm property to distinguish hardware type that would
- + * cause a little bit differences on power-on sequence.
- + * Not MCM that indicates switch works as the remote standalone
- + * integrated circuit so the GPIO pin would be used to complete
- + * the reset, otherwise memory-mapped register accessing used
- + * through syscon provides in the case of MCM.
- + */
- + priv->mcm = of_property_read_bool(dn, "mediatek,mcm");
- + if (priv->mcm) {
- + dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n");
- +
- + priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");
- + if (IS_ERR(priv->rstc)) {
- + dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
- + return PTR_ERR(priv->rstc);
- + }
- + } else {
- + priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset",
- + GPIOD_OUT_LOW);
- + if (IS_ERR(priv->reset)) {
- + dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
- + return PTR_ERR(priv->reset);
- + }
- + }
- +
- + if (priv->id == ID_MT7530) {
- + priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
- + if (IS_ERR(priv->core_pwr))
- + return PTR_ERR(priv->core_pwr);
- +
- + priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
- + if (IS_ERR(priv->io_pwr))
- + return PTR_ERR(priv->io_pwr);
- + }
- +
- + regmap_config = devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config),
- + GFP_KERNEL);
- + if (!regmap_config)
- + return -ENOMEM;
- +
- + regmap_config->reg_bits = 16;
- + regmap_config->val_bits = 32;
- + regmap_config->reg_stride = 4;
- + regmap_config->max_register = MT7530_CREV;
- + regmap_config->disable_locking = true;
- + priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
- + priv->bus, regmap_config);
- + if (IS_ERR(priv->regmap))
- + return PTR_ERR(priv->regmap);
- +
- + if (priv->id == ID_MT7531) {
- + ret = mt7531_create_sgmii(priv);
- + if (ret)
- + return ret;
- + }
- +
- + return dsa_register_switch(priv->ds);
- +}
- +
- +static void
- +mt7530_remove(struct mdio_device *mdiodev)
- +{
- + struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
- + int ret = 0, i;
- +
- + if (!priv)
- + return;
- +
- + ret = regulator_disable(priv->core_pwr);
- + if (ret < 0)
- + dev_err(priv->dev,
- + "Failed to disable core power: %d\n", ret);
- +
- + ret = regulator_disable(priv->io_pwr);
- + if (ret < 0)
- + dev_err(priv->dev, "Failed to disable io pwr: %d\n",
- + ret);
- +
- + mt7530_remove_common(priv);
- +
- + for (i = 0; i < 2; ++i)
- + mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs);
- +}
- +
- +static void mt7530_shutdown(struct mdio_device *mdiodev)
- +{
- + struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
- +
- + if (!priv)
- + return;
- +
- + dsa_switch_shutdown(priv->ds);
- +
- + dev_set_drvdata(&mdiodev->dev, NULL);
- +}
- +
- +static struct mdio_driver mt7530_mdio_driver = {
- + .probe = mt7530_probe,
- + .remove = mt7530_remove,
- + .shutdown = mt7530_shutdown,
- + .mdiodrv.driver = {
- + .name = "mt7530-mdio",
- + .of_match_table = mt7530_of_match,
- + },
- +};
- +
- +mdio_module_driver(mt7530_mdio_driver);
- +
- +MODULE_AUTHOR("Sean Wang <[email protected]>");
- +MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch (MDIO)");
- +MODULE_LICENSE("GPL");
- --- a/drivers/net/dsa/mt7530.c
- +++ b/drivers/net/dsa/mt7530.c
- @@ -14,7 +14,6 @@
- #include <linux/of_mdio.h>
- #include <linux/of_net.h>
- #include <linux/of_platform.h>
- -#include <linux/pcs/pcs-mtk-lynxi.h>
- #include <linux/phylink.h>
- #include <linux/regmap.h>
- #include <linux/regulator/consumer.h>
- @@ -192,31 +191,6 @@ core_clear(struct mt7530_priv *priv, u32
- }
-
- static int
- -mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
- -{
- - struct mii_bus *bus = context;
- - u16 page, r, lo, hi;
- - int ret;
- -
- - page = (reg >> 6) & 0x3ff;
- - r = (reg >> 2) & 0xf;
- - lo = val & 0xffff;
- - hi = val >> 16;
- -
- - /* MT7530 uses 31 as the pseudo port */
- - ret = bus->write(bus, 0x1f, 0x1f, page);
- - if (ret < 0)
- - return ret;
- -
- - ret = bus->write(bus, 0x1f, r, lo);
- - if (ret < 0)
- - return ret;
- -
- - ret = bus->write(bus, 0x1f, 0x10, hi);
- - return ret;
- -}
- -
- -static int
- mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val)
- {
- int ret;
- @@ -230,29 +204,6 @@ mt7530_mii_write(struct mt7530_priv *pri
- return ret;
- }
-
- -static int
- -mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
- -{
- - struct mii_bus *bus = context;
- - u16 page, r, lo, hi;
- - int ret;
- -
- - page = (reg >> 6) & 0x3ff;
- - r = (reg >> 2) & 0xf;
- -
- - /* MT7530 uses 31 as the pseudo port */
- - ret = bus->write(bus, 0x1f, 0x1f, page);
- - if (ret < 0)
- - return ret;
- -
- - lo = bus->read(bus, 0x1f, r);
- - hi = bus->read(bus, 0x1f, 0x10);
- -
- - *val = (hi << 16) | (lo & 0xffff);
- -
- - return 0;
- -}
- -
- static u32
- mt7530_mii_read(struct mt7530_priv *priv, u32 reg)
- {
- @@ -3008,72 +2959,6 @@ static const struct phylink_pcs_ops mt75
- .pcs_an_restart = mt7530_pcs_an_restart,
- };
-
- -static void
- -mt7530_mdio_regmap_lock(void *mdio_lock)
- -{
- - mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
- -}
- -
- -static void
- -mt7530_mdio_regmap_unlock(void *mdio_lock)
- -{
- - mutex_unlock(mdio_lock);
- -}
- -
- -static const struct regmap_bus mt7530_regmap_bus = {
- - .reg_write = mt7530_regmap_write,
- - .reg_read = mt7530_regmap_read,
- -};
- -
- -static int
- -mt7531_create_sgmii(struct mt7530_priv *priv)
- -{
- - struct regmap_config *mt7531_pcs_config[2];
- - struct phylink_pcs *pcs;
- - struct regmap *regmap;
- - int i, ret = 0;
- -
- - for (i = 0; i < 2; i++) {
- - mt7531_pcs_config[i] = devm_kzalloc(priv->dev,
- - sizeof(struct regmap_config),
- - GFP_KERNEL);
- - if (!mt7531_pcs_config[i]) {
- - ret = -ENOMEM;
- - break;
- - }
- -
- - mt7531_pcs_config[i]->name = i ? "port6" : "port5";
- - mt7531_pcs_config[i]->reg_bits = 16;
- - mt7531_pcs_config[i]->val_bits = 32;
- - mt7531_pcs_config[i]->reg_stride = 4;
- - mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
- - mt7531_pcs_config[i]->max_register = 0x17c;
- - mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
- - mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
- - mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
- -
- - regmap = devm_regmap_init(priv->dev,
- - &mt7530_regmap_bus, priv->bus,
- - mt7531_pcs_config[i]);
- - if (IS_ERR(regmap)) {
- - ret = PTR_ERR(regmap);
- - break;
- - }
- - pcs = mtk_pcs_lynxi_create(priv->dev, regmap,
- - MT7531_PHYA_CTRL_SIGNAL3, 0);
- - if (!pcs) {
- - ret = -ENXIO;
- - break;
- - }
- - priv->ports[5 + i].sgmii_pcs = pcs;
- - }
- -
- - if (ret && i)
- - mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs);
- -
- - return ret;
- -}
- -
- static int
- mt753x_setup(struct dsa_switch *ds)
- {
- @@ -3132,7 +3017,7 @@ static int mt753x_set_mac_eee(struct dsa
- return 0;
- }
-
- -static const struct dsa_switch_ops mt7530_switch_ops = {
- +const struct dsa_switch_ops mt7530_switch_ops = {
- .get_tag_protocol = mtk_get_tag_protocol,
- .setup = mt753x_setup,
- .get_strings = mt7530_get_strings,
- @@ -3166,8 +3051,9 @@ static const struct dsa_switch_ops mt753
- .get_mac_eee = mt753x_get_mac_eee,
- .set_mac_eee = mt753x_set_mac_eee,
- };
- +EXPORT_SYMBOL_GPL(mt7530_switch_ops);
-
- -static const struct mt753x_info mt753x_table[] = {
- +const struct mt753x_info mt753x_table[] = {
- [ID_MT7621] = {
- .id = ID_MT7621,
- .pcs_ops = &mt7530_pcs_ops,
- @@ -3200,16 +3086,9 @@ static const struct mt753x_info mt753x_t
- .mac_port_config = mt7531_mac_config,
- },
- };
- +EXPORT_SYMBOL_GPL(mt753x_table);
-
- -static const struct of_device_id mt7530_of_match[] = {
- - { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
- - { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
- - { .compatible = "mediatek,mt7531", .data = &mt753x_table[ID_MT7531], },
- - { /* sentinel */ },
- -};
- -MODULE_DEVICE_TABLE(of, mt7530_of_match);
- -
- -static int
- +int
- mt7530_probe_common(struct mt7530_priv *priv)
- {
- struct device *dev = priv->dev;
- @@ -3246,88 +3125,9 @@ mt7530_probe_common(struct mt7530_priv *
-
- return 0;
- }
- +EXPORT_SYMBOL_GPL(mt7530_probe_common);
-
- -static int
- -mt7530_probe(struct mdio_device *mdiodev)
- -{
- - static struct regmap_config *regmap_config;
- - struct mt7530_priv *priv;
- - struct device_node *dn;
- - int ret;
- -
- - dn = mdiodev->dev.of_node;
- -
- - priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
- - if (!priv)
- - return -ENOMEM;
- -
- - priv->bus = mdiodev->bus;
- - priv->dev = &mdiodev->dev;
- -
- - ret = mt7530_probe_common(priv);
- - if (ret)
- - return ret;
- -
- - /* Use medatek,mcm property to distinguish hardware type that would
- - * cause a little bit differences on power-on sequence.
- - * Not MCM that indicates switch works as the remote standalone
- - * integrated circuit so the GPIO pin would be used to complete
- - * the reset, otherwise memory-mapped register accessing used
- - * through syscon provides in the case of MCM.
- - */
- - priv->mcm = of_property_read_bool(dn, "mediatek,mcm");
- - if (priv->mcm) {
- - dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n");
- -
- - priv->rstc = devm_reset_control_get(&mdiodev->dev, "mcm");
- - if (IS_ERR(priv->rstc)) {
- - dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
- - return PTR_ERR(priv->rstc);
- - }
- - } else {
- - priv->reset = devm_gpiod_get_optional(&mdiodev->dev, "reset",
- - GPIOD_OUT_LOW);
- - if (IS_ERR(priv->reset)) {
- - dev_err(&mdiodev->dev, "Couldn't get our reset line\n");
- - return PTR_ERR(priv->reset);
- - }
- - }
- -
- - if (priv->id == ID_MT7530) {
- - priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
- - if (IS_ERR(priv->core_pwr))
- - return PTR_ERR(priv->core_pwr);
- -
- - priv->io_pwr = devm_regulator_get(&mdiodev->dev, "io");
- - if (IS_ERR(priv->io_pwr))
- - return PTR_ERR(priv->io_pwr);
- - }
- -
- - regmap_config = devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config),
- - GFP_KERNEL);
- - if (!regmap_config)
- - return -ENOMEM;
- -
- - regmap_config->reg_bits = 16;
- - regmap_config->val_bits = 32;
- - regmap_config->reg_stride = 4;
- - regmap_config->max_register = MT7530_CREV;
- - regmap_config->disable_locking = true;
- - priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
- - priv->bus, regmap_config);
- - if (IS_ERR(priv->regmap))
- - return PTR_ERR(priv->regmap);
- -
- - if (priv->id == ID_MT7531) {
- - ret = mt7531_create_sgmii(priv);
- - if (ret)
- - return ret;
- - }
- -
- - return dsa_register_switch(priv->ds);
- -}
- -
- -static void
- +void
- mt7530_remove_common(struct mt7530_priv *priv)
- {
- if (priv->irq)
- @@ -3337,55 +3137,7 @@ mt7530_remove_common(struct mt7530_priv
-
- mutex_destroy(&priv->reg_mutex);
- }
- -
- -static void
- -mt7530_remove(struct mdio_device *mdiodev)
- -{
- - struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
- - int ret = 0, i;
- -
- - if (!priv)
- - return;
- -
- - ret = regulator_disable(priv->core_pwr);
- - if (ret < 0)
- - dev_err(priv->dev,
- - "Failed to disable core power: %d\n", ret);
- -
- - ret = regulator_disable(priv->io_pwr);
- - if (ret < 0)
- - dev_err(priv->dev, "Failed to disable io pwr: %d\n",
- - ret);
- -
- - mt7530_remove_common(priv);
- -
- - for (i = 0; i < 2; ++i)
- - mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs);
- -}
- -
- -static void mt7530_shutdown(struct mdio_device *mdiodev)
- -{
- - struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
- -
- - if (!priv)
- - return;
- -
- - dsa_switch_shutdown(priv->ds);
- -
- - dev_set_drvdata(&mdiodev->dev, NULL);
- -}
- -
- -static struct mdio_driver mt7530_mdio_driver = {
- - .probe = mt7530_probe,
- - .remove = mt7530_remove,
- - .shutdown = mt7530_shutdown,
- - .mdiodrv.driver = {
- - .name = "mt7530",
- - .of_match_table = mt7530_of_match,
- - },
- -};
- -
- -mdio_module_driver(mt7530_mdio_driver);
- +EXPORT_SYMBOL_GPL(mt7530_remove_common);
-
- MODULE_AUTHOR("Sean Wang <[email protected]>");
- MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");
- --- a/drivers/net/dsa/mt7530.h
- +++ b/drivers/net/dsa/mt7530.h
- @@ -834,4 +834,10 @@ static inline void INIT_MT7530_DUMMY_POL
- p->reg = reg;
- }
-
- +int mt7530_probe_common(struct mt7530_priv *priv);
- +void mt7530_remove_common(struct mt7530_priv *priv);
- +
- +extern const struct dsa_switch_ops mt7530_switch_ops;
- +extern const struct mt753x_info mt753x_table[];
- +
- #endif /* __MT7530_H */
|