cpsw: enable DM_ETH on dra74 and am437x evms
Subsystems (2)
v3 cover cpsw: enable DM_ETH on dra74 and am437x evms
This series adds the following
* Enable DM_ETH on dra74, am437x gp and am437x sk evms.
* Add support to verify of_is_device_conpatible() based on linux implementation
* Fix an issue in fdtdec get addr for address and size cell length
Changes from initial version:
* removed 02/11 fix size cell and address cell parse from DT and used fdtdec_get_addr_size_auto_noparent() to get mdio base and gmii_sel register address. Added as separate patch in this series.
* used fdt_node_check_compatible() to check if the device or machine is compatible with the given compatible string.
* change first argument from node offset to device pointer so that in future it is will be easy to migrate out of indexing DT by offsets.
Changes from v2:
* Just rebase on top of u-boot/master and resolve conflicts.
Mugunthan V N (12):
drivers: core: device: add support to check dt compatible for a
device/machine
ti_omap5_common: eth: do not define DM_ETH for spl
drivers: net: cpsw: fix cpsw dp parse when num slaves as 1
ARM: omap5: add platform specific ethernet phy modes configurations
drivers: net: cpsw: fix get mdio base and gmii_sel reg from DT
drivers: net: cpsw: add support for reading mac address from efuse
arm: dts: am4372: add syscon node to cpsw to read mac address
arm: dts: dra7: add syscon node to cpsw to read mac address
arm: dts: dra7: fix ethernet name with proper device address
defconfig: am437x_gp_evm: enable eth driver model
defconfig: am437x_sk_evm: enable eth driver model
defconfig: dra74_evm: enable eth driver model
arch/arm/dts/am4372.dtsi | 1 + arch/arm/dts/dra7.dtsi | 3 +- arch/arm/include/asm/arch-omap5/cpu.h | 12 ++++ configs/am437x_gp_evm_defconfig | 1 + configs/am437x_sk_evm_defconfig | 1 + configs/dra74_evm_defconfig | 1 + drivers/core/device.c | 14 ++++ drivers/net/Makefile | 2 +- drivers/net/cpsw-common.c | 121 ++++++++++++++++++++++++++++++++++ drivers/net/cpsw.c | 54 ++++++++------- include/configs/ti_omap5_common.h | 1 + include/cpsw.h | 1 + include/dm/device.h | 23 +++++++ 13 files changed, 209 insertions(+), 26 deletions(-) create mode 100644 drivers/net/cpsw-common.c
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 1/12 drivers: core: device: add support to check dt compatible for a device/machine
Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.
Idea taken from Linux.
--- drivers/core/device.c | 14 ++++++++++++++ include/dm/device.h | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+)
drivers/core/device.c +14 -0
@@ -715,3 +715,17 @@ int device_set_name(struct udevice *dev, const char *name)return 0 ; } + +bool of_device_is_compatible (struct udevice *dev,const char *compat) +{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt, dev->of_offset, compat); +} + +bool of_machine_is_compatible (const char *compat) +{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt,0 , compat); +}
include/dm/device.h +23 -0
@@ -532,6 +532,29 @@ bool device_is_last_sibling(struct udevice *dev);int device_set_name (struct udevice *dev,const char *name);/** +* of_device_is_compatible() - check if the device is compatible with the compat +* +* This allows to check whether the device is comaptible with the compat. +* +* @dev: udevice pointer for which compatible needs to be verified. +* @compat: Compatible string which needs to verified in the given +* device +* @return true if OK, false if the compatible is not found +*/ +bool of_device_is_compatible (struct udevice *dev,const char *compat); + +/** +* of_machine_is_compatible() - check if the machine is compatible with +* the compat +* +* This allows to check whether the machine is comaptible with the compat. +* +* @compat: Compatible string which needs to verified +* @return true if OK, false if the compatible is not found +*/ +bool of_machine_is_compatible (const char *compat); + +/** * device_is_on_pci_bus - Test if a device is on a PCI bus * * @dev: device to test
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 2/12 ti_omap5_common: eth: do not define DM_ETH for spl
In reply to Mugunthan V NSince omap's spl doesn't support DM currently, do not define DM_ETH for spl build.
--- include/configs/ti_omap5_common.h | 1 + 1 file changed, 1 insertion(+)
include/configs/ti_omap5_common.h +1 -0
@@ -153,6 +153,7 @@#ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC#undef CONFIG_TIMER +#undef CONFIG_DM_ETH#endif #endif /* __CONFIG_TI_OMAP5_COMMON_H */
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 3/12 drivers: net: cpsw: fix cpsw dp parse when num slaves as 1
In reply to Mugunthan V NOn some boards number of slaves can be 1 when only one port ethernet is pinned out. So do not break when slave_index and num slaves check fails, instead continue to parse the next child.
--- drivers/net/cpsw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/cpsw.c +2 -4
@@ -1209,10 +1209,8 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)if (!strncmp (name,"slave" ,5 )) {u32 phy_id[2 ]; -if (slave_index >= priv->data.slaves) { -printf ("error: num slaves and slave nodes did not match\n" ); -return -EINVAL ; - } +if (slave_index >= priv->data.slaves) +continue ; phy_mode =fdt_getprop (fdt, subnode,"phy-mode" ,NULL );if (phy_mode) priv->data.slave_data[slave_index].phy_if =
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 4/12 ARM: omap5: add platform specific ethernet phy modes configurations
In reply to Mugunthan V NAdd platforms specific phy mode configuration bits to be used to configure phy mode in control module.
--- arch/arm/include/asm/arch-omap5/cpu.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/include/asm/arch-omap5/cpu.h +12 -0
@@ -116,4 +116,16 @@ struct watchdog {#define CPSW_BASE 0x48484000#define CPSW_MDIO_BASE 0x48485000 +/* gmii_sel register defines */ +#define GMII1_SEL_MII 0x0 +#define GMII1_SEL_RMII 0x1 +#define GMII1_SEL_RGMII 0x2 +#define GMII2_SEL_MII (GMII1_SEL_MII << 4) +#define GMII2_SEL_RMII (GMII1_SEL_RMII << 4) +#define GMII2_SEL_RGMII (GMII1_SEL_RGMII << 4) + +#define MII_MODE_ENABLE (GMII1_SEL_MII | GMII2_SEL_MII) +#define RMII_MODE_ENABLE (GMII1_SEL_RMII | GMII2_SEL_RMII) +#define RGMII_MODE_ENABLE (GMII1_SEL_RGMII | GMII2_SEL_RGMII) +#endif /* _CPU_H */
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 5/12 drivers: net: cpsw: fix get mdio base and gmii_sel reg from DT
In reply to Mugunthan V NSince dra7x platforms address bus is define as 64 bits to support LAPE, fdtdec_get_addr() returns a invalid address for mdio based and gmii_sel register address. Fixing this by using fdtdec_get_addr_size_auto_noparent() which will derive address cell and size cell from its parent.
--- drivers/net/cpsw.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/net/cpsw.c +20 -4
@@ -1137,6 +1137,11 @@ static const struct eth_ops cpsw_eth_ops = { .stop = cpsw_eth_stop, }; +static inline fdt_addr_t cpsw_get_addr_by_node (const void *fdt,int node) +{ +return fdtdec_get_addr_size_auto_noparent (fdt, node,"reg" ,0 ,NULL ); +} +static int cpsw_eth_ofdata_to_platdata (struct udevice *dev) {struct eth_pdata *pdata =dev_get_platdata (dev);
@@ -1202,8 +1207,14 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) name =fdt_get_name (fdt, subnode, &len);if (!strncmp (name,"mdio" ,4 )) { - priv->data.mdio_base =fdtdec_get_addr (fdt, subnode, -"reg" ); +u32 mdio_base; + + mdio_base =cpsw_get_addr_by_node (fdt, subnode); +if (mdio_base ==FDT_ADDR_T_NONE ) { +error ("Not able to get MDIO address space\n" ); +return -ENOENT ; + } + priv->data.mdio_base = mdio_base; }if (!strncmp (name,"slave" ,5 )) {
@@ -1221,8 +1232,13 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) }if (!strncmp (name,"cpsw-phy-sel" ,12 )) { - priv->data.gmii_sel =fdtdec_get_addr (fdt, subnode, -"reg" ); + priv->data.gmii_sel =cpsw_get_addr_by_node (fdt, + subnode); + +if (priv->data.gmii_sel ==FDT_ADDR_T_NONE ) { +error ("Not able to get gmii_sel reg address\n" ); +return -ENOENT ; + } } }
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 6/12 drivers: net: cpsw: add support for reading mac address from efuse
In reply to Mugunthan V NDifferent TI platforms has to read with different combination to get the mac address from efuse. So add support to read mac address based on machine/device compatibles.
The code is taken from Linux drivers/net/ethernet/ti/cpsw-common.c done by Tony Lindgren.
--- drivers/net/Makefile | 2 +- drivers/net/cpsw-common.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/cpsw.c | 24 +++------ include/cpsw.h | 1 + 4 files changed, 131 insertions(+), 17 deletions(-) create mode 100644 drivers/net/cpsw-common.c
drivers/net/Makefile +1 -1
@@ -59,7 +59,7 @@ obj-$(CONFIG_SMC91111) += smc91111.o obj-$(CONFIG_SMC911X) += smc911x.o obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o -obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o +obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o obj-$(CONFIG_ULI526X) += uli526x.o
drivers/net/cpsw-common.c new file +121 -0
121 lines not on this page · raw message
drivers/net/cpsw.c +8 -16
@@ -26,6 +26,7 @@#include <phy.h> #include <asm/arch/cpu.h> #include <dm.h> +#include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -1151,9 +1152,8 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)int node = dev->of_offset;int subnode;int slave_index =0 ; -uint32_t mac_hi, mac_lo; -fdt32_t gmii =0 ;int active_slave; +int ret; pdata->iobase =dev_get_addr (dev); priv->data.version =CPSW_CTRL_VERSION_2 ;
@@ -1250,20 +1250,11 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) priv->data.slave_data[1 ].sliver_reg_ofs =CPSW_SLIVER1_OFFSET ; } - subnode =fdtdec_lookup_phandle (fdt, node,"syscon" ); - priv->data.mac_id =fdt_translate_address ((void *)fdt, subnode, &gmii); - priv->data.mac_id +=AM335X_GMII_SEL_OFFSET ; - priv->data.mac_id += active_slave *8 ; - -/* try reading mac address from efuse */ - mac_lo =readl (priv->data.mac_id); - mac_hi =readl (priv->data.mac_id +4 ); - pdata->enetaddr[0 ] = mac_hi &0xFF ; - pdata->enetaddr[1 ] = (mac_hi &0xFF00 ) >>8 ; - pdata->enetaddr[2 ] = (mac_hi &0xFF0000 ) >>16 ; - pdata->enetaddr[3 ] = (mac_hi &0xFF000000 ) >>24 ; - pdata->enetaddr[4 ] = mac_lo &0xFF ; - pdata->enetaddr[5 ] = (mac_lo &0xFF00 ) >>8 ; + ret =ti_cm_get_macid (dev, active_slave, pdata->enetaddr); +if (ret <0 ) { +error ("cpsw read efuse mac failed\n" ); +return ret; + } pdata->phy_interface = priv->data.slave_data[active_slave].phy_if;if (pdata->phy_interface ==-1 ) {
@@ -1284,6 +1275,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)writel (RGMII_MODE_ENABLE , priv->data.gmii_sel);break ; } +return 0 ; }
include/cpsw.h +1 -0
@@ -51,5 +51,6 @@ struct cpsw_platform_data { };int cpsw_register (struct cpsw_platform_data *data); +int ti_cm_get_macid (struct udevice *dev,int slave,u8 *mac_addr);#endif /* _CPSW_H_ */
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 7/12 arm: dts: am4372: add syscon node to cpsw to read mac address
In reply to Mugunthan V NAdd syscon node to cpsw device node to read mac address from efuse.
--- arch/arm/dts/am4372.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/dts/am4372.dtsi +1 -0
@@ -547,6 +547,7 @@ active_slave = <0>; cpts_clock_mult = <0x80000000>; cpts_clock_shift = <29>; + syscon = <&scm_conf>; ranges; davinci_mdio: mdio at 4a101000 {
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 8/12 arm: dts: dra7: add syscon node to cpsw to read mac address
In reply to Mugunthan V NAdd syscon node to cpsw device node to read mac address from efuse.
--- arch/arm/dts/dra7.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm/dts/dra7.dtsi +1 -0
@@ -1426,6 +1426,7 @@ active_slave = <0>; cpts_clock_mult = <0x80000000>; cpts_clock_shift = <29>; + syscon = <&scm_conf>; reg = <0x48484000 0x1000 0x48485200 0x2E00>; #address-cells = <1>;
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 9/12 arm: dts: dra7: fix ethernet name with proper device address
In reply to Mugunthan V NFix typo error for cpsw device name with proper device address
--- arch/arm/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/dra7.dtsi +1 -1
@@ -1411,7 +1411,7 @@ ti,irqs-safe-map = <0>; }; - mac: ethernet at 4a100000 { + mac: ethernet at 48484000 { compatible = "ti,cpsw"; ti,hwmods = "gmac"; clocks = <&dpll_gmac_ck>, <&gmac_gmii_ref_clk_div>;
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 10/12 defconfig: am437x_gp_evm: enable eth driver model
In reply to Mugunthan V NEnable eth driver model for am437x_gp_evm as cpsw supports driver model.
--- configs/am437x_gp_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am437x_gp_evm_defconfig +1 -0
@@ -47,3 +47,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0403 CONFIG_G_DNL_PRODUCT_NUM=0xbd00 +CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 11/12 defconfig: am437x_sk_evm: enable eth driver model
In reply to Mugunthan V NEnable eth driver model for am437x_sk_evm as cpsw supports driver model.
--- configs/am437x_sk_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am437x_sk_evm_defconfig +1 -0
@@ -51,3 +51,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0403 CONFIG_G_DNL_PRODUCT_NUM=0xbd00 +CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 12/12 defconfig: dra74_evm: enable eth driver model
In reply to Mugunthan V NEnable eth driver model for dra74_evm as cpsw supports driver model.
--- configs/dra74_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/dra74_evm_defconfig +1 -0
@@ -50,3 +50,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Texas Instruments" CONFIG_G_DNL_VENDOR_NUM=0x0451 CONFIG_G_DNL_PRODUCT_NUM=0xd022 +CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.339.g3ad15fd
PATCH v3 1/12 drivers: core: device: add support to check dt compatible for a device/machine
In reply to Mugunthan V NHi Mugunthan,
Quoted 18 lines · Mugunthan V N
Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.
Idea taken from Linux.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Joe Hershberger <[email protected]>--- drivers/core/device.c | 14 ++++++++++++++ include/dm/device.h | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+)drivers/core/device.c +0
-0
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 719
Quoted 5 lines
drivers/core/device.c +2
-0@@ -715,3 +715,17 @@ int device_set_name(struct udevice *dev, const char *name)return 0 ; } + +bool of_device_is_compatible (struct udevice *dev,const char *compat)
This function is in device.h, so I think device_is_compatible() is a better name. Where does compat come from? Is it another device, or something else entirely?
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 726
Quoted 7 lines
drivers/core/device.c +7
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt, dev->of_offset, compat); +} + +bool of_machine_is_compatible (const char *compat)
This should go in fdtdec.h I think. It doesn't have anything to do with devices. So fdtdec_machine_is_compatible().
Quoted 11 lines
drivers/core/device.c +5
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt,0 , compat); +}include/dm/device.h +0
-0@@ -532,6 +532,29 @@ bool device_is_last_sibling(struct udevice *dev);int device_set_name (struct udevice *dev,const char *name);
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 542
Quoted 10 lines
include/dm/device.h +8
-0/** +* of_device_is_compatible() - check if the device is compatible with the compat +* +* This allows to check whether the device is comaptible with the compat. +* +* @dev: udevice pointer for which compatible needs to be verified. +* @compat: Compatible string which needs to verified in the given +* device +* @return true if OK, false if the compatible is not found
Does this mean false if @compat is not found in the device's compatible string list? Can you beef up the comment a bit to be specific?
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 550
Quoted 8 lines
include/dm/device.h +8
-0+*/ +bool of_device_is_compatible (struct udevice *dev,const char *compat); + +/** +* of_machine_is_compatible() - check if the machine is compatible with +* the compat +* +* This allows to check whether the machine is comaptible with the compat.
Again can you beef up the comment? What is machine? Where does it actually look?
Quoted 11 lines
include/dm/device.h +7
-1+* +* @compat: Compatible string which needs to verified +* @return true if OK, false if the compatible is not found +*/ +bool of_machine_is_compatible (const char *compat); + +/** * device_is_on_pci_bus - Test if a device is on a PCI bus * * @dev: device to test --
Quoted 2 lines
2.8.1.339.g3ad15fd
Regards,
Simon
PATCH v3 1/12 drivers: core: device: add support to check dt compatible for a device/machine
Quoted 22 lines · Simon Glass
Hi Mugunthan,
Quoted 19 lines · Mugunthan V N
Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.
Idea taken from Linux.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Joe Hershberger <[email protected]>--- drivers/core/device.c | 14 ++++++++++++++ include/dm/device.h | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+)drivers/core/device.c +0
-0@@ -715,3 +715,17 @@ int device_set_name(struct udevice *dev, const char *name)
Quoted 8 lines
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 719
Quoted 4 lines
drivers/core/device.c +2
-0return 0 ; } + +bool of_device_is_compatible (struct udevice *dev,const char *compat)This function is in
device.h, so I thinkdevice_is_compatible()is a better name. Where does compat come from? Is it another device, or something else entirely?
I have used the funtion names as is from the kernel so that porting kernel driver to U-boot will be easier.
The compat comes from the driver which uses the API, compat is the device compatible string like "ti,am3517-emac"
Quoted 11 lines
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 726
Quoted 8 lines
drivers/core/device.c +7
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt, dev->of_offset, compat); +} + +bool of_machine_is_compatible (const char *compat)This should go in
fdtdec.hI think. It doesn't have anything to do with devices. Sofdtdec_machine_is_compatible().
I have used the funtion names as is from the kernel so that porting kernel driver to U-boot will be easier.
Quoted 13 lines
Quoted 13 lines
drivers/core/device.c +5
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt,0 , compat); +}include/dm/device.h +0
-0@@ -532,6 +532,29 @@ bool device_is_last_sibling(struct udevice *dev);int device_set_name (struct udevice *dev,const char *name);
Quoted 13 lines
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 542
Quoted 9 lines
include/dm/device.h +8
-0/** +* of_device_is_compatible() - check if the device is compatible with the compat +* +* This allows to check whether the device is comaptible with the compat. +* +* @dev: udevice pointer for which compatible needs to be verified. +* @compat: Compatible string which needs to verified in the given +* device +* @return true if OK, false if the compatible is not found Does this mean false if @compat is not found in the device's compatible string list? Can you beef up the comment a bit to be specific?
Yes, return true if compatible is found. Will modify like below.
@return true if the compatible is found, false if the compatible is not found
Quoted 12 lines
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 550
Quoted 9 lines
include/dm/device.h +8
-0+*/ +bool of_device_is_compatible (struct udevice *dev,const char *compat); + +/** +* of_machine_is_compatible() - check if the machine is compatible with +* the compat +* +* This allows to check whether the machine is comaptible with the compat. Again can you beef up the comment? What is machine? Where does it actually look?
Will do.
Quoted 5 lines
Quoted 5 lines
include/dm/device.h +5
-0+* +* @compat: Compatible string which needs to verified +* @return true if OK, false if the compatible is not found +*/ +bool of_machine_is_compatible (const char *compat);
Quoted 9 lines
Quoted 8 lines
include/dm/device.h +2
-1+ +/** * device_is_on_pci_bus - Test if a device is on a PCI bus * * @dev: device to test -- 2.8.1.339.g3ad15fd
Regards
Mugunthan V N
[U-Boot] drivers: core: device: add support to check dt compatible for a device/machine
In reply to Mugunthan V N[U-Boot] ti_omap5_common: eth: do not define DM_ETH for spl
In reply to Mugunthan V N[U-Boot] drivers: net: cpsw: fix cpsw dp parse when num slaves as 1
In reply to Mugunthan V N[U-Boot] ARM: omap5: add platform specific ethernet phy modes configurations
In reply to Mugunthan V N[U-Boot] drivers: net: cpsw: fix get mdio base and gmii_sel reg from DT
In reply to Mugunthan V N[U-Boot] drivers: net: cpsw: add support for reading mac address from efuse
In reply to Mugunthan V N[U-Boot] arm: dts: am4372: add syscon node to cpsw to read mac address
In reply to Mugunthan V N[U-Boot] arm: dts: dra7: add syscon node to cpsw to read mac address
In reply to Mugunthan V N[U-Boot] arm: dts: dra7: fix ethernet name with proper device address
In reply to Mugunthan V N[U-Boot] defconfig: am437x_gp_evm: enable eth driver model
In reply to Mugunthan V N[U-Boot] defconfig: am437x_sk_evm: enable eth driver model
In reply to Mugunthan V N[U-Boot] defconfig: dra74_evm: enable eth driver model
In reply to Mugunthan V NPATCH v3 1/12 drivers: core: device: add support to check dt compatible for a device/machine
In reply to Mugunthan V NHi Mugunthan,
Quoted 33 lines · Mugunthan V N
Quoted 22 lines · Simon Glass
Hi Mugunthan,
Quoted 19 lines · Mugunthan V N
Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.
Idea taken from Linux.
Signed-off-by Mugunthan V N <[email protected]>Reviewed-by Joe Hershberger <[email protected]>--- drivers/core/device.c | 14 ++++++++++++++ include/dm/device.h | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+)drivers/core/device.c +0
-0@@ -715,3 +715,17 @@ int device_set_name(struct udevice *dev, const char *name)Quoted 8 lines
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 719
Quoted 4 lines
drivers/core/device.c +2
-0return 0 ; } + +bool of_device_is_compatible (struct udevice *dev,const char *compat)This function is in
device.h, so I thinkdevice_is_compatible()is a better name. Where does compat come from? Is it another device, or something else entirely?
Quoted 5 lines
I have used the funtion names as is from the kernel so that porting kernel driver to U-boot will be easier.
The compat comes from the driver which uses the API, compat is the device compatible string like "ti,am3517-emac"
OK, please update the function comment. Also what do you think about adding a new of.h /of.c files to hold this function prototype? I really want to keep the APIs clean.
Quoted 13 lines
Quoted 12 lines
drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 726
Quoted 9 lines
drivers/core/device.c +7
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt, dev->of_offset, compat); +} + +bool of_machine_is_compatible (const char *compat)This should go in
fdtdec.hI think. It doesn't have anything to do with devices. Sofdtdec_machine_is_compatible().
Quoted 2 lines
I have used the funtion names as is from the kernel so that porting kernel driver to U-boot will be easier.
Does one function really matter? In that case, it should still go in fdtdec, you can keep the of_ prefix. Perhaps we should use that more generally. My reason for not is that the current fdtdec API is not the same as of_. It uses (const void *blob, int offset) instead of (struct of_node *node), etc.
Quoted 63 lines
Quoted 14 lines
Quoted 14 lines
drivers/core/device.c +5
-0+{ +const void *fdt = gd->fdt_blob; + +return !fdt_node_check_compatible (fdt,0 , compat); +}include/dm/device.h +0
-0@@ -532,6 +532,29 @@ bool device_is_last_sibling(struct udevice *dev);int device_set_name (struct udevice *dev,const char *name);Quoted 13 lines
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 542
Quoted 9 lines
include/dm/device.h +8
-0/** +* of_device_is_compatible() - check if the device is compatible with the compat +* +* This allows to check whether the device is comaptible with the compat. +* +* @dev: udevice pointer for which compatible needs to be verified. +* @compat: Compatible string which needs to verified in the given +* device +* @return true if OK, false if the compatible is not found Does this mean false if @compat is not found in the device's compatible string list? Can you beef up the comment a bit to be specific?
Yes, return true if compatible is found. Will modify like below.
@return true if the compatible is found, false if the compatible is not found
Quoted 12 lines
include/dm/device.h bool device_is_last_sibling(struct udevice *dev); · line 550
Quoted 9 lines
include/dm/device.h +8
-0+*/ +bool of_device_is_compatible (struct udevice *dev,const char *compat); + +/** +* of_machine_is_compatible() - check if the machine is compatible with +* the compat +* +* This allows to check whether the machine is comaptible with the compat. Again can you beef up the comment? What is machine? Where does it actually look?
Will do.
Quoted 5 lines
Quoted 5 lines
include/dm/device.h +5
-0+* +* @compat: Compatible string which needs to verified +* @return true if OK, false if the compatible is not found +*/ +bool of_machine_is_compatible (const char *compat);Quoted 9 lines
Quoted 8 lines
include/dm/device.h +2
-1+ +/** * device_is_on_pci_bus - Test if a device is on a PCI bus * * @dev: device to test -- 2.8.1.339.g3ad15fd
Quoted 2 lines
Regards
Mugunthan V N
Regards,
Simon