Some mvebu comphy + mox + fdt_support changes
Subsystems (4)
cover Some mvebu comphy + mox + fdt_support changes
From: Marek Behún <[email protected]>
Hello Stefan,
as requested I am resending this series with board maintainers added in Ccs.
Original message:
Pali prepared patches that convert A3720 comphy driver to use Linux' DT bindings. (Yes, I have patches that convert the whole driver into using SMC calls into ATF, but haven't found time yet to rebase them since last year, and Pali has done this in the meantime :-D Maybe I'll look into my old patches sometimes, but this is now usable.)
These patches needed some changes in Turris MOX board code, and I added some more changes to handling device-tree fixups, and this lead to adding some code into fdt_support, which can hopefully be used by other people as well.
Marek
Marek Behún (8):
treewide: Use fdt_create_phandle() where appropriate
fdt_support: Remove fdt_alloc_phandle() in favor of
fdt_generate_phandle()
fdt_support: Remove FDT_STATUS_FAIL_ERROR_CODE
fdt_support: Fix comment for fdt_create_phandle()
fdt_support: Add some useful functions
arm: mvebu: turris_mox: Find DT nodes by compatible or alias instead
of path
arm: mvebu: turris_mox: Fix unstable board topology reading
fdt_support: Add fdt_delete_disabled_nodes() and use in Turris MOX
Pali Rohár (3):
include/linux/byteorder: Fix compilation of __constant_cpu_to_be32()
arm: mvebu: turris_mox: Enable eth1 in U-Boot if a network module is
present
phy: marvell: a3700: Convert to official DT bindings in COMPHY driver
arch/arm/cpu/armv7/ls102xa/fdt.c | 6 +- arch/arm/dts/armada-3720-espressobin.dts | 21 +-- arch/arm/dts/armada-3720-turris-mox.dts | 25 +-- arch/arm/dts/armada-3720-uDPU.dts | 23 +-- arch/arm/dts/armada-37xx.dtsi | 20 +- board/CZ.NIC/turris_mox/turris_mox.c | 223 ++++++++--------------- board/Marvell/octeon_ebb7304/board.c | 5 +- board/freescale/lx2160a/eth_lx2160aqds.c | 8 +- board/freescale/lx2160a/eth_lx2162aqds.c | 8 +- board/gateworks/gw_ventana/common.c | 3 +- board/kontron/sl28/sl28.c | 2 +- common/fdt_support.c | 174 +++++++++++++++--- drivers/misc/fsl_portals.c | 10 +- drivers/pci/pcie_layerscape_fixup.c | 8 +- drivers/pci/pcie_layerscape_gen4_fixup.c | 8 +- drivers/phy/marvell/comphy_a3700.c | 133 ++++++++++++++ drivers/phy/marvell/comphy_core.c | 59 +----- drivers/phy/marvell/comphy_core.h | 23 +++ drivers/phy/marvell/comphy_cp110.c | 58 ++++++ include/fdt_support.h | 51 ++++-- include/linux/byteorder/swab.h | 4 + 21 files changed, 551 insertions(+), 321 deletions(-)
Signature · 1 line
2.32.0
PATCH RESEND 1/11 include/linux/byteorder: Fix compilation of __constant_cpu_to_be32()
From: Pali Rohár <[email protected]>
The macro __constant_cpu_to_be32() uses ___constant_swab32(), which for some reason is not defined and causes the following error during compilation:
include/linux/byteorder/little_endian.h:28:52: warning:
implicit declaration of function ‘___constant_swab32’;
did you mean ‘__builtin_bswap32’? [-Wimplicit-function-declaration]
#define __constant_cpu_to_be32(x) ((__force __be32)___constant_swab32((x)))Declare all ___constant_swabXX() macros.
--- include/linux/byteorder/swab.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/byteorder/swab.h +4 -0
@@ -39,6 +39,10 @@ (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) )) +#define ___constant_swab16 (x) ___swab16(x) +#define ___constant_swab32 (x) ___swab32(x) +#define ___constant_swab64 (x) ___swab64(x) +/* * provide defaults when no architecture-specific optimization is detected */
Signature · 1 line
2.32.0
PATCH RESEND 2/11 treewide: Use fdt_create_phandle() where appropriate
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Replace fdt_alloc_phandle() with subsequent fdt_set_phandle() by fdt_create_phandle().
--- board/Marvell/octeon_ebb7304/board.c | 5 ++--- drivers/misc/fsl_portals.c | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-)
board/Marvell/octeon_ebb7304/board.c +2 -3
@@ -205,7 +205,7 @@ static int fdt_fix_mix(const void *fdt)int env_lmac =-1 ;int lmac_fdt_node =-1 ;int mix_fdt_node =-1 ; -int lmac_phandle; +unsigned int lmac_phandle;char *compat;/* Get the lmac for this environment variable */
@@ -229,8 +229,7 @@ static int fdt_fix_mix(const void *fdt) } } - lmac_phandle =fdt_alloc_phandle ((void *)fdt); -fdt_set_phandle ((void *)fdt, lmac_fdt_node, lmac_phandle); + lmac_phandle =fdt_create_phandle ((void *)fdt, lmac_fdt_node);/* Get the fdt mix node corresponding to this lmac */ mix_fdt_node =get_mix_fdt_node (fdt, env_node, env_lmac);
drivers/misc/fsl_portals.c +4 -6
@@ -106,7 +106,7 @@ static int fdt_qportal(void *blob, int off, int id, char *name, enum fsl_dpaa_dev dev, int create) { int childoff, dev_off, ret = 0; -u32 dev_handle; +unsigned int dev_handle;#ifdef CONFIG_FSL_CORENET int num;u32 liodns[2 ];
@@ -142,11 +142,9 @@ static int fdt_qportal(void *blob, int off, int id, char *name,if (childoff >0 ) { dev_handle =fdt_get_phandle (blob, dev_off);if (dev_handle <=0 ) { - dev_handle =fdt_alloc_phandle (blob); - ret =fdt_set_phandle (blob, dev_off, - dev_handle); -if (ret <0 ) -return ret; + dev_handle =fdt_create_phandle (blob, dev_off); +if (!dev_handle) +return -FDT_ERR_NOPHANDLES ; } ret = fdt_setprop(blob, childoff, "dev-handle",
Signature · 1 line
2.32.0
PATCH RESEND 3/11 fdt_support: Remove fdt_alloc_phandle() in favor of fdt_generate_phandle()
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Commit f0921f5098d ("fdt: Sync up to the latest libfdt") introduced fdt_generate_phandle() in libfdt, making fdt_alloc_phandle() obsolete in fdt_support.
--- board/freescale/lx2160a/eth_lx2160aqds.c | 8 +++++-- board/freescale/lx2160a/eth_lx2162aqds.c | 8 +++++-- common/fdt_support.c | 28 +++++++----------------- include/fdt_support.h | 1 - 4 files changed, 20 insertions(+), 25 deletions(-)
board/freescale/lx2160a/eth_lx2160aqds.c +6 -2
@@ -775,10 +775,11 @@ int fdt_fixup_board_phy(void *fdt)int fpga_offset, offset, subnodeoffset;struct mii_dev *mii_dev;struct list_head *mii_devs, *entry; -int ret, dpmac_id, phandle, i; +int ret, dpmac_id, i;struct phy_device *phy_dev;char ethname[ETH_NAME_LEN ];phy_interface_t phy_iface; +uint32_t phandle; ret =0 ;/* we know FPGA is connected to i2c0, therefore search path directly,
@@ -794,7 +795,10 @@ int fdt_fixup_board_phy(void *fdt)return fpga_offset; } - phandle =fdt_alloc_phandle (fdt); + ret =fdt_generate_phandle (fdt, &phandle); +if (ret <0 ) +return ret; + mii_devs =mdio_get_list_head ();list_for_each (entry, mii_devs) {
board/freescale/lx2160a/eth_lx2162aqds.c +6 -2
@@ -787,10 +787,11 @@ int fdt_fixup_board_phy(void *fdt)int fpga_offset, offset, subnodeoffset;struct mii_dev *mii_dev;struct list_head *mii_devs, *entry; -int ret, dpmac_id, phandle, i; +int ret, dpmac_id, i;struct phy_device *phy_dev;char ethname[ETH_NAME_LEN ];phy_interface_t phy_iface; +uint32_t phandle; ret =0 ;/* we know FPGA is connected to i2c0, therefore search path directly,
@@ -806,7 +807,10 @@ int fdt_fixup_board_phy(void *fdt)return fpga_offset; } - phandle =fdt_alloc_phandle (fdt); + ret =fdt_generate_phandle (fdt, &phandle); +if (ret <0 ) +return ret; + mii_devs =mdio_get_list_head ();list_for_each (entry, mii_devs) {
common/fdt_support.c +8 -20
@@ -1463,24 +1463,6 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,return -FDT_ERR_NOTFOUND ; } -/** -* fdt_alloc_phandle: Return next free phandle value -* -* @blob: ptr to device tree -*/ -int fdt_alloc_phandle (void *blob) -{ -int offset; -uint32_t phandle =0 ; - -for (offset =fdt_next_node (blob,-1 ,NULL ); offset >=0 ; - offset =fdt_next_node (blob, offset,NULL )) { - phandle =max (phandle,fdt_get_phandle (blob, offset)); - } - -return phandle +1 ; -} -/* * fdt_set_phandle: Create a phandle property for the given node *
@@ -1530,13 +1512,19 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle)unsigned int fdt_create_phandle (void *fdt,int nodeoffset) {/* see if there is a phandle already */ -int phandle =fdt_get_phandle (fdt, nodeoffset); +uint32_t phandle =fdt_get_phandle (fdt, nodeoffset);/* if we got 0, means no phandle so create one */ if (phandle ==0 ) {int ret; - phandle =fdt_alloc_phandle (fdt); + ret =fdt_generate_phandle (fdt, &phandle); +if (ret <0 ) { +printf ("Can't generate phandle: %s\n" , +fdt_strerror (ret)); +return 0 ; + } + ret =fdt_set_phandle (fdt, nodeoffset, phandle);if (ret <0 ) { printf("Can't set phandle %u: %s\n", phandle,
include/fdt_support.h +0 -1
@@ -285,7 +285,6 @@ int fdt_get_dma_range(const void *blob, int node_offset, phys_addr_t *cpu,int fdt_node_offset_by_compat_reg (void *blob,const char *compat,phys_addr_t compat_off); -int fdt_alloc_phandle (void *blob);int fdt_set_phandle (void *fdt,int nodeoffset,uint32_t phandle);unsigned int fdt_create_phandle (void *fdt,int nodeoffset);int fdt_add_edid (void *blob,const char *compat,unsigned char *buf);
Signature · 1 line
2.32.0
Re: [PATCH u-boot-marvell RESEND 03/11] fdt_support: Remove fdt_alloc_phandle() in favor of fdt_generate_phandle()
Quoted 14 lines · Marek Behún
From: Marek Behún <[email protected]>
Commit
f0921f5098d("fdt: Sync up to the latest libfdt") introducedfdt_generate_phandle()in libfdt, makingfdt_alloc_phandle()obsolete infdt_support.Signed-off-by Marek Behún <[email protected]>Reviewed-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc "hui.song" <[email protected]>Cc Meenakshi Aggarwal <[email protected]>Cc Priyanka Jain <[email protected]>Cc Ioana Ciornei <[email protected]>
Quoted 6 lines
--- board/freescale/lx2160a/eth_lx2160aqds.c | 8 +++++-- board/freescale/lx2160a/eth_lx2162aqds.c | 8 +++++-- common/fdt_support.c | 28 +++++++----------------- include/fdt_support.h | 1 - 4 files changed, 20 insertions(+), 25 deletions(-)
PATCH RESEND 4/11 fdt_support: Remove FDT_STATUS_FAIL_ERROR_CODE
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Since no one uses this feature and I am not aware of any parsers of this in Linux, remove it.
--- arch/arm/cpu/armv7/ls102xa/fdt.c | 6 +++--- board/gateworks/gw_ventana/common.c | 3 +-- board/kontron/sl28/sl28.c | 2 +- common/fdt_support.c | 20 +++++--------------- drivers/pci/pcie_layerscape_fixup.c | 8 ++++---- drivers/pci/pcie_layerscape_gen4_fixup.c | 8 ++++---- include/fdt_support.h | 18 ++++++++---------- 7 files changed, 26 insertions(+), 39 deletions(-)
arch/arm/cpu/armv7/ls102xa/fdt.c +3 -3
@@ -184,13 +184,13 @@ void ft_cpu_setup(void *blob, struct bd_info *bd)#if defined(CONFIG_QSPI_BOOT ) || defined(CONFIG_SD_BOOT_QSPI ) off =fdt_node_offset_by_compat_reg (blob,FSL_IFC_COMPAT ,CONFIG_SYS_IFC_ADDR ); -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED );#else off =fdt_node_offset_by_compat_reg (blob,FSL_QSPI_COMPAT ,QSPI0_BASE_ADDR ); -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ); off =fdt_node_offset_by_compat_reg (blob,FSL_DSPI_COMPAT ,DSPI1_BASE_ADDR ); -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED );#endif }
board/gateworks/gw_ventana/common.c +1 -2
@@ -1681,8 +1681,7 @@ void ft_early_fixup(void *blob, int board_type)* disable serial2 node for GW54xx for compatibility with older * 3.10.x kernel that improperly had this node enabled in the DT */ -fdt_set_status_by_alias (blob,"serial2" ,FDT_STATUS_DISABLED , -0 ); +fdt_set_status_by_alias (blob,"serial2" ,FDT_STATUS_DISABLED );/* GW54xx-E adds WDOG2_B external reset */ if (rev <'E' )
board/kontron/sl28/sl28.c +1 -1
@@ -75,7 +75,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)if (CONFIG_IS_ENABLED (SL28_SPL_LOADS_OPTEE_BL32 )) { node =fdt_node_offset_by_compatible (blob,-1 ,"linaro,optee-tz" );if (node) -fdt_set_node_status (blob, node,FDT_STATUS_OKAY ,0 ); +fdt_set_node_status (blob, node,FDT_STATUS_OKAY ); }return 0 ;
common/fdt_support.c +5 -15
@@ -1541,14 +1541,10 @@ unsigned int fdt_create_phandle(void *fdt, int nodeoffset)* * @fdt: ptr to device tree * @nodeoffset: node to update -* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, -* FDT_STATUS_FAIL, FDT_STATUS_FAIL_ERROR_CODE -* @error_code: optional, only used if status is FDT_STATUS_FAIL_ERROR_CODE +* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL */ -int fdt_set_node_status (void *fdt,int nodeoffset, -enum fdt_status status,unsigned int error_code) +int fdt_set_node_status (void *fdt,int nodeoffset,enum fdt_status status) { -char buf[16 ];int ret =0 ;if (nodeoffset <0 )
@@ -1564,10 +1560,6 @@ int fdt_set_node_status(void *fdt, int nodeoffset,case FDT_STATUS_FAIL : ret =fdt_setprop_string (fdt, nodeoffset,"status" ,"fail" );break ; -case FDT_STATUS_FAIL_ERROR_CODE : -sprintf (buf,"fail-%d" , error_code); - ret =fdt_setprop_string (fdt, nodeoffset,"status" , buf); -break ;default :printf ("Invalid fdt status: %x\n" , status); ret =-1 ;
@@ -1582,16 +1574,14 @@ int fdt_set_node_status(void *fdt, int nodeoffset,* * @fdt: ptr to device tree * @alias: alias of node to update -* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, -* FDT_STATUS_FAIL, FDT_STATUS_FAIL_ERROR_CODE -* @error_code: optional, only used if status is FDT_STATUS_FAIL_ERROR_CODE +* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL */ int fdt_set_status_by_alias (void *fdt,const char * alias, -enum fdt_status status,unsigned int error_code) +enum fdt_status status) {int offset =fdt_path_offset (fdt, alias); -return fdt_set_node_status (fdt, offset, status, error_code); +return fdt_set_node_status (fdt, offset, status); }#if defined(CONFIG_VIDEO ) || defined(CONFIG_LCD )
drivers/pci/pcie_layerscape_fixup.c +4 -4
@@ -582,9 +582,9 @@ static void ft_pcie_rc_fix(void *blob, struct ls_pcie_rc *pcie_rc)return ;if (pcie_rc->enabled && pcie->mode ==PCI_HEADER_TYPE_BRIDGE ) -fdt_set_node_status (blob, off,FDT_STATUS_OKAY ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_OKAY );else -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ); }static void ft_pcie_ep_fix (void *blob,struct ls_pcie_rc *pcie_rc)
@@ -598,9 +598,9 @@ static void ft_pcie_ep_fix(void *blob, struct ls_pcie_rc *pcie_rc)return ;if (pcie_rc->enabled && pcie->mode ==PCI_HEADER_TYPE_NORMAL ) -fdt_set_node_status (blob, off,FDT_STATUS_OKAY ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_OKAY );else -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ); }static void ft_pcie_ls_setup (void *blob,struct ls_pcie_rc *pcie_rc)
drivers/pci/pcie_layerscape_gen4_fixup.c +4 -4
@@ -193,9 +193,9 @@ static void ft_pcie_ep_layerscape_gen4_fix(void *blob, struct ls_pcie_g4 *pcie) }if (pcie->enabled && pcie->mode ==PCI_HEADER_TYPE_NORMAL ) -fdt_set_node_status (blob, off,FDT_STATUS_OKAY ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_OKAY );else -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ); }static void ft_pcie_rc_layerscape_gen4_fix (void *blob,struct ls_pcie_g4 *pcie)
@@ -214,9 +214,9 @@ static void ft_pcie_rc_layerscape_gen4_fix(void *blob, struct ls_pcie_g4 *pcie) }if (pcie->enabled && pcie->mode ==PCI_HEADER_TYPE_BRIDGE ) -fdt_set_node_status (blob, off,FDT_STATUS_OKAY ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_OKAY );else -fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ,0 ); +fdt_set_node_status (blob, off,FDT_STATUS_DISABLED ); }static void ft_pcie_layerscape_gen4_setup (void *blob,struct ls_pcie_g4 *pcie)
include/fdt_support.h +8 -10
@@ -299,36 +299,34 @@ enum fdt_status {FDT_STATUS_OKAY ,FDT_STATUS_DISABLED , FDT_STATUS_FAIL, - FDT_STATUS_FAIL_ERROR_CODE, }; -int fdt_set_node_status (void *fdt,int nodeoffset, -enum fdt_status status,unsigned int error_code); +int fdt_set_node_status (void *fdt,int nodeoffset,enum fdt_status status);static inline int fdt_status_okay (void *fdt,int nodeoffset) { -return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_OKAY ,0 ); +return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_OKAY ); }static inline int fdt_status_disabled (void *fdt,int nodeoffset) { -return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_DISABLED ,0 ); +return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_DISABLED ); }static inline int fdt_status_fail (void *fdt,int nodeoffset) { -return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_FAIL ,0 ); +return fdt_set_node_status (fdt, nodeoffset,FDT_STATUS_FAIL ); }int fdt_set_status_by_alias (void *fdt,const char *alias, -enum fdt_status status,unsigned int error_code); +enum fdt_status status);static inline int fdt_status_okay_by_alias (void *fdt,const char *alias) { -return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_OKAY ,0 ); +return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_OKAY ); }static inline int fdt_status_disabled_by_alias (void *fdt,const char *alias) { -return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_DISABLED ,0 ); +return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_DISABLED ); }static inline int fdt_status_fail_by_alias (void *fdt,const char *alias) { -return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_FAIL ,0 ); +return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_FAIL ); }/* Helper to read a big number; size is in cells (not bytes) */
Signature · 1 line
2.32.0
Re: [PATCH u-boot-marvell RESEND 04/11] fdt_support: Remove FDT_STATUS_FAIL_ERROR_CODE
Quoted 14 lines · Marek Behún
From: Marek Behún <[email protected]>
Since no one uses this feature and I am not aware of any parsers of this in Linux, remove it.
Signed-off-by Marek Behún <[email protected]>Reviewed-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Pratyush Yadav <[email protected]>Cc Tim Harvey <[email protected]>Cc Michael Walle <[email protected]>Cc Priyanka Jain <[email protected]>
Quoted 9 lines
--- arch/arm/cpu/armv7/ls102xa/fdt.c | 6 +++--- board/gateworks/gw_ventana/common.c | 3 +-- board/kontron/sl28/sl28.c | 2 +- common/fdt_support.c | 20 +++++--------------- drivers/pci/pcie_layerscape_fixup.c | 8 ++++---- drivers/pci/pcie_layerscape_gen4_fixup.c | 8 ++++---- include/fdt_support.h | 18 ++++++++---------- 7 files changed, 26 insertions(+), 39 deletions(-)
OpenBSD?
PATCH RESEND 5/11 fdt_support: Fix comment for fdt_create_phandle()
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
This function does not necessarily create a new phandle. If a phandle exists, no new phandle is created.
--- common/fdt_support.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/fdt_support.c +1 -1
@@ -1504,7 +1504,7 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle) }/* -* fdt_create_phandle: Create a phandle property for the given node +* fdt_create_phandle: Get or create a phandle property for the given node * * @fdt: ptr to device tree * @nodeoffset: node to update
Signature · 1 line
2.32.0
PATCH RESEND 6/11 fdt_support: Add some useful functions
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Add functions
fdt_node_offset_by_pathf(), fdt_create_phandle_by_pathf(), fdt_set_status_by_pathf()
to get node offset, get/create node phandle and set status for node given by path/alias formatted with sprintf.
Add functions
fdt_create_phandle_by_compatible(), fdt_set_status_by_compatible()
to get/create node phandle and set status for first node given by compatible.
--- common/fdt_support.c | 119 ++++++++++++++++++++++++++++++++++++++++++ include/fdt_support.h | 30 +++++++++++ 2 files changed, 149 insertions(+)
common/fdt_support.c +119 -0
@@ -1463,6 +1463,37 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,return -FDT_ERR_NOTFOUND ; } +static int vnode_offset_by_pathf (void *blob,const char *fmt,va_list ap) +{ +char path[512 ]; +int len; + + len =vsnprintf (path,sizeof (path), fmt, ap); +if (len <0 || len +1 >sizeof (path)) +return -FDT_ERR_NOSPACE ; + +return fdt_path_offset (blob, path); +} + +/** +* fdt_node_offset_by_pathf: Find node offset by sprintf formatted path +* +* @blob: ptr to device tree +* @fmt: path format +* @ap: vsnprintf arguments +*/ +int fdt_node_offset_by_pathf (void *blob,const char *fmt, ...) +{ +va_list ap; +int res; + +va_start (ap, fmt); + res =vnode_offset_by_pathf (blob, fmt, ap); +va_end (ap); + +return res; +} +/* * fdt_set_phandle: Create a phandle property for the given node *
@@ -1536,6 +1567,51 @@ unsigned int fdt_create_phandle(void *fdt, int nodeoffset)return phandle; } +/** +* fdt_create_phandle_by_compatible: Get or create a phandle for first node with +* given compatible +* +* @fdt: ptr to device tree +* @compat: node's compatible string +*/ +unsigned int fdt_create_phandle_by_compatible (void *fdt,const char *compat) +{ +int offset =fdt_node_offset_by_compatible (fdt,-1 , compat); + +if (offset <0 ) { +printf ("Can't find node with compatible \"%s\": %s\n" , compat, +fdt_strerror (offset)); +return 0 ; + } + +return fdt_create_phandle (fdt, offset); +} + +/** +* fdt_create_phandle_by_pathf: Get or create a phandle for node given by +* sprintf-formatted path +* +* @fdt: ptr to device tree +* @fmt, ...: path format string and arguments to pass to sprintf +*/ +unsigned int fdt_create_phandle_by_pathf (void *fdt,const char *fmt, ...) +{ +va_list ap; +int offset; + +va_start (ap, fmt); + offset =vnode_offset_by_pathf (fdt, fmt, ap); +va_end (ap); + +if (offset <0 ) { +printf ("Can't find node by given path: %s\n" , +fdt_strerror (offset)); +return 0 ; + } + +return fdt_create_phandle (fdt, offset); +} +/* * fdt_set_node_status: Set status for the given node *
@@ -1584,6 +1660,49 @@ int fdt_set_status_by_alias(void *fdt, const char* alias,return fdt_set_node_status (fdt, offset, status); } +/** +* fdt_set_status_by_compatible: Set node status for first node with given +* compatible +* +* @fdt: ptr to device tree +* @compat: node's compatible string +* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL +*/ +int fdt_set_status_by_compatible (void *fdt,const char *compat, +enum fdt_status status) +{ +int offset =fdt_node_offset_by_compatible (fdt,-1 , compat); + +if (offset <0 ) +return offset; + +return fdt_set_node_status (fdt, offset, status); +} + +/** +* fdt_set_status_by_pathf: Set node status for node given by sprintf-formatted +* path +* +* @fdt: ptr to device tree +* @status: FDT_STATUS_OKAY, FDT_STATUS_DISABLED, FDT_STATUS_FAIL +* @fmt, ...: path format string and arguments to pass to sprintf +*/ +int fdt_set_status_by_pathf (void *fdt,enum fdt_status status,const char *fmt, + ...) +{ +va_list ap; +int offset; + +va_start (ap, fmt); + offset =vnode_offset_by_pathf (fdt, fmt, ap); +va_end (ap); + +if (offset <0 ) +return offset; + +return fdt_set_node_status (fdt, offset, status); +} +#if defined(CONFIG_VIDEO ) || defined(CONFIG_LCD )int fdt_add_edid (void *blob,const char *compat,unsigned char *edid_buf) {
include/fdt_support.h +30 -0
@@ -285,8 +285,13 @@ int fdt_get_dma_range(const void *blob, int node_offset, phys_addr_t *cpu,int fdt_node_offset_by_compat_reg (void *blob,const char *compat,phys_addr_t compat_off); +int fdt_node_offset_by_pathf (void *blob,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 )));int fdt_set_phandle (void *fdt,int nodeoffset,uint32_t phandle);unsigned int fdt_create_phandle (void *fdt,int nodeoffset); +unsigned int fdt_create_phandle_by_compatible (void *fdt,const char *compat); +unsigned int fdt_create_phandle_by_pathf (void *fdt,const char *fmt, ...) + __attribute__ ((format (printf,2 ,3 )));int fdt_add_edid (void *blob,const char *compat,unsigned char *buf); int fdt_verify_alias_address(void *fdt, int anode, const char *alias,
@@ -329,6 +334,31 @@ static inline int fdt_status_fail_by_alias(void *fdt, const char *alias)return fdt_set_status_by_alias (fdt, alias,FDT_STATUS_FAIL ); } +int fdt_set_status_by_compatible (void *fdt,const char *compat, +enum fdt_status status); +static inline int fdt_status_okay_by_compatible (void *fdt,const char *compat) +{ +return fdt_set_status_by_compatible (fdt, compat,FDT_STATUS_OKAY ); +} +static inline int fdt_status_disabled_by_compatible (void *fdt, +const char *compat) +{ +return fdt_set_status_by_compatible (fdt, compat,FDT_STATUS_DISABLED ); +} +static inline int fdt_status_fail_by_compatible (void *fdt,const char *compat) +{ +return fdt_set_status_by_compatible (fdt, compat,FDT_STATUS_FAIL ); +} + +int fdt_set_status_by_pathf (void *fdt,enum fdt_status status,const char *fmt, + ...) __attribute__ ((format (printf,3 ,4 ))); +#define fdt_status_okay_by_pathf (fdt, fmt, ...) \ + fdt_set_status_by_pathf((fdt), FDT_STATUS_OKAY, (fmt), ##__VA_ARGS__) +#define fdt_status_disabled_by_pathf (fdt, fmt, ...) \ + fdt_set_status_by_pathf((fdt), FDT_STATUS_DISABLED, (fmt), ##__VA_ARGS__) +#define fdt_status_fail_by_pathf (fdt, fmt, ...) \ + fdt_set_status_by_pathf((fdt), FDT_STATUS_FAIL, (fmt), ##__VA_ARGS__) +/* Helper to read a big number; size is in cells (not bytes) */ static inline u64 fdt_read_number (const fdt32_t *cell,int size) {
Signature · 1 line
2.32.0
PATCH RESEND 7/11 arm: mvebu: turris_mox: Find DT nodes by compatible or alias instead of path
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
It is better to find DT nodes by compatible strings or aliases instead of path.
There were issues with Linux some DTBs having different names of some nodes, e.g.
internal-regs
instead of
internal-regs@d0000000
This should be a generic fix for such issues.
Also since fdt_support now contains needed functions, we can drop our own implementations.
--- board/CZ.NIC/turris_mox/turris_mox.c | 186 +++++++++------------------ 1 file changed, 63 insertions(+), 123 deletions(-)
board/CZ.NIC/turris_mox/turris_mox.c +63 -123
@@ -41,22 +41,14 @@#define ARMADA_37XX_SPI_DOUT (MVEBU_REGISTER(0x10608))#define ARMADA_37XX_SPI_DIN (MVEBU_REGISTER(0x1060c)) -#define ETH1_PATH "/soc/internal-regs@d0000000/ethernet@40000" -#define MDIO_PATH "/soc/internal-regs@d0000000/mdio@32004" -#define SFP_GPIO_PATH "/soc/internal-regs@d0000000/spi@10600/moxtet@1/gpio@0" -#define PCIE_PATH "/soc/pcie@d0070000" -#define SFP_PATH "/sfp" -#define LED_PATH "/leds/led" -#define BUTTON_PATH "/gpio-keys/reset" -DECLARE_GLOBAL_DATA_PTR ;#if defined(CONFIG_OF_BOARD_FIXUP )int board_fix_fdt (void *blob) {u8 topology[MAX_MOX_MODULES ]; -int i, size, node; -bool enable; +enum fdt_status status; +int i, size, ret;/* * SPI driver is not loaded in driver model yet, but we have to find out
@@ -94,21 +86,15 @@ int board_fix_fdt(void *blob)if (size >1 && (topology[1 ] ==MOX_MODULE_PCI || topology[1 ] ==MOX_MODULE_USB3 || topology[1 ] ==MOX_MODULE_PASSPCI )) - enable = true; + status =FDT_STATUS_OKAY ;else - enable = false; - - node =fdt_path_offset (blob,PCIE_PATH ); + status =FDT_STATUS_DISABLED ; -if (node <0 ) { -printf ("Cannot find PCIe node in U-Boot's device tree!\n" ); -return 0 ; - } - -if (fdt_setprop_string (blob, node,"status" , - enable ?"okay" :"disabled" ) <0 ) { -printf ("Cannot %s PCIe in U-Boot's device tree!\n" , - enable ?"enable" :"disable" ); + ret =fdt_set_status_by_compatible (blob,"marvell,armada-3700-pcie" , + status); +if (ret <0 ) { +printf ("Cannot set status for PCIe in U-Boot's device tree: %s!\n" , +fdt_strerror (ret));return 0 ; }
@@ -416,12 +402,18 @@ static bool read_reset_button(void)struct udevice *button, *led;int i; -if (device_get_global_by_ofnode (ofnode_path (BUTTON_PATH ), &button)) { +if (device_get_global_by_ofnode ( +ofnode_first_subnode (ofnode_by_compatible (ofnode_null (), +"gpio-keys" )), + &button)) {printf ("Cannot find reset button!\n" );return false; } -if (device_get_global_by_ofnode (ofnode_path (LED_PATH ), &led)) { +if (device_get_global_by_ofnode ( +ofnode_first_subnode (ofnode_by_compatible (ofnode_null (), +"gpio-leds" )), + &led)) {printf ("Cannot find status LED!\n" );return false; }
@@ -661,92 +653,34 @@ handle_reset_btn:#if defined(CONFIG_OF_BOARD_SETUP ) -static int vnode_by_path (void *blob,const char *fmt,va_list ap) +static bool is_topaz (int id) { -char path[128 ]; - -vsnprintf (path,128 , fmt, ap); -return fdt_path_offset (blob, path); +return topaz && id == peridot + topaz -1 ; } -static int node_by_path (void *blob,const char *fmt, ...) +static int switch_addr (int id) { -va_list ap; -int res; - -va_start (ap, fmt); - res =vnode_by_path (blob, fmt, ap); -va_end (ap); - -return res; +return is_topaz (id) ?0x2 :0x10 + id; } -static int phandle_by_path (void *blob,const char *fmt, ...) +static int setup_switch (void *blob,int id) { -va_list ap; -int node, phandle, res; - -va_start (ap, fmt); - node =vnode_by_path (blob, fmt, ap); -va_end (ap); +int res, addr, i, node; +char mdio_path[64 ]; + node =fdt_node_offset_by_compatible (blob,-1 ,"marvell,orion-mdio" );if (node <0 )return node; - phandle =fdt_get_phandle (blob, node); -if (phandle >0 ) -return phandle; - - phandle =fdt_get_max_phandle (blob); -if (phandle <0 ) -return phandle; - - phandle +=1 ; - - res =fdt_setprop_u32 (blob, node,"linux,phandle" , phandle); + res =fdt_get_path (blob, node, mdio_path,sizeof (mdio_path));if (res <0 )return res; - res =fdt_setprop_u32 (blob, node,"phandle" , phandle); -if (res <0 ) -return res; - -return phandle; -} - -static int enable_by_path (void *blob,const char *fmt, ...) -{ -va_list ap; -int node; - -va_start (ap, fmt); - node =vnode_by_path (blob, fmt, ap); -va_end (ap); - -if (node <0 ) -return node; - -return fdt_setprop_string (blob, node,"status" ,"okay" ); -} - -static bool is_topaz (int id) -{ -return topaz && id == peridot + topaz -1 ; -} - -static int switch_addr (int id) -{ -return is_topaz (id) ?0x2 :0x10 + id; -} - -static int setup_switch (void *blob,int id) -{ -int res, addr, i, node, phandle; - addr =switch_addr (id);/* first enable the switch by setting status = "okay" */ - res =enable_by_path (blob,MDIO_PATH "/switch%i@%x" , id, addr); + res =fdt_status_okay_by_pathf (blob,"%s/switch%i@%x" , mdio_path, id, + addr);if (res <0 )return res;
@@ -755,13 +689,13 @@ static int setup_switch(void *blob, int id)* enable corresponding ports */ if (id < peridot + topaz -1 ) { - res =enable_by_path (blob, -MDIO_PATH "/switch%i@%x/ports/port@a" , - id, addr); + res =fdt_status_okay_by_pathf (blob, +"%s/switch%i@%x/ports/port@a" , + mdio_path, id, addr); }else if (id == peridot -1 && !topaz && sfp) { - res =enable_by_path (blob, -MDIO_PATH "/switch%i@%x/ports/port-sfp@a" , - id, addr); + res =fdt_status_okay_by_pathf (blob, +"%s/switch%i@%x/ports/port-sfp@a" , + mdio_path, id, addr); }else { res =0 ; }
@@ -772,18 +706,21 @@ static int setup_switch(void *blob, int id)return 0 ;/* finally change link property if needed */ - node =node_by_path (blob,MDIO_PATH "/switch%i@%x/ports/port@a" , id, - addr); + node =fdt_node_offset_by_pathf (blob,"%s/switch%i@%x/ports/port@a" , + mdio_path, id, addr);if (node <0 )return node;for (i = id +1 ; i < peridot + topaz; ++i) { - phandle =phandle_by_path (blob, -MDIO_PATH "/switch%i@%x/ports/port@%x" , - i,switch_addr (i), -is_topaz (i) ?5 :9 ); -if (phandle <0 ) -return phandle; +unsigned int phandle; + + phandle =fdt_create_phandle_by_pathf (blob, +"%s/switch%i@%x/ports/port@%x" , + mdio_path, i, +switch_addr (i), +is_topaz (i) ?5 :9 ); +if (!phandle) +return -FDT_ERR_NOPHANDLES ;if (i == id +1 ) res =fdt_setprop_u32 (blob, node,"link" , phandle);
@@ -816,18 +753,15 @@ static int remove_disabled_nodes(void *blob)int ft_board_setup (void *blob,struct bd_info *bd) { -int node, phandle, res; +int res;/* * If MOX B (PCI), MOX F (USB) or MOX G (Passthrough PCI) modules are * connected, enable the PCIe node. */ if (pci || usb || passpci) { - node =fdt_path_offset (blob,PCIE_PATH ); -if (node <0 ) -return node; - - res =fdt_setprop_string (blob, node,"status" ,"okay" ); + res =fdt_status_okay_by_compatible (blob, +"marvell,armada-3700-pcie" );if (res <0 )return res;
@@ -844,7 +778,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)if (peridot || topaz) {int i; - res =enable_by_path (blob,ETH1_PATH ); + res =fdt_status_okay_by_alias (blob,"ethernet1" );if (res <0 )return res;
@@ -862,20 +796,25 @@ int ft_board_setup(void *blob, struct bd_info *bd)* Also enable and configure SFP GPIO controller node. */ if (sfp) { - res =enable_by_path (blob,SFP_PATH ); +int node; + + res =fdt_status_okay_by_compatible (blob,"sff,sfp" );if (res <0 )return res; - res =enable_by_path (blob,ETH1_PATH ); + res =fdt_status_okay_by_alias (blob,"ethernet1" );if (res <0 )return res;if (!peridot) { - phandle =phandle_by_path (blob,SFP_PATH ); -if (phandle <0 ) -return res; +unsigned int phandle; + + phandle =fdt_create_phandle_by_compatible (blob, +"sff,sfp" ); +if (!phandle) +return -FDT_ERR_NOPHANDLES ; - node =node_by_path (blob,ETH1_PATH ); + node =fdt_path_offset (blob,"ethernet1" );if (node <0 )return node;
@@ -889,7 +828,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)return res; } - res =enable_by_path (blob,SFP_GPIO_PATH ); + res =fdt_status_okay_by_compatible (blob,"cznic,moxtet-gpio" );if (res <0 )return res;
@@ -897,7 +836,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)char newname[16 ];/* moxtet-sfp is on non-zero position, change default */ - node =node_by_path (blob,SFP_GPIO_PATH ); + node =fdt_node_offset_by_compatible (blob,-1 , +"cznic,moxtet-gpio" );if (node <0 )return node;
Signature · 1 line
2.32.0
PATCH RESEND 8/11 arm: mvebu: turris_mox: Enable eth1 in U-Boot if a network module is present
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Enable eth1 node in U-Boot's device-tree if a network module (SFP, Topaz or Peridot) is detected.
This is required for proper detection of eth1 comphy in a3700 comphy driver by the following patches.
--- board/CZ.NIC/turris_mox/turris_mox.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
board/CZ.NIC/turris_mox/turris_mox.c +16 -5
@@ -46,8 +46,8 @@ DECLARE_GLOBAL_DATA_PTR;#if defined(CONFIG_OF_BOARD_FIXUP )int board_fix_fdt (void *blob) { +enum fdt_status status_pcie, status_eth1;u8 topology[MAX_MOX_MODULES ]; -enum fdt_status status;int i, size, ret;/*
@@ -65,6 +65,9 @@ int board_fix_fdt(void *blob)while (!(readl (ARMADA_37XX_SPI_CTRL ) &0x2 ))udelay (1 ); + status_pcie =FDT_STATUS_DISABLED ; + status_eth1 =FDT_STATUS_DISABLED ; +for (i =0 ; i <MAX_MOX_MODULES ; ++i) {writel (0x0 ,ARMADA_37XX_SPI_DOUT );
@@ -76,6 +79,11 @@ int board_fix_fdt(void *blob)break ; topology[i] &=0xf ; + +if (topology[i] ==MOX_MODULE_SFP || + topology[i] ==MOX_MODULE_TOPAZ || + topology[i] ==MOX_MODULE_PERIDOT ) + status_eth1 =FDT_STATUS_OKAY ; } size = i;
@@ -83,15 +91,18 @@ int board_fix_fdt(void *blob)/* disable SPI CS1 */ clrbits_le32 (ARMADA_37XX_SPI_CTRL ,BIT (17 )); + ret =fdt_set_status_by_alias (blob,"ethernet1" , status_eth1); +if (ret <0 ) +printf ("Cannot set status for eth1 in U-Boot's device tree: %s!\n" , +fdt_strerror (ret)); +if (size >1 && (topology[1 ] ==MOX_MODULE_PCI || topology[1 ] ==MOX_MODULE_USB3 || topology[1 ] ==MOX_MODULE_PASSPCI )) - status =FDT_STATUS_OKAY ; -else - status =FDT_STATUS_DISABLED ; + status_pcie =FDT_STATUS_OKAY ; ret =fdt_set_status_by_compatible (blob,"marvell,armada-3700-pcie" , - status); + status_pcie);if (ret <0 ) {printf ("Cannot set status for PCIe in U-Boot's device tree: %s!\n" ,fdt_strerror (ret));
Signature · 1 line
2.32.0
PATCH RESEND 9/11 phy: marvell: a3700: Convert to official DT bindings in COMPHY driver
In reply to Marek BehúnFrom: Pali Rohár <[email protected]>
Convert A3720 common PHY driver to official DT bindings.
This puts us closer to be able to synchronize A3720 device-trees with those from Linux.
--- arch/arm/dts/armada-3720-espressobin.dts | 21 +--- arch/arm/dts/armada-3720-turris-mox.dts | 25 ++--- arch/arm/dts/armada-3720-uDPU.dts | 23 +--- arch/arm/dts/armada-37xx.dtsi | 20 +++- drivers/phy/marvell/comphy_a3700.c | 133 +++++++++++++++++++++++ drivers/phy/marvell/comphy_core.c | 59 +--------- drivers/phy/marvell/comphy_core.h | 23 ++++ drivers/phy/marvell/comphy_cp110.c | 58 ++++++++++ 8 files changed, 250 insertions(+), 112 deletions(-)
arch/arm/dts/armada-3720-espressobin.dts +3 -18
@@ -80,24 +80,6 @@ }; }; -&comphy { - max-lanes = <3>; - phy0 { - phy-type = <COMPHY_TYPE_USB3_HOST0>; - phy-speed = <COMPHY_SPEED_5G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_PEX0>; - phy-speed = <COMPHY_SPEED_2_5G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_SATA0>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { status = "okay"; pinctrl-names = "default";
@@ -119,6 +101,7 @@ /* CON3 */ &sata { status = "okay"; + phys = <&comphy2 0>; }; &sdhci0 {
@@ -200,6 +183,7 @@ /* CON31 */ &usb3 { status = "okay"; + phys = <&comphy0 0>; }; &pcie0 {
@@ -207,4 +191,5 @@ pinctrl-0 = <&pcie_pins>; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; status = "okay"; + phys = <&comphy1 0>; };
arch/arm/dts/armada-3720-turris-mox.dts +7 -18
@@ -94,24 +94,6 @@ }; }; -&comphy { - max-lanes = <3>; - phy0 { - phy-type = <COMPHY_TYPE_SGMII1>; - phy-speed = <COMPHY_SPEED_3_125G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_PEX0>; - phy-speed = <COMPHY_SPEED_5G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_USB3_HOST0>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { status = "okay"; pinctrl-names = "default";
@@ -120,6 +102,11 @@ phy = <ð_phy1>; }; +ð1 { + phy-mode = "2500base-x"; + phys = <&comphy0 1>; +}; + &i2c0 { pinctrl-names = "default"; pinctrl-0 = <&i2c1_pins>;
@@ -222,6 +209,7 @@ &usb3 { vbus-supply = <®_usb3_vbus>; status = "okay"; + phys = <&comphy2 0>; }; &pcie0 {
@@ -229,4 +217,5 @@ pinctrl-0 = <&pcie_pins>; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; status = "disabled"; + phys = <&comphy1 0>; };
arch/arm/dts/armada-3720-uDPU.dts +4 -19
@@ -106,36 +106,21 @@ }; }; -&comphy { - phy0 { - phy-type = <COMPHY_TYPE_SGMII1>; - phy-speed = <COMPHY_SPEED_1_25G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_SGMII0>; - phy-speed = <COMPHY_SPEED_1_25G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_USB3_HOST1>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { pinctrl-0 = <&pcie_pins>; status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii"; managed = "in-band-status"; phy = <ðphy0>; + phys = <&comphy1 0>; }; ð1 { status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii"; managed = "in-band-status"; phy = <ðphy1>; + phys = <&comphy0 1>; }; &i2c0 {
arch/arm/dts/armada-37xx.dtsi +17 -3
@@ -316,9 +316,23 @@ compatible = "marvell,mvebu-comphy", "marvell,comphy-armada-3700"; reg = <0x18300 0x28>, <0x1f300 0x3d000>; - mux-bitcount = <4>; - mux-lane-order = <1 0 2>; - max-lanes = <3>; + #address-cells = <1>; + #size-cells = <0>; + + comphy0: phy@0 { + reg = <0>; + #phy-cells = <1>; + }; + + comphy1: phy@1 { + reg = <1>; + #phy-cells = <1>; + }; + + comphy2: phy@2 { + reg = <2>; + #phy-cells = <1>; + }; }; };
drivers/phy/marvell/comphy_a3700.c +133 -0
145 lines not on this page · raw message
drivers/phy/marvell/comphy_core.c +5 -54
85 lines not on this page · raw message
drivers/phy/marvell/comphy_core.h +23 -0
@@ -32,6 +32,7 @@ struct comphy_mux_data {struct chip_serdes_phy_config {struct comphy_mux_data *mux_data; +int (*comphy_init_map)(int ,struct chip_serdes_phy_config *);int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *,struct comphy_map *);int (*rx_training)(struct chip_serdes_phy_config *,u32 );
@@ -85,9 +86,20 @@ static inline void reg_set16(void __iomem *addr, u16 data, u16 mask)/* SoC specific init functions */ #ifdef CONFIG_ARMADA_3700 +int comphy_a3700_init_serdes_map (int node,struct chip_serdes_phy_config *cfg);int comphy_a3700_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map);#else +static inline int +comphy_a3700_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +/* +* This function should never be called in this configuration, so +* lets return an error here. +*/ +return -1 ; +} +static inline int comphy_a3700_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map) {
@@ -100,11 +112,22 @@ static inline int comphy_a3700_init(struct chip_serdes_phy_config *ptr_chip_cfg,#endif #ifdef CONFIG_ARMADA_8K +int comphy_cp110_init_serdes_map (int node,struct chip_serdes_phy_config *cfg);int comphy_cp110_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map);int comphy_cp110_sfi_rx_training (struct chip_serdes_phy_config *ptr_chip_cfg,u32 lane);#else +static inline int +comphy_cp110_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +/* +* This function should never be called in this configuration, so +* lets return an error here. +*/ +return -1 ; +} +static inline int comphy_cp110_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map) {
drivers/phy/marvell/comphy_cp110.c +58 -0
64 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH u-boot-marvell RESEND 09/11] phy: marvell: a3700: Convert to official DT bindings in COMPHY driver
Quoted 7 lines · Marek Behún
From: Pali Rohár <[email protected]>
Convert A3720 common PHY driver to official DT bindings.
This puts us closer to be able to synchronize A3720 device-trees with those from Linux.
Quoted 7 lines
Signed-off-by Pali Rohár <[email protected]>Signed-off-by Marek Behún <[email protected]>Cc Konstantin Porotchkin <[email protected]>Cc Robert Marko <[email protected]>Cc Luka Perkov <[email protected]>Cc Marcin Wojtas <[email protected]>Cc Grzegorz Jaszczyk <[email protected]>
Thanks,
Stefan
Quoted 552 lines
--- arch/arm/dts/armada-3720-espressobin.dts | 21 +--- arch/arm/dts/armada-3720-turris-mox.dts | 25 ++--- arch/arm/dts/armada-3720-uDPU.dts | 23 +--- arch/arm/dts/armada-37xx.dtsi | 20 +++- drivers/phy/marvell/comphy_a3700.c | 133 +++++++++++++++++++++++ drivers/phy/marvell/comphy_core.c | 59 +--------- drivers/phy/marvell/comphy_core.h | 23 ++++ drivers/phy/marvell/comphy_cp110.c | 58 ++++++++++ 8 files changed, 250 insertions(+), 112 deletions(-)arch/arm/dts/armada-3720-espressobin.dts +3
-18@@ -80,24 +80,6 @@ }; }; -&comphy { - max-lanes = <3>; - phy0 { - phy-type = <COMPHY_TYPE_USB3_HOST0>; - phy-speed = <COMPHY_SPEED_5G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_PEX0>; - phy-speed = <COMPHY_SPEED_2_5G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_SATA0>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { status = "okay"; pinctrl-names = "default";@@ -119,6 +101,7 @@ /* CON3 */ &sata { status = "okay"; + phys = <&comphy2 0>; }; &sdhci0 {@@ -200,6 +183,7 @@ /* CON31 */ &usb3 { status = "okay"; + phys = <&comphy0 0>; }; &pcie0 {@@ -207,4 +191,5 @@ pinctrl-0 = <&pcie_pins>; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; status = "okay"; + phys = <&comphy1 0>; };arch/arm/dts/armada-3720-turris-mox.dts +7
-18@@ -94,24 +94,6 @@ }; }; -&comphy { - max-lanes = <3>; - phy0 { - phy-type = <COMPHY_TYPE_SGMII1>; - phy-speed = <COMPHY_SPEED_3_125G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_PEX0>; - phy-speed = <COMPHY_SPEED_5G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_USB3_HOST0>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { status = "okay"; pinctrl-names = "default";@@ -120,6 +102,11 @@ phy = <ð_phy1>; }; +ð1 { + phy-mode = "2500base-x"; + phys = <&comphy0 1>; +}; + &i2c0 { pinctrl-names = "default"; pinctrl-0 = <&i2c1_pins>;@@ -222,6 +209,7 @@ &usb3 { vbus-supply = <®_usb3_vbus>; status = "okay"; + phys = <&comphy2 0>; }; &pcie0 {@@ -229,4 +217,5 @@ pinctrl-0 = <&pcie_pins>; reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>; status = "disabled"; + phys = <&comphy1 0>; };arch/arm/dts/armada-3720-uDPU.dts +4
-19@@ -106,36 +106,21 @@ }; }; -&comphy { - phy0 { - phy-type = <COMPHY_TYPE_SGMII1>; - phy-speed = <COMPHY_SPEED_1_25G>; - }; - - phy1 { - phy-type = <COMPHY_TYPE_SGMII0>; - phy-speed = <COMPHY_SPEED_1_25G>; - }; - - phy2 { - phy-type = <COMPHY_TYPE_USB3_HOST1>; - phy-speed = <COMPHY_SPEED_5G>; - }; -}; - ð0 { pinctrl-0 = <&pcie_pins>; status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii"; managed = "in-band-status"; phy = <ðphy0>; + phys = <&comphy1 0>; }; ð1 { status = "okay"; - phy-mode = "2500base-x"; + phy-mode = "sgmii"; managed = "in-band-status"; phy = <ðphy1>; + phys = <&comphy0 1>; }; &i2c0 {arch/arm/dts/armada-37xx.dtsi +17
-3@@ -316,9 +316,23 @@ compatible = "marvell,mvebu-comphy", "marvell,comphy-armada-3700"; reg = <0x18300 0x28>, <0x1f300 0x3d000>; - mux-bitcount = <4>; - mux-lane-order = <1 0 2>; - max-lanes = <3>; + #address-cells = <1>; + #size-cells = <0>; + + comphy0: phy@0 { + reg = <0>; + #phy-cells = <1>; + }; + + comphy1: phy@1 { + reg = <1>; + #phy-cells = <1>; + }; + + comphy2: phy@2 { + reg = <2>; + #phy-cells = <1>; + }; }; };drivers/phy/marvell/comphy_a3700.c +133
-0@@ -11,6 +11,7 @@#include <asm/arch/cpu.h> #include <asm/arch/soc.h> #include <linux/delay.h> +#include <phy.h> #include "comphy_a3700.h" @@ -982,6 +983,138 @@ void comphy_dedicated_phys_init(void)debug_exit (); } +static int find_available_node_by_compatible (int offset,const char *compatible) +{ +do { + offset =fdt_node_offset_by_compatible (gd->fdt_blob, offset, + compatible); + }while (offset >0 && !fdtdec_get_is_enabled (gd->fdt_blob, offset)); + +return offset; +} + +static bool comphy_a3700_find_lane (const int nodes[3 ],int node, +int port,int *lane,int *invert) +{ +int res, i, j; + +for (i =0 ; ; i++) { +struct fdtdec_phandle_args args; + + res =fdtdec_parse_phandle_with_args (gd->fdt_blob, node,"phys" , +"#phy-cells" ,0 , i, &args); +if (res) +return false; + +for (j =0 ; j <3 ; j++) { +if (nodes[j] >=0 && args.node == nodes[j] && + (args.args_count >=1 ? args.args[0 ] :0 ) == port) { + *lane = j; + *invert = args.args_count >=2 ? args.args[1 ] + :0 ; +return true; + } + } + } + +return false; +} + +static void comphy_a3700_fill_cfg (struct chip_serdes_phy_config *cfg, +const int nodes[3 ],const char *compatible, +int type) +{ +int node, lane, port, speed, invert; + + port = (type ==COMPHY_TYPE_SGMII1 ) ?1 :0 ; + + node =-1 ; +while (1 ) { + node =find_available_node_by_compatible (node, compatible); +if (node <0 ) +return ; + +if (comphy_a3700_find_lane (nodes, node, port, &lane, &invert)) +break ; + } + +if (cfg->comphy_map_data[lane].type !=COMPHY_TYPE_UNCONNECTED ) { +printf ("Error: More PHYs defined for lane %d, skipping\n" , + lane); +return ; + } + +if (type ==COMPHY_TYPE_SGMII0 || type ==COMPHY_TYPE_SGMII1 ) { +const char *phy_mode; + + phy_mode =fdt_getprop (gd->fdt_blob, node,"phy-mode" ,NULL ); +if (phy_mode && + !strcmp (phy_mode, +phy_string_for_interface (PHY_INTERFACE_MODE_2500BASEX ))) + speed =COMPHY_SPEED_3_125G ; +else + speed =COMPHY_SPEED_1_25G ; + }else if (type ==COMPHY_TYPE_SATA0 ) { + speed =COMPHY_SPEED_6G ; + }else { + speed =COMPHY_SPEED_5G ; + } + + cfg->comphy_map_data[lane].type = type; + cfg->comphy_map_data[lane].speed = speed; + cfg->comphy_map_data[lane].invert = invert; +} + +static const fdt32_t comphy_a3700_mux_lane_order[3 ] = { +__constant_cpu_to_be32 (1 ), +__constant_cpu_to_be32 (0 ), +__constant_cpu_to_be32 (2 ), +}; + +int comphy_a3700_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +int comphy_nodes[3 ]; +int child, i; + +for (i =0 ; i <ARRAY_SIZE (comphy_nodes); i++) + comphy_nodes[i] = -FDT_ERR_NOTFOUND ; + +fdt_for_each_subnode (child, gd->fdt_blob, node) { +if (!fdtdec_get_is_enabled (gd->fdt_blob, child)) +continue ; + + i =fdtdec_get_int (gd->fdt_blob, child,"reg" ,-1 ); +if (i <0 || i >=ARRAY_SIZE (comphy_nodes)) +continue ; + + comphy_nodes[i] = child; + } + +for (i =0 ; i <ARRAY_SIZE (comphy_nodes); i++) { + cfg->comphy_map_data[i].type =COMPHY_TYPE_UNCONNECTED ; + cfg->comphy_map_data[i].speed =COMPHY_SPEED_INVALID ; + } + +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada3700-u3d" , +COMPHY_TYPE_USB3_DEVICE ); +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada3700-xhci" , +COMPHY_TYPE_USB3_HOST0 ); +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada-3700-pcie" , +COMPHY_TYPE_PEX0 ); +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada-3700-ahci" , +COMPHY_TYPE_SATA0 ); +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada-3700-neta" , +COMPHY_TYPE_SGMII0 ); +comphy_a3700_fill_cfg (cfg, comphy_nodes,"marvell,armada-3700-neta" , +COMPHY_TYPE_SGMII1 ); + + cfg->comphy_lanes_count =3 ; + cfg->comphy_mux_bitcount =4 ; + cfg->comphy_mux_lane_order = comphy_a3700_mux_lane_order; + +return 0 ; +} +int comphy_a3700_init (struct chip_serdes_phy_config *chip_cfg,struct comphy_map *serdes_map) {drivers/phy/marvell/comphy_core.c +5
-54@@ -86,11 +86,8 @@ __weak int comphy_update_map(struct comphy_map *serdes_map, int count)static int comphy_probe (struct udevice *dev) { -const void *blob = gd->fdt_blob;int node =dev_of_offset (dev);struct chip_serdes_phy_config *chip_cfg =dev_get_priv (dev); -int subnode; -int lane;int last_idx =0 ;static int current_idx;int res;@@ -104,30 +101,14 @@ static int comphy_probe(struct udevice *dev)if (IS_ERR (chip_cfg->hpipe3_base_addr))return PTR_ERR (chip_cfg->hpipe3_base_addr); - chip_cfg->comphy_lanes_count =fdtdec_get_int (blob, node, -"max-lanes" ,0 ); -if (chip_cfg->comphy_lanes_count <=0 ) { -dev_err (dev,"comphy max lanes is wrong\n" ); -return -EINVAL ; - } - - chip_cfg->comphy_mux_bitcount =fdtdec_get_int (blob, node, -"mux-bitcount" ,0 ); -if (chip_cfg->comphy_mux_bitcount <=0 ) { -dev_err (dev,"comphy mux bit count is wrong\n" ); -return -EINVAL ; - } - - chip_cfg->comphy_mux_lane_order = -fdtdec_locate_array (blob, node,"mux-lane-order" , - chip_cfg->comphy_lanes_count); -if (device_is_compatible (dev,"marvell,comphy-armada-3700" )) { + chip_cfg->comphy_init_map = comphy_a3700_init_serdes_map; chip_cfg->ptr_comphy_chip_init = comphy_a3700_init; chip_cfg->rx_training =NULL ; }if (device_is_compatible (dev,"marvell,comphy-cp110" )) { + chip_cfg->comphy_init_map = comphy_cp110_init_serdes_map; chip_cfg->ptr_comphy_chip_init = comphy_cp110_init; chip_cfg->rx_training = comphy_cp110_sfi_rx_training; }@@ -141,39 +122,9 @@ static int comphy_probe(struct udevice *dev)return -ENODEV ; } - lane =0 ; -fdt_for_each_subnode (subnode, blob, node) { -/* Skip disabled ports */ -if (!fdtdec_get_is_enabled (blob, subnode)) -continue ; - - chip_cfg->comphy_map_data[lane].type = -fdtdec_get_int (blob, subnode,"phy-type" , -COMPHY_TYPE_INVALID ); - -if (chip_cfg->comphy_map_data[lane].type == -COMPHY_TYPE_INVALID ) { -printf ("no phy type for lane %d, setting lane as unconnected\n" , - lane +1 ); -continue ; - } - - chip_cfg->comphy_map_data[lane].speed = -fdtdec_get_int (blob, subnode,"phy-speed" , -COMPHY_SPEED_INVALID ); - - chip_cfg->comphy_map_data[lane].invert = -fdtdec_get_int (blob, subnode,"phy-invert" , -COMPHY_POLARITY_NO_INVERT ); - - chip_cfg->comphy_map_data[lane].clk_src = -fdtdec_get_bool (blob, subnode,"clk-src" ); - - chip_cfg->comphy_map_data[lane].end_point = -fdtdec_get_bool (blob, subnode,"end_point" ); - - lane++; - } + res = chip_cfg->comphy_init_map (node, chip_cfg); +if (res <0 ) +return res; res =comphy_update_map (chip_cfg->comphy_map_data, chip_cfg->comphy_lanes_count);if (res <0 )drivers/phy/marvell/comphy_core.h +23
-0@@ -32,6 +32,7 @@ struct comphy_mux_data {struct chip_serdes_phy_config {struct comphy_mux_data *mux_data; +int (*comphy_init_map)(int ,struct chip_serdes_phy_config *);int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *,struct comphy_map *);int (*rx_training)(struct chip_serdes_phy_config *,u32 );@@ -85,9 +86,20 @@ static inline void reg_set16(void __iomem *addr, u16 data, u16 mask)/* SoC specific init functions */ #ifdef CONFIG_ARMADA_3700 +int comphy_a3700_init_serdes_map (int node,struct chip_serdes_phy_config *cfg);int comphy_a3700_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map);#else +static inline int +comphy_a3700_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +/* +* This function should never be called in this configuration, so +* lets return an error here. +*/ +return -1 ; +} +static inline int comphy_a3700_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map) {@@ -100,11 +112,22 @@ static inline int comphy_a3700_init(struct chip_serdes_phy_config *ptr_chip_cfg,#endif #ifdef CONFIG_ARMADA_8K +int comphy_cp110_init_serdes_map (int node,struct chip_serdes_phy_config *cfg);int comphy_cp110_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map);int comphy_cp110_sfi_rx_training (struct chip_serdes_phy_config *ptr_chip_cfg,u32 lane);#else +static inline int +comphy_cp110_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +/* +* This function should never be called in this configuration, so +* lets return an error here. +*/ +return -1 ; +} +static inline int comphy_cp110_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map) {drivers/phy/marvell/comphy_cp110.c +51
-0@@ -554,6 +554,64 @@ void comphy_dedicated_phys_init(void)debug_exit (); } +int comphy_cp110_init_serdes_map (int node,struct chip_serdes_phy_config *cfg) +{ +int lane, subnode; + + cfg->comphy_lanes_count =fdtdec_get_int (gd->fdt_blob, node, +"max-lanes" ,0 ); +if (cfg->comphy_lanes_count <=0 ) { +printf ("comphy max lanes is wrong\n" ); +return -EINVAL ; + } + + cfg->comphy_mux_bitcount =fdtdec_get_int (gd->fdt_blob, node, +"mux-bitcount" ,0 ); +if (cfg->comphy_mux_bitcount <=0 ) { +printf ("comphy mux bit count is wrong\n" ); +return -EINVAL ; + } + + cfg->comphy_mux_lane_order =fdtdec_locate_array (gd->fdt_blob, node, +"mux-lane-order" , + cfg->comphy_lanes_count); + + lane =0 ; +fdt_for_each_subnode (subnode, gd->fdt_blob, node) { +/* Skip disabled ports */ +if (!fdtdec_get_is_enabled (gd->fdt_blob, subnode)) +continue ; + + cfg->comphy_map_data[lane].type = +fdtdec_get_int (gd->fdt_blob, subnode,"phy-type" , +COMPHY_TYPE_INVALID ); + +if (cfg->comphy_map_data[lane].type ==COMPHY_TYPE_INVALID ) { +printf ("no phy type for lane %d, setting lane as unconnected\n" , + lane +1 ); +continue ; + } + + cfg->comphy_map_data[lane].speed = +fdtdec_get_int (gd->fdt_blob, subnode,"phy-speed" , +COMPHY_SPEED_INVALID ); + + cfg->comphy_map_data[lane].invert = +fdtdec_get_int (gd->fdt_blob, subnode,"phy-invert" , +COMPHY_POLARITY_NO_INVERT ); + + cfg->comphy_map_data[lane].clk_src = +fdtdec_get_bool (gd->fdt_blob, subnode,"clk-src" ); + + cfg->comphy_map_data[lane].end_point = +fdtdec_get_bool (gd->fdt_blob, subnode,"end_point" );
drivers/phy/marvell/comphy_cp110.c void comphy_dedicated_phys_init(void) · line 617
Quoted 10 lines
drivers/phy/marvell/comphy_cp110.c +7
-0+ + lane++; + } + +return 0 ; +} +int comphy_cp110_init (struct chip_serdes_phy_config *ptr_chip_cfg,struct comphy_map *serdes_map) {
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH RESEND 10/11 arm: mvebu: turris_mox: Fix unstable board topology reading
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
The pre-relocation board topology reading in board_fix_fdt() is
unstable: sometimes wrong data are read from the SPI bus.
This is due to wrong order of SPI bus configuration instructions: we first need to set the pins to SPI mode, and only after that configure the bus.
Also add a 1ms delay before enabling chip-select, so that the clock pin is high for some time before reading the bus.
--- board/CZ.NIC/turris_mox/turris_mox.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
board/CZ.NIC/turris_mox/turris_mox.c +3 -1
@@ -56,9 +56,11 @@ int board_fix_fdt(void *blob)* to read SPI by reading/writing SPI registers directly */ -writel (0x10df ,ARMADA_37XX_SPI_CFG );/* put pin from GPIO to SPI mode */ clrbits_le32 (ARMADA_37XX_NB_GPIO_SEL ,BIT (12 )); +/* configure cpol, cpha, prescale */ +writel (0x10df ,ARMADA_37XX_SPI_CFG ); +mdelay (1 );/* enable SPI CS1 */ setbits_le32 (ARMADA_37XX_SPI_CTRL ,BIT (17 ));
Signature · 1 line
2.32.0
PATCH RESEND 11/11 fdt_support: Add fdt_delete_disabled_nodes() and use in Turris MOX
In reply to Marek BehúnFrom: Marek Behún <[email protected]>
Move Turris MOX specific remove_disabled_nodes() to fdt_support with name fdt_delete_disabled_nodes(), so that others can potentially use it.
--- board/CZ.NIC/turris_mox/turris_mox.c | 20 +------------------- common/fdt_support.c | 23 +++++++++++++++++++++++ include/fdt_support.h | 2 ++ 3 files changed, 26 insertions(+), 19 deletions(-)
board/CZ.NIC/turris_mox/turris_mox.c +1 -19
@@ -746,24 +746,6 @@ static int setup_switch(void *blob, int id)return 0 ; } -static int remove_disabled_nodes (void *blob) -{ -while (1 ) { -int res, offset; - - offset =fdt_node_offset_by_prop_value (blob,-1 ,"status" , -"disabled" ,9 ); -if (offset <0 ) -break ; - - res =fdt_del_node (blob, offset); -if (res <0 ) -return res; - } - -return 0 ; -} -int ft_board_setup (void *blob,struct bd_info *bd) {int res;
@@ -869,7 +851,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)fdt_fixup_ethernet (blob);/* Finally remove disabled nodes, as per Rob Herring's request. */ -remove_disabled_nodes (blob); +fdt_delete_disabled_nodes (blob);return 0 ; }
common/fdt_support.c +23 -0
@@ -695,6 +695,29 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)return actualsize; } +/** +* fdt_delete_disabled_nodes: Delete all nodes with status == "disabled" +* +* @blob: ptr to device tree +*/ +int fdt_delete_disabled_nodes (void *blob) +{ +while (1 ) { +int ret, offset; + + offset =fdt_node_offset_by_prop_value (blob,-1 ,"status" , +"disabled" ,9 ); +if (offset <0 ) +break ; + + ret =fdt_del_node (blob, offset); +if (ret <0 ) +return ret; + } + +return 0 ; +} +#ifdef CONFIG_PCI #define CONFIG_SYS_PCI_NR_INBOUND_WIN 4
include/fdt_support.h +2 -0
@@ -228,6 +228,8 @@ void set_working_fdt_addr(ulong addr);int fdt_shrink_to_minimum (void *blob,uint extrasize);int fdt_increase_size (void *fdt,int add_len); +int fdt_delete_disabled_nodes (void *blob); +int fdt_fixup_nor_flash_size (void *blob);struct node_info ;
Signature · 1 line
2.32.0
Hello! Could you review this patch series?
Quoted 66 lines · On Friday 26 November 2021 14:57:04 Marek Behún wrote:
From: Marek Behún <[email protected]>
Hello Stefan,
as requested I am resending this series with board maintainers added in Ccs.
Original message:
Pali prepared patches that convert A3720 comphy driver to use Linux' DT bindings. (Yes, I have patches that convert the whole driver into using SMC calls into ATF, but haven't found time yet to rebase them since last year, and Pali has done this in the meantime :-D Maybe I'll look into my old patches sometimes, but this is now usable.)
These patches needed some changes in Turris MOX board code, and I added some more changes to handling device-tree fixups, and this lead to adding some code into
fdt_support, which can hopefully be used by other people as well.Marek
Marek Behún (8):
treewide: Usefdt_create_phandle()where appropriate
fdt_support: Removefdt_alloc_phandle()in favor of
fdt_generate_phandle()
fdt_support: RemoveFDT_STATUS_FAIL_ERROR_CODE
fdt_support: Fix comment forfdt_create_phandle()
fdt_support: Add some useful functions
arm: mvebu:turris_mox: Find DT nodes by compatible or alias instead
of path
arm: mvebu:turris_mox: Fix unstable board topology reading
fdt_support: Addfdt_delete_disabled_nodes()and use in Turris MOXPali Rohár (3):
include/linux/byteorder: Fix compilation of__constant_cpu_to_be32()
arm: mvebu:turris_mox: Enable eth1 in U-Boot if a network module is
present
phy: marvell: a3700: Convert to official DT bindings in COMPHY driverarch/arm/cpu/armv7/ls102xa/fdt.c | 6 +- arch/arm/dts/armada-3720-espressobin.dts | 21 +-- arch/arm/dts/armada-3720-turris-mox.dts | 25 +-- arch/arm/dts/armada-3720-uDPU.dts | 23 +-- arch/arm/dts/armada-37xx.dtsi | 20 +- board/CZ.NIC/turris_mox/turris_mox.c | 223 ++++++++--------------- board/Marvell/octeon_ebb7304/board.c | 5 +- board/freescale/lx2160a/eth_lx2160aqds.c | 8 +- board/freescale/lx2160a/eth_lx2162aqds.c | 8 +- board/gateworks/gw_ventana/common.c | 3 +- board/kontron/sl28/sl28.c | 2 +- common/fdt_support.c | 174 +++++++++++++++--- drivers/misc/fsl_portals.c | 10 +- drivers/pci/pcie_layerscape_fixup.c | 8 +- drivers/pci/pcie_layerscape_gen4_fixup.c | 8 +- drivers/phy/marvell/comphy_a3700.c | 133 ++++++++++++++ drivers/phy/marvell/comphy_core.c | 59 +----- drivers/phy/marvell/comphy_core.h | 23 +++ drivers/phy/marvell/comphy_cp110.c | 58 ++++++ include/fdt_support.h | 51 ++++-- include/linux/byteorder/swab.h | 4 + 21 files changed, 551 insertions(+), 321 deletions(-)Signature · 1 line
2.32.0
Quoted 15 lines · Marek Behún
From: Marek Behún <[email protected]>
Hello Stefan,
as requested I am resending this series with board maintainers added in Ccs.
Original message:
Pali prepared patches that convert A3720 comphy driver to use Linux' DT bindings. (Yes, I have patches that convert the whole driver into using SMC calls into ATF, but haven't found time yet to rebase them since last year, and Pali has done this in the meantime :-D Maybe I'll look into my old patches sometimes, but this is now usable.)
Quoted 4 lines
These patches needed some changes in Turris MOX board code, and I added some more changes to handling device-tree fixups, and this lead to adding some code into
fdt_support, which can hopefully be used by other people as well.
No reply yet. Let's move forward if nobody objects.
Applied to u-boot-marvell/next
Thanks,
Stefan
Quoted 34 lines
Marek
Marek Behún (8):
treewide: Usefdt_create_phandle()where appropriate
fdt_support: Removefdt_alloc_phandle()in favor of
fdt_generate_phandle()
fdt_support: RemoveFDT_STATUS_FAIL_ERROR_CODE
fdt_support: Fix comment forfdt_create_phandle()
fdt_support: Add some useful functions
arm: mvebu:turris_mox: Find DT nodes by compatible or alias instead
of path
arm: mvebu:turris_mox: Fix unstable board topology reading
fdt_support: Addfdt_delete_disabled_nodes()and use in Turris MOXPali Rohár (3):
include/linux/byteorder: Fix compilation of__constant_cpu_to_be32()
arm: mvebu:turris_mox: Enable eth1 in U-Boot if a network module is
present
phy: marvell: a3700: Convert to official DT bindings in COMPHY driverarch/arm/cpu/armv7/ls102xa/fdt.c | 6 +- arch/arm/dts/armada-3720-espressobin.dts | 21 +-- arch/arm/dts/armada-3720-turris-mox.dts | 25 +-- arch/arm/dts/armada-3720-uDPU.dts | 23 +-- arch/arm/dts/armada-37xx.dtsi | 20 +- board/CZ.NIC/turris_mox/turris_mox.c | 223 ++++++++--------------- board/Marvell/octeon_ebb7304/board.c | 5 +- board/freescale/lx2160a/eth_lx2160aqds.c | 8 +- board/freescale/lx2160a/eth_lx2162aqds.c | 8 +- board/gateworks/gw_ventana/common.c | 3 +- board/kontron/sl28/sl28.c | 2 +- common/fdt_support.c | 174 +++++++++++++++--- drivers/misc/fsl_portals.c | 10 +- drivers/pci/pcie_layerscape_fixup.c | 8 +-
Quoted 9 lines
drivers/pci/pcie_layerscape_gen4_fixup.c | 8 +- drivers/phy/marvell/comphy_a3700.c | 133 ++++++++++++++ drivers/phy/marvell/comphy_core.c | 59 +----- drivers/phy/marvell/comphy_core.h | 23 +++ drivers/phy/marvell/comphy_cp110.c | 58 ++++++ include/fdt_support.h | 51 ++++-- include/linux/byteorder/swab.h | 4 + 21 files changed, 551 insertions(+), 321 deletions(-)
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]