From nobody Thu Nov 14 06:40:04 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77AEFC761AF for ; Mon, 3 Apr 2023 01:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbjDCBT5 (ORCPT ); Sun, 2 Apr 2023 21:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbjDCBTs (ORCPT ); Sun, 2 Apr 2023 21:19:48 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E8A9B44E; Sun, 2 Apr 2023 18:19:19 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pj8qr-0004mj-26; Mon, 03 Apr 2023 03:19:17 +0200 Date: Mon, 3 Apr 2023 02:19:13 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Sean Wang , Landen Chao , DENG Qingfang , Philipp Zabel , Russell King , =?utf-8?B?QXLEsW7DpyDDnG5hbA==?= Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [PATCH net-next v2 11/14] net: dsa: mt7530: introduce separate MDIO driver Message-ID: <1ea36bcda839daa39be7175fd24e9a78e0685b60.1680483896.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Andrew Lunn --- MAINTAINERS | 1 + drivers/net/dsa/Kconfig | 15 +- 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, 300 insertions(+), 258 deletions(-) create mode 100644 drivers/net/dsa/mt7530-mdio.c diff --git a/MAINTAINERS b/MAINTAINERS index dffcc253563bd..4970a6c6a0a86 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13177,6 +13177,7 @@ M: Landen Chao M: DENG Qingfang L: netdev@vger.kernel.org S: Maintained +F: drivers/net/dsa/mt7530-mdio.c F: drivers/net/dsa/mt7530.* F: net/dsa/tag_mtk.c =20 diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index 6b45fa8b69078..941d020fe4b61 100644 --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -38,11 +38,22 @@ config NET_DSA_MT7530 tristate "MediaTek MT7530 and MT7531 Ethernet switch support" select NET_DSA_TAG_MTK select MEDIATEK_GE_PHY - select PCS_MTK_LYNXI + 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 is supported. + 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 PCS_MTK_LYNXI + help + 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. =20 config NET_DSA_MV88E6060 tristate "Marvell 88E6060 ethernet switch chip support" diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile index 16eb879e0cb4d..c5da75cb0a6b5 100644 --- a/drivers/net/dsa/Makefile +++ b/drivers/net/dsa/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_FIXED_PHY) +=3D dsa_loop_bdinfo.o endif obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) +=3D lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530) +=3D mt7530.o +obj-$(CONFIG_NET_DSA_MT7530_MDIO) +=3D mt7530-mdio.o obj-$(CONFIG_NET_DSA_MV88E6060) +=3D mv88e6060.o obj-$(CONFIG_NET_DSA_RZN1_A5PSW) +=3D rzn1_a5psw.o obj-$(CONFIG_NET_DSA_SMSC_LAN9303) +=3D lan9303-core.o diff --git a/drivers/net/dsa/mt7530-mdio.c b/drivers/net/dsa/mt7530-mdio.c new file mode 100644 index 0000000000000..34a547b88e497 --- /dev/null +++ b/drivers/net/dsa/mt7530-mdio.c @@ -0,0 +1,271 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mt7530.h" + +static int +mt7530_regmap_write(void *context, unsigned int reg, unsigned int val) +{ + struct mii_bus *bus =3D context; + u16 page, r, lo, hi; + int ret; + + page =3D (reg >> 6) & 0x3ff; + r =3D (reg >> 2) & 0xf; + lo =3D val & 0xffff; + hi =3D val >> 16; + + /* MT7530 uses 31 as the pseudo port */ + ret =3D bus->write(bus, 0x1f, 0x1f, page); + if (ret < 0) + return ret; + + ret =3D bus->write(bus, 0x1f, r, lo); + if (ret < 0) + return ret; + + ret =3D 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 =3D context; + u16 page, r, lo, hi; + int ret; + + page =3D (reg >> 6) & 0x3ff; + r =3D (reg >> 2) & 0xf; + + /* MT7530 uses 31 as the pseudo port */ + ret =3D bus->write(bus, 0x1f, 0x1f, page); + if (ret < 0) + return ret; + + lo =3D bus->read(bus, 0x1f, r); + hi =3D bus->read(bus, 0x1f, 0x10); + + *val =3D (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 =3D { + .reg_write =3D mt7530_regmap_write, + .reg_read =3D 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 =3D 0; + + for (i =3D 0; i < 2; i++) { + mt7531_pcs_config[i] =3D devm_kzalloc(priv->dev, + sizeof(struct regmap_config), + GFP_KERNEL); + if (!mt7531_pcs_config[i]) { + ret =3D -ENOMEM; + break; + } + + mt7531_pcs_config[i]->name =3D i ? "port6" : "port5"; + mt7531_pcs_config[i]->reg_bits =3D 16; + mt7531_pcs_config[i]->val_bits =3D 32; + mt7531_pcs_config[i]->reg_stride =3D 4; + mt7531_pcs_config[i]->reg_base =3D MT7531_SGMII_REG_BASE(5 + i); + mt7531_pcs_config[i]->max_register =3D 0x17c; + mt7531_pcs_config[i]->lock =3D mt7530_mdio_regmap_lock; + mt7531_pcs_config[i]->unlock =3D mt7530_mdio_regmap_unlock; + mt7531_pcs_config[i]->lock_arg =3D &priv->bus->mdio_lock; + + regmap =3D devm_regmap_init(priv->dev, + &mt7530_regmap_bus, priv->bus, + mt7531_pcs_config[i]); + if (IS_ERR(regmap)) { + ret =3D PTR_ERR(regmap); + break; + } + pcs =3D mtk_pcs_lynxi_create(priv->dev, regmap, + MT7531_PHYA_CTRL_SIGNAL3, 0); + if (!pcs) { + ret =3D -ENXIO; + break; + } + priv->ports[5 + i].sgmii_pcs =3D pcs; + } + + if (ret && i) + mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs); + + return ret; +} + +static const struct of_device_id mt7530_of_match[] =3D { + { .compatible =3D "mediatek,mt7621", .data =3D &mt753x_table[ID_MT7621], = }, + { .compatible =3D "mediatek,mt7530", .data =3D &mt753x_table[ID_MT7530], = }, + { .compatible =3D "mediatek,mt7531", .data =3D &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 =3D mdiodev->dev.of_node; + + priv =3D devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->bus =3D mdiodev->bus; + priv->dev =3D &mdiodev->dev; + + ret =3D 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 =3D of_property_read_bool(dn, "mediatek,mcm"); + if (priv->mcm) { + dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n"); + + priv->rstc =3D 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 =3D 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 =3D=3D ID_MT7530) { + priv->core_pwr =3D devm_regulator_get(&mdiodev->dev, "core"); + if (IS_ERR(priv->core_pwr)) + return PTR_ERR(priv->core_pwr); + + priv->io_pwr =3D devm_regulator_get(&mdiodev->dev, "io"); + if (IS_ERR(priv->io_pwr)) + return PTR_ERR(priv->io_pwr); + } + + regmap_config =3D devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config), + GFP_KERNEL); + if (!regmap_config) + return -ENOMEM; + + regmap_config->reg_bits =3D 16; + regmap_config->val_bits =3D 32; + regmap_config->reg_stride =3D 4; + regmap_config->max_register =3D MT7530_CREV; + regmap_config->disable_locking =3D true; + priv->regmap =3D 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 =3D=3D ID_MT7531) { + ret =3D 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 =3D dev_get_drvdata(&mdiodev->dev); + int ret =3D 0, i; + + if (!priv) + return; + + ret =3D regulator_disable(priv->core_pwr); + if (ret < 0) + dev_err(priv->dev, + "Failed to disable core power: %d\n", ret); + + ret =3D 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 =3D 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 =3D 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 =3D { + .probe =3D mt7530_probe, + .remove =3D mt7530_remove, + .shutdown =3D mt7530_shutdown, + .mdiodrv.driver =3D { + .name =3D "mt7530-mdio", + .of_match_table =3D mt7530_of_match, + }, +}; + +mdio_module_driver(mt7530_mdio_driver); + +MODULE_AUTHOR("Sean Wang "); +MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch (MDIO)"); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 47e3c413ccf12..ac485ee83ed07 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -191,31 +190,6 @@ core_clear(struct mt7530_priv *priv, u32 reg, u32 val) core_rmw(priv, reg, val, 0); } =20 -static int -mt7530_regmap_write(void *context, unsigned int reg, unsigned int val) -{ - struct mii_bus *bus =3D context; - u16 page, r, lo, hi; - int ret; - - page =3D (reg >> 6) & 0x3ff; - r =3D (reg >> 2) & 0xf; - lo =3D val & 0xffff; - hi =3D val >> 16; - - /* MT7530 uses 31 as the pseudo port */ - ret =3D bus->write(bus, 0x1f, 0x1f, page); - if (ret < 0) - return ret; - - ret =3D bus->write(bus, 0x1f, r, lo); - if (ret < 0) - return ret; - - ret =3D bus->write(bus, 0x1f, 0x10, hi); - return ret; -} - static int mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u32 val) { @@ -230,29 +204,6 @@ mt7530_mii_write(struct mt7530_priv *priv, u32 reg, u3= 2 val) return ret; } =20 -static int -mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val) -{ - struct mii_bus *bus =3D context; - u16 page, r, lo, hi; - int ret; - - page =3D (reg >> 6) & 0x3ff; - r =3D (reg >> 2) & 0xf; - - /* MT7530 uses 31 as the pseudo port */ - ret =3D bus->write(bus, 0x1f, 0x1f, page); - if (ret < 0) - return ret; - - lo =3D bus->read(bus, 0x1f, r); - hi =3D bus->read(bus, 0x1f, 0x10); - - *val =3D (hi << 16) | (lo & 0xffff); - - return 0; -} - static u32 mt7530_mii_read(struct mt7530_priv *priv, u32 reg) { @@ -2945,72 +2896,6 @@ static const struct phylink_pcs_ops mt7530_pcs_ops = =3D { .pcs_an_restart =3D mt7530_pcs_an_restart, }; =20 -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 =3D { - .reg_write =3D mt7530_regmap_write, - .reg_read =3D 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 =3D 0; - - for (i =3D 0; i < 2; i++) { - mt7531_pcs_config[i] =3D devm_kzalloc(priv->dev, - sizeof(struct regmap_config), - GFP_KERNEL); - if (!mt7531_pcs_config[i]) { - ret =3D -ENOMEM; - break; - } - - mt7531_pcs_config[i]->name =3D i ? "port6" : "port5"; - mt7531_pcs_config[i]->reg_bits =3D 16; - mt7531_pcs_config[i]->val_bits =3D 32; - mt7531_pcs_config[i]->reg_stride =3D 4; - mt7531_pcs_config[i]->reg_base =3D MT7531_SGMII_REG_BASE(5 + i); - mt7531_pcs_config[i]->max_register =3D 0x17c; - mt7531_pcs_config[i]->lock =3D mt7530_mdio_regmap_lock; - mt7531_pcs_config[i]->unlock =3D mt7530_mdio_regmap_unlock; - mt7531_pcs_config[i]->lock_arg =3D &priv->bus->mdio_lock; - - regmap =3D devm_regmap_init(priv->dev, - &mt7530_regmap_bus, priv->bus, - mt7531_pcs_config[i]); - if (IS_ERR(regmap)) { - ret =3D PTR_ERR(regmap); - break; - } - pcs =3D mtk_pcs_lynxi_create(priv->dev, regmap, - MT7531_PHYA_CTRL_SIGNAL3, 0); - if (!pcs) { - ret =3D -ENXIO; - break; - } - priv->ports[5 + i].sgmii_pcs =3D pcs; - } - - if (ret && i) - mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs); - - return ret; -} - static int mt753x_setup(struct dsa_switch *ds) { @@ -3069,7 +2954,7 @@ static int mt753x_set_mac_eee(struct dsa_switch *ds, = int port, return 0; } =20 -static const struct dsa_switch_ops mt7530_switch_ops =3D { +const struct dsa_switch_ops mt7530_switch_ops =3D { .get_tag_protocol =3D mtk_get_tag_protocol, .setup =3D mt753x_setup, .get_strings =3D mt7530_get_strings, @@ -3103,8 +2988,9 @@ static const struct dsa_switch_ops mt7530_switch_ops = =3D { .get_mac_eee =3D mt753x_get_mac_eee, .set_mac_eee =3D mt753x_set_mac_eee, }; +EXPORT_SYMBOL_GPL(mt7530_switch_ops); =20 -static const struct mt753x_info mt753x_table[] =3D { +const struct mt753x_info mt753x_table[] =3D { [ID_MT7621] =3D { .id =3D ID_MT7621, .pcs_ops =3D &mt7530_pcs_ops, @@ -3143,16 +3029,9 @@ static const struct mt753x_info mt753x_table[] =3D { .mac_port_config =3D mt7531_mac_config, }, }; +EXPORT_SYMBOL_GPL(mt753x_table); =20 -static const struct of_device_id mt7530_of_match[] =3D { - { .compatible =3D "mediatek,mt7621", .data =3D &mt753x_table[ID_MT7621], = }, - { .compatible =3D "mediatek,mt7530", .data =3D &mt753x_table[ID_MT7530], = }, - { .compatible =3D "mediatek,mt7531", .data =3D &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 =3D priv->dev; @@ -3189,88 +3068,9 @@ mt7530_probe_common(struct mt7530_priv *priv) =20 return 0; } +EXPORT_SYMBOL_GPL(mt7530_probe_common); =20 -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 =3D mdiodev->dev.of_node; - - priv =3D devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->bus =3D mdiodev->bus; - priv->dev =3D &mdiodev->dev; - - ret =3D 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 =3D of_property_read_bool(dn, "mediatek,mcm"); - if (priv->mcm) { - dev_info(&mdiodev->dev, "MT7530 adapts as multi-chip module\n"); - - priv->rstc =3D 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 =3D 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 =3D=3D ID_MT7530) { - priv->core_pwr =3D devm_regulator_get(&mdiodev->dev, "core"); - if (IS_ERR(priv->core_pwr)) - return PTR_ERR(priv->core_pwr); - - priv->io_pwr =3D devm_regulator_get(&mdiodev->dev, "io"); - if (IS_ERR(priv->io_pwr)) - return PTR_ERR(priv->io_pwr); - } - - regmap_config =3D devm_kzalloc(&mdiodev->dev, sizeof(*regmap_config), - GFP_KERNEL); - if (!regmap_config) - return -ENOMEM; - - regmap_config->reg_bits =3D 16; - regmap_config->val_bits =3D 32; - regmap_config->reg_stride =3D 4; - regmap_config->max_register =3D MT7530_CREV; - regmap_config->disable_locking =3D true; - priv->regmap =3D 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 =3D=3D ID_MT7531) { - ret =3D 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) @@ -3280,55 +3080,7 @@ mt7530_remove_common(struct mt7530_priv *priv) =20 mutex_destroy(&priv->reg_mutex); } - -static void -mt7530_remove(struct mdio_device *mdiodev) -{ - struct mt7530_priv *priv =3D dev_get_drvdata(&mdiodev->dev); - int ret =3D 0, i; - - if (!priv) - return; - - ret =3D regulator_disable(priv->core_pwr); - if (ret < 0) - dev_err(priv->dev, - "Failed to disable core power: %d\n", ret); - - ret =3D 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 =3D 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 =3D 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 =3D { - .probe =3D mt7530_probe, - .remove =3D mt7530_remove, - .shutdown =3D mt7530_shutdown, - .mdiodrv.driver =3D { - .name =3D "mt7530", - .of_match_table =3D mt7530_of_match, - }, -}; - -mdio_module_driver(mt7530_mdio_driver); +EXPORT_SYMBOL_GPL(mt7530_remove_common); =20 MODULE_AUTHOR("Sean Wang "); MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch"); diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 2a611173a7d08..ce02aa592a7a8 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -814,4 +814,10 @@ static inline void INIT_MT7530_DUMMY_POLL(struct mt753= 0_dummy_poll *p, p->reg =3D reg; } =20 +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 */ --=20 2.40.0