u-boot-net refactors, fixes, cleanups
Subsystems (7)
v4 cover u-boot-net refactors, fixes, cleanups
From: Marek Behún <[email protected]>
Hello,
this is v4 of https://patchwork.ozlabs.org/project/uboot/list/?series=290889.
Changes since v3:
- rebased on top of origin/next
- fixed binman failure: added #address-cells/#sice-cells to sandbox' test.dts' mdio node in patch
Changes since v2:
- added UT tests for ofnode_get_phy_node() and ofnode_get_phy_mode(), as requested by Simon
Marek Behún (14):
net: mdio-uclass: fix type for phy_mode_str and phy_handle_str
net: mdio-uclass: use ARRAY_SIZE()
net: introduce helpers to get PHY ofnode from MAC
net: mdio-uclass: add wrappers for read/write/reset operations
treewide: use dm_mdio_read/write/reset() wrappers
net: phy: fix parsing wrong property
net: introduce helpers to get PHY interface mode from a device/ofnode
treewide: Rename PHY_INTERFACE_MODE_COUNT to PHY_INTERFACE_MODE_MAX
treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA
phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum
definition
net: phy: xilinx: Check interface type in ->config(), not ->probe()
net: phy: use ->is_c45 instead of is_10g_interface() bcmgenet, sun8i_emac: Don't connect PHY two times
net: phy: don't require PHY interface mode during PHY creation
arch/sandbox/dts/test.dts | 14 +++ board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/boundary/nitrogen6x/nitrogen6x.c | 2 +- board/freescale/corenet_ds/eth_hydra.c | 2 +- board/freescale/corenet_ds/eth_superhydra.c | 4 +- board/freescale/t104xrdb/eth.c | 4 +- board/gdsys/a38x/controlcenterdc.c | 7 +- board/gdsys/a38x/ihs_phys.c | 6 +- board/st/stm32f746-disco/stm32f746-disco.c | 13 +-- drivers/core/ofnode.c | 44 ++++++++ drivers/core/read.c | 10 ++ drivers/net/ag7xxx.c | 9 +- drivers/net/altera_tse.c | 17 +-- drivers/net/bcm6348-eth.c | 8 +- drivers/net/bcmgenet.c | 12 +- drivers/net/designware.c | 10 +- drivers/net/dwc_eth_qos.c | 40 +------ drivers/net/ethoc.c | 4 +- drivers/net/fec_mxc.c | 11 +- drivers/net/fm/b4860.c | 8 +- drivers/net/fm/eth.c | 13 +-- drivers/net/fm/init.c | 8 +- drivers/net/fm/ls1043.c | 6 +- drivers/net/fm/ls1046.c | 8 +- drivers/net/fm/p1023.c | 4 +- drivers/net/fm/p4080.c | 6 +- drivers/net/fm/p5020.c | 6 +- drivers/net/fm/p5040.c | 6 +- drivers/net/fm/t1024.c | 4 +- drivers/net/fm/t1040.c | 4 +- drivers/net/fm/t2080.c | 6 +- drivers/net/fm/t4240.c | 6 +- drivers/net/fsl_enetc.c | 13 +-- drivers/net/ftgmac100.c | 11 +- drivers/net/higmacv300.c | 9 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +---- drivers/net/ldpaa_eth/ldpaa_wriop.c | 10 +- drivers/net/ldpaa_eth/ls1088a.c | 4 +- drivers/net/ldpaa_eth/ls2080a.c | 4 +- drivers/net/ldpaa_eth/lx2160a.c | 4 +- drivers/net/macb.c | 10 +- drivers/net/mdio_mux_sandbox.c | 6 +- drivers/net/mscc_eswitch/jr2_switch.c | 2 +- drivers/net/mscc_eswitch/luton_switch.c | 2 +- drivers/net/mscc_eswitch/ocelot_switch.c | 2 +- drivers/net/mscc_eswitch/serval_switch.c | 2 +- drivers/net/mscc_eswitch/servalt_switch.c | 2 +- drivers/net/mt7620-eth.c | 45 +++----- drivers/net/mtk_eth.c | 8 +- drivers/net/mvgbe.c | 7 +- drivers/net/mvneta.c | 11 +- drivers/net/mvpp2.c | 9 +- drivers/net/pch_gbe.c | 4 +- drivers/net/phy/aquantia.c | 2 +- drivers/net/phy/ethernet_id.c | 5 +- drivers/net/phy/phy.c | 117 +++++++------------- drivers/net/phy/xilinx_gmii2rgmii.c | 14 +-- drivers/net/pic32_eth.c | 11 +- drivers/net/qe/dm_qe_uec.c | 11 +- drivers/net/ravb.c | 19 +--- drivers/net/sh_eth.c | 19 +--- drivers/net/sni_ave.c | 16 +-- drivers/net/sni_netsec.c | 10 +- drivers/net/sun8i_emac.c | 13 +-- drivers/net/sunxi_emac.c | 5 +- drivers/net/ti/am65-cpsw-nuss.c | 15 +-- drivers/net/ti/cpsw.c | 10 +- drivers/net/ti/keystone_net.c | 24 ++-- drivers/net/tsec.c | 9 +- drivers/net/xilinx_axi_emac.c | 10 +- drivers/net/zynq_gem.c | 9 +- include/_exports.h | 3 +- include/dm/ofnode.h | 27 +++++ include/dm/read.h | 36 ++++++ include/exports.h | 3 +- include/fm_eth.h | 2 +- include/miiphy.h | 31 ++++++ include/phy.h | 40 ++----- include/phy_interface.h | 11 +- include/vsc9953.h | 2 +- net/mdio-mux-uclass.c | 16 +-- net/mdio-uclass.c | 96 ++++++++-------- test/dm/mdio.c | 18 +-- test/dm/mdio_mux.c | 16 +-- test/dm/ofnode.c | 22 ++++ 85 files changed, 508 insertions(+), 631 deletions(-)
Signature · 1 line
2.35.1
PATCH v4 1/14 net: mdio-uclass: fix type for phy_mode_str and phy_handle_str
From: Marek Behún <[email protected]>
These global variables should both have type
static const char * const
--- net/mdio-uclass.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/mdio-uclass.c +6 -5
@@ -17,13 +17,14 @@/* DT node properties for MAC-PHY interface */ #define PHY_MODE_STR_CNT 2 -static const char *phy_mode_str[PHY_MODE_STR_CNT ] = {"phy-mode" , -"phy-connection-type" }; +static const char *const phy_mode_str[PHY_MODE_STR_CNT ] = { +"phy-mode" ,"phy-connection-type" +};/* DT node properties that reference a PHY node */ #define PHY_HANDLE_STR_CNT 3 -const char *phy_handle_str[PHY_HANDLE_STR_CNT ] = {"phy-handle" , -"phy" , -"phy-device" }; +static const char *const phy_handle_str[PHY_HANDLE_STR_CNT ] = { +"phy-handle" ,"phy" ,"phy-device" +};void dm_mdio_probe_devices (void ) {
Signature · 1 line
2.35.1
PATCH v4 2/14 net: mdio-uclass: use ARRAY_SIZE()
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Use the ARRAY_SIZE() macro instead of hardcoding sizes of arrays in macros.
--- net/mdio-uclass.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/mdio-uclass.c +5 -6
@@ -16,13 +16,12 @@#include <linux/compat.h> /* DT node properties for MAC-PHY interface */ -#define PHY_MODE_STR_CNT 2 -static const char *const phy_mode_str[PHY_MODE_STR_CNT ] = { +static const char *const phy_mode_str[] = {"phy-mode" ,"phy-connection-type" }; +/* DT node properties that reference a PHY node */ -#define PHY_HANDLE_STR_CNT 3 -static const char *const phy_handle_str[PHY_HANDLE_STR_CNT ] = { +static const char *const phy_handle_str[] = {"phy-handle" ,"phy" ,"phy-device" };
@@ -149,7 +148,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, goto out; } -for (i =0 ; i <PHY_HANDLE_STR_CNT ; i++) +for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++)if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL ,0 ,0 , &phandle))break ;
@@ -199,7 +198,7 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) } interface =PHY_INTERFACE_MODE_NONE ; -for (i =0 ; i <PHY_MODE_STR_CNT ; i++) { +for (i =0 ; i <ARRAY_SIZE (phy_mode_str); i++) { if_str =dev_read_string (ethdev, phy_mode_str[i]);if (if_str) { interface =phy_get_interface_by_name (if_str);
Signature · 1 line
2.35.1
PATCH v4 3/14 net: introduce helpers to get PHY ofnode from MAC
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Add helpers ofnode_get_phy_node() and dev_get_phy_node() and use it in net/mdio-uclass.c function dm_eth_connect_phy_handle(). Also add corresponding UT test.
This is useful because other part's of U-Boot may want to get PHY ofnode without connecting a PHY.
--- arch/sandbox/dts/test.dts | 13 +++++++++++++ drivers/core/ofnode.c | 21 +++++++++++++++++++++ drivers/core/read.c | 5 +++++ include/dm/ofnode.h | 14 ++++++++++++++ include/dm/read.h | 19 +++++++++++++++++++ net/mdio-uclass.c | 24 ++++++------------------ test/dm/ofnode.c | 18 ++++++++++++++++++ 7 files changed, 96 insertions(+), 18 deletions(-)
arch/sandbox/dts/test.dts +13 -0
@@ -530,6 +530,13 @@ fake-host-hwaddr = [00 00 66 44 22 22]; }; + phy_eth0: phy-test-eth { + compatible = "sandbox,eth"; + reg = <0x10007000 0x1000>; + fake-host-hwaddr = [00 00 66 44 22 77]; + phy-handle = <ðphy1>; + }; + dsa_eth0: dsa-test-eth { compatible = "sandbox,eth"; reg = <0x10006000 0x1000>;
@@ -1555,6 +1562,12 @@ mdio: mdio-test { compatible = "sandbox,mdio"; + #address-cells = <1>; + #size-cells = <0>; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; }; pm-bus-test {
drivers/core/ofnode.c +21 -0
@@ -1198,3 +1198,24 @@ const char *ofnode_conf_read_str(const char *prop_name)return ofnode_read_string (node, prop_name); } + +ofnode ofnode_get_phy_node (ofnode node) +{ +/* DT node properties that reference a PHY node */ +static const char *const phy_handle_str[] = { +"phy-handle" ,"phy" ,"phy-device" , + }; +struct ofnode_phandle_args args = { + .node =ofnode_null () + }; +int i; + +assert (ofnode_valid (node)); + +for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) +if (!ofnode_parse_phandle_with_args (node, phy_handle_str[i], +NULL ,0 ,0 , &args)) +break ; + +return args.node; +}
drivers/core/read.c +5 -0
@@ -398,3 +398,8 @@ int dev_decode_display_timing(const struct udevice *dev, int index, {return ofnode_decode_display_timing (dev_ofnode (dev), index, config); } + +ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +}
include/dm/ofnode.h +14 -0
@@ -1217,4 +1217,18 @@ int ofnode_conf_read_int(const char *prop_name, int default_val);*/ const char *ofnode_conf_read_str (const char *prop_name); +/** +* ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @eth_node: ofnode belonging to the Ethernet controller +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode ofnode_get_phy_node (ofnode eth_node); +#endif
include/dm/read.h +19 -0
@@ -743,6 +743,20 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res);int dev_decode_display_timing (const struct udevice *dev,int index,struct display_timing *config); +/** +* dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @dev: device representing the MAC +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode dev_get_phy_node (const struct udevice *dev); +#else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include <asm/global_data.h>
@@ -1092,6 +1106,11 @@ static inline int dev_decode_display_timing(const struct udevice *dev, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +static inline ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +} +#endif /* CONFIG_DM_DEV_READ_INLINE */ /**
net/mdio-uclass.c +6 -18
@@ -20,11 +20,6 @@ static const char * const phy_mode_str[] = { "phy-mode", "phy-connection-type" }; -/* DT node properties that reference a PHY node */ -static const char *const phy_handle_str[] = { -"phy-handle" ,"phy" ,"phy-device" -}; -void dm_mdio_probe_devices (void ) {struct udevice *it;
@@ -137,23 +132,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,u32 phy_addr;struct udevice *mdiodev;struct phy_device *phy; -struct ofnode_phandle_args phandle = {.node =ofnode_null ()};ofnode phynode; -int i;if (CONFIG_IS_ENABLED (PHY_FIXED ) &&ofnode_phy_is_fixed_link (dev_ofnode (ethdev), &phynode)) { phy =phy_connect (NULL ,0 , ethdev, interface); - phandle.node = phynode; goto out; } -for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) -if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL , -0 ,0 , &phandle)) -break ; - -if (!ofnode_valid (phandle.node)) { + phynode =dev_get_phy_node (ethdev); +if (!ofnode_valid (phynode)) {dev_dbg (ethdev,"can't find PHY node\n" );return NULL ; }
@@ -162,16 +150,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,* reading 'reg' directly should be fine. This is a PHY node, the * address is always size 1 and requires no translation */ -if (ofnode_read_u32 (phandle.node,"reg" , &phy_addr)) { +if (ofnode_read_u32 (phynode,"reg" , &phy_addr)) {dev_dbg (ethdev,"missing reg property in phy node\n" );return NULL ; }if (uclass_get_device_by_ofnode (UCLASS_MDIO , -ofnode_get_parent (phandle.node), +ofnode_get_parent (phynode), &mdiodev)) {dev_dbg (ethdev,"can't find MDIO bus for node %s\n" , -ofnode_get_name (ofnode_get_parent (phandle.node))); +ofnode_get_name (ofnode_get_parent (phynode)));return NULL ; }
@@ -179,7 +167,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, out:if (phy) - phy->node = phandle.node; + phy->node = phynode;return phy; }
test/dm/ofnode.c +18 -0
@@ -447,3 +447,21 @@ static int dm_test_ofnode_string_err(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_string_err,UT_TESTF_LIVE_TREE ); + +static int dm_test_ofnode_get_phy (struct unit_test_state *uts) +{ +ofnode eth_node, phy_node; +u32 reg; + + eth_node =ofnode_path ("/phy-test-eth" ); +ut_assert (ofnode_valid (eth_node)); + + phy_node =ofnode_get_phy_node (eth_node); +ut_assert (ofnode_valid (phy_node)); + + reg =ofnode_read_u32_default (phy_node,"reg" ,-1U ); +ut_asserteq_64 (0x1 , reg); + +return 0 ; +} +DM_TEST (dm_test_ofnode_get_phy,0 );
Signature · 1 line
2.35.1
PATCH v4 4/14 net: mdio-uclass: add wrappers for read/write/reset operations
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Add wrappers dm_mdio_read(), dm_mdio_write() and dm_mdio_reset() for DM MDIO's .read(), .write() and .reset() operations.
--- include/miiphy.h | 31 +++++++++++++++++++++++++++++++ net/mdio-uclass.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+)
include/miiphy.h +31 -0
@@ -157,6 +157,37 @@ struct mdio_ops {*/ void dm_mdio_probe_devices (void ); +/** +* dm_mdio_read - Wrapper over .read() operation for DM MDIO +* +* @mdiodev: mdio device +* @addr: PHY address on MDIO bus +* @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22 +* @reg: register address +* Return: register value if non-negative, -error code otherwise +*/ +int dm_mdio_read (struct udevice *mdio_dev,int addr,int devad,int reg); + +/** +* dm_mdio_write - Wrapper over .write() operation for DM MDIO +* +* @mdiodev: mdio device +* @addr: PHY address on MDIO bus +* @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22 +* @reg: register address +* @val: value to write +* Return: 0 on success, -error code otherwise +*/ +int dm_mdio_write (struct udevice *mdio_dev,int addr,int devad,int reg,u16 val); + +/** +* dm_mdio_reset - Wrapper over .reset() operation for DM MDIO +* +* @mdiodev: mdio device +* Return: 0 on success, -error code otherwise +*/ +int dm_mdio_reset (struct udevice *mdio_dev); +/** * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO *
net/mdio-uclass.c +31 -0
@@ -57,6 +57,37 @@ static int dm_mdio_post_bind(struct udevice *dev)return 0 ; } +int dm_mdio_read (struct udevice *mdio_dev,int addr,int devad,int reg) +{ +struct mdio_ops *ops =mdio_get_ops (mdio_dev); + +if (!ops->read) +return -ENOSYS ; + +return ops->read (mdio_dev, addr, devad, reg); +} + +int dm_mdio_write (struct udevice *mdio_dev,int addr,int devad,int reg, +u16 val) +{ +struct mdio_ops *ops =mdio_get_ops (mdio_dev); + +if (!ops->write) +return -ENOSYS ; + +return ops->write (mdio_dev, addr, devad, reg, val); +} + +int dm_mdio_reset (struct udevice *mdio_dev) +{ +struct mdio_ops *ops =mdio_get_ops (mdio_dev); + +if (!ops->reset) +return 0 ; + +return ops->reset (mdio_dev); +} +/* * Following read/write/reset functions are registered with legacy MII code. * These are called for PHY operations by upper layers and we further call the
Signature · 1 line
2.35.1
PATCH v4 6/14 net: phy: fix parsing wrong property
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
The "phy-interface-type" property should be "phy-connection-type".
--- drivers/net/phy/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
@@ -989,7 +989,7 @@ struct phy_device *fixed_phy_create(ofnode node) if_str =ofnode_read_string (node,"phy-mode" );if (!if_str) { - if_str =ofnode_read_string (node,"phy-interface-type" ); + if_str =ofnode_read_string (node,"phy-connection-type" ); }if (if_str) { interface =phy_get_interface_by_name (if_str);
Signature · 1 line
2.35.1
PATCH v4 5/14 treewide: use dm_mdio_read/write/reset() wrappers
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Use the new dm_mdio_read/write/reset() wrappers treewide, instead of always getting and dereferencing MDIO operations structure pointer.
--- drivers/net/mdio_mux_sandbox.c | 6 ++---- net/mdio-mux-uclass.c | 16 ++++------------ net/mdio-uclass.c | 19 ++++--------------- test/dm/mdio.c | 18 +++++++++--------- test/dm/mdio_mux.c | 16 ++++++++-------- 5 files changed, 27 insertions(+), 48 deletions(-)
drivers/net/mdio_mux_sandbox.c +2 -4
@@ -20,7 +20,6 @@ struct mdio_mux_sandbox_priv {static int mdio_mux_sandbox_mark_selection (struct udevice *dev,int sel) {struct udevice *mdio; -struct mdio_ops *ops;int err;/*
@@ -30,9 +29,8 @@ static int mdio_mux_sandbox_mark_selection(struct udevice *dev, int sel) err =uclass_get_device_by_name (UCLASS_MDIO ,"mdio-test" , &mdio);if (err)return err; - ops =mdio_get_ops (mdio); -return ops->write (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG_CNT -1 , (u16 )sel); +return dm_mdio_write (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG_CNT -1 , (u16 )sel); }static int mdio_mux_sandbox_select (struct udevice *dev,int cur,int sel)
net/mdio-mux-uclass.c +4 -12
@@ -54,11 +54,6 @@ static struct udevice *mmux_get_parent_mdio(struct udevice *mux)return pdata->mdio_parent; } -static struct mdio_ops *mmux_get_mdio_parent_ops (struct udevice *mux) -{ -return mdio_get_ops (mmux_get_parent_mdio (mux)); -} -/* call driver select function before performing MDIO r/w */ static int mmux_change_sel (struct udevice *ch,bool sel) {
@@ -90,14 +85,13 @@ static int mmux_read(struct udevice *ch, int addr, int devad, {struct udevice *mux = ch->parent;struct udevice *parent_mdio =mmux_get_parent_mdio (mux); -struct mdio_ops *parent_ops =mmux_get_mdio_parent_ops (mux);int err; err =mmux_change_sel (ch, true);if (err)return err; - err = parent_ops->read (parent_mdio, addr, devad, reg); + err =dm_mdio_read (parent_mdio, addr, devad, reg);mmux_change_sel (ch, false);return err;
@@ -109,14 +103,13 @@ static int mmux_write(struct udevice *ch, int addr, int devad, {struct udevice *mux = ch->parent;struct udevice *parent_mdio =mmux_get_parent_mdio (mux); -struct mdio_ops *parent_ops =mmux_get_mdio_parent_ops (mux);int err; err =mmux_change_sel (ch, true);if (err)return err; - err = parent_ops->write (parent_mdio, addr, devad, reg, val); + err =dm_mdio_write (parent_mdio, addr, devad, reg, val);mmux_change_sel (ch, false);return err;
@@ -127,18 +120,17 @@ static int mmux_reset(struct udevice *ch) {struct udevice *mux = ch->parent;struct udevice *parent_mdio =mmux_get_parent_mdio (mux); -struct mdio_ops *parent_ops =mmux_get_mdio_parent_ops (mux);int err;/* reset is optional, if it's not implemented just exit */ -if (!parent_ops->reset) +if (!mdio_get_ops (parent_mdio)->reset)return 0 ; err =mmux_change_sel (ch, true);if (err)return err; - err = parent_ops->reset (parent_mdio); + err =dm_mdio_reset (parent_mdio);mmux_change_sel (ch, false);return err;
net/mdio-uclass.c +4 -15
@@ -95,27 +95,18 @@ int dm_mdio_reset(struct udevice *mdio_dev)*/ static int mdio_read (struct mii_dev *mii_bus,int addr,int devad,int reg) { -struct udevice *dev = mii_bus->priv; - -return mdio_get_ops (dev)->read (dev, addr, devad, reg); +return dm_mdio_read (mii_bus->priv, addr, devad, reg); }static int mdio_write (struct mii_dev *mii_bus,int addr,int devad,int reg,u16 val) { -struct udevice *dev = mii_bus->priv; - -return mdio_get_ops (dev)->write (dev, addr, devad, reg, val); +return dm_mdio_write (mii_bus->priv, addr, devad, reg, val); }static int mdio_reset (struct mii_dev *mii_bus) { -struct udevice *dev = mii_bus->priv; - -if (mdio_get_ops (dev)->reset) -return mdio_get_ops (dev)->reset (dev); -else -return 0 ; +return dm_mdio_reset (mii_bus->priv); }static int dm_mdio_post_probe (struct udevice *dev)
@@ -135,10 +126,8 @@ static int dm_mdio_post_probe(struct udevice *dev)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); +dm_mdio_reset (dev);mdio_unregister (pdata->mii_bus);mdio_free (pdata->mii_bus);
test/dm/mdio.c +9 -9
@@ -38,18 +38,18 @@ static int dm_test_mdio(struct unit_test_state *uts)ut_assertnonnull (ops->read);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_assertok (dm_mdio_write (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ,TEST_REG_VALUE )); + reg =dm_mdio_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 ); +ut_assert (dm_mdio_read (dev,SANDBOX_PHY_ADDR +1 ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG ) !=0 ); -ut_assertok (ops->reset (dev)); - reg = ops->read (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG ); +ut_assertok (dm_mdio_reset (dev)); + reg =dm_mdio_read (dev,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG );ut_asserteq (reg,0 );return 0 ;
test/dm/mdio_mux.c +8 -8
@@ -57,22 +57,22 @@ static int dm_test_mdio_mux(struct unit_test_state *uts)* is selected to the selection #. Just reading that register from * either of the child buses should return the id of the child bus */ - reg = ops->read (mdio_ch0,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG_CNT -1 ); + reg =dm_mdio_read (mdio_ch0,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG_CNT -1 );ut_asserteq (reg,0 ); - reg = ops->read (mdio_ch1,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG_CNT -1 ); + reg =dm_mdio_read (mdio_ch1,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG_CNT -1 );ut_asserteq (reg,1 ); mmops->select (mux,MDIO_MUX_SELECT_NONE ,5 ); - reg = ops_parent->read (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG_CNT -1 ); + reg =dm_mdio_read (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG_CNT -1 );ut_asserteq (reg,5 ); mmops->deselect (mux,5 ); - reg = ops_parent->read (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , -SANDBOX_PHY_REG_CNT -1 ); + reg =dm_mdio_read (mdio,SANDBOX_PHY_ADDR ,MDIO_DEVAD_NONE , +SANDBOX_PHY_REG_CNT -1 );ut_asserteq (reg, (u16 )MDIO_MUX_SELECT_NONE );return 0 ;
Signature · 1 line
2.35.1
PATCH v4 8/14 treewide: Rename PHY_INTERFACE_MODE_COUNT to PHY_INTERFACE_MODE_MAX
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Rename constant PHY_INTERFACE_MODE_COUNT to PHY_INTERFACE_MODE_MAX to make it compatible with Linux' naming.
--- drivers/core/ofnode.c | 2 +- drivers/net/phy/aquantia.c | 2 +- include/phy_interface.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/core/ofnode.c +1 -1
@@ -1234,7 +1234,7 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)if (!mode)return PHY_INTERFACE_MODE_NONE ; -for (i =0 ; i <PHY_INTERFACE_MODE_COUNT ; i++) +for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++)if (!strcmp (mode, phy_interface_strings[i]))return i;
drivers/net/phy/aquantia.c +1 -1
@@ -305,7 +305,7 @@ struct {u16 syscfg;int cnt;u16 start_rate; -} aquantia_syscfg[PHY_INTERFACE_MODE_COUNT] = { +} aquantia_syscfg[PHY_INTERFACE_MODE_MAX] = { [PHY_INTERFACE_MODE_SGMII] = {0x04b, AQUANTIA_VND1_GSYSCFG_1G, AQUANTIA_VND1_GSTART_RATE_1G}, [PHY_INTERFACE_MODE_2500BASEX] = {0x144, AQUANTIA_VND1_GSYSCFG_2_5G,
include/phy_interface.h +1 -1
@@ -41,7 +41,7 @@ typedef enum {PHY_INTERFACE_MODE_USXGMII ,PHY_INTERFACE_MODE_NONE ,/* Must be last */ -PHY_INTERFACE_MODE_COUNT , +PHY_INTERFACE_MODE_MAX , } phy_interface_t; static const char * const phy_interface_strings[] = {
Signature · 1 line
2.35.1
PATCH v4 11/14 net: phy: xilinx: Check interface type in ->config(), not ->probe()
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
We want to be able to have phydev->interface uninitialized during ->probe(). We should assume that phydev->interface is initialized only before ->config().
--- drivers/net/phy/xilinx_gmii2rgmii.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/phy/xilinx_gmii2rgmii.c +5 -5
@@ -26,6 +26,11 @@ static int xilinxgmiitorgmii_config(struct phy_device *phydev)debug ("%s\n" , __func__); +if (phydev->interface !=PHY_INTERFACE_MODE_GMII ) { +printf ("Incorrect interface type\n" ); +return -EINVAL ; + } +if (!ofnode_valid (node))return -EINVAL ;
@@ -114,11 +119,6 @@ static int xilinxgmiitorgmii_probe(struct phy_device *phydev) {debug ("%s\n" , __func__); -if (phydev->interface !=PHY_INTERFACE_MODE_GMII ) { -printf ("Incorrect interface type\n" ); -return -EINVAL ; - } - phydev->flags |=PHY_FLAG_BROKEN_RESET ;return 0 ;
Signature · 1 line
2.35.1
PATCH v4 10/14 phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition to make it have zero value. This makes it possible (although not encouraged) to test for invalid/nonexistent interface mode with !val instead of val == PHY_INTERFACE_MODE_NA.
The comment near the definition says "Must be last", because when the constant was introduced in commit 5f184715ecd3 ("Create PHY Lib for U-Boot"), it was used as the maximum value when interating over the constants. But this is no longer true - we use PHY_INTERFACE_MODE_MAX for that now, and so we can move it.
--- include/phy_interface.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
include/phy_interface.h +2 -3
@@ -13,6 +13,7 @@#include <string.h> typedef enum { + PHY_INTERFACE_MODE_NA, /* don't touch */ PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_SGMII,
@@ -39,12 +40,11 @@ typedef enum {PHY_INTERFACE_MODE_NCSI ,PHY_INTERFACE_MODE_10GBASER ,PHY_INTERFACE_MODE_USXGMII , -PHY_INTERFACE_MODE_NA ,/* Must be last */ -PHY_INTERFACE_MODE_MAX , } phy_interface_t;static const char *const phy_interface_strings[] = { + [PHY_INTERFACE_MODE_NA ] ="" , [PHY_INTERFACE_MODE_MII ] ="mii" , [PHY_INTERFACE_MODE_GMII ] ="gmii" , [PHY_INTERFACE_MODE_SGMII] = "sgmii",
@@ -71,7 +71,6 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", - [PHY_INTERFACE_MODE_NA] = "", };/* Backplane modes:
Signature · 1 line
2.35.1
PATCH v4 12/14 net: phy: use ->is_c45 instead of is_10g_interface()
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Use phydev->is_c45 instead of is_10g_interface(phydev->interface) to determine whether clause 45 protocol should be used.
--- drivers/net/phy/phy.c | 8 ++++---- include/phy.h | 12 ------------ 2 files changed, 4 insertions(+), 16 deletions(-)
drivers/net/phy/phy.c +4 -4
@@ -632,10 +632,10 @@ static int phy_probe(struct phy_device *phydev)return err; } -static struct phy_driver *generic_for_interface (phy_interface_t interface) +static struct phy_driver *generic_for_phy (struct phy_device *phydev) {#ifdef CONFIG_PHYLIB_10G -if (is_10g_interface (interface)) +if (phydev->is_c45)return &gen10g_driver;#endif
@@ -656,7 +656,7 @@ static struct phy_driver *get_phy_driver(struct phy_device *phydev, }/* If we made it here, there's no driver for this PHY */ -return generic_for_interface (interface); +return generic_for_phy (phydev); } struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
@@ -859,7 +859,7 @@ int phy_reset(struct phy_device *phydev)#ifdef CONFIG_PHYLIB_10G /* If it's 10G, we need to issue reset through one of the MMDs */ -if (is_10g_interface (phydev->interface)) { +if (phydev->is_c45) {if (!phydev->mmds)gen10g_discover_mmds (phydev);
include/phy.h +0 -12
@@ -359,18 +359,6 @@ static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,#ifdef CONFIG_PHYLIB_10G extern struct phy_driver gen10g_driver; - -/* -* List all 10G interfaces here, the assumption being that PHYs on these -* interfaces are C45 -*/ -static inline int is_10g_interface (phy_interface_t interface) -{ -return interface ==PHY_INTERFACE_MODE_XGMII || - interface ==PHY_INTERFACE_MODE_USXGMII || - interface ==PHY_INTERFACE_MODE_10GBASER ; -} -#endif /**
Signature · 1 line
2.35.1
PATCH v4 7/14 net: introduce helpers to get PHY interface mode from a device/ofnode
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Add helpers ofnode_read_phy_mode() and dev_read_phy_mode() to parse the "phy-mode" / "phy-connection-type" property. Add corresponding UT test.
Use them treewide.
This allows us to inline the phy_get_interface_by_name() into ofnode_read_phy_mode(), since the former is not used anymore.
--- arch/sandbox/dts/test.dts | 1 + board/st/stm32f746-disco/stm32f746-disco.c | 13 +++----- drivers/core/ofnode.c | 23 ++++++++++++++ drivers/core/read.c | 5 +++ drivers/net/ag7xxx.c | 9 ++---- drivers/net/altera_tse.c | 13 ++------ drivers/net/bcm6348-eth.c | 6 +--- drivers/net/bcmgenet.c | 10 ++---- drivers/net/designware.c | 10 ++---- drivers/net/dwc_eth_qos.c | 36 +++------------------- drivers/net/fec_mxc.c | 11 ++----- drivers/net/fm/eth.c | 13 +------- drivers/net/fsl_enetc.c | 13 +++----- drivers/net/ftgmac100.c | 11 ++----- drivers/net/higmacv300.c | 9 ++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +++-------------- drivers/net/macb.c | 10 ++---- drivers/net/mt7620-eth.c | 35 +++++++-------------- drivers/net/mtk_eth.c | 8 ++--- drivers/net/mvgbe.c | 7 ++--- drivers/net/mvneta.c | 11 ++----- drivers/net/mvpp2.c | 9 ++---- drivers/net/phy/phy.c | 25 ++------------- drivers/net/pic32_eth.c | 11 ++----- drivers/net/qe/dm_qe_uec.c | 11 ++----- drivers/net/ravb.c | 15 +++------ drivers/net/sh_eth.c | 15 +++------ drivers/net/sni_ave.c | 12 ++------ drivers/net/sni_netsec.c | 10 ++---- drivers/net/sun8i_emac.c | 11 ++----- drivers/net/ti/am65-cpsw-nuss.c | 15 +++------ drivers/net/ti/cpsw.c | 10 ++---- drivers/net/ti/keystone_net.c | 24 +++++++-------- drivers/net/tsec.c | 9 ++---- drivers/net/xilinx_axi_emac.c | 10 ++---- drivers/net/zynq_gem.c | 9 ++---- include/dm/ofnode.h | 13 ++++++++ include/dm/read.h | 17 ++++++++++ include/phy.h | 8 ----- net/mdio-uclass.c | 18 +---------- test/dm/ofnode.c | 4 +++ 41 files changed, 166 insertions(+), 372 deletions(-)
arch/sandbox/dts/test.dts +1 -0
@@ -535,6 +535,7 @@ reg = <0x10007000 0x1000>; fake-host-hwaddr = [00 00 66 44 22 77]; phy-handle = <ðphy1>; + phy-mode = "2500base-x"; }; dsa_eth0: dsa-test-eth {
board/st/stm32f746-disco/stm32f746-disco.c +5 -8
@@ -117,16 +117,13 @@ int board_late_init(void)int board_init (void ) {#ifdef CONFIG_ETH_DESIGNWARE -const char *phy_mode; -int node; +ofnode node; - node =fdt_node_offset_by_compatible (gd->fdt_blob,0 ,"st,stm32-dwmac" ); -if (node <0 ) + node =ofnode_by_compatible (ofnode_null (),"st,stm32-dwmac" ); +if (!ofnode_valid (node))return -1 ; - phy_mode =fdt_getprop (gd->fdt_blob, node,"phy-mode" ,NULL ); - -switch (phy_get_interface_by_name (phy_mode)) { +switch (ofnode_read_phy_mode (node)) {case PHY_INTERFACE_MODE_RMII :STM32_SYSCFG ->pmc |=SYSCFG_PMC_MII_RMII_SEL ;break ;
@@ -134,7 +131,7 @@ int board_init(void)STM32_SYSCFG ->pmc &= ~SYSCFG_PMC_MII_RMII_SEL ;break ;default : - printf("PHY interface %s not supported !\n", phy_mode); + printf("Unsupported PHY interface!\n"); }#endif
drivers/core/ofnode.c +23 -0
@@ -1219,3 +1219,26 @@ ofnode ofnode_get_phy_node(ofnode node)return args.node; } + +phy_interface_t ofnode_read_phy_mode (ofnode node) +{ +const char *mode; +int i; + +assert (ofnode_valid (node)); + + mode =ofnode_read_string (node,"phy-mode" ); +if (!mode) + mode =ofnode_read_string (node,"phy-connection-type" ); + +if (!mode) +return PHY_INTERFACE_MODE_NONE ; + +for (i =0 ; i <PHY_INTERFACE_MODE_COUNT ; i++) +if (!strcmp (mode, phy_interface_strings[i])) +return i; + +debug ("%s: Invalid PHY interface '%s'\n" , __func__, mode); + +return PHY_INTERFACE_MODE_NONE ; +}
drivers/core/read.c +5 -0
@@ -403,3 +403,8 @@ ofnode dev_get_phy_node(const struct udevice *dev) {return ofnode_get_phy_node (dev_ofnode (dev)); } + +phy_interface_t dev_read_phy_mode (const struct udevice *dev) +{ +return ofnode_read_phy_mode (dev_ofnode (dev)); +}
drivers/net/ag7xxx.c +2 -7
@@ -1254,7 +1254,6 @@ static const struct eth_ops ag7xxx_eth_ops = {static int ag7xxx_eth_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode;int ret; pdata->iobase =dev_read_addr (dev);
@@ -1265,13 +1264,9 @@ static int ag7xxx_eth_of_to_plat(struct udevice *dev)if (ret <=0 )return ret; - phy_mode =fdt_getprop (gd->fdt_blob, ret,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }return 0 ; }
drivers/net/altera_tse.c +3 -10
@@ -676,17 +676,10 @@ static int altera_tse_probe(struct udevice *dev)static int altera_tse_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode; - - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }return 0 ; }
drivers/net/bcm6348-eth.c +1 -5
@@ -415,7 +415,6 @@ static int bcm6348_eth_probe(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct bcm6348_eth_priv *priv =dev_get_priv (dev);struct ofnode_phandle_args phy; -const char *phy_mode;int ret, i;/* get base address */
@@ -425,10 +424,7 @@ static int bcm6348_eth_probe(struct udevice *dev) pdata->iobase = (phys_addr_t ) priv->base;/* get phy mode */ - pdata->phy_interface =PHY_INTERFACE_MODE_NONE ; - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev);if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -ENODEV ;
drivers/net/bcmgenet.c +2 -8
@@ -690,20 +690,14 @@ static int bcmgenet_eth_of_to_plat(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct bcmgenet_eth_priv *priv =dev_get_priv (dev);struct ofnode_phandle_args phy_node; -const char *phy_mode;int ret; pdata->iobase =dev_read_addr (dev);/* Get phy mode from DT */ - pdata->phy_interface =-1 ; - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } ret =dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phy_node);
drivers/net/designware.c +2 -8
@@ -914,21 +914,15 @@ int designware_eth_of_to_plat(struct udevice *dev)struct dw_eth_dev *priv =dev_get_priv (dev);#endif struct eth_pdata *pdata = &dw_pdata->eth_pdata; -const char *phy_mode;#if CONFIG_IS_ENABLED (DM_GPIO )int reset_flags =GPIOD_IS_OUT ;#endif int ret =0 ; pdata->iobase =dev_read_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } pdata->max_speed =dev_read_u32_default (dev,"max-speed" ,0 );
drivers/net/dwc_eth_qos.c +4 -32
@@ -270,7 +270,7 @@ struct eqos_config {int config_mac;int config_mac_mdio;unsigned int axi_bus_width; -phy_interface_t (*interface)(struct udevice *dev); +phy_interface_t (*interface)(const struct udevice *dev);struct eqos_ops *ops; };
@@ -1729,21 +1729,7 @@ err_probe:return ret; } -static phy_interface_t eqos_get_interface_stm32 (struct udevice *dev) -{ -const char *phy_mode; -phy_interface_t interface =PHY_INTERFACE_MODE_NONE ; - -debug ("%s(dev=%p):\n" , __func__, dev); - - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); -if (phy_mode) - interface =phy_get_interface_by_name (phy_mode); - -return interface; -} - -static phy_interface_t eqos_get_interface_tegra186 (struct udevice *dev) +static phy_interface_t eqos_get_interface_tegra186 (const struct udevice *dev) {return PHY_INTERFACE_MODE_MII ; }
@@ -1766,20 +1752,6 @@ static int eqos_probe_resources_imx(struct udevice *dev)return 0 ; } -static phy_interface_t eqos_get_interface_imx (struct udevice *dev) -{ -const char *phy_mode; -phy_interface_t interface =PHY_INTERFACE_MODE_NONE ; - -debug ("%s(dev=%p):\n" , __func__, dev); - - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); -if (phy_mode) - interface =phy_get_interface_by_name (phy_mode); - -return interface; -} -static int eqos_remove_resources_tegra186 (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -1985,7 +1957,7 @@ static const struct eqos_config __maybe_unused eqos_stm32_config = { .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV, .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, .axi_bus_width = EQOS_AXI_WIDTH_64, - .interface = eqos_get_interface_stm32, + .interface = dev_read_phy_mode, .ops = &eqos_stm32_ops };
@@ -2013,7 +1985,7 @@ struct eqos_config __maybe_unused eqos_imx_config = { .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB, .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_250_300, .axi_bus_width = EQOS_AXI_WIDTH_64, - .interface = eqos_get_interface_imx, + .interface = dev_read_phy_mode, .ops = &eqos_imx_ops };
drivers/net/fec_mxc.c +2 -9
@@ -1310,20 +1310,13 @@ static int fecmxc_of_to_plat(struct udevice *dev)int ret =0 ;struct eth_pdata *pdata =dev_get_plat (dev);struct fec_priv *priv =dev_get_priv (dev); -const char *phy_mode; pdata->iobase =dev_read_addr (dev); priv->eth = (struct ethernet_regs *)pdata->iobase; - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }#ifdef CONFIG_DM_REGULATOR device_get_supply_regulator (dev,"phy-supply" , &priv->phy_supply);
drivers/net/fm/eth.c +1 -12
@@ -954,17 +954,6 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) return 0; }#else /* CONFIG_DM_ETH */ -#ifdef CONFIG_PHYLIB -phy_interface_t fman_read_sys_if (struct udevice *dev) -{ -const char *if_str; - - if_str =ofnode_read_string (dev_ofnode (dev),"phy-connection-type" ); -debug ("MAC system interface mode %s\n" , if_str); - -return phy_get_interface_by_name (if_str); -} -#endif static int fm_eth_bind (struct udevice *dev) {
@@ -1038,7 +1027,7 @@ static int fm_eth_probe(struct udevice *dev) reg = (void *)(uintptr_t )dev_read_addr (dev); fm_eth->mac_type =dev_get_driver_data (dev);#ifdef CONFIG_PHYLIB - fm_eth->enet_if =fman_read_sys_if (dev); + fm_eth->enet_if =dev_read_phy_mode (dev);#else fm_eth->enet_if =PHY_INTERFACE_MODE_SGMII ;printf ("%s: warning - unable to determine interface type\n" , __func__);
drivers/net/fsl_enetc.c +4 -9
@@ -260,9 +260,6 @@ static int enetc_init_sxgmii(struct udevice *dev)static void enetc_start_pcs (struct udevice *dev) {struct enetc_priv *priv =dev_get_priv (dev); -const char *if_str; - - priv->if_type =PHY_INTERFACE_MODE_NONE ;/* register internal MDIO for debug purposes */ if (enetc_read_port (priv,ENETC_PCAPR0 ) &ENETC_PCAPRO_MDIO ) {
@@ -279,14 +276,12 @@ static void enetc_start_pcs(struct udevice *dev)return ; } - if_str =ofnode_read_string (dev_ofnode (dev),"phy-mode" ); -if (if_str) - priv->if_type =phy_get_interface_by_name (if_str); -else + priv->if_type =dev_read_phy_mode (dev); +if (priv->if_type ==PHY_INTERFACE_MODE_NONE ) {enetc_dbg (dev,"phy-mode property not found, defaulting to SGMII\n" ); -if (priv->if_type <0 ) - priv->if_type =PHY_INTERFACE_MODE_NONE ; + priv->if_type =PHY_INTERFACE_MODE_SGMII ; + }switch (priv->if_type) {case PHY_INTERFACE_MODE_SGMII :
drivers/net/ftgmac100.c +3 -8
@@ -549,17 +549,12 @@ static int ftgmac100_of_to_plat(struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev);struct ftgmac100_data *priv =dev_get_priv (dev); -const char *phy_mode; pdata->iobase =dev_read_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -dev_err (dev,"Invalid PHY interface '%s'\n" , phy_mode); + + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } pdata->max_speed =dev_read_u32_default (dev,"max-speed" ,0 );
drivers/net/higmacv300.c +2 -7
@@ -561,19 +561,14 @@ static int higmac_remove(struct udevice *dev)static int higmac_of_to_plat (struct udevice *dev) {struct higmac_priv *priv =dev_get_priv (dev); -int phyintf =PHY_INTERFACE_MODE_NONE ; -const char *phy_mode;ofnode phy_node; priv->base =dev_remap_addr_index (dev,0 ); priv->macif_ctrl =dev_remap_addr_index (dev,1 ); - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) - phyintf =phy_get_interface_by_name (phy_mode); -if (phyintf ==PHY_INTERFACE_MODE_NONE ) + priv->phyintf =dev_read_phy_mode (dev); +if (priv->phyintf ==PHY_INTERFACE_MODE_NONE )return -ENODEV ; - priv->phyintf = phyintf; phy_node =dev_read_subnode (dev,"phy" );if (!ofnode_valid (phy_node)) {
drivers/net/ldpaa_eth/ldpaa_eth.c +5 -23
@@ -1120,31 +1120,14 @@ static uint32_t ldpaa_eth_get_dpmac_id(struct udevice *dev)return fdtdec_get_uint (gd->fdt_blob, port_node,"reg" ,-1 ); } -static const char *ldpaa_eth_get_phy_mode_str (struct udevice *dev) -{ -int port_node =dev_of_offset (dev); -const char *phy_mode_str; - - phy_mode_str =fdt_getprop (gd->fdt_blob, port_node, -"phy-connection-type" ,NULL ); -if (phy_mode_str) -return phy_mode_str; - - phy_mode_str =fdt_getprop (gd->fdt_blob, port_node,"phy-mode" ,NULL ); -return phy_mode_str; -} -static int ldpaa_eth_bind (struct udevice *dev) { -const char *phy_mode_str =NULL ;uint32_t dpmac_id;char eth_name[16 ];int phy_mode =-1 ; - phy_mode_str =ldpaa_eth_get_phy_mode_str (dev); -if (phy_mode_str) - phy_mode =phy_get_interface_by_name (phy_mode_str); -if (phy_mode ==-1 ) { + phy_mode =dev_read_phy_mode (dev); +if (phy_mode ==PHY_INTERFACE_MODE_NONE ) {dev_err (dev,"incorrect phy mode\n" );return -EINVAL ; }
@@ -1155,7 +1138,8 @@ static int ldpaa_eth_bind(struct udevice *dev)return -EINVAL ; } -sprintf (eth_name,"DPMAC%d@%s" , dpmac_id, phy_mode_str); +sprintf (eth_name,"DPMAC%d@%s" , dpmac_id, +phy_string_for_interface (phy_mode));device_set_name (dev, eth_name);return 0 ;
@@ -1164,11 +1148,9 @@ static int ldpaa_eth_bind(struct udevice *dev)static int ldpaa_eth_of_to_plat (struct udevice *dev) {struct ldpaa_eth_priv *priv =dev_get_priv (dev); -const char *phy_mode_str; priv->dpmac_id =ldpaa_eth_get_dpmac_id (dev); - phy_mode_str =ldpaa_eth_get_phy_mode_str (dev); - priv->phy_mode =phy_get_interface_by_name (phy_mode_str); + priv->phy_mode =dev_read_phy_mode (dev);return 0 ; }
drivers/net/macb.c +2 -8
@@ -1360,17 +1360,11 @@ static int macb_eth_probe(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct macb_device *macb =dev_get_priv (dev);struct ofnode_phandle_args phandle_args; -const char *phy_mode;int ret; - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); - -if (phy_mode) - macb->phy_interface =phy_get_interface_by_name (phy_mode); -if (macb->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + macb->phy_interface =dev_read_phy_mode (dev); +if (macb->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }/* Read phyaddr from DT */ if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
drivers/net/mt7620-eth.c +11 -24
@@ -1048,33 +1048,20 @@ static int mt7620_eth_parse_gsw_port(struct mt7620_eth_priv *priv, u32 idx, ofnode node) {ofnode subnode; -const char *str; -int mode, speed, ret; +int speed, ret;u32 phy_addr; - str =ofnode_read_string (node,"phy-mode" ); -if (str) { - mode =phy_get_interface_by_name (str); -if (mode <0 ) { -dev_err (priv->dev,"mt7620_eth: invalid phy-mode\n" ); -return -EINVAL ; - } - -switch (mode) { -case PHY_INTERFACE_MODE_MII : -case PHY_INTERFACE_MODE_RMII : -case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_NONE : -break ; -default : -dev_err (priv->dev, -"mt7620_eth: unsupported phy-mode\n" ); -return -ENOTSUPP ; - } + priv->port_cfg[idx].mode =ofnode_read_phy_mode (node); - priv->port_cfg[idx].mode = mode; - }else { - priv->port_cfg[idx].mode =PHY_INTERFACE_MODE_NONE ; +switch (priv->port_cfg[idx].mode) { +case PHY_INTERFACE_MODE_MII : +case PHY_INTERFACE_MODE_RMII : +case PHY_INTERFACE_MODE_RGMII : +case PHY_INTERFACE_MODE_NONE : +break ; +default : +dev_err (priv->dev,"mt7620_eth: unsupported phy-mode\n" ); +return -ENOTSUPP ; } subnode =ofnode_find_subnode (node,"fixed-link" );
drivers/net/mtk_eth.c +3 -5
@@ -1447,11 +1447,9 @@ static int mtk_eth_of_to_plat(struct udevice *dev) priv->gmac_id =dev_read_u32_default (dev,"mediatek,gmac-id" ,0 );/* Interface mode is required */ - str =dev_read_string (dev,"phy-mode" ); -if (str) { - pdata->phy_interface =phy_get_interface_by_name (str); - priv->phy_interface = pdata->phy_interface; - }else { + pdata->phy_interface =dev_read_phy_mode (dev); + priv->phy_interface = pdata->phy_interface; +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) {printf ("error: phy-mode is not set\n" );return -EINVAL ; }
drivers/net/mvgbe.c +2 -5
@@ -993,7 +993,6 @@ static int mvgbe_of_to_plat(struct udevice *dev)struct mvgbe_device *dmvgbe =dev_get_priv (dev);void *blob = (void *)gd->fdt_blob;int node =dev_of_offset (dev); -const char *phy_mode;int fl_node;int pnode;unsigned long addr;
@@ -1005,10 +1004,8 @@ static int mvgbe_of_to_plat(struct udevice *dev) "marvell,kirkwood-eth-port");/* Get phy-mode / phy_interface from DT */ - phy_mode =fdt_getprop (gd->fdt_blob, pnode,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -else + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) pdata->phy_interface =PHY_INTERFACE_MODE_GMII ; dmvgbe->phy_interface = pdata->phy_interface;
drivers/net/mvneta.c +2 -9
@@ -1799,20 +1799,13 @@ static const struct eth_ops mvneta_ops = {static int mvneta_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode; pdata->iobase =dev_read_addr (dev);/* Get phy-mode / phy_interface from DT */ - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }return 0 ; }
drivers/net/mvpp2.c +2 -7
@@ -4786,11 +4786,9 @@ static int mvpp2_port_init(struct udevice *dev, struct mvpp2_port *port)static int phy_info_parse (struct udevice *dev,struct mvpp2_port *port) {int port_node =dev_of_offset (dev); -const char *phy_mode_str;int phy_node;u32 id;u32 phyaddr =0 ; -int phy_mode =-1 ;int fixed_link =0 ;int ret;
@@ -4821,10 +4819,8 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port) phyaddr =PHY_MAX_ADDR ; } - phy_mode_str =fdt_getprop (gd->fdt_blob, port_node,"phy-mode" ,NULL ); -if (phy_mode_str) - phy_mode =phy_get_interface_by_name (phy_mode_str); -if (phy_mode ==-1 ) { + port->phy_interface =dev_read_phy_mode (dev); +if (port->phy_interface ==PHY_INTERFACE_MODE_NONE ) {dev_err (dev,"incorrect phy mode\n" );return -EINVAL ; }
@@ -4847,7 +4843,6 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port) port->first_rxq = port->id * rxq_number; else port->first_rxq = port->id * port->priv->max_port_rxqs; - port->phy_interface = phy_mode; port->phyaddr = phyaddr;return 0 ;
drivers/net/phy/phy.c +2 -23
@@ -982,25 +982,16 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,*/ struct phy_device *fixed_phy_create (ofnode node) { -phy_interface_t interface =PHY_INTERFACE_MODE_NONE ;struct phy_device *phydev; -const char *if_str;ofnode subnode; - if_str =ofnode_read_string (node,"phy-mode" ); -if (!if_str) { - if_str =ofnode_read_string (node,"phy-connection-type" ); - } -if (if_str) { - interface =phy_get_interface_by_name (if_str); - } - subnode =ofnode_find_subnode (node,"fixed-link" );if (!ofnode_valid (subnode)) {return NULL ; } - phydev =phy_device_create (NULL ,0 ,PHY_FIXED_ID , false, interface); + phydev =phy_device_create (NULL ,0 ,PHY_FIXED_ID , false, +ofnode_read_phy_mode (node));if (phydev) phydev->node = subnode;
@@ -1098,15 +1089,3 @@ int phy_shutdown(struct phy_device *phydev)return 0 ; } - -int phy_get_interface_by_name (const char *str) -{ -int i; - -for (i =0 ; i <PHY_INTERFACE_MODE_COUNT ; i++) { -if (!strcmp (str, phy_interface_strings[i])) -return i; - } - -return -1 ; -}
drivers/net/pic32_eth.c +2 -9
@@ -534,7 +534,6 @@ static int pic32_eth_probe(struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev);struct pic32eth_dev *priv =dev_get_priv (dev); -const char *phy_mode;void __iomem *iobase;fdt_addr_t addr;fdt_size_t size;
@@ -550,15 +549,9 @@ static int pic32_eth_probe(struct udevice *dev) pdata->iobase = (phys_addr_t )addr;/* get phy mode */ - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }/* get phy addr */ offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
drivers/net/qe/dm_qe_uec.c +2 -9
@@ -1133,19 +1133,12 @@ static int qe_uec_remove(struct udevice *dev)static int qe_uec_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode; pdata->iobase = (phys_addr_t )devfdt_get_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), -"phy-connection-type" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }return 0 ; }
drivers/net/ravb.c +4 -11
@@ -674,20 +674,13 @@ static const struct eth_ops ravb_ops = {int ravb_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode;const fdt32_t *cell; -int ret =0 ; pdata->iobase =dev_read_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } pdata->max_speed =1000 ; cell =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"max-speed" ,NULL );
@@ -696,7 +689,7 @@ int ravb_of_to_plat(struct udevice *dev)sprintf (bb_miiphy_buses[0 ].name, dev->name); -return ret; +return 0 ; }static const struct udevice_id ravb_ids[] = {
drivers/net/sh_eth.c +4 -11
@@ -915,20 +915,13 @@ static const struct eth_ops sh_ether_ops = {int sh_ether_of_to_plat (struct udevice *dev) {struct eth_pdata *pdata =dev_get_plat (dev); -const char *phy_mode;const fdt32_t *cell; -int ret =0 ; pdata->iobase =dev_read_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } pdata->max_speed =1000 ; cell =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"max-speed" ,NULL );
@@ -937,7 +930,7 @@ int sh_ether_of_to_plat(struct udevice *dev)sprintf (bb_miiphy_buses[0 ].name, dev->name); -return ret; +return 0 ; }static const struct udevice_id sh_ether_ids[] = {
drivers/net/sni_ave.c +3 -9
@@ -738,7 +738,6 @@ static int ave_of_to_plat(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct ave_private *priv =dev_get_priv (dev);struct ofnode_phandle_args args; -const char *phy_mode;const u32 *valp;int ret, nc, nr;const char *name;
@@ -748,15 +747,10 @@ static int ave_of_to_plat(struct udevice *dev)return -EINVAL ; pdata->iobase =dev_read_addr (dev); - pdata->phy_interface =-1 ; - phy_mode =fdt_getprop (gd->fdt_blob,dev_of_offset (dev),"phy-mode" , -NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -dev_err (dev,"Invalid PHY interface '%s'\n" , phy_mode); + + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } pdata->max_speed =0 ; valp = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed",
drivers/net/sni_netsec.c +2 -8
@@ -1029,19 +1029,13 @@ static int netsec_of_to_plat(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct netsec_priv *priv =dev_get_priv (dev);struct ofnode_phandle_args phandle_args; -const char *phy_mode; pdata->iobase =dev_read_addr_index (dev,0 ); priv->eeprom_base =dev_read_addr_index (dev,1 ) -EERPROM_MAP_OFFSET ; - pdata->phy_interface =-1 ; - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -pr_err ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }if (!dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phandle_args))
drivers/net/sun8i_emac.c +2 -9
@@ -882,7 +882,6 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)struct sun8i_eth_pdata *sun8i_pdata =dev_get_plat (dev);struct eth_pdata *pdata = &sun8i_pdata->eth_pdata;struct emac_eth_dev *priv =dev_get_priv (dev); -const char *phy_mode;const fdt32_t *reg;int node =dev_of_offset (dev);int offset =0 ;
@@ -946,16 +945,10 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) } priv->phyaddr =fdtdec_get_int (gd->fdt_blob, offset,"reg" ,-1 ); - phy_mode =fdt_getprop (gd->fdt_blob, node,"phy-mode" ,NULL ); - -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev);printf ("phy interface%d\n" , pdata->phy_interface); - -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }if (priv->variant ==H3_EMAC ) { ret =sun8i_handle_internal_phy (dev, priv);
drivers/net/ti/am65-cpsw-nuss.c +4 -11
@@ -602,21 +602,14 @@ static int am65_cpsw_ofdata_parse_phy(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct am65_cpsw_priv *priv =dev_get_priv (dev);struct ofnode_phandle_args out_args; -const char *phy_mode;int ret =0 ;dev_read_u32 (dev,"reg" , &priv->port_id); - phy_mode =dev_read_string (dev,"phy-mode" ); -if (phy_mode) { - pdata->phy_interface = -phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -dev_err (dev,"Invalid PHY mode '%s', port %u\n" , - phy_mode, priv->port_id); - ret = -EINVAL ; - goto out; - } + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) { +dev_err (dev,"Invalid PHY mode, port %u\n" , priv->port_id); +return -EINVAL ; }dev_read_u32 (dev,"max-speed" , (u32 *)&pdata->max_speed);
drivers/net/ti/cpsw.c +2 -8
@@ -1194,15 +1194,12 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data, {struct ofnode_phandle_args out_args;struct cpsw_slave_data *slave_data; -const char *phy_mode;u32 phy_id[2 ];int ret; slave_data = &data->slave_data[slave_index]; - phy_mode =ofnode_read_string (subnode,"phy-mode" ); -if (phy_mode) - slave_data->phy_if =phy_get_interface_by_name (phy_mode); + slave_data->phy_if =ofnode_read_phy_mode (subnode); ret =ofnode_parse_phandle_with_args (subnode,"phy-handle" ,NULL ,0 ,0 , &out_args);
@@ -1348,11 +1345,8 @@ static int cpsw_eth_of_to_plat(struct udevice *dev) } pdata->phy_interface = data->slave_data[data->active_slave].phy_if; -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, -phy_string_for_interface (pdata->phy_interface)); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - }return 0 ; }
drivers/net/ti/keystone_net.c +11 -13
@@ -687,7 +687,6 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave,int phy;int dma_count;u32 dma_channel[8 ]; -const char *phy_mode; priv->slave_port =fdtdec_get_int (fdt, slave,"slave-port" ,-1 ); priv->net_rx_buffs.rx_flow = priv->slave_port *8 ;
@@ -728,20 +727,19 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, priv->sgmii_link_type =SGMII_LINK_MAC_PHY ; priv->has_mdio = true; }else if (priv->link_type ==LINK_TYPE_RGMII_LINK_MAC_PHY ) { - phy_mode =fdt_getprop (fdt, slave,"phy-mode" ,NULL ); -if (phy_mode) { - priv->phy_if =phy_get_interface_by_name (phy_mode); -if (priv->phy_if !=PHY_INTERFACE_MODE_RGMII && - priv->phy_if !=PHY_INTERFACE_MODE_RGMII_ID && - priv->phy_if !=PHY_INTERFACE_MODE_RGMII_RXID && - priv->phy_if !=PHY_INTERFACE_MODE_RGMII_TXID ) { -pr_err ("invalid phy-mode\n" ); -return -EINVAL ; - } - }else { + priv->phy_if =ofnode_read_phy_mode (offset_to_ofnode (slave)); +if (priv->phy_if ==PHY_INTERFACE_MODE_NONE ) priv->phy_if =PHY_INTERFACE_MODE_RGMII ; - } pdata->phy_interface = priv->phy_if; + +if (priv->phy_if !=PHY_INTERFACE_MODE_RGMII && + priv->phy_if !=PHY_INTERFACE_MODE_RGMII_ID && + priv->phy_if !=PHY_INTERFACE_MODE_RGMII_RXID && + priv->phy_if !=PHY_INTERFACE_MODE_RGMII_TXID ) { +pr_err ("invalid phy-mode\n" ); +return -EINVAL ; + } + priv->has_mdio = true; }
drivers/net/tsec.c +2 -7
@@ -834,7 +834,6 @@ int tsec_probe(struct udevice *dev)struct ofnode_phandle_args phandle_args;u32 tbiaddr =CONFIG_SYS_TBIPA_VALUE ;struct tsec_data *data; -const char *phy_mode;ofnode parent, child;fdt_addr_t reg;u32 max_speed;
@@ -894,12 +893,8 @@ int tsec_probe(struct udevice *dev) priv->tbiaddr = tbiaddr; - phy_mode =dev_read_prop (dev,"phy-connection-type" ,NULL ); -if (!phy_mode) - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) pdata->phy_interface =tsec_get_interface (priv); priv->interface = pdata->phy_interface;
drivers/net/xilinx_axi_emac.c +2 -8
@@ -821,7 +821,6 @@ static int axi_emac_of_to_plat(struct udevice *dev)struct eth_pdata *pdata = &plat->eth_pdata;int node =dev_of_offset (dev);int offset =0 ; -const char *phy_mode; pdata->iobase =dev_read_addr (dev); plat->mactype =dev_get_driver_data (dev);
@@ -850,14 +849,9 @@ static int axi_emac_of_to_plat(struct udevice *dev) plat->phy_of_handle = offset; } - phy_mode =fdt_getprop (gd->fdt_blob, node,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -printf ("%s: Invalid PHY interface '%s'\n" , __func__, - phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } plat->eth_hasnobuf =fdtdec_get_bool (gd->fdt_blob, node,"xlnx,eth-hasnobuf" );
drivers/net/zynq_gem.c +2 -7
@@ -827,7 +827,6 @@ static int zynq_gem_of_to_plat(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev);struct zynq_gem_priv *priv =dev_get_priv (dev);struct ofnode_phandle_args phandle_args; -const char *phy_mode; pdata->iobase = (phys_addr_t )dev_read_addr (dev); priv->iobase = (struct zynq_gem_regs *)pdata->iobase;
@@ -859,13 +858,9 @@ static int zynq_gem_of_to_plat(struct udevice *dev) } } - phy_mode =dev_read_prop (dev,"phy-mode" ,NULL ); -if (phy_mode) - pdata->phy_interface =phy_get_interface_by_name (phy_mode); -if (pdata->phy_interface ==-1 ) { -debug ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode); + pdata->phy_interface =dev_read_phy_mode (dev); +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE )return -EINVAL ; - } priv->interface = pdata->phy_interface; priv->int_pcs =dev_read_bool (dev,"is-internal-pcspma" );
include/dm/ofnode.h +13 -0
@@ -12,6 +12,7 @@#include <dm/of.h> #include <dm/of_access.h> #include <log.h> +#include <phy_interface.h> /* Enable checks to protect against invalid calls */ #undef OF_CHECKS
@@ -1231,4 +1232,16 @@ const char *ofnode_conf_read_str(const char *prop_name);*/ ofnode ofnode_get_phy_node (ofnode eth_node); +/** +* ofnode_read_phy_mode() - Read PHY connection type from a MAC node +* +* This function parses the "phy-mode" / "phy-connection-type" property and +* returns the corresponding PHY interface type. +* +* @mac_node: ofnode containing the property +* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on +* error +*/ +phy_interface_t ofnode_read_phy_mode (ofnode mac_node); +#endif
include/dm/read.h +17 -0
@@ -757,6 +757,18 @@ int dev_decode_display_timing(const struct udevice *dev, int index,*/ ofnode dev_get_phy_node (const struct udevice *dev); +/** +* dev_read_phy_mode() - Read PHY connection type from a MAC +* +* This function parses the "phy-mode" / "phy-connection-type" property and +* returns the corresponding PHY interface type. +* +* @dev: device representing the MAC +* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on +* error +*/ +phy_interface_t dev_read_phy_mode (const struct udevice *dev); +#else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include <asm/global_data.h>
@@ -1111,6 +1123,11 @@ static inline ofnode dev_get_phy_node(const struct udevice *dev) return ofnode_get_phy_node(dev_ofnode(dev)); } +static inline phy_interface_t dev_read_phy_mode (const struct udevice *dev) +{ +return ofnode_read_phy_mode (dev_ofnode (dev)); +} +#endif /* CONFIG_DM_DEV_READ_INLINE */ /**
include/phy.h +0 -8
@@ -568,14 +568,6 @@ int phy_xilinx_gmii2rgmii_init(void);int board_phy_config (struct phy_device *phydev);int get_phy_id (struct mii_dev *bus,int addr,int devad,u32 *phy_id); -/** -* phy_get_interface_by_name() - Look up a PHY interface name -* -* @str: PHY interface name, e.g. "mii" -* @return: PHY_INTERFACE_MODE_... value, or -1 if not found -*/ -int phy_get_interface_by_name (const char *str); -/** * phy_interface_is_rgmii - Convenience function for testing if a PHY interface * is RGMII (all variants)
net/mdio-uclass.c +1 -17
@@ -15,11 +15,6 @@#include <dm/uclass-internal.h> #include <linux/compat.h> -/* DT node properties for MAC-PHY interface */ -static const char *const phy_mode_str[] = { -"phy-mode" ,"phy-connection-type" -}; -void dm_mdio_probe_devices (void ) {struct udevice *it;
@@ -195,26 +190,15 @@ out:/* Connect to a PHY linked in eth DT node */ struct phy_device *dm_eth_phy_connect (struct udevice *ethdev) { -const char *if_str;phy_interface_t interface;struct phy_device *phy; -int i;if (!dev_has_ofnode (ethdev)) {debug ("%s: supplied eth dev has no DT node!\n" , ethdev->name);return NULL ; } - interface =PHY_INTERFACE_MODE_NONE ; -for (i =0 ; i <ARRAY_SIZE (phy_mode_str); i++) { - if_str =dev_read_string (ethdev, phy_mode_str[i]); -if (if_str) { - interface =phy_get_interface_by_name (if_str); -break ; - } - } -if (interface <0 ) - interface =PHY_INTERFACE_MODE_NONE ; + interface =dev_read_phy_mode (ethdev);if (interface ==PHY_INTERFACE_MODE_NONE )dev_dbg (ethdev,"can't find interface mode, default to NONE\n" );
test/dm/ofnode.c +4 -0
@@ -451,11 +451,15 @@ DM_TEST(dm_test_ofnode_string_err, UT_TESTF_LIVE_TREE);static int dm_test_ofnode_get_phy (struct unit_test_state *uts) {ofnode eth_node, phy_node; +phy_interface_t mode;u32 reg; eth_node =ofnode_path ("/phy-test-eth" );ut_assert (ofnode_valid (eth_node)); + mode =ofnode_read_phy_mode (eth_node); +ut_assert (mode ==PHY_INTERFACE_MODE_2500BASEX ); + phy_node =ofnode_get_phy_node (eth_node);ut_assert (ofnode_valid (phy_node));
Signature · 1 line
2.35.1
PATCH v4 9/14 treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Rename constant PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA to make it compatible with Linux' naming.
--- board/freescale/corenet_ds/eth_hydra.c | 2 +- board/freescale/corenet_ds/eth_superhydra.c | 4 ++-- board/freescale/t104xrdb/eth.c | 4 ++-- drivers/core/ofnode.c | 4 ++-- drivers/net/ag7xxx.c | 2 +- drivers/net/altera_tse.c | 2 +- drivers/net/bcm6348-eth.c | 2 +- drivers/net/bcmgenet.c | 2 +- drivers/net/designware.c | 2 +- drivers/net/dwc_eth_qos.c | 4 ++-- drivers/net/fec_mxc.c | 2 +- drivers/net/fm/b4860.c | 8 ++++---- drivers/net/fm/init.c | 8 ++++---- drivers/net/fm/ls1043.c | 6 +++--- drivers/net/fm/ls1046.c | 8 ++++---- drivers/net/fm/p1023.c | 4 ++-- drivers/net/fm/p4080.c | 6 +++--- drivers/net/fm/p5020.c | 6 +++--- drivers/net/fm/p5040.c | 6 +++--- drivers/net/fm/t1024.c | 4 ++-- drivers/net/fm/t1040.c | 4 ++-- drivers/net/fm/t2080.c | 6 +++--- drivers/net/fm/t4240.c | 6 +++--- drivers/net/fsl_enetc.c | 2 +- drivers/net/ftgmac100.c | 2 +- drivers/net/higmacv300.c | 2 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 2 +- drivers/net/ldpaa_eth/ldpaa_wriop.c | 10 +++++----- drivers/net/ldpaa_eth/ls1088a.c | 4 ++-- drivers/net/ldpaa_eth/ls2080a.c | 4 ++-- drivers/net/ldpaa_eth/lx2160a.c | 4 ++-- drivers/net/macb.c | 2 +- drivers/net/mscc_eswitch/jr2_switch.c | 2 +- drivers/net/mscc_eswitch/luton_switch.c | 2 +- drivers/net/mscc_eswitch/ocelot_switch.c | 2 +- drivers/net/mscc_eswitch/serval_switch.c | 2 +- drivers/net/mscc_eswitch/servalt_switch.c | 2 +- drivers/net/mt7620-eth.c | 12 ++++++------ drivers/net/mtk_eth.c | 2 +- drivers/net/mvgbe.c | 2 +- drivers/net/mvneta.c | 2 +- drivers/net/mvpp2.c | 2 +- drivers/net/pic32_eth.c | 2 +- drivers/net/qe/dm_qe_uec.c | 2 +- drivers/net/ravb.c | 2 +- drivers/net/sh_eth.c | 2 +- drivers/net/sni_ave.c | 2 +- drivers/net/sni_netsec.c | 2 +- drivers/net/sun8i_emac.c | 2 +- drivers/net/ti/am65-cpsw-nuss.c | 2 +- drivers/net/ti/cpsw.c | 2 +- drivers/net/ti/keystone_net.c | 2 +- drivers/net/tsec.c | 2 +- drivers/net/xilinx_axi_emac.c | 2 +- drivers/net/zynq_gem.c | 2 +- include/dm/ofnode.h | 2 +- include/dm/read.h | 2 +- include/fm_eth.h | 2 +- include/phy_interface.h | 8 ++++---- include/vsc9953.h | 2 +- net/mdio-uclass.c | 4 ++-- 61 files changed, 105 insertions(+), 105 deletions(-)
board/freescale/corenet_ds/eth_hydra.c +1 -1
@@ -471,7 +471,7 @@ int board_eth_init(struct bd_info *bis)fm_info_set_mdio (i,miiphy_get_dev_by_name ("HYDRA_RGMII_MDIO" ));break ; -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :fm_info_set_phy_address (i,0 );break ;default :
board/freescale/corenet_ds/eth_superhydra.c +2 -2
@@ -583,7 +583,7 @@ int board_eth_init(struct bd_info *bis)fm_info_set_mdio (i,miiphy_get_dev_by_name ("SUPER_HYDRA_RGMII_MDIO" ));break ; -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :fm_info_set_phy_address (i,0 );break ;default :
@@ -733,7 +733,7 @@ int board_eth_init(struct bd_info *bis)fm_info_set_mdio (i,miiphy_get_dev_by_name ("SUPER_HYDRA_RGMII_MDIO" ));break ; -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :fm_info_set_phy_address (i,0 );break ;default :
board/freescale/t104xrdb/eth.c +2 -2
@@ -89,7 +89,7 @@ int board_eth_init(struct bd_info *bis)case PHY_INTERFACE_MODE_QSGMII :fm_info_set_phy_address (i,0 );break ; -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :fm_info_set_phy_address (i,0 );break ;default :
@@ -99,7 +99,7 @@ int board_eth_init(struct bd_info *bis)break ; }if (fm_info_get_enet_if (i) ==PHY_INTERFACE_MODE_QSGMII || -fm_info_get_enet_if (i) ==PHY_INTERFACE_MODE_NONE ) +fm_info_get_enet_if (i) ==PHY_INTERFACE_MODE_NA )fm_info_set_mdio (i,NULL );else fm_info_set_mdio(i,
drivers/core/ofnode.c +2 -2
@@ -1232,7 +1232,7 @@ phy_interface_t ofnode_read_phy_mode(ofnode node) mode =ofnode_read_string (node,"phy-connection-type" );if (!mode) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++)if (!strcmp (mode, phy_interface_strings[i]))
@@ -1240,5 +1240,5 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)debug ("%s: Invalid PHY interface '%s'\n" , __func__, mode); -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/ag7xxx.c +1 -1
@@ -1265,7 +1265,7 @@ static int ag7xxx_eth_of_to_plat(struct udevice *dev)return ret; pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;return 0 ;
drivers/net/altera_tse.c +1 -1
@@ -678,7 +678,7 @@ static int altera_tse_of_to_plat(struct udevice *dev)struct eth_pdata *pdata =dev_get_plat (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;return 0 ;
drivers/net/bcm6348-eth.c +1 -1
@@ -425,7 +425,7 @@ static int bcm6348_eth_probe(struct udevice *dev)/* get phy mode */ pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -ENODEV ;/* get phy */
drivers/net/bcmgenet.c +1 -1
@@ -696,7 +696,7 @@ static int bcmgenet_eth_of_to_plat(struct udevice *dev)/* Get phy mode from DT */ pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
drivers/net/designware.c +1 -1
@@ -921,7 +921,7 @@ int designware_eth_of_to_plat(struct udevice *dev) pdata->iobase =dev_read_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; pdata->max_speed =dev_read_u32_default (dev,"max-speed" ,0 );
drivers/net/dwc_eth_qos.c +2 -2
@@ -1682,7 +1682,7 @@ static int eqos_probe_resources_stm32(struct udevice *dev) interface = eqos->config->interface (dev); -if (interface ==PHY_INTERFACE_MODE_NONE ) { +if (interface ==PHY_INTERFACE_MODE_NA ) {pr_err ("Invalid PHY interface\n" );return -EINVAL ; }
@@ -1743,7 +1743,7 @@ static int eqos_probe_resources_imx(struct udevice *dev) interface = eqos->config->interface (dev); -if (interface ==PHY_INTERFACE_MODE_NONE ) { +if (interface ==PHY_INTERFACE_MODE_NA ) {pr_err ("Invalid PHY interface\n" );return -EINVAL ; }
drivers/net/fec_mxc.c +1 -1
@@ -1315,7 +1315,7 @@ static int fecmxc_of_to_plat(struct udevice *dev) priv->eth = (struct ethernet_regs *)pdata->iobase; pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;#ifdef CONFIG_DM_REGULATOR
drivers/net/fm/b4860.c +4 -4
@@ -55,7 +55,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)#endif if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;/*B4860 has two 10Gig Mac*/ if ((port == FM1_10GEC1 || port == FM1_10GEC2) &&
@@ -112,7 +112,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) (port == FM1_DTSEC2) || (port == FM1_DTSEC3) || (port == FM1_DTSEC4)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } } }
@@ -131,8 +131,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/init.c +4 -4
@@ -130,7 +130,7 @@ static int fm_port_to_index(enum fm_port port)/* * Determine if an interface is actually active based on HW config -* we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NONE if +* we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NA if * the interface is not active based on HW cfg of the SoC */ void fman_enet_init (void )
@@ -141,7 +141,7 @@ void fman_enet_init(void)phy_interface_t enet_if; enet_if =fman_port_enet_if (fm_info[i].port); -if (enet_if !=PHY_INTERFACE_MODE_NONE ) { +if (enet_if !=PHY_INTERFACE_MODE_NA ) { fm_info[i].enabled =1 ; fm_info[i].enet_if = enet_if; }else {
@@ -221,12 +221,12 @@ phy_interface_t fm_info_get_enet_if(enum fm_port port)int i =fm_port_to_index (port);if (i ==-1 ) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (fm_info[i].enabled)return fm_info[i].enet_if; -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } static void
drivers/net/fm/ls1043.c +3 -3
@@ -54,13 +54,13 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr13 =in_be32 (&gur->rcwsr[13 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XFI_FM1_MAC9 )))return PHY_INTERFACE_MODE_XGMII ;if ((port ==FM1_DTSEC9 ) && (is_serdes_configured (XFI_FM1_MAC9 ))) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (port ==FM1_DTSEC3 ) if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) ==
@@ -107,5 +107,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port)break ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/ls1046.c +4 -4
@@ -54,19 +54,19 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr13 =in_be32 (&gur->rcwsr[13 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XFI_FM1_MAC9 )))return PHY_INTERFACE_MODE_XGMII ;if ((port ==FM1_DTSEC9 ) && (is_serdes_configured (XFI_FM1_MAC9 ))) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC2 ) && (is_serdes_configured (XFI_FM1_MAC10 )))return PHY_INTERFACE_MODE_XGMII ;if ((port ==FM1_DTSEC10 ) && (is_serdes_configured (XFI_FM1_MAC10 ))) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (port ==FM1_DTSEC3 ) if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) ==
@@ -118,5 +118,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port)break ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/p1023.c +2 -2
@@ -46,7 +46,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 pordevsr =in_be32 (&gur->pordevsr);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;/* DTSEC1 can be SGMII, RGMII or RMII */ if (port ==FM1_DTSEC1 ) {
@@ -68,5 +68,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_RGMII ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/p4080.c +3 -3
@@ -54,7 +54,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr11 =in_be32 (&gur->rcwsr[11 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XAUI_FM1 )))return PHY_INTERFACE_MODE_XGMII ;
@@ -91,8 +91,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/p5020.c +3 -3
@@ -50,7 +50,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr11 =in_be32 (&gur->rcwsr[11 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XAUI_FM1 )))return PHY_INTERFACE_MODE_XGMII ;
@@ -82,8 +82,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/p5040.c +3 -3
@@ -56,7 +56,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr11 =in_be32 (&gur->rcwsr[11 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XAUI_FM1 )))return PHY_INTERFACE_MODE_XGMII ;
@@ -99,8 +99,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/t1024.c +2 -2
@@ -39,7 +39,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr13 =in_be32 (&gur->rcwsr[13 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if ((port ==FM1_10GEC1 ) && (is_serdes_configured (XFI_FM1_MAC1 )))return PHY_INTERFACE_MODE_XGMII ;
@@ -83,5 +83,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port)break ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/t1040.c +2 -2
@@ -56,8 +56,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/t2080.c +3 -3
@@ -47,7 +47,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr13 =in_be32 (&gur->rcwsr[13 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; if ((port == FM1_10GEC1 || port == FM1_10GEC2) && ((is_serdes_configured(XAUI_FM1_MAC9)) ||
@@ -85,8 +85,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)return PHY_INTERFACE_MODE_SGMII ;break ;default : -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fm/t4240.c +3 -3
@@ -61,7 +61,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)u32 rcwsr13 =in_be32 (&gur->rcwsr[13 ]);if (is_device_disabled (port)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; if ((port == FM1_10GEC1 || port == FM1_10GEC2) && ((is_serdes_configured(XAUI_FM1_MAC9)) ||
@@ -73,7 +73,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)if ((port ==FM1_DTSEC9 || port ==FM1_DTSEC10 ) && ((is_serdes_configured (XFI_FM1_MAC9 )) || (is_serdes_configured (XFI_FM1_MAC10 )))) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; if ((port == FM2_10GEC1 || port == FM2_10GEC2) && ((is_serdes_configured(XAUI_FM2_MAC9)) ||
@@ -166,5 +166,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port)break ; } -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/fsl_enetc.c +1 -1
@@ -277,7 +277,7 @@ static void enetc_start_pcs(struct udevice *dev) } priv->if_type =dev_read_phy_mode (dev); -if (priv->if_type ==PHY_INTERFACE_MODE_NONE ) { +if (priv->if_type ==PHY_INTERFACE_MODE_NA ) {enetc_dbg (dev,"phy-mode property not found, defaulting to SGMII\n" ); priv->if_type =PHY_INTERFACE_MODE_SGMII ;
drivers/net/ftgmac100.c +1 -1
@@ -553,7 +553,7 @@ static int ftgmac100_of_to_plat(struct udevice *dev) pdata->iobase =dev_read_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; pdata->max_speed =dev_read_u32_default (dev,"max-speed" ,0 );
drivers/net/higmacv300.c +1 -1
@@ -567,7 +567,7 @@ static int higmac_of_to_plat(struct udevice *dev) priv->macif_ctrl =dev_remap_addr_index (dev,1 ); priv->phyintf =dev_read_phy_mode (dev); -if (priv->phyintf ==PHY_INTERFACE_MODE_NONE ) +if (priv->phyintf ==PHY_INTERFACE_MODE_NA )return -ENODEV ; phy_node =dev_read_subnode (dev,"phy" );
drivers/net/ldpaa_eth/ldpaa_eth.c +1 -1
@@ -1127,7 +1127,7 @@ static int ldpaa_eth_bind(struct udevice *dev)int phy_mode =-1 ; phy_mode =dev_read_phy_mode (dev); -if (phy_mode ==PHY_INTERFACE_MODE_NONE ) { +if (phy_mode ==PHY_INTERFACE_MODE_NA ) {dev_err (dev,"incorrect phy mode\n" );return -EINVAL ; }
drivers/net/ldpaa_eth/ldpaa_wriop.c +5 -5
@@ -16,7 +16,7 @@ struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS];__weak phy_interface_t wriop_dpmac_enet_if (int dpmac_id,int lane_prtc) { -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }void wriop_init_dpmac (int sd,int dpmac_id,int lane_prtcl)
@@ -26,10 +26,10 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; - dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; + dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NA ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl); -if (enet_if !=PHY_INTERFACE_MODE_NONE ) { +if (enet_if !=PHY_INTERFACE_MODE_NA ) { dpmac_info[dpmac_id].enabled =1 ; dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if;
@@ -183,10 +183,10 @@ phy_interface_t wriop_get_enet_if(int dpmac_id)int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (dpmac_info[i].enabled)return dpmac_info[i].enet_if; -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }
drivers/net/ldpaa_eth/ls1088a.c +2 -2
@@ -50,7 +50,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)enum srds_prtcl ;if (is_device_disabled (dpmac_id +1 )) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;switch (lane_prtcl) {case SGMII1 :
@@ -66,7 +66,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)if (lane_prtcl >=QSGMII_A && lane_prtcl <=QSGMII_B )return PHY_INTERFACE_MODE_QSGMII ; -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }void wriop_init_dpmac_qsgmii (int sd,int lane_prtcl)
drivers/net/ldpaa_eth/ls2080a.c +2 -2
@@ -62,7 +62,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)enum srds_prtcl ;if (is_device_disabled (dpmac_id +1 )) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (lane_prtcl >=SGMII1 && lane_prtcl <=SGMII16 )return PHY_INTERFACE_MODE_SGMII ;
@@ -76,7 +76,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)if (lane_prtcl >=QSGMII_A && lane_prtcl <=QSGMII_D )return PHY_INTERFACE_MODE_QSGMII ; -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }void wriop_init_dpmac_qsgmii (int sd,int lane_prtcl)
drivers/net/ldpaa_eth/lx2160a.c +2 -2
@@ -58,7 +58,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)enum srds_prtcl ;if (is_device_disabled (dpmac_id)) -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ;if (lane_prtcl >=SGMII1 && lane_prtcl <=SGMII18 )return PHY_INTERFACE_MODE_SGMII ;
@@ -78,7 +78,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl)if (lane_prtcl >= _100GE1 && lane_prtcl <= _100GE2)return PHY_INTERFACE_MODE_CAUI4 ; -return PHY_INTERFACE_MODE_NONE ; +return PHY_INTERFACE_MODE_NA ; }#ifdef CONFIG_SYS_FSL_HAS_RGMII
drivers/net/macb.c +1 -1
@@ -1363,7 +1363,7 @@ static int macb_eth_probe(struct udevice *dev)int ret; macb->phy_interface =dev_read_phy_mode (dev); -if (macb->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (macb->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;/* Read phyaddr from DT */
drivers/net/mscc_eswitch/jr2_switch.c +1 -1
@@ -954,7 +954,7 @@ static int jr2_probe(struct udevice *dev) phy =phy_connect (priv->ports[i].bus, priv->ports[i].phy_addr, dev, -PHY_INTERFACE_MODE_NONE ); +PHY_INTERFACE_MODE_NA );if (phy)board_phy_config (phy); }
drivers/net/mscc_eswitch/luton_switch.c +1 -1
@@ -685,7 +685,7 @@ static int luton_probe(struct udevice *dev) phy =phy_connect (priv->ports[i].bus, priv->ports[i].phy_addr, dev, -PHY_INTERFACE_MODE_NONE ); +PHY_INTERFACE_MODE_NA );if (phy && i >=MAX_INT_PORT )board_phy_config (phy); }
drivers/net/mscc_eswitch/ocelot_switch.c +1 -1
@@ -608,7 +608,7 @@ static int ocelot_probe(struct udevice *dev) phy =phy_connect (priv->ports[i].bus, priv->ports[i].phy_addr, dev, -PHY_INTERFACE_MODE_NONE ); +PHY_INTERFACE_MODE_NA );if (phy &&external_bus (priv, i))board_phy_config (phy); }
drivers/net/mscc_eswitch/serval_switch.c +1 -1
@@ -561,7 +561,7 @@ static int serval_probe(struct udevice *dev) phy =phy_connect (priv->ports[i].bus, priv->ports[i].phy_addr, dev, -PHY_INTERFACE_MODE_NONE ); +PHY_INTERFACE_MODE_NA );if (phy)board_phy_config (phy); }
drivers/net/mscc_eswitch/servalt_switch.c +1 -1
@@ -482,7 +482,7 @@ static int servalt_probe(struct udevice *dev)continue ;phy_connect (priv->ports[i].bus, priv->ports[i].phy_addr, dev, -PHY_INTERFACE_MODE_NONE ); +PHY_INTERFACE_MODE_NA ); }return 0 ;
drivers/net/mt7620-eth.c +6 -6
@@ -596,7 +596,7 @@ static int mt7620_setup_gmac_mode(struct mt7620_eth_priv *priv, u32 gmac,case PHY_INTERFACE_MODE_RGMII : ge_mode =MT7620_SYSC_GE_RGMII ;break ; -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :if (gmac ==2 ) ge_mode =MT7620_SYSC_GE_ESW_PHY ;else
@@ -620,7 +620,7 @@ static void mt7620_gsw_setup_port(struct mt7620_eth_priv *priv, u32 port, {u32 pmcr; -if (port_cfg->mode ==PHY_INTERFACE_MODE_NONE ) { +if (port_cfg->mode ==PHY_INTERFACE_MODE_NA ) {if (port ==5 ) {gsw_write (priv,GSW_PMCR (port),FORCE_MODE );return ;
@@ -666,7 +666,7 @@ static void mt7620_gsw_setup_phy_polling(struct mt7620_eth_priv *priv) {int phy_addr_st, phy_addr_end; -if (priv->port_cfg[0 ].mode ==PHY_INTERFACE_MODE_NONE ) +if (priv->port_cfg[0 ].mode ==PHY_INTERFACE_MODE_NA ) priv->ephy_num =NUM_FE_PHYS ;else priv->ephy_num =NUM_FE_PHYS -1 ;
@@ -1057,7 +1057,7 @@ static int mt7620_eth_parse_gsw_port(struct mt7620_eth_priv *priv, u32 idx,case PHY_INTERFACE_MODE_MII :case PHY_INTERFACE_MODE_RMII :case PHY_INTERFACE_MODE_RGMII : -case PHY_INTERFACE_MODE_NONE : +case PHY_INTERFACE_MODE_NA :break ;default :dev_err (priv->dev,"mt7620_eth: unsupported phy-mode\n" );
@@ -1128,14 +1128,14 @@ static int mt7620_eth_parse_gsw_cfg(struct udevice *dev)if (ret)return ret; }else { - priv->port_cfg[0 ].mode =PHY_INTERFACE_MODE_NONE ; + priv->port_cfg[0 ].mode =PHY_INTERFACE_MODE_NA ; } subnode =ofnode_find_subnode (dev_ofnode (dev),"port5" );if (ofnode_valid (subnode))return mt7620_eth_parse_gsw_port (priv,1 , subnode); - priv->port_cfg[1 ].mode =PHY_INTERFACE_MODE_NONE ; + priv->port_cfg[1 ].mode =PHY_INTERFACE_MODE_NA ;return 0 ; }
drivers/net/mtk_eth.c +1 -1
@@ -1449,7 +1449,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev)/* Interface mode is required */ pdata->phy_interface =dev_read_phy_mode (dev); priv->phy_interface = pdata->phy_interface; -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) { +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA ) {printf ("error: phy-mode is not set\n" );return -EINVAL ; }
drivers/net/mvgbe.c +1 -1
@@ -1005,7 +1005,7 @@ static int mvgbe_of_to_plat(struct udevice *dev)/* Get phy-mode / phy_interface from DT */ pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA ) pdata->phy_interface =PHY_INTERFACE_MODE_GMII ; dmvgbe->phy_interface = pdata->phy_interface;
drivers/net/mvneta.c +1 -1
@@ -1804,7 +1804,7 @@ static int mvneta_of_to_plat(struct udevice *dev)/* Get phy-mode / phy_interface from DT */ pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;return 0 ;
drivers/net/mvpp2.c +1 -1
@@ -4820,7 +4820,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port) } port->phy_interface =dev_read_phy_mode (dev); -if (port->phy_interface ==PHY_INTERFACE_MODE_NONE ) { +if (port->phy_interface ==PHY_INTERFACE_MODE_NA ) {dev_err (dev,"incorrect phy mode\n" );return -EINVAL ; }
drivers/net/pic32_eth.c +1 -1
@@ -550,7 +550,7 @@ static int pic32_eth_probe(struct udevice *dev)/* get phy mode */ pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;/* get phy addr */
drivers/net/qe/dm_qe_uec.c +1 -1
@@ -1137,7 +1137,7 @@ static int qe_uec_of_to_plat(struct udevice *dev) pdata->iobase = (phys_addr_t )devfdt_get_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;return 0 ;
drivers/net/ravb.c +1 -1
@@ -679,7 +679,7 @@ int ravb_of_to_plat(struct udevice *dev) pdata->iobase =dev_read_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; pdata->max_speed =1000 ;
drivers/net/sh_eth.c +1 -1
@@ -920,7 +920,7 @@ int sh_ether_of_to_plat(struct udevice *dev) pdata->iobase =dev_read_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; pdata->max_speed =1000 ;
drivers/net/sni_ave.c +1 -1
@@ -749,7 +749,7 @@ static int ave_of_to_plat(struct udevice *dev) pdata->iobase =dev_read_addr (dev); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; pdata->max_speed =0 ;
drivers/net/sni_netsec.c +1 -1
@@ -1034,7 +1034,7 @@ static int netsec_of_to_plat(struct udevice *dev) priv->eeprom_base =dev_read_addr_index (dev,1 ) -EERPROM_MAP_OFFSET ; pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
drivers/net/sun8i_emac.c +1 -1
@@ -947,7 +947,7 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) pdata->phy_interface =dev_read_phy_mode (dev);printf ("phy interface%d\n" , pdata->phy_interface); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;if (priv->variant ==H3_EMAC ) {
drivers/net/ti/am65-cpsw-nuss.c +1 -1
@@ -607,7 +607,7 @@ static int am65_cpsw_ofdata_parse_phy(struct udevice *dev)dev_read_u32 (dev,"reg" , &priv->port_id); pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) { +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA ) {dev_err (dev,"Invalid PHY mode, port %u\n" , priv->port_id);return -EINVAL ; }
drivers/net/ti/cpsw.c +1 -1
@@ -1345,7 +1345,7 @@ static int cpsw_eth_of_to_plat(struct udevice *dev) } pdata->phy_interface = data->slave_data[data->active_slave].phy_if; -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ;return 0 ;
drivers/net/ti/keystone_net.c +1 -1
@@ -728,7 +728,7 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, priv->has_mdio = true; }else if (priv->link_type ==LINK_TYPE_RGMII_LINK_MAC_PHY ) { priv->phy_if =ofnode_read_phy_mode (offset_to_ofnode (slave)); -if (priv->phy_if ==PHY_INTERFACE_MODE_NONE ) +if (priv->phy_if ==PHY_INTERFACE_MODE_NA ) priv->phy_if =PHY_INTERFACE_MODE_RGMII ; pdata->phy_interface = priv->phy_if;
drivers/net/tsec.c +1 -1
@@ -894,7 +894,7 @@ int tsec_probe(struct udevice *dev) priv->tbiaddr = tbiaddr; pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA ) pdata->phy_interface =tsec_get_interface (priv); priv->interface = pdata->phy_interface;
drivers/net/xilinx_axi_emac.c +1 -1
@@ -850,7 +850,7 @@ static int axi_emac_of_to_plat(struct udevice *dev) } pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node,
drivers/net/zynq_gem.c +1 -1
@@ -859,7 +859,7 @@ static int zynq_gem_of_to_plat(struct udevice *dev) } pdata->phy_interface =dev_read_phy_mode (dev); -if (pdata->phy_interface ==PHY_INTERFACE_MODE_NONE ) +if (pdata->phy_interface ==PHY_INTERFACE_MODE_NA )return -EINVAL ; priv->interface = pdata->phy_interface;
include/dm/ofnode.h +1 -1
@@ -1239,7 +1239,7 @@ ofnode ofnode_get_phy_node(ofnode eth_node);* returns the corresponding PHY interface type. * * @mac_node: ofnode containing the property -* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on +* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on * error */ phy_interface_t ofnode_read_phy_mode (ofnode mac_node);
include/dm/read.h +1 -1
@@ -764,7 +764,7 @@ ofnode dev_get_phy_node(const struct udevice *dev);* returns the corresponding PHY interface type. * * @dev: device representing the MAC -* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on +* Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on * error */ phy_interface_t dev_read_phy_mode (const struct udevice *dev);
include/fm_eth.h +1 -1
@@ -72,7 +72,7 @@ enum fm_eth_type {#define FM_ETH_INFO_INITIALIZER (idx, pregs) \ .fm = idx, \ .phy_regs = (void *)pregs, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \#ifdef CONFIG_SYS_FMAN_V3 #define FM_DTSEC_INFO_INITIALIZER (idx, n) \
include/phy_interface.h +4 -4
@@ -39,7 +39,7 @@ typedef enum {PHY_INTERFACE_MODE_NCSI ,PHY_INTERFACE_MODE_10GBASER ,PHY_INTERFACE_MODE_USXGMII , -PHY_INTERFACE_MODE_NONE ,/* Must be last */ +PHY_INTERFACE_MODE_NA ,/* Must be last */ PHY_INTERFACE_MODE_MAX , } phy_interface_t;
@@ -71,7 +71,7 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", - [PHY_INTERFACE_MODE_NONE] = "", + [PHY_INTERFACE_MODE_NA] = "", };/* Backplane modes:
@@ -86,8 +86,8 @@ static const char * const backplane_mode_strings[] = {static inline const char *phy_string_for_interface (phy_interface_t i) {/* Default to unknown */ -if (i >PHY_INTERFACE_MODE_NONE ) - i =PHY_INTERFACE_MODE_NONE ; +if (i >PHY_INTERFACE_MODE_NA ) + i =PHY_INTERFACE_MODE_NA ;return phy_interface_strings[i]; }
include/vsc9953.h +1 -1
@@ -691,7 +691,7 @@ struct vsc9953_vcap { .phyaddr = 0, \ .index = idx, \ .phy_regs = NULL, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \ .bus = NULL, \ .phydev = NULL, \ }
net/mdio-uclass.c +2 -2
@@ -199,8 +199,8 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) } interface =dev_read_phy_mode (ethdev); -if (interface ==PHY_INTERFACE_MODE_NONE ) -dev_dbg (ethdev,"can't find interface mode, default to NONE\n" ); +if (interface ==PHY_INTERFACE_MODE_NA ) +dev_dbg (ethdev,"can't find interface mode, default to NA\n" ); phy =dm_eth_connect_phy_handle (ethdev, interface);
Signature · 1 line
2.35.1
PATCH v4 13/14 bcmgenet, sun8i_emac: Don't connect PHY two times
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
The bcmgenet and sun8i_emac drivers call phy_connect(), which finds / creates the PHY and also connects it to the eth device via phy_connect_dev(), then set some phydev members (bcmgenet only), and then call phy_connect_dev() explicitly again.
Drop the second phy_connect_dev(), since it is unnecesary.
--- drivers/net/bcmgenet.c | 2 -- drivers/net/sun8i_emac.c | 2 -- 2 files changed, 4 deletions(-)
drivers/net/bcmgenet.c +0 -2
@@ -526,8 +526,6 @@ static int bcmgenet_phy_init(struct bcmgenet_eth_priv *priv, void *dev) } phydev->advertising = phydev->supported; -phy_connect_dev (phydev, dev); - priv->phydev = phydev;phy_config (priv->phydev);
drivers/net/sun8i_emac.c +0 -2
@@ -391,8 +391,6 @@ static int sun8i_phy_init(struct emac_eth_dev *priv, void *dev)if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); - priv->phydev = phydev;phy_config (priv->phydev);
Signature · 1 line
2.35.1
PATCH v4 14/14 net: phy: don't require PHY interface mode during PHY creation
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Currently we require PHY interface mode to be known when finding/creating the PHY - the functions
* phy_connect_phy_id()
* phy_device_create()
* create_phy_by_mask()
* search_for_existing_phy()
* get_phy_device_by_mask()
* phy_find_by_mask()
all require the interface parameter, but the only thing done with it is that it is assigned to phydev->interface.
This makes it impossible to find a PHY device without overwriting the set mode.
Since the interface mode is not used during .probe() and should be used at first in .config(), drop the interface parameter from these functions. Make the default value of phydev->interface (in phy_device_create()) to be PHY_INTERFACE_MODE_NA. Move the interface parameter to phy_connect_dev(), where it should be.
Change all occurrences treewide. In occurrences where we don't call phy_connect_dev() for some reason (they only configure the PHY without connecting it to an ethernet controller), set
phydev->interface = value from phy_find_by_mask call.
--- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/boundary/nitrogen6x/nitrogen6x.c | 2 +- board/gdsys/a38x/controlcenterdc.c | 7 +- board/gdsys/a38x/ihs_phys.c | 6 +- drivers/net/altera_tse.c | 4 +- drivers/net/ethoc.c | 4 +- drivers/net/pch_gbe.c | 4 +- drivers/net/phy/ethernet_id.c | 5 +- drivers/net/phy/phy.c | 88 +++++++++++--------------- drivers/net/phy/xilinx_gmii2rgmii.c | 4 +- drivers/net/ravb.c | 4 +- drivers/net/sh_eth.c | 4 +- drivers/net/sni_ave.c | 4 +- drivers/net/sunxi_emac.c | 5 +- include/_exports.h | 3 +- include/exports.h | 3 +- include/phy.h | 20 +++--- 17 files changed, 75 insertions(+), 94 deletions(-)
board/CZ.NIC/turris_mox/turris_mox.c +1 -1
@@ -396,7 +396,7 @@ static void mox_phy_leds_start_blinking(void)return ; } - phydev =phy_find_by_mask (bus,BIT (1 ),PHY_INTERFACE_MODE_RGMII ); + phydev =phy_find_by_mask (bus,BIT (1 ));if (!phydev) {printf ("Cannot get ethernet PHY!\n" );return ;
board/boundary/nitrogen6x/nitrogen6x.c +1 -1
@@ -345,7 +345,7 @@ int board_eth_init(struct bd_info *bis)if (!bus)return -EINVAL ;/* scan phy 4,5,6,7 */ - phydev =phy_find_by_mask (bus, (0xf <<4 ),PHY_INTERFACE_MODE_RGMII ); + phydev =phy_find_by_mask (bus, (0xf <<4 ));if (!phydev) { ret = -EINVAL ; goto free_bus;
board/gdsys/a38x/controlcenterdc.c +4 -3
@@ -194,11 +194,12 @@ void init_host_phys(struct mii_dev *bus)for (k =0 ; k <2 ; ++k) {struct phy_device *phydev; - phydev =phy_find_by_mask (bus,1 << k, -PHY_INTERFACE_MODE_SGMII ); + phydev =phy_find_by_mask (bus,1 << k); -if (phydev) +if (phydev) { + phydev->interface =PHY_INTERFACE_MODE_SGMII ;phy_config (phydev); + } } }
board/gdsys/a38x/ihs_phys.c +3 -3
@@ -28,6 +28,7 @@ static void ihs_phy_config(struct phy_device *phydev, bool qinpn, bool qoutpn) {u16 reg; + phydev->interface =PHY_INTERFACE_MODE_MII ;phy_config (phydev);/* enable QSGMII autonegotiation with flow control */
@@ -142,10 +143,9 @@ struct porttype *get_porttype(uint octo_phy_mask, uint k)int init_single_phy (struct porttype *porttype,struct mii_dev *bus,uint bus_idx,uint m,uint phy_idx) { -struct phy_device *phydev =phy_find_by_mask ( - bus,1 << (m *8 + phy_idx), -PHY_INTERFACE_MODE_MII ); +struct phy_device *phydev; + phydev =phy_find_by_mask (bus,BIT (m *8 + phy_idx));printf (" %u" , bus_idx *32 + m *8 + phy_idx);if (!phydev)
drivers/net/altera_tse.c +2 -2
@@ -435,11 +435,11 @@ static int tse_phy_init(struct altera_tse_priv *priv, void *dev)if (priv->phyaddr) mask =1 << priv->phyaddr; - phydev =phy_find_by_mask (priv->bus, mask, priv->interface); + phydev =phy_find_by_mask (priv->bus, mask);if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev, priv->interface); phydev->supported &=PHY_GBIT_FEATURES ; phydev->advertising = phydev->supported;
drivers/net/ethoc.c +2 -2
@@ -614,11 +614,11 @@ static int ethoc_phy_init(struct ethoc *priv, void *dev) mask =1 <<CONFIG_PHY_ADDR ;#endif - phydev =phy_find_by_mask (priv->bus, mask,PHY_INTERFACE_MODE_MII ); + phydev =phy_find_by_mask (priv->bus, mask);if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev,PHY_INTERFACE_MODE_MII ); phydev->supported &=PHY_BASIC_FEATURES ; phydev->advertising = phydev->supported;
drivers/net/pch_gbe.c +2 -2
@@ -416,13 +416,13 @@ static int pch_gbe_phy_init(struct udevice *dev)struct phy_device *phydev;int mask =0xffffffff ; - phydev =phy_find_by_mask (priv->bus, mask, plat->phy_interface); + phydev =phy_find_by_mask (priv->bus, mask);if (!phydev) {printf ("pch_gbe: cannot find the phy\n" );return -1 ; } -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev, plat->phy_interface); phydev->supported &=PHY_GBIT_FEATURES ; phydev->advertising = phydev->supported;
drivers/net/phy/ethernet_id.c +2 -3
@@ -11,8 +11,7 @@#include <linux/delay.h> #include <asm/gpio.h> -struct phy_device *phy_connect_phy_id (struct mii_dev *bus,struct udevice *dev, -phy_interface_t interface) +struct phy_device *phy_connect_phy_id (struct mii_dev *bus,struct udevice *dev) {struct phy_device *phydev;struct ofnode_phandle_args phandle_args;
@@ -61,7 +60,7 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, } id = vendor <<16 | device; - phydev =phy_device_create (bus,0 , id, false, interface); + phydev =phy_device_create (bus,0 , id, false);if (phydev) phydev->node = node;
drivers/net/phy/phy.c +37 -51
236 lines not on this page · raw message
drivers/net/phy/xilinx_gmii2rgmii.c +2 -2
@@ -42,13 +42,13 @@ static int xilinxgmiitorgmii_config(struct phy_device *phydev) ext_phyaddr =ofnode_read_u32_default (phandle.node,"reg" ,-1 ); ext_phydev =phy_find_by_mask (phydev->bus, -1 << ext_phyaddr, -PHY_INTERFACE_MODE_RGMII ); +1 << ext_phyaddr);if (!ext_phydev) {printf ("%s, No external phy device found\n" , __func__);return -EINVAL ; } + ext_phydev->interface =PHY_INTERFACE_MODE_RGMII ; ext_phydev->node = phandle.node; phydev->priv = ext_phydev;
drivers/net/ravb.c +2 -2
@@ -319,11 +319,11 @@ static int ravb_phy_config(struct udevice *dev)mdelay (1 ); } - phydev =phy_find_by_mask (eth->bus, mask, pdata->phy_interface); + phydev =phy_find_by_mask (eth->bus, mask);if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev, pdata->phy_interface); eth->phydev = phydev;
drivers/net/sh_eth.c +2 -2
@@ -762,11 +762,11 @@ static int sh_eth_phy_config(struct udevice *dev)struct phy_device *phydev;int mask =0xffffffff ; - phydev =phy_find_by_mask (priv->bus, mask, pdata->phy_interface); + phydev =phy_find_by_mask (priv->bus, mask);if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev, pdata->phy_interface); port_info->phydev = phydev;phy_config (phydev);
drivers/net/sni_ave.c +2 -2
@@ -393,11 +393,11 @@ static int ave_phy_init(struct ave_private *priv, void *dev)struct phy_device *phydev;int mask =GENMASK (31 ,0 ), ret; - phydev =phy_find_by_mask (priv->bus, mask, priv->phy_mode); + phydev =phy_find_by_mask (priv->bus, mask);if (!phydev)return -ENODEV ; -phy_connect_dev (phydev, dev); +phy_connect_dev (phydev, dev, priv->phy_mode); phydev->supported &=PHY_GBIT_FEATURES ;if (priv->max_speed) {
drivers/net/sunxi_emac.c +2 -3
@@ -272,12 +272,11 @@ static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev)if (ret)return ret; - priv->phydev =phy_find_by_mask (priv->bus, mask, -PHY_INTERFACE_MODE_MII ); + priv->phydev =phy_find_by_mask (priv->bus, mask);if (!priv->phydev)return -ENODEV ; -phy_connect_dev (priv->phydev, dev); +phy_connect_dev (priv->phydev, dev,PHY_INTERFACE_MODE_MII );phy_config (priv->phydev);return 0 ;
include/_exports.h +1 -2
@@ -77,8 +77,7 @@ EXPORT_FUNC(mdio_get_current_dev, struct mii_dev *, mdio_get_current_dev, void) EXPORT_FUNC(phy_find_by_mask, struct phy_device *, phy_find_by_mask, - struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface) + struct mii_dev *bus, unsigned phy_mask) EXPORT_FUNC(mdio_phydev_for_ethname, struct phy_device *, mdio_phydev_for_ethname, const char *ethname) EXPORT_FUNC(miiphy_set_current_dev, int, miiphy_set_current_dev,
include/exports.h +1 -2
@@ -55,8 +55,7 @@ int i2c_read (uchar, uint, int , uchar* , int);#endif #ifdef CONFIG_PHY_AQUANTIA struct mii_dev *mdio_get_current_dev (void ); -struct phy_device *phy_find_by_mask (struct mii_dev *bus,unsigned phy_mask, -phy_interface_t interface); +struct phy_device *phy_find_by_mask (struct mii_dev *bus,unsigned phy_mask);struct phy_device *mdio_phydev_for_ethname (const char *ethname);int miiphy_set_current_dev (const char *devname);#endif
include/phy.h +9 -11
@@ -388,11 +388,9 @@ int phy_reset(struct phy_device *phydev);* * @bus: MII/MDIO bus to scan * @phy_mask: bitmap of PYH addresses to scan -* @interface: type of MAC-PHY interface * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ -struct phy_device *phy_find_by_mask (struct mii_dev *bus,unsigned phy_mask, -phy_interface_t interface); +struct phy_device *phy_find_by_mask (struct mii_dev *bus,unsigned phy_mask);#ifdef CONFIG_PHY_FIXED
@@ -421,8 +419,10 @@ static inline struct phy_device *fixed_phy_create(ofnode node)* phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device +* @interface: type of MAC-PHY interface */ -void phy_connect_dev (struct phy_device *phydev,struct udevice *dev); +void phy_connect_dev (struct phy_device *phydev,struct udevice *dev, +phy_interface_t interface);/** * phy_connect() - Creates a PHY device for the Ethernet interface
@@ -449,12 +449,10 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,* @addr: PHY address on MDIO bus * @phy_id: where to store the ID retrieved * @is_c45: Device Identifiers if is_c45 -* @interface: interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ struct phy_device *phy_device_create (struct mii_dev *bus,int addr, -u32 phy_id,bool is_c45, -phy_interface_t interface); +u32 phy_id,bool is_c45);/** * phy_connect_phy_id() - Connect to phy device by reading PHY id
@@ -462,12 +460,10 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr,* * @bus: MII/MDIO bus that hosts the PHY * @dev: Ethernet device to associate to the PHY -* @interface: Interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, * or NULL otherwise */ -struct phy_device *phy_connect_phy_id (struct mii_dev *bus,struct udevice *dev, -phy_interface_t interface); +struct phy_device *phy_connect_phy_id (struct mii_dev *bus,struct udevice *dev);static inline ofnode phy_get_ofnode (struct phy_device *phydev) {
@@ -482,8 +478,10 @@ static inline ofnode phy_get_ofnode(struct phy_device *phydev)* phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device +* @interface: type of MAC-PHY interface */ -void phy_connect_dev (struct phy_device *phydev,struct eth_device *dev); +void phy_connect_dev (struct phy_device *phydev,struct eth_device *dev, +phy_interface_t interface);/** * phy_connect() - Creates a PHY device for the Ethernet interface
Signature · 1 line
2.35.1
Quoted 120 lines · Marek Behún
From: Marek Behún <[email protected]>
Hello,
this is v4 of https://patchwork.ozlabs.org/project/uboot/list/?series=290889.
Changes since v3:
- rebased on top of origin/next
- fixed binman failure: added #address-cells/#sice-cells to sandbox'test.dts' mdio node in patchChanges since v2:
- added UT tests forofnode_get_phy_node()andofnode_get_phy_mode(), as requested by SimonMarek Behún (14):
net: mdio-uclass: fix type forphy_mode_strandphy_handle_str
net: mdio-uclass: useARRAY_SIZE()
net: introduce helpers to get PHY ofnode from MAC
net: mdio-uclass: add wrappers for read/write/reset operations
treewide: use dm_mdio_read/write/reset() wrappers
net: phy: fix parsing wrong property
net: introduce helpers to get PHY interface mode from a device/ofnode
treewide: RenamePHY_INTERFACE_MODE_COUNTtoPHY_INTERFACE_MODE_MAX
treewide: RenamePHY_INTERFACE_MODE_NONEtoPHY_INTERFACE_MODE_NA
phy: MovePHY_INTERFACE_MODE_NAto the beginning of the enum
definition
net: phy: xilinx: Check interface type in ->config(), not ->probe()
net: phy: use ->is_c45 instead ofis_10g_interface()bcmgenet,sun8i_emac: Don't connect PHY two times
net: phy: don't require PHY interface mode during PHY creationarch/sandbox/dts/test.dts | 14 +++ board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/boundary/nitrogen6x/nitrogen6x.c | 2 +- board/freescale/corenet_ds/eth_hydra.c | 2 +- board/freescale/corenet_ds/eth_superhydra.c | 4 +- board/freescale/t104xrdb/eth.c | 4 +- board/gdsys/a38x/controlcenterdc.c | 7 +- board/gdsys/a38x/ihs_phys.c | 6 +- board/st/stm32f746-disco/stm32f746-disco.c | 13 +-- drivers/core/ofnode.c | 44 ++++++++ drivers/core/read.c | 10 ++ drivers/net/ag7xxx.c | 9 +- drivers/net/altera_tse.c | 17 +-- drivers/net/bcm6348-eth.c | 8 +- drivers/net/bcmgenet.c | 12 +- drivers/net/designware.c | 10 +- drivers/net/dwc_eth_qos.c | 40 +------ drivers/net/ethoc.c | 4 +- drivers/net/fec_mxc.c | 11 +- drivers/net/fm/b4860.c | 8 +- drivers/net/fm/eth.c | 13 +-- drivers/net/fm/init.c | 8 +- drivers/net/fm/ls1043.c | 6 +- drivers/net/fm/ls1046.c | 8 +- drivers/net/fm/p1023.c | 4 +- drivers/net/fm/p4080.c | 6 +- drivers/net/fm/p5020.c | 6 +- drivers/net/fm/p5040.c | 6 +- drivers/net/fm/t1024.c | 4 +- drivers/net/fm/t1040.c | 4 +- drivers/net/fm/t2080.c | 6 +- drivers/net/fm/t4240.c | 6 +- drivers/net/fsl_enetc.c | 13 +-- drivers/net/ftgmac100.c | 11 +- drivers/net/higmacv300.c | 9 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 28 +---- drivers/net/ldpaa_eth/ldpaa_wriop.c | 10 +- drivers/net/ldpaa_eth/ls1088a.c | 4 +- drivers/net/ldpaa_eth/ls2080a.c | 4 +- drivers/net/ldpaa_eth/lx2160a.c | 4 +- drivers/net/macb.c | 10 +- drivers/net/mdio_mux_sandbox.c | 6 +- drivers/net/mscc_eswitch/jr2_switch.c | 2 +- drivers/net/mscc_eswitch/luton_switch.c | 2 +- drivers/net/mscc_eswitch/ocelot_switch.c | 2 +- drivers/net/mscc_eswitch/serval_switch.c | 2 +- drivers/net/mscc_eswitch/servalt_switch.c | 2 +- drivers/net/mt7620-eth.c | 45 +++----- drivers/net/mtk_eth.c | 8 +- drivers/net/mvgbe.c | 7 +- drivers/net/mvneta.c | 11 +- drivers/net/mvpp2.c | 9 +- drivers/net/pch_gbe.c | 4 +- drivers/net/phy/aquantia.c | 2 +- drivers/net/phy/ethernet_id.c | 5 +- drivers/net/phy/phy.c | 117 +++++++------------- drivers/net/phy/xilinx_gmii2rgmii.c | 14 +-- drivers/net/pic32_eth.c | 11 +- drivers/net/qe/dm_qe_uec.c | 11 +- drivers/net/ravb.c | 19 +--- drivers/net/sh_eth.c | 19 +--- drivers/net/sni_ave.c | 16 +-- drivers/net/sni_netsec.c | 10 +- drivers/net/sun8i_emac.c | 13 +-- drivers/net/sunxi_emac.c | 5 +- drivers/net/ti/am65-cpsw-nuss.c | 15 +-- drivers/net/ti/cpsw.c | 10 +- drivers/net/ti/keystone_net.c | 24 ++-- drivers/net/tsec.c | 9 +- drivers/net/xilinx_axi_emac.c | 10 +- drivers/net/zynq_gem.c | 9 +- include/_exports.h | 3 +- include/dm/ofnode.h | 27 +++++ include/dm/read.h | 36 ++++++ include/exports.h | 3 +- include/fm_eth.h | 2 +- include/miiphy.h | 31 ++++++ include/phy.h | 40 ++----- include/phy_interface.h | 11 +- include/vsc9953.h | 2 +- net/mdio-mux-uclass.c | 16 +-- net/mdio-uclass.c | 96 ++++++++-------- test/dm/mdio.c | 18 +-- test/dm/mdio_mux.c | 16 +-- test/dm/ofnode.c | 22 ++++ 85 files changed, 508 insertions(+), 631 deletions(-)
Quoted 3 lines
--
2.35.1
Applied to u-boot-net/next
Thanks,
Ramon
Re: [PATCH u-boot-net v4 03/14] net: introduce helpers to get PHY ofnode from MAC
In reply to Marek BehúnQuoted 242 lines · Marek Behún
From: Marek Behún <[email protected]>
Add helpers
ofnode_get_phy_node()anddev_get_phy_node()and use it innet/mdio-uclass.cfunctiondm_eth_connect_phy_handle(). Also add corresponding UT test.This is useful because other part's of U-Boot may want to get PHY ofnode without connecting a PHY.
Signed-off-by Marek Behún <[email protected]>Reviewed-by Ramon Fried <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/sandbox/dts/test.dts | 13 +++++++++++++ drivers/core/ofnode.c | 21 +++++++++++++++++++++ drivers/core/read.c | 5 +++++ include/dm/ofnode.h | 14 ++++++++++++++ include/dm/read.h | 19 +++++++++++++++++++ net/mdio-uclass.c | 24 ++++++------------------ test/dm/ofnode.c | 18 ++++++++++++++++++ 7 files changed, 96 insertions(+), 18 deletions(-)arch/sandbox/dts/test.dts +13
-0@@ -530,6 +530,13 @@ fake-host-hwaddr = [00 00 66 44 22 22]; }; + phy_eth0: phy-test-eth { + compatible = "sandbox,eth"; + reg = <0x10007000 0x1000>; + fake-host-hwaddr = [00 00 66 44 22 77]; + phy-handle = <ðphy1>; + }; + dsa_eth0: dsa-test-eth { compatible = "sandbox,eth"; reg = <0x10006000 0x1000>;@@ -1555,6 +1562,12 @@ mdio: mdio-test { compatible = "sandbox,mdio"; + #address-cells = <1>; + #size-cells = <0>; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; }; pm-bus-test {drivers/core/ofnode.c +21
-0@@ -1198,3 +1198,24 @@ const char *ofnode_conf_read_str(const char *prop_name)return ofnode_read_string (node, prop_name); } + +ofnode ofnode_get_phy_node (ofnode node) +{ +/* DT node properties that reference a PHY node */ +static const char *const phy_handle_str[] = { +"phy-handle" ,"phy" ,"phy-device" , + }; +struct ofnode_phandle_args args = { + .node =ofnode_null () + }; +int i; + +assert (ofnode_valid (node)); + +for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) +if (!ofnode_parse_phandle_with_args (node, phy_handle_str[i], +NULL ,0 ,0 , &args)) +break ; + +return args.node; +}drivers/core/read.c +5
-0@@ -398,3 +398,8 @@ int dev_decode_display_timing(const struct udevice *dev, int index, {return ofnode_decode_display_timing (dev_ofnode (dev), index, config); } + +ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +}include/dm/ofnode.h +14
-0@@ -1217,4 +1217,18 @@ int ofnode_conf_read_int(const char *prop_name, int default_val);*/ const char *ofnode_conf_read_str (const char *prop_name); +/** +* ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @eth_node: ofnode belonging to the Ethernet controller +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode ofnode_get_phy_node (ofnode eth_node); +#endif include/dm/read.h +19
-0@@ -743,6 +743,20 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res);int dev_decode_display_timing (const struct udevice *dev,int index,struct display_timing *config); +/** +* dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @dev: device representing the MAC +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode dev_get_phy_node (const struct udevice *dev); +#else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include <asm/global_data.h> @@ -1092,6 +1106,11 @@ static inline int dev_decode_display_timing(const struct udevice *dev, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +static inline ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +} +#endif /* CONFIG_DM_DEV_READ_INLINE */ /** net/mdio-uclass.c +6
-18@@ -20,11 +20,6 @@ static const char * const phy_mode_str[] = { "phy-mode", "phy-connection-type" }; -/* DT node properties that reference a PHY node */ -static const char *const phy_handle_str[] = { -"phy-handle" ,"phy" ,"phy-device" -}; -void dm_mdio_probe_devices (void ) {struct udevice *it;@@ -137,23 +132,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,u32 phy_addr;struct udevice *mdiodev;struct phy_device *phy; -struct ofnode_phandle_args phandle = {.node =ofnode_null ()};ofnode phynode; -int i;if (CONFIG_IS_ENABLED (PHY_FIXED ) &&ofnode_phy_is_fixed_link (dev_ofnode (ethdev), &phynode)) { phy =phy_connect (NULL ,0 , ethdev, interface); - phandle.node = phynode; goto out; } -for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) -if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL , -0 ,0 , &phandle)) -break ; - -if (!ofnode_valid (phandle.node)) { + phynode =dev_get_phy_node (ethdev); +if (!ofnode_valid (phynode)) {dev_dbg (ethdev,"can't find PHY node\n" );return NULL ; }@@ -162,16 +150,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,* reading 'reg' directly should be fine. This is a PHY node, the * address is always size 1 and requires no translation */ -if (ofnode_read_u32 (phandle.node,"reg" , &phy_addr)) { +if (ofnode_read_u32 (phynode,"reg" , &phy_addr)) {dev_dbg (ethdev,"missing reg property in phy node\n" );return NULL ; }if (uclass_get_device_by_ofnode (UCLASS_MDIO , -ofnode_get_parent (phandle.node), +ofnode_get_parent (phynode), &mdiodev)) {dev_dbg (ethdev,"can't find MDIO bus for node %s\n" , -ofnode_get_name (ofnode_get_parent (phandle.node))); +ofnode_get_name (ofnode_get_parent (phynode)));return NULL ; }@@ -179,7 +167,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, out:if (phy) - phy->node = phandle.node; + phy->node = phynode;return phy; }test/dm/ofnode.c +8
-0@@ -447,3 +447,21 @@ static int dm_test_ofnode_string_err(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_string_err,UT_TESTF_LIVE_TREE ); + +static int dm_test_ofnode_get_phy (struct unit_test_state *uts) +{ +ofnode eth_node, phy_node; +u32 reg; + + eth_node =ofnode_path ("/phy-test-eth" ); +ut_assert (ofnode_valid (eth_node));
test/dm/ofnode.c static int dm_test_ofnode_string_err(struct unit_test_state *uts) · line 467
Quoted 10 lines
test/dm/ofnode.c +10
-0+ + phy_node =ofnode_get_phy_node (eth_node); +ut_assert (ofnode_valid (phy_node)); + + reg =ofnode_read_u32_default (phy_node,"reg" ,-1U ); +ut_asserteq_64 (0x1 , reg); + +return 0 ; +} +DM_TEST (dm_test_ofnode_get_phy,0 );
So this patch consistently leads to:
https://source.denx.de/u-boot/u-boot/-/jobs/423690#L222
on current master. I did have to manually merge a few changes, but I think I did that correctly. I don't see _why_ this leads to failure. Simon, any ideas?
Signature · 1 line
Tom
Re: [PATCH u-boot-net v4 03/14] net: introduce helpers to get PHY ofnode from MAC
Quoted 252 lines · Tom Rini
Quoted 250 lines · Marek Behún
From: Marek Behún <[email protected]>
Add helpers
ofnode_get_phy_node()anddev_get_phy_node()and use it innet/mdio-uclass.cfunctiondm_eth_connect_phy_handle(). Also add corresponding UT test.This is useful because other part's of U-Boot may want to get PHY ofnode without connecting a PHY.
Signed-off-by Marek Behún <[email protected]>Reviewed-by Ramon Fried <[email protected]>Reviewed-by Simon Glass <[email protected]>--- arch/sandbox/dts/test.dts | 13 +++++++++++++ drivers/core/ofnode.c | 21 +++++++++++++++++++++ drivers/core/read.c | 5 +++++ include/dm/ofnode.h | 14 ++++++++++++++ include/dm/read.h | 19 +++++++++++++++++++ net/mdio-uclass.c | 24 ++++++------------------ test/dm/ofnode.c | 18 ++++++++++++++++++ 7 files changed, 96 insertions(+), 18 deletions(-)arch/sandbox/dts/test.dts +13
-0@@ -530,6 +530,13 @@ fake-host-hwaddr = [00 00 66 44 22 22]; }; + phy_eth0: phy-test-eth { + compatible = "sandbox,eth"; + reg = <0x10007000 0x1000>; + fake-host-hwaddr = [00 00 66 44 22 77]; + phy-handle = <ðphy1>; + }; + dsa_eth0: dsa-test-eth { compatible = "sandbox,eth"; reg = <0x10006000 0x1000>;@@ -1555,6 +1562,12 @@ mdio: mdio-test { compatible = "sandbox,mdio"; + #address-cells = <1>; + #size-cells = <0>; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; }; pm-bus-test {drivers/core/ofnode.c +21
-0@@ -1198,3 +1198,24 @@ const char *ofnode_conf_read_str(const char *prop_name)return ofnode_read_string (node, prop_name); } + +ofnode ofnode_get_phy_node (ofnode node) +{ +/* DT node properties that reference a PHY node */ +static const char *const phy_handle_str[] = { +"phy-handle" ,"phy" ,"phy-device" , + }; +struct ofnode_phandle_args args = { + .node =ofnode_null () + }; +int i; + +assert (ofnode_valid (node)); + +for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) +if (!ofnode_parse_phandle_with_args (node, phy_handle_str[i], +NULL ,0 ,0 , &args)) +break ; + +return args.node; +}drivers/core/read.c +5
-0@@ -398,3 +398,8 @@ int dev_decode_display_timing(const struct udevice *dev, int index, {return ofnode_decode_display_timing (dev_ofnode (dev), index, config); } + +ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +}include/dm/ofnode.h +14
-0@@ -1217,4 +1217,18 @@ int ofnode_conf_read_int(const char *prop_name, int default_val);*/ const char *ofnode_conf_read_str (const char *prop_name); +/** +* ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @eth_node: ofnode belonging to the Ethernet controller +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode ofnode_get_phy_node (ofnode eth_node); +#endif include/dm/read.h +19
-0@@ -743,6 +743,20 @@ int dev_read_pci_bus_range(const struct udevice *dev, struct resource *res);int dev_decode_display_timing (const struct udevice *dev,int index,struct display_timing *config); +/** +* dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link) +* +* This function parses PHY handle from the Ethernet controller's ofnode +* (trying all possible PHY handle property names), and returns the PHY ofnode. +* +* Before this is used, ofnode_phy_is_fixed_link() should be checked first, and +* if the result to that is true, this function should not be called. +* +* @dev: device representing the MAC +* Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode +*/ +ofnode dev_get_phy_node (const struct udevice *dev); +#else /* CONFIG_DM_DEV_READ_INLINE is enabled */ #include <asm/global_data.h> @@ -1092,6 +1106,11 @@ static inline int dev_decode_display_timing(const struct udevice *dev, return ofnode_decode_display_timing(dev_ofnode(dev), index, config); } +static inline ofnode dev_get_phy_node (const struct udevice *dev) +{ +return ofnode_get_phy_node (dev_ofnode (dev)); +} +#endif /* CONFIG_DM_DEV_READ_INLINE */ /** net/mdio-uclass.c +6
-18@@ -20,11 +20,6 @@ static const char * const phy_mode_str[] = { "phy-mode", "phy-connection-type" }; -/* DT node properties that reference a PHY node */ -static const char *const phy_handle_str[] = { -"phy-handle" ,"phy" ,"phy-device" -}; -void dm_mdio_probe_devices (void ) {struct udevice *it;@@ -137,23 +132,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,u32 phy_addr;struct udevice *mdiodev;struct phy_device *phy; -struct ofnode_phandle_args phandle = {.node =ofnode_null ()};ofnode phynode; -int i;if (CONFIG_IS_ENABLED (PHY_FIXED ) &&ofnode_phy_is_fixed_link (dev_ofnode (ethdev), &phynode)) { phy =phy_connect (NULL ,0 , ethdev, interface); - phandle.node = phynode; goto out; } -for (i =0 ; i <ARRAY_SIZE (phy_handle_str); i++) -if (!dev_read_phandle_with_args (ethdev, phy_handle_str[i],NULL , -0 ,0 , &phandle)) -break ; - -if (!ofnode_valid (phandle.node)) { + phynode =dev_get_phy_node (ethdev); +if (!ofnode_valid (phynode)) {dev_dbg (ethdev,"can't find PHY node\n" );return NULL ; }@@ -162,16 +150,16 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,* reading 'reg' directly should be fine. This is a PHY node, the * address is always size 1 and requires no translation */ -if (ofnode_read_u32 (phandle.node,"reg" , &phy_addr)) { +if (ofnode_read_u32 (phynode,"reg" , &phy_addr)) {dev_dbg (ethdev,"missing reg property in phy node\n" );return NULL ; }if (uclass_get_device_by_ofnode (UCLASS_MDIO , -ofnode_get_parent (phandle.node), +ofnode_get_parent (phynode), &mdiodev)) {dev_dbg (ethdev,"can't find MDIO bus for node %s\n" , -ofnode_get_name (ofnode_get_parent (phandle.node))); +ofnode_get_name (ofnode_get_parent (phynode)));return NULL ; }@@ -179,7 +167,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, out:if (phy) - phy->node = phandle.node; + phy->node = phynode;return phy; }test/dm/ofnode.c +16
-0@@ -447,3 +447,21 @@ static int dm_test_ofnode_string_err(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_string_err,UT_TESTF_LIVE_TREE ); + +static int dm_test_ofnode_get_phy (struct unit_test_state *uts) +{ +ofnode eth_node, phy_node; +u32 reg; + + eth_node =ofnode_path ("/phy-test-eth" ); +ut_assert (ofnode_valid (eth_node)); + + phy_node =ofnode_get_phy_node (eth_node); +ut_assert (ofnode_valid (phy_node)); + + reg =ofnode_read_u32_default (phy_node,"reg" ,-1U ); +ut_asserteq_64 (0x1 , reg); + +return 0 ;
Quoted 8 lines
test/dm/ofnode.c static int dm_test_ofnode_string_err(struct unit_test_state *uts) · line 467
Quoted 2 lines
test/dm/ofnode.c +2
-0+} +DM_TEST (dm_test_ofnode_get_phy,0 );So this patch consistently leads to:
https://source.denx.de/u-boot/u-boot/-/jobs/423690#L222
on current master. I did have to manually merge a few changes, but I think I did that correctly. I don't see _why_ this leads to failure. Simon, any ideas?
This is addressed with:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Signature · 1 line
Tom