net: introduce MDIO DM class for MDIO devices
Subsystems (2)
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that support DM_ETH and have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.
--- cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 50 ++++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 105 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+) create mode 100644 net/mdio-uclass.c
cmd/mdio.c +5 -0
@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered.
drivers/net/Kconfig +13 -0
@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NET
include/dm/uclass-id.h +1 -0
@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */
include/miiphy.h +50 -0
54 lines not on this page · raw message
net/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.o
net/mdio-uclass.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
Quoted 7 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>
Looks good!
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanHi Alex,
Quoted 6 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.
Please add a test case for testing mdio (see test/dm/*)
Quoted 68 lines
Signed-off-by Alex Marginean <[email protected]>--- cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 50 ++++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 105 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+) create mode 100644 net/mdio-uclass.ccmd/mdio.c +5
-0@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered. drivers/net/Kconfig +13
-0@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NETinclude/dm/uclass-id.h +1
-0@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */include/miiphy.h +0
-0
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 124
Quoted 7 lines
include/miiphy.h +4
-0@@ -118,4 +118,54 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,#define ESTATUS_1000XF 0x8000#define ESTATUS_1000XH 0x4000 +#ifdef CONFIG_DM_MDIO + +/** +* struct mii_pdata - Platform data for MDIO buses
wrong name: mii_pdata
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 127
Quoted 3 lines
include/miiphy.h +3
-0+* +* @mii_bus: Supporting MII legacy bus +* @priv_pdata: device specific platdata
there is no such field called priv_pdata.
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 134
Quoted 7 lines
include/miiphy.h +7
-0+*/ +struct mdio_perdev_priv { +struct mii_dev *mii_bus; +}; + +/** +* struct mii_ops - MDIO bus operations
struct mdio_ops
Quoted 6 lines
include/miiphy.h +6
-0+* +* @read: Read from a PHY register +* @write: Write to a PHY register +* @reset: Reset the MDIO bus, NULL if not supported +*/ +struct mdio_ops {
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 150
Quoted 10 lines
include/miiphy.h +10
-0+int (*read)(struct udevice *mdio_dev,int addr,int devad,int reg); +int (*write)(struct udevice *mdio_dev,int addr,int devad,int reg, +u16 val); +int (*reset)(struct udevice *mdio_dev); +}; + +#define mdio_get_ops (dev) ((struct mdio_ops *)(dev)->driver->ops) + +/** +* mii_dm_probe_devices - Call probe on all MII devices, currently used for
wrong name "mii_dm_probe_devices". MII devices -> MDIO devices?
Quoted 55 lines
include/miiphy.h +20
-0+* MDIO console commands. +*/ +void dm_mdio_probe_devices (void ); + +/** +* dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO +* +* @dev: mdio dev +* @addr: PHY address on MDIO bus +* @ethdev: ethernet device to connect to the PHY +* @interface: MAC-PHY protocol +* +* @return pointer to phy_device, or 0 on error +*/ +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface); + +#endif +#endif net/Makefile +1
-0@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.onet/mdio-uclass.c new file +16
-0@@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <miiphy.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> + +void dm_mdio_probe_devices (void ) +{ +struct udevice *it; +struct uclass *uc;
net/mdio-uclass.c line 26
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+ +uclass_get (UCLASS_MDIO , &uc); + uclass_foreach_dev(it, uc) { +device_probe (it); + } +} + +static int dm_mdio_post_bind (struct udevice *dev) +{ +if (strchr (dev->name,' ' )) {
Is such check a must have? If yes, could you please add some comments?
net/mdio-uclass.c line 35
Quoted 9 lines
net/mdio-uclass.c new file +9
-0+debug ("\nError: MDIO device name \"%s\" has a space!\n" , + dev->name); +return -EINVAL ; + } + +return 0 ; +} + +static int dm_mdio_read (struct mii_dev *mii_bus,int addr,int devad,int reg)
This does not look correct. Normally the dm_ functions should have udevice * as its first argument.
net/mdio-uclass.c line 42
Quoted 7 lines
net/mdio-uclass.c new file +7
-0+{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->read (dev, addr, devad, reg); +} + +static int dm_mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,
ditto
net/mdio-uclass.c line 50
Quoted 8 lines
net/mdio-uclass.c new file +8
-0+ u16 val) +{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->write (dev, addr, devad, reg, val); +} + +static int dm_mdio_reset (struct mii_dev *mii_bus)
ditto
Quoted 38 lines
net/mdio-uclass.c new file +38
-0+{ +struct udevice *dev = mii_bus->priv; + +if (mdio_get_ops (dev)->reset) +return mdio_get_ops (dev)->reset (dev); +else +return 0 ; +} + +static int dm_mdio_post_probe (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + + pdata->mii_bus =mdio_alloc (); + pdata->mii_bus->read = dm_mdio_read; + pdata->mii_bus->write = dm_mdio_write; + pdata->mii_bus->reset = dm_mdio_reset; + pdata->mii_bus->priv = dev; +strncpy (pdata->mii_bus->name, dev->name,MDIO_NAME_LEN ); + +return mdio_register (pdata->mii_bus); +} + +static int dm_mdio_pre_remove (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); +struct mdio_ops *ops =mdio_get_ops (dev); + +if (ops->reset) + ops->reset (dev); +mdio_free (pdata->mii_bus); + +return 0 ; +} + +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface)
net/mdio-uclass.c line 98
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + +if (device_probe (dev)) +return 0 ; + +return phy_connect (pdata->mii_bus, addr, ethdev, interface); +} + +UCLASS_DRIVER (mii) = {
UCLASS_DRIVER(mdio)?
net/mdio-uclass.c line 100
Quoted 2 lines
net/mdio-uclass.c new file +2
-0+ .id = UCLASS_MDIO, + .name = "mii",
"mdio"?
net/mdio-uclass.c
Quoted 6 lines
net/mdio-uclass.c new file +5
-1+ .post_bind = dm_mdio_post_bind, + .post_probe = dm_mdio_post_probe, + .pre_remove = dm_mdio_pre_remove, + .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), +}; --
Regards,
Bin
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
Hi Bin,
Quoted 11 lines · Bin Meng
Hi Alex,
Quoted 6 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Please add a test case for testing mdio (see test/dm/*)
OK, will look into it.
Quoted 72 lines
Quoted 72 lines
Signed-off-by Alex Marginean <[email protected]>--- cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 50 ++++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 105 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+)create mode 100644
net/mdio-uclass.ccmd/mdio.c +5
-0@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered. drivers/net/Kconfig +13
-0@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NETinclude/dm/uclass-id.h +1
-0@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */include/miiphy.h +0
-0@@ -118,4 +118,54 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,#define ESTATUS_1000XF 0x8000#define ESTATUS_1000XH 0x4000
Quoted 6 lines
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 124
Quoted 4 lines
include/miiphy.h +4
-0+#ifdef CONFIG_DM_MDIO + +/** +* struct mii_pdata - Platform data for MDIO buses wrong name:
mii_pdata
Oops, I had this renamed and refactored and I seem to missed the comments entirely. And a few other things as you pointed out below.
Quoted 7 lines
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 127
Quoted 4 lines
include/miiphy.h +3
-0+* +* @mii_bus: Supporting MII legacy bus +* @priv_pdata: device specific platdata there is no such field called
priv_pdata.
Quoted 9 lines
include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 134
Quoted 7 lines
include/miiphy.h +7
-0+*/ +struct mdio_perdev_priv { +struct mii_dev *mii_bus; +}; + +/** +* struct mii_ops - MDIO bus operations struct
mdio_ops
Thanks for pointing these out, I'll send a v2 with the fixes.
Quoted 79 lines
Quoted 7 lines
include/miiphy.h +6
-0+* +* @read: Read from a PHY register +* @write: Write to a PHY register +* @reset: Reset the MDIO bus, NULL if not supported +*/ +struct mdio_ops {include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 150
Quoted 10 lines
include/miiphy.h +10
-0+int (*read)(struct udevice *mdio_dev,int addr,int devad,int reg); +int (*write)(struct udevice *mdio_dev,int addr,int devad,int reg, +u16 val); +int (*reset)(struct udevice *mdio_dev); +}; + +#define mdio_get_ops (dev) ((struct mdio_ops *)(dev)->driver->ops) + +/** +* mii_dm_probe_devices - Call probe on all MII devices, currently used for wrong name "
mii_dm_probe_devices". MII devices -> MDIO devices?Quoted 59 lines
include/miiphy.h +20
-0+* MDIO console commands. +*/ +void dm_mdio_probe_devices (void ); + +/** +* dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO +* +* @dev: mdio dev +* @addr: PHY address on MDIO bus +* @ethdev: ethernet device to connect to the PHY +* @interface: MAC-PHY protocol +* +* @return pointer to phy_device, or 0 on error +*/ +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface); + +#endif +#endif net/Makefile +1
-0@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.onet/mdio-uclass.c new file +20
-0@@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <miiphy.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> + +void dm_mdio_probe_devices (void ) +{ +struct udevice *it; +struct uclass *uc; + +uclass_get (UCLASS_MDIO , &uc); + uclass_foreach_dev(it, uc) { +device_probe (it);
Quoted 8 lines
net/mdio-uclass.c line 26
Quoted 6 lines
net/mdio-uclass.c new file +6
-0+ } +} + +static int dm_mdio_post_bind (struct udevice *dev) +{ +if (strchr (dev->name,' ' )) {Is such check a must have? If yes, could you please add some comments?
These names may be used in mdio command and I'm guessing the command gets confused if there are spaces, I'll put a comment here.
Quoted 13 lines
net/mdio-uclass.c line 35
Quoted 10 lines
net/mdio-uclass.c new file +9
-0+debug ("\nError: MDIO device name \"%s\" has a space!\n" , + dev->name); +return -EINVAL ; + } + +return 0 ; +} + +static int dm_mdio_read (struct mii_dev *mii_bus,int addr,int devad,int reg)This does not look correct. Normally the
dm_functions should have udevice * as its first argument.
These are not exported through dm api, instead they are registered to legacy mii API. I should probably rename the function and drop dm_, I'll add comments to these functions to so people don't get confused.
Quoted 73 lines
net/mdio-uclass.c line 42
Quoted 8 lines
net/mdio-uclass.c new file +7
-0+{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->read (dev, addr, devad, reg); +} + +static int dm_mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,ditto
net/mdio-uclass.c line 50
Quoted 8 lines
net/mdio-uclass.c new file +8
-0+ u16 val) +{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->write (dev, addr, devad, reg, val); +} + +static int dm_mdio_reset (struct mii_dev *mii_bus)ditto
Quoted 38 lines
net/mdio-uclass.c new file +38
-0+{ +struct udevice *dev = mii_bus->priv; + +if (mdio_get_ops (dev)->reset) +return mdio_get_ops (dev)->reset (dev); +else +return 0 ; +} + +static int dm_mdio_post_probe (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + + pdata->mii_bus =mdio_alloc (); + pdata->mii_bus->read = dm_mdio_read; + pdata->mii_bus->write = dm_mdio_write; + pdata->mii_bus->reset = dm_mdio_reset; + pdata->mii_bus->priv = dev; +strncpy (pdata->mii_bus->name, dev->name,MDIO_NAME_LEN ); + +return mdio_register (pdata->mii_bus); +} + +static int dm_mdio_pre_remove (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); +struct mdio_ops *ops =mdio_get_ops (dev); + +if (ops->reset) + ops->reset (dev); +mdio_free (pdata->mii_bus); + +return 0 ; +} + +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface)net/mdio-uclass.c line 98
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + +if (device_probe (dev)) +return 0 ; + +return phy_connect (pdata->mii_bus, addr, ethdev, interface); +} + +UCLASS_DRIVER (mii) = {
UCLASS_DRIVER(mdio)?
Quoted 4 lines
net/mdio-uclass.c line 100
Quoted 2 lines
net/mdio-uclass.c new file +2
-0+ .id = UCLASS_MDIO, + .name = "mii","mdio"?
Yes, you're right, it should be "mdio".
Quoted 11 lines
net/mdio-uclass.c
Quoted 7 lines
net/mdio-uclass.c new file +5
-1+ .post_bind = dm_mdio_post_bind, + .post_probe = dm_mdio_post_probe, + .pre_remove = dm_mdio_pre_remove, + .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), +}; --Regards,
Bin
Thank you, Bin!
Alex
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
In reply to Bin MengHi Bin,
Thanks for the review. I shouldn't have tried to look at this while falling asleep in the airport. :(
-Joe
Quoted 297 lines · Bin Meng
Hi Alex,
Quoted 6 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Please add a test case for testing mdio (see test/dm/*)
Quoted 68 lines
Signed-off-by Alex Marginean <[email protected]>--- cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 50 ++++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 105 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+) create mode 100644 net/mdio-uclass.ccmd/mdio.c +5
-0@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered. drivers/net/Kconfig +13
-0@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NETinclude/dm/uclass-id.h +1
-0@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */include/miiphy.h +0
-0include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 124
Quoted 7 lines
include/miiphy.h +4
-0@@ -118,4 +118,54 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,#define ESTATUS_1000XF 0x8000#define ESTATUS_1000XH 0x4000 +#ifdef CONFIG_DM_MDIO + +/** +* struct mii_pdata - Platform data for MDIO buses wrong name:
mii_pdatainclude/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 127
Quoted 3 lines
include/miiphy.h +3
-0+* +* @mii_bus: Supporting MII legacy bus +* @priv_pdata: device specific platdata there is no such field called
priv_pdata.include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 134
Quoted 7 lines
include/miiphy.h +7
-0+*/ +struct mdio_perdev_priv { +struct mii_dev *mii_bus; +}; + +/** +* struct mii_ops - MDIO bus operations struct
mdio_opsQuoted 6 lines
include/miiphy.h +6
-0+* +* @read: Read from a PHY register +* @write: Write to a PHY register +* @reset: Reset the MDIO bus, NULL if not supported +*/ +struct mdio_ops {include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 150
Quoted 10 lines
include/miiphy.h +10
-0+int (*read)(struct udevice *mdio_dev,int addr,int devad,int reg); +int (*write)(struct udevice *mdio_dev,int addr,int devad,int reg, +u16 val); +int (*reset)(struct udevice *mdio_dev); +}; + +#define mdio_get_ops (dev) ((struct mdio_ops *)(dev)->driver->ops) + +/** +* mii_dm_probe_devices - Call probe on all MII devices, currently used for wrong name "
mii_dm_probe_devices". MII devices -> MDIO devices?Quoted 55 lines
include/miiphy.h +20
-0+* MDIO console commands. +*/ +void dm_mdio_probe_devices (void ); + +/** +* dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO +* +* @dev: mdio dev +* @addr: PHY address on MDIO bus +* @ethdev: ethernet device to connect to the PHY +* @interface: MAC-PHY protocol +* +* @return pointer to phy_device, or 0 on error +*/ +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface); + +#endif +#endif net/Makefile +1
-0@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.onet/mdio-uclass.c new file +16
-0@@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <miiphy.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> + +void dm_mdio_probe_devices (void ) +{ +struct udevice *it; +struct uclass *uc;net/mdio-uclass.c line 26
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+ +uclass_get (UCLASS_MDIO , &uc); + uclass_foreach_dev(it, uc) { +device_probe (it); + } +} + +static int dm_mdio_post_bind (struct udevice *dev) +{ +if (strchr (dev->name,' ' )) {Is such check a must have? If yes, could you please add some comments?
net/mdio-uclass.c line 35
Quoted 9 lines
net/mdio-uclass.c new file +9
-0+debug ("\nError: MDIO device name \"%s\" has a space!\n" , + dev->name); +return -EINVAL ; + } + +return 0 ; +} + +static int dm_mdio_read (struct mii_dev *mii_bus,int addr,int devad,int reg)This does not look correct. Normally the
dm_functions should have udevice * as its first argument.net/mdio-uclass.c line 42
Quoted 7 lines
net/mdio-uclass.c new file +7
-0+{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->read (dev, addr, devad, reg); +} + +static int dm_mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,ditto
net/mdio-uclass.c line 50
Quoted 8 lines
net/mdio-uclass.c new file +8
-0+ u16 val) +{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->write (dev, addr, devad, reg, val); +} + +static int dm_mdio_reset (struct mii_dev *mii_bus)ditto
Quoted 38 lines
net/mdio-uclass.c new file +38
-0+{ +struct udevice *dev = mii_bus->priv; + +if (mdio_get_ops (dev)->reset) +return mdio_get_ops (dev)->reset (dev); +else +return 0 ; +} + +static int dm_mdio_post_probe (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + + pdata->mii_bus =mdio_alloc (); + pdata->mii_bus->read = dm_mdio_read; + pdata->mii_bus->write = dm_mdio_write; + pdata->mii_bus->reset = dm_mdio_reset; + pdata->mii_bus->priv = dev; +strncpy (pdata->mii_bus->name, dev->name,MDIO_NAME_LEN ); + +return mdio_register (pdata->mii_bus); +} + +static int dm_mdio_pre_remove (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); +struct mdio_ops *ops =mdio_get_ops (dev); + +if (ops->reset) + ops->reset (dev); +mdio_free (pdata->mii_bus); + +return 0 ; +} + +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface)net/mdio-uclass.c line 98
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + +if (device_probe (dev)) +return 0 ; + +return phy_connect (pdata->mii_bus, addr, ethdev, interface); +} + +UCLASS_DRIVER (mii) = {
UCLASS_DRIVER(mdio)?net/mdio-uclass.c line 100
Quoted 2 lines
net/mdio-uclass.c new file +2
-0+ .id = UCLASS_MDIO, + .name = "mii","mdio"?
net/mdio-uclass.c
Quoted 6 lines
net/mdio-uclass.c new file +5
-1+ .post_bind = dm_mdio_post_bind, + .post_probe = dm_mdio_post_probe, + .pre_remove = dm_mdio_pre_remove, + .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), +}; --Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 1/1 net: introduce MDIO DM class for MDIO devices
Quoted 6 lines · Joe Hershberger
Hi Bin,
Thanks for the review. I shouldn't have tried to look at this while falling asleep in the airport. :(
-Joe
I guess I should have double checked the comments and the other things too, sorry for that..
I'll send a v2 on Monday.
Thank you!
Alex
Quoted 299 lines · Bin Meng
Quoted 297 lines
Hi Alex,
Quoted 6 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Please add a test case for testing mdio (see test/dm/*)
Quoted 68 lines
Signed-off-by Alex Marginean <[email protected]>--- cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 50 ++++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 105 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 175 insertions(+)create mode 100644
net/mdio-uclass.ccmd/mdio.c +5
-0@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered. drivers/net/Kconfig +13
-0@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NETinclude/dm/uclass-id.h +1
-0@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */include/miiphy.h +0
-0include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 124
Quoted 7 lines
include/miiphy.h +4
-0@@ -118,4 +118,54 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,#define ESTATUS_1000XF 0x8000#define ESTATUS_1000XH 0x4000 +#ifdef CONFIG_DM_MDIO + +/** +* struct mii_pdata - Platform data for MDIO buses wrong name:
mii_pdatainclude/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 127
Quoted 3 lines
include/miiphy.h +3
-0+* +* @mii_bus: Supporting MII legacy bus +* @priv_pdata: device specific platdata there is no such field called
priv_pdata.include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 134
Quoted 7 lines
include/miiphy.h +7
-0+*/ +struct mdio_perdev_priv { +struct mii_dev *mii_bus; +}; + +/** +* struct mii_ops - MDIO bus operations struct
mdio_opsQuoted 6 lines
include/miiphy.h +6
-0+* +* @read: Read from a PHY register +* @write: Write to a PHY register +* @reset: Reset the MDIO bus, NULL if not supported +*/ +struct mdio_ops {include/miiphy.h int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, · line 150
Quoted 10 lines
include/miiphy.h +10
-0+int (*read)(struct udevice *mdio_dev,int addr,int devad,int reg); +int (*write)(struct udevice *mdio_dev,int addr,int devad,int reg, +u16 val); +int (*reset)(struct udevice *mdio_dev); +}; + +#define mdio_get_ops (dev) ((struct mdio_ops *)(dev)->driver->ops) + +/** +* mii_dm_probe_devices - Call probe on all MII devices, currently used for wrong name "
mii_dm_probe_devices". MII devices -> MDIO devices?Quoted 55 lines
include/miiphy.h +20
-0+* MDIO console commands. +*/ +void dm_mdio_probe_devices (void ); + +/** +* dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO +* +* @dev: mdio dev +* @addr: PHY address on MDIO bus +* @ethdev: ethernet device to connect to the PHY +* @interface: MAC-PHY protocol +* +* @return pointer to phy_device, or 0 on error +*/ +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface); + +#endif +#endif net/Makefile +1
-0@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.onet/mdio-uclass.c new file +16
-0@@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <miiphy.h> +#include <dm/device-internal.h> +#include <dm/uclass-internal.h> + +void dm_mdio_probe_devices (void ) +{ +struct udevice *it; +struct uclass *uc;net/mdio-uclass.c line 26
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+ +uclass_get (UCLASS_MDIO , &uc); + uclass_foreach_dev(it, uc) { +device_probe (it); + } +} + +static int dm_mdio_post_bind (struct udevice *dev) +{ +if (strchr (dev->name,' ' )) {Is such check a must have? If yes, could you please add some comments?
net/mdio-uclass.c line 35
Quoted 9 lines
net/mdio-uclass.c new file +9
-0+debug ("\nError: MDIO device name \"%s\" has a space!\n" , + dev->name); +return -EINVAL ; + } + +return 0 ; +} + +static int dm_mdio_read (struct mii_dev *mii_bus,int addr,int devad,int reg)This does not look correct. Normally the
dm_functions should have udevice * as its first argument.net/mdio-uclass.c line 42
Quoted 7 lines
net/mdio-uclass.c new file +7
-0+{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->read (dev, addr, devad, reg); +} + +static int dm_mdio_write(struct mii_dev *mii_bus, int addr, int devad, int reg,ditto
net/mdio-uclass.c line 50
Quoted 8 lines
net/mdio-uclass.c new file +8
-0+ u16 val) +{ +struct udevice *dev = mii_bus->priv; + +return mdio_get_ops (dev)->write (dev, addr, devad, reg, val); +} + +static int dm_mdio_reset (struct mii_dev *mii_bus)ditto
Quoted 38 lines
net/mdio-uclass.c new file +38
-0+{ +struct udevice *dev = mii_bus->priv; + +if (mdio_get_ops (dev)->reset) +return mdio_get_ops (dev)->reset (dev); +else +return 0 ; +} + +static int dm_mdio_post_probe (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + + pdata->mii_bus =mdio_alloc (); + pdata->mii_bus->read = dm_mdio_read; + pdata->mii_bus->write = dm_mdio_write; + pdata->mii_bus->reset = dm_mdio_reset; + pdata->mii_bus->priv = dev; +strncpy (pdata->mii_bus->name, dev->name,MDIO_NAME_LEN ); + +return mdio_register (pdata->mii_bus); +} + +static int dm_mdio_pre_remove (struct udevice *dev) +{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); +struct mdio_ops *ops =mdio_get_ops (dev); + +if (ops->reset) + ops->reset (dev); +mdio_free (pdata->mii_bus); + +return 0 ; +} + +struct phy_device *dm_mdio_phy_connect (struct udevice *dev,int addr, +struct udevice *ethdev, +phy_interface_t interface)net/mdio-uclass.c line 98
Quoted 10 lines
net/mdio-uclass.c new file +10
-0+{ +struct mdio_perdev_priv *pdata =dev_get_uclass_priv (dev); + +if (device_probe (dev)) +return 0 ; + +return phy_connect (pdata->mii_bus, addr, ethdev, interface); +} + +UCLASS_DRIVER (mii) = {
UCLASS_DRIVER(mdio)?net/mdio-uclass.c line 100
Quoted 2 lines
net/mdio-uclass.c new file +2
-0+ .id = UCLASS_MDIO, + .name = "mii","mdio"?
net/mdio-uclass.c
Quoted 6 lines
net/mdio-uclass.c new file +5
-1+ .post_bind = dm_mdio_post_bind, + .post_probe = dm_mdio_post_probe, + .pre_remove = dm_mdio_pre_remove, + .per_device_auto_alloc_size = sizeof(struct mdio_perdev_priv), +}; --Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v2 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanAdds UCLASS_MDIO DM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that support DM_ETH and have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.
---
Changes in v2:
- fixed several comments using wrong API names
- dropped dm_ from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missing mdio_unregister in dm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 49 ++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 net/mdio-uclass.c
cmd/mdio.c +5 -0
@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered.
drivers/net/Kconfig +13 -0
@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NET
include/dm/uclass-id.h +1 -0
@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */
include/miiphy.h +49 -0
53 lines not on this page · raw message
net/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.o
net/mdio-uclass.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/2 test: dm: add MDIO test
A very simple test for DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.
---
Changes in v2:
- new patch, v1 didn't have a test included
arch/sandbox/dts/test.dts | 4 ++ configs/sandbox_defconfig | 2 + drivers/net/Kconfig | 10 +++++ drivers/net/Makefile | 1 + drivers/net/mdio_sandbox.c | 92 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mdio.c | 48 ++++++++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 drivers/net/mdio_sandbox.c create mode 100644 test/dm/mdio.c
arch/sandbox/dts/test.dts +4 -0
@@ -799,6 +799,10 @@ dmas = <&dma 0>, <&dma 1>, <&dma 2>; dma-names = "m2m", "tx0", "rx0"; }; + + mdio-test { + compatible = "sandbox,mdio_sandbox"; + }; }; #include "sandbox_pmic.dtsi"
configs/sandbox_defconfig +2 -0
@@ -139,7 +139,9 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_SST=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_PHYLIB=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=y
drivers/net/Kconfig +10 -0
@@ -24,6 +24,16 @@ config DM_MDIO This is currently implemented in net/mdio-uclass.c Look in include/miiphy.h for details. +config MDIO_SANDBOX + depends on DM_MDIO && SANDBOX + default y + bool "Sandbox: Mocked MDIO driver" + help + This driver implements dummy read/write/reset MDIO functions mimicking + a bus with a single PHY. + + This driver is used in for testing in test/dm/mdio.c + menuconfig NETDEVICES bool "Network device support" depends on NET
drivers/net/Makefile +1 -0
@@ -77,3 +77,4 @@ obj-y += ti/ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o obj-y += mscc_eswitch/ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o +obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o
drivers/net/mdio_sandbox.c new file +92 -0
92 lines not on this page · raw message
test/dm/Makefile +1 -0
@@ -60,4 +60,5 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o obj-$(CONFIG_DMA) += dma.o +obj-$(CONFIG_DM_MDIO) += mdio.o endif
test/dm/mdio.c new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/2 test: dm: add MDIO test
Hi Alex,
Quoted 10 lines · Alex Marginean
A very simple test for
DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.Signed-off-by Alex Marginean <[email protected]>---
Changes in v2:
- new patch, v1 didn't have a test included
Quoted 11 lines
arch/sandbox/dts/test.dts | 4 ++ configs/sandbox_defconfig | 2 + drivers/net/Kconfig | 10 +++++ drivers/net/Makefile | 1 + drivers/net/mdio_sandbox.c | 92 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mdio.c | 48 ++++++++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 drivers/net/mdio_sandbox.c create mode 100644 test/dm/mdio.c
However, please see some nits below.
arch/sandbox/dts/test.dts line 804
Quoted 11 lines
arch/sandbox/dts/test.dts +3
-0@@ -799,6 +799,10 @@ dmas = <&dma 0>, <&dma 1>, <&dma 2>; dma-names = "m2m", "tx0", "rx0"; }; + + mdio-test { + compatible = "sandbox,mdio_sandbox";
nits: it reads better if we had "sandbox,mdio"
configs/sandbox_defconfig
Quoted 8 lines
arch/sandbox/dts/test.dts +1
-0+ }; }; #include "sandbox_pmic.dtsi"configs/sandbox_defconfig +0
-0
nits: I think we need update all sandbox defconfigs, or just update arch/Kconfig and imply PHYLIB & DM_MDIO there.
Quoted 107 lines
configs/sandbox_defconfig +2
-0@@ -139,7 +139,9 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_SST=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_PHYLIB=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=ydrivers/net/Kconfig +10
-0@@ -24,6 +24,16 @@ config DM_MDIO This is currently implemented in net/mdio-uclass.c Look in include/miiphy.h for details. +config MDIO_SANDBOX + depends on DM_MDIO && SANDBOX + default y + bool "Sandbox: Mocked MDIO driver" + help + This driver implements dummy read/write/reset MDIO functions mimicking + a bus with a single PHY. + + This driver is used in for testing in test/dm/mdio.c + menuconfig NETDEVICES bool "Network device support" depends on NETdrivers/net/Makefile +1
-0@@ -77,3 +77,4 @@ obj-y += ti/ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o obj-y += mscc_eswitch/ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o +obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.odrivers/net/mdio_sandbox.c new file +61
-0@@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <dm.h> +#include <errno.h> +#include <miiphy.h> + +#define SANDBOX_PHY_ADDR 5 +#define SANDBOX_PHY_REG 0 + +struct mdio_sandbox_priv { +int enabled; +u16 reg; +}; + +static int mdio_sandbox_read (struct udevice *dev,int addr,int devad,int reg) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + +if (!priv->enabled) +return -ENODEV ; + +if (addr !=SANDBOX_PHY_ADDR ) +return -ENODEV ; +if (devad !=MDIO_DEVAD_NONE ) +return -ENODEV ; +if (reg !=SANDBOX_PHY_REG ) +return -ENODEV ; + +return priv->reg; +} + +static int mdio_sandbox_write (struct udevice *dev,int addr,int devad,int reg, +u16 val) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + +if (!priv->enabled) +return -ENODEV ; + +if (addr !=SANDBOX_PHY_ADDR ) +return -ENODEV ; +if (devad !=MDIO_DEVAD_NONE ) +return -ENODEV ; +if (reg !=SANDBOX_PHY_REG ) +return -ENODEV ; + + priv->reg = val; + +return 0 ; +} + +static int mdio_sandbox_reset (struct udevice *dev) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + + priv->reg =0 ; +
drivers/net/mdio_sandbox.c line 71
Quoted 10 lines
drivers/net/mdio_sandbox.c new file +10
-0+return 0 ; +} + +static const struct mdio_ops mdio_sandbox_ops = { + .read = mdio_sandbox_read, + .write = mdio_sandbox_write, + .reset = mdio_sandbox_reset, +}; + +int mdio_sandbox_probe (struct udevice *dev)
This should be static.
Quoted 70 lines
drivers/net/mdio_sandbox.c new file +21
-0+{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + + priv->enabled =1 ; + +return 0 ; +} + +static const struct udevice_id mdio_sandbox_ids[] = { + { .compatible ="sandbox,mdio_sandbox" }, + { } +}; + +U_BOOT_DRIVER (mdio_sandbox) = { + .name ="mdio_sandbox" , + .id =UCLASS_MDIO , + .of_match = mdio_sandbox_ids, + .probe = mdio_sandbox_probe, + .ops = &mdio_sandbox_ops, + .priv_auto_alloc_size =sizeof (struct mdio_sandbox_priv ), +};test/dm/Makefile +1
-0@@ -60,4 +60,5 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o obj-$(CONFIG_DMA) += dma.o +obj-$(CONFIG_DM_MDIO) += mdio.o endiftest/dm/mdio.c new file +33
-0@@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <misc.h> +#include <test/ut.h> +#include <miiphy.h> + +/* macros copied over from mdio_sandbox.c */ +#define SANDBOX_PHY_ADDR 5 +#define SANDBOX_PHY_REG 0 + +#define TEST_REG_VALUE 0xabcd + +static int dm_test_mdio (struct unit_test_state *uts) +{ +struct uclass *uc; +struct udevice *dev; +struct mdio_ops *ops; +u16 reg; + +ut_assertok (uclass_get (UCLASS_MDIO , &uc)); + +ut_assertok (uclass_get_device_by_name (UCLASS_MDIO ,"mdio-test" , &dev)); + + ops =mdio_get_ops (dev); +ut_assertnonnull (ops); +ut_assertnonnull (ops->read);
test/dm/mdio.c line 43
Quoted 10 lines
test/dm/mdio.c new file +10
-0+ut_assertnonnull (ops->write); + +ut_assertok (ops->write (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ,TEST_REG_VALUE )); + reg = ops->read (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ); +ut_asserteq (reg,TEST_REG_VALUE ); + +ut_assert (ops->read (dev,SANDBOX_PHY_ADDR +1 ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ) !=0 );
Please add a test for ops->reset.
test/dm/mdio.c
Quoted 6 lines
test/dm/mdio.c new file +5
-1+ +return 0 ; +} + +DM_TEST (dm_test_mdio,DM_TESTF_SCAN_FDT ); --
Regards,
Bin
PATCH v2 2/2 test: dm: add MDIO test
Hi Bin,
Quoted 25 lines · Bin Meng
Hi Alex,
Quoted 18 lines · Alex Marginean
A very simple test for
DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.Signed-off-by Alex Marginean <[email protected]>---
Changes in v2:
- new patch, v1 didn't have a test includedarch/sandbox/dts/test.dts | 4 ++ configs/sandbox_defconfig | 2 + drivers/net/Kconfig | 10 +++++ drivers/net/Makefile | 1 + drivers/net/mdio_sandbox.c | 92 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mdio.c | 48 ++++++++++++++++++++ 7 files changed, 158 insertions(+)Quoted 3 lines
create mode 100644
drivers/net/mdio_sandbox.c
create mode 100644test/dm/mdio.c
Quoted 4 lines
Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>However, please see some nits below.
Thank you for the review, I'll send a v3 for these later today. Alex
Quoted 240 lines
arch/sandbox/dts/test.dts line 804
Quoted 12 lines
arch/sandbox/dts/test.dts +3
-0@@ -799,6 +799,10 @@ dmas = <&dma 0>, <&dma 1>, <&dma 2>; dma-names = "m2m", "tx0", "rx0"; }; + + mdio-test { + compatible = "sandbox,mdio_sandbox";nits: it reads better if we had "sandbox,mdio"
configs/sandbox_defconfig
Quoted 8 lines
arch/sandbox/dts/test.dts +1
-0+ }; }; #include "sandbox_pmic.dtsi"configs/sandbox_defconfig +0
-0nits: I think we need update all sandbox defconfigs, or just update
arch/Kconfigand imply PHYLIB &DM_MDIOthere.Quoted 107 lines
configs/sandbox_defconfig +2
-0@@ -139,7 +139,9 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_SST=y CONFIG_SPI_FLASH_WINBOND=y +CONFIG_PHYLIB=y CONFIG_DM_ETH=y +CONFIG_DM_MDIO=y CONFIG_NVME=y CONFIG_PCI=y CONFIG_DM_PCI=ydrivers/net/Kconfig +10
-0@@ -24,6 +24,16 @@ config DM_MDIO This is currently implemented in net/mdio-uclass.c Look in include/miiphy.h for details. +config MDIO_SANDBOX + depends on DM_MDIO && SANDBOX + default y + bool "Sandbox: Mocked MDIO driver" + help + This driver implements dummy read/write/reset MDIO functions mimicking + a bus with a single PHY. + + This driver is used in for testing in test/dm/mdio.c + menuconfig NETDEVICES bool "Network device support" depends on NETdrivers/net/Makefile +1
-0@@ -77,3 +77,4 @@ obj-y += ti/ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o obj-y += mscc_eswitch/ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o +obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.odrivers/net/mdio_sandbox.c new file +61
-0@@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <dm.h> +#include <errno.h> +#include <miiphy.h> + +#define SANDBOX_PHY_ADDR 5 +#define SANDBOX_PHY_REG 0 + +struct mdio_sandbox_priv { +int enabled; +u16 reg; +}; + +static int mdio_sandbox_read (struct udevice *dev,int addr,int devad,int reg) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + +if (!priv->enabled) +return -ENODEV ; + +if (addr !=SANDBOX_PHY_ADDR ) +return -ENODEV ; +if (devad !=MDIO_DEVAD_NONE ) +return -ENODEV ; +if (reg !=SANDBOX_PHY_REG ) +return -ENODEV ; + +return priv->reg; +} + +static int mdio_sandbox_write (struct udevice *dev,int addr,int devad,int reg, +u16 val) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + +if (!priv->enabled) +return -ENODEV ; + +if (addr !=SANDBOX_PHY_ADDR ) +return -ENODEV ; +if (devad !=MDIO_DEVAD_NONE ) +return -ENODEV ; +if (reg !=SANDBOX_PHY_REG ) +return -ENODEV ; + + priv->reg = val; + +return 0 ; +} + +static int mdio_sandbox_reset (struct udevice *dev) +{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + + priv->reg =0 ; +drivers/net/mdio_sandbox.c line 71
Quoted 10 lines
drivers/net/mdio_sandbox.c new file +10
-0+return 0 ; +} + +static const struct mdio_ops mdio_sandbox_ops = { + .read = mdio_sandbox_read, + .write = mdio_sandbox_write, + .reset = mdio_sandbox_reset, +}; + +int mdio_sandbox_probe (struct udevice *dev)This should be static.
Quoted 70 lines
drivers/net/mdio_sandbox.c new file +21
-0+{ +struct mdio_sandbox_priv *priv =dev_get_priv (dev); + + priv->enabled =1 ; + +return 0 ; +} + +static const struct udevice_id mdio_sandbox_ids[] = { + { .compatible ="sandbox,mdio_sandbox" }, + { } +}; + +U_BOOT_DRIVER (mdio_sandbox) = { + .name ="mdio_sandbox" , + .id =UCLASS_MDIO , + .of_match = mdio_sandbox_ids, + .probe = mdio_sandbox_probe, + .ops = &mdio_sandbox_ops, + .priv_auto_alloc_size =sizeof (struct mdio_sandbox_priv ), +};test/dm/Makefile +1
-0@@ -60,4 +60,5 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o obj-$(CONFIG_DMA) += dma.o +obj-$(CONFIG_DM_MDIO) += mdio.o endiftest/dm/mdio.c new file +33
-0@@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2019 +* Alex Marginean, NXP +*/ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <misc.h> +#include <test/ut.h> +#include <miiphy.h> + +/* macros copied over from mdio_sandbox.c */ +#define SANDBOX_PHY_ADDR 5 +#define SANDBOX_PHY_REG 0 + +#define TEST_REG_VALUE 0xabcd + +static int dm_test_mdio (struct unit_test_state *uts) +{ +struct uclass *uc; +struct udevice *dev; +struct mdio_ops *ops; +u16 reg; + +ut_assertok (uclass_get (UCLASS_MDIO , &uc)); + +ut_assertok (uclass_get_device_by_name (UCLASS_MDIO ,"mdio-test" , &dev)); + + ops =mdio_get_ops (dev); +ut_assertnonnull (ops); +ut_assertnonnull (ops->read);test/dm/mdio.c line 43
Quoted 10 lines
test/dm/mdio.c new file +10
-0+ut_assertnonnull (ops->write); + +ut_assertok (ops->write (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ,TEST_REG_VALUE )); + reg = ops->read (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ); +ut_asserteq (reg,TEST_REG_VALUE ); + +ut_assert (ops->read (dev,SANDBOX_PHY_ADDR +1 ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ) !=0 );Please add a test for
ops->reset.test/dm/mdio.c
Quoted 6 lines
test/dm/mdio.c new file +5
-1+ +return 0 ; +} + +DM_TEST (dm_test_mdio,DM_TESTF_SCAN_FDT ); --Regards,
Bin
PATCH v2 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanQuoted 18 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Quoted 9 lines
cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 49 ++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 net/mdio-uclass.c
PATCH v3 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanAdds UCLASS_MDIO DM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that support DM_ETH and have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.
---
Changes in v2:
- fixed several comments using wrong API names
- dropped dm_ from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missing mdio_unregister in dm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 49 ++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 net/mdio-uclass.c
cmd/mdio.c +5 -0
@@ -203,6 +203,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (argc <2 )return CMD_RET_USAGE ; +#ifdef CONFIG_DM_MDIO +/* probe DM MII device before any operation so they are all accesible */ +dm_mdio_probe_devices (); +#endif +/* * We use the last specified parameters, unless new ones are * entered.
drivers/net/Kconfig +13 -0
@@ -11,6 +11,19 @@ config DM_ETH This is currently implemented in net/eth-uclass.c Look in include/net.h for details. +config DM_MDIO + bool "Enable Driver Model for MDIO devices" + depends on DM_ETH && PHYLIB + help + Enable driver model for MDIO devices + + Adds UCLASS_MDIO DM class supporting MDIO buses that are probed as + stand-alone devices. Useful in particular for systems that support + DM_ETH and have a stand-alone MDIO hardware block shared by multiple + Ethernet interfaces. + This is currently implemented in net/mdio-uclass.c + Look in include/miiphy.h for details. + menuconfig NETDEVICES bool "Network device support" depends on NET
include/dm/uclass-id.h +1 -0
@@ -58,6 +58,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* MDIO bus */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */
include/miiphy.h +49 -0
53 lines not on this page · raw message
net/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += eth-uclass.o else obj-$(CONFIG_NET) += eth_legacy.o endif +obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.o
net/mdio-uclass.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 2/2 test: dm: add MDIO test
A very simple test for DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.
---
Changes in v2:
- new patch, v1 didn't have a test included
Changes in v3:
- DM_MDIO and PHYLIB are now implied in arc/Kconfig
- added basic test for mdio reset op
- simplified compatible, static probe function
arch/Kconfig | 2 + arch/sandbox/dts/test.dts | 4 ++ drivers/net/Kconfig | 10 +++++ drivers/net/Makefile | 1 + drivers/net/mdio_sandbox.c | 92 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mdio.c | 53 ++++++++++++++++++++++ 7 files changed, 163 insertions(+) create mode 100644 drivers/net/mdio_sandbox.c create mode 100644 test/dm/mdio.c
arch/Kconfig +2 -0
@@ -120,6 +120,8 @@ config SANDBOX imply VIRTIO_NET imply DM_SOUND imply PCH + imply PHYLIB + imply DM_MDIO config SH bool "SuperH architecture"
arch/sandbox/dts/test.dts +4 -0
@@ -799,6 +799,10 @@ dmas = <&dma 0>, <&dma 1>, <&dma 2>; dma-names = "m2m", "tx0", "rx0"; }; + + mdio-test { + compatible = "sandbox,mdio"; + }; }; #include "sandbox_pmic.dtsi"
drivers/net/Kconfig +10 -0
@@ -24,6 +24,16 @@ config DM_MDIO This is currently implemented in net/mdio-uclass.c Look in include/miiphy.h for details. +config MDIO_SANDBOX + depends on DM_MDIO && SANDBOX + default y + bool "Sandbox: Mocked MDIO driver" + help + This driver implements dummy read/write/reset MDIO functions mimicking + a bus with a single PHY. + + This driver is used in for testing in test/dm/mdio.c + menuconfig NETDEVICES bool "Network device support" depends on NET
drivers/net/Makefile +1 -0
@@ -77,3 +77,4 @@ obj-y += ti/ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o obj-y += mscc_eswitch/ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o +obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o
drivers/net/mdio_sandbox.c new file +92 -0
92 lines not on this page · raw message
test/dm/Makefile +1 -0
@@ -60,4 +60,5 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o obj-$(CONFIG_DMA) += dma.o +obj-$(CONFIG_DM_MDIO) += mdio.o endif
test/dm/mdio.c new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 2/2 test: dm: add MDIO test
Quoted 14 lines · Alex Marginean
A very simple test for
DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.Signed-off-by Alex Marginean <[email protected]>---
Changes in v2:
- new patch, v1 didn't have a test included
Changes in v3:
-DM_MDIOand PHYLIB are now implied in arc/Kconfig
- added basic test for mdio reset op
- simplified compatible, static probe function
Quoted 11 lines
arch/Kconfig | 2 + arch/sandbox/dts/test.dts | 4 ++ drivers/net/Kconfig | 10 +++++ drivers/net/Makefile | 1 + drivers/net/mdio_sandbox.c | 92 ++++++++++++++++++++++++++++++++++++++ test/dm/Makefile | 1 + test/dm/mdio.c | 53 ++++++++++++++++++++++ 7 files changed, 163 insertions(+) create mode 100644 drivers/net/mdio_sandbox.c create mode 100644 test/dm/mdio.c
PATCH v3 2/2 test: dm: add MDIO test
In reply to Alex MargineanQuoted 5 lines · Alex Marginean
A very simple test for
DM_MDIO, mimicks a register write/read through the sandbox bus to a dummy PHY.Signed-off-by Alex Marginean <[email protected]>
[U-Boot] test: dm: add MDIO test
In reply to Alex MargineanHi Alex,
https://patchwork.ozlabs.org/patch/1109369/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanHi Alex,
Quoted 20 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
Quoted 9 lines
cmd/mdio.c | 5 ++ drivers/net/Kconfig | 13 +++++ include/dm/uclass-id.h | 1 + include/miiphy.h | 49 ++++++++++++++++++ net/Makefile | 1 + net/mdio-uclass.c | 115 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 184 insertions(+) create mode 100644 net/mdio-uclass.c
Please keep the RoB tag if there is nothing changed so that I know this has been reviewed :)
Regards,
Bin
PATCH v3 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanQuoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 11 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
PATCH v3 1/2 net: introduce MDIO DM class for MDIO devices
In reply to Alex MargineanQuoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-Joe
PATCH v3 1/2 net: introduce MDIO DM class for MDIO devices
+Ken,
Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
Quoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-Joe
I didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of adding UCLASS_MDIO and code like _post_probe they seem to deal with different needs.
Ken, can you please take a look at the patch I sent? It has a wrapper over phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.
Thank you!
Alex
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/ sun8i_mdio_write... then it is easy for turning old mdio driver to DM.
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.
Yours,
Ken
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devices
External Email
----------------------------------------------------------------------
+Ken,
Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- none
Quoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-Joe
I didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of adding UCLASS_MDIO and code like _post_probe they seem to deal with different needs.
Ken, can you please take a look at the patch I sent? It has a wrapper over phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.
Thank you!
Alex
Hi Ken,
Quoted 15 lines · Ken Ma
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. > I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/sun8i_mdio_write... then it is easy for turning old mdio driver to DM. >
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.
Quoted 2 lines
Yours,
Ken
OK, I think I get what you wanted to do. Either way it's not too difficult to convert existing MDIOs to DM, but they have to start using struct udevice. That's similar to what was done on DM_ETH and others.
The helpers mapping eth/phy/mdio make sense and could be useful, that's something I'll try to look into.
Thank you!
Alex
Quoted 55 lines
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devicesExternal Email
----------------------------------------------------------------------
+Ken,Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- noneQuoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-JoeI didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of addingUCLASS_MDIOand code like_post_probethey seem to deal with different needs.Ken, can you please take a look at the patch I sent? It has a wrapper over
phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.Thank you!
Alex
Hi Alex
In another thread (https://lists.denx.de/pipermail/u-boot/2019-June/371933.html)
I asked Ken (before learning of their cut-backs) if I should take a stab at re-integrating his work
where Joe also pointed out the impending acceptance of your work.
I'm not sure where we left off here in this thread and wondering if you are working on that or not. Ive been staring at this for a bit and ready to take a stab at it if you are not.
if easier - i'm nhed73 on the #u-boot irc channel
Thanks
---Nevo
Quoted 93 lines · Alexandru Marginean
Hi Ken,
Quoted 15 lines · Ken Ma
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. > I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/sun8i_mdio_write... then it is easy for turning old mdio driver to DM. >
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.Quoted 2 lines
Yours,
KenOK, I think I get what you wanted to do. Either way it's not too difficult to convert existing MDIOs to DM, but they have to start using struct udevice. That's similar to what was done on
DM_ETHand others.The helpers mapping eth/phy/mdio make sense and could be useful, that's something I'll try to look into.
Thank you!
AlexQuoted 47 lines
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devicesExternal Email
----------------------------------------------------------------------
+Ken,Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- noneQuoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-JoeQuoted 8 lines
I didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of addingUCLASS_MDIOand code like_post_probethey seem to deal with different needs.Ken, can you please take a look at the patch I sent? It has a wrapper over
phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.Thank you!
Alex_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Hi Nevo,
Quoted 10 lines · Nevo Hed
Hi Alex
In another thread (https://lists.denx.de/pipermail/u-boot/2019-June/371933.html)
I asked Ken (before learning of their cut-backs) if I should take a stab at re-integrating his work
where Joe also pointed out the impending acceptance of your work.I'm not sure where we left off here in this thread and wondering if you are working on that or not. Ive been staring at this for a bit and ready to take a stab at it if you are not.
I am planning to add helpers to MDIO uclass, along the lines Ken sent initially, on top of the current patch. It looks like the helpers would fit just fine. I didn't get to do it yet though.
One difference between the two DM MDIO implementations is the way MDIO ops work, the patch I sent abstracts away the legacy mii_bus from DM MDIO driver. I would keep that as it, which means a bit more rework on the marvell driver. I didn't look into this in detail yet. I think I can send a version of the helpers in [1] in about a week, maybe more, right now I'm trying to get MDIO MUX DM support out for review plus some updates for the NXP platform I'm working on. I can take a stab at porting the marvell driver too, but I can't test it. If you want to put some time into this right now feel free to do it :)
Quoted 5 lines
if easier - i'm
nhed73on the #u-boot irc channelThanks
---Nevo
I can join if you want to discuss details, let me know.
Thanks!
Alex
Quoted 101 lines
Quoted 85 lines · Alexandru Marginean
Hi Ken,
Quoted 15 lines · Ken Ma
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. > I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/sun8i_mdio_write... then it is easy for turning old mdio driver to DM. >
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.Quoted 2 lines
Yours,
KenOK, I think I get what you wanted to do. Either way it's not too difficult to convert existing MDIOs to DM, but they have to start using struct udevice. That's similar to what was done on
DM_ETHand others.The helpers mapping eth/phy/mdio make sense and could be useful, that's something I'll try to look into.
Thank you!
AlexQuoted 52 lines
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devicesExternal Email
----------------------------------------------------------------------
+Ken,Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- noneQuoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-JoeI didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of addingUCLASS_MDIOand code like_post_probethey seem to deal with different needs.Ken, can you please take a look at the patch I sent? It has a wrapper over
phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.Quoted 8 lines
Quoted 3 lines
Thank you!
Alex_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Quoted 11 lines · Alex Marginean
Hi Nevo,
Quoted 7 lines · Nevo Hed
Hi Alex
In another thread (https://lists.denx.de/pipermail/u-boot/2019-June/371933.html)
I asked Ken (before learning of their cut-backs) if I should take a stab at re-integrating his work
where Joe also pointed out the impending acceptance of your work.
Quoted 7 lines
Quoted 3 lines
I'm not sure where we left off here in this thread and wondering if you are working on that or not. Ive been staring at this for a bit and ready to take a stab at it if you are not.
I am planning to add helpers to MDIO uclass, along the lines Ken sent initially, on top of the current patch. It looks like the helpers would fit just fine. I didn't get to do it yet though.
I'm intending to take this as is... I assume that fits with your plan for this.
Thanks,
-Joe
Quoted 129 lines
One difference between the two DM MDIO implementations is the way MDIO ops work, the patch I sent abstracts away the legacy
mii_busfrom DM MDIO driver. I would keep that as it, which means a bit more rework on the marvell driver. I didn't look into this in detail yet. I think I can send a version of the helpers in [1] in about a week, maybe more, right now I'm trying to get MDIO MUX DM support out for review plus some updates for the NXP platform I'm working on. I can take a stab at porting the marvell driver too, but I can't test it. If you want to put some time into this right now feel free to do it :)Quoted 5 lines
if easier - i'm
nhed73on the #u-boot irc channelThanks
---NevoI can join if you want to discuss details, let me know.
Thanks!
AlexQuoted 92 lines
Quoted 89 lines · Alexandru Marginean
Hi Ken,
Quoted 15 lines · Ken Ma
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. > I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/sun8i_mdio_write... then it is easy for turning old mdio driver to DM. >
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.Quoted 2 lines
Yours,
KenOK, I think I get what you wanted to do. Either way it's not too difficult to convert existing MDIOs to DM, but they have to start using struct udevice. That's similar to what was done on
DM_ETHand others.The helpers mapping eth/phy/mdio make sense and could be useful, that's something I'll try to look into.
Thank you!
AlexQuoted 55 lines
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devicesExternal Email
----------------------------------------------------------------------
+Ken,Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- noneQuoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-JoeI didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of addingUCLASS_MDIOand code like_post_probethey seem to deal with different needs.Ken, can you please take a look at the patch I sent? It has a wrapper over
phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.Thank you!
AlexQuoted 9 lines
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Quoted 16 lines · Joe Hershberger
Quoted 15 lines · Alex Marginean
Hi Nevo,
Quoted 10 lines · Nevo Hed
Hi Alex
In another thread (https://lists.denx.de/pipermail/u-boot/2019-June/371933.html)
I asked Ken (before learning of their cut-backs) if I should take a stab at re-integrating his work
where Joe also pointed out the impending acceptance of your work.I'm not sure where we left off here in this thread and wondering if you are working on that or not. Ive been staring at this for a bit and ready to take a stab at it if you are not.
Quoted 5 lines
Quoted 3 lines
I am planning to add helpers to MDIO uclass, along the lines Ken sent initially, on top of the current patch. It looks like the helpers would fit just fine. I didn't get to do it yet though.
I'm intending to take this as is... I assume that fits with your plan for this.
Thanks Joe, it does fit with the plan so far.
Nevo and I started a conversation on the side on a respin of the Marvell MDIO driver, I'll send that out when it's ready too.
Alex
Quoted 133 lines
Thanks,
-JoeQuoted 129 lines
One difference between the two DM MDIO implementations is the way MDIO ops work, the patch I sent abstracts away the legacy
mii_busfrom DM MDIO driver. I would keep that as it, which means a bit more rework on the marvell driver. I didn't look into this in detail yet. I think I can send a version of the helpers in [1] in about a week, maybe more, right now I'm trying to get MDIO MUX DM support out for review plus some updates for the NXP platform I'm working on. I can take a stab at porting the marvell driver too, but I can't test it. If you want to put some time into this right now feel free to do it :)Quoted 5 lines
if easier - i'm
nhed73on the #u-boot irc channelThanks
---NevoI can join if you want to discuss details, let me know.
Thanks!
AlexQuoted 92 lines
Quoted 89 lines · Alexandru Marginean
Hi Ken,
Quoted 15 lines · Ken Ma
Hi Alex
Thanks a lot for your information!
I think our patches have no essential difference.
The 2 patches have only small implementation difference:
In my patch, mii bus ops functions(read/write/reset...) need to be implemented while in your patch mdio bus functions need to be implemented and then mii bus ops functions will call mdio bus ops functions. > I had planned to reuse those existed mii ops functions such as smc911x_miiphy_read/ smc911x_miiphy_write/ sun8i_mdio_read/sun8i_mdio_write... then it is easy for turning old mdio driver to DM. >
Now I am not working on u-boot, so I am sorry that I will not do the pulling work.Quoted 2 lines
Yours,
KenOK, I think I get what you wanted to do. Either way it's not too difficult to convert existing MDIOs to DM, but they have to start using struct udevice. That's similar to what was done on
DM_ETHand others.The helpers mapping eth/phy/mdio make sense and could be useful, that's something I'll try to look into.
Thank you!
AlexQuoted 55 lines
-----Original Message-----
From: Alex Marginean <[email protected]>
Sent: Tuesday, June 11, 2019 9:18 AM
To: joe.hershberger at ni.com; Ken Ma <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>
Subject: [EXT] Re: [U-Boot] [PATCH 1/2 v3] net: introduce MDIO DM class for MDIO devicesExternal Email
----------------------------------------------------------------------
+Ken,Hi Joe,
Quoted 22 lines · Joe Hershberger
Quoted 9 lines · Alex Marginean
Adds
UCLASS_MDIODM class supporting MDIO buses that are probed as stand-alone devices. Useful in particular for systems that supportDM_ETHand have a stand-alone MDIO hardware block shared by multiple Ethernet interfaces.Signed-off-by Alex Marginean <[email protected]>---
Quoted 10 lines
Changes in v2:
- fixed several comments using wrong API names
- droppeddm_from names of internal functions that don't use udevice *
- fixed UCLASS driver name
- added missingmdio_unregisterindm_mdio_pre_remove
- added a comment on why spaces in names aren't ok
- added a comment on how static mdio_read/_write/_reset functions are used
Changes in v3:
- noneQuoted 8 lines
Not sure if you already noticed this [1] or not, but there may be something there that you want to incorporate or maybe not.
Cheers,
-JoeI didn't notice it, thanks for pointing it out!
Apart from the obvious overlap of addingUCLASS_MDIOand code like_post_probethey seem to deal with different needs.Ken, can you please take a look at the patch I sent? It has a wrapper over
phy_connect, but provides no helpers on how the caller would get the PHY ADDR. Do you want to try pulling the API you add on top of the patch I sent, or do you want me to try? It looks like it would work with minimal effort.Thank you!
AlexQuoted 9 lines
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
Hi Alex,
https://patchwork.ozlabs.org/patch/1109368/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe