usb: Covert to support Live DT
Subsystems (7)
cover usb: Covert to support Live DT
This patch set convert to use APIs leading with dev_ or ofnode_ which supports live DT instead of fdt_ or fdtdec or devfdt_.
Two functions update there parameter from offset to ofnode:
- usb_get_maximum_speed()
- usb_get_dr_mode()
Kever Yang (10):
usb: dwc3-of-simple: Drop redundant inclding header file
usb: ehci-msm: Use dev interface to get device address
usb: cdns3: Migrate to use ofnode API for bind function
usb: dwc3-generic: Migrate to use ofnode API for bind function
usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
usb: host: dwc3-sti-glue: Migrate to use ofnode API
usb: musb-new: Migrate to use ofnode API
usb: dwc3: core: reorder the header file including sequence
usb: Use ofnode as usb_get_dr_mode() parameter
usb: Use ofnode as usb_get_maximum_speed() parameter
drivers/usb/cdns3/core.c | 17 +++++++---------- drivers/usb/cdns3/gadget.c | 2 +- drivers/usb/common/common.c | 12 +++++------- drivers/usb/dwc3/core.c | 6 +++--- drivers/usb/dwc3/dwc3-generic.c | 16 +++++++--------- drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- drivers/usb/gadget/dwc2_udc_otg.c | 5 ++--- drivers/usb/host/dwc3-of-simple.c | 1 - drivers/usb/host/dwc3-sti-glue.c | 20 +++++++------------- drivers/usb/host/ehci-msm.c | 4 +--- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/xhci-dwc3.c | 3 +-- drivers/usb/musb-new/ti-musb.c | 12 +++++------- include/linux/usb/otg.h | 8 ++++---- 14 files changed, 45 insertions(+), 65 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/10 usb: dwc3-of-simple: Drop redundant inclding header file
The fdtdec.h is no use in this file, remove the include code.
---
drivers/usb/host/dwc3-of-simple.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/host/dwc3-of-simple.c +0 -1
@@ -12,7 +12,6 @@#include <common.h> #include <dm.h> -#include <fdtdec.h> #include <reset.h> #include <clk.h>
Signature · 1 line
2.17.1
PATCH 2/10 usb: ehci-msm: Use dev interface to get device address
In reply to Kever YangUse dev_read_addr_ptr() instead of devfdt_get_addr() so that we can support live DT.
---
drivers/usb/host/ehci-msm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/host/ehci-msm.c +1 -3
@@ -10,8 +10,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> -#include <linux/libfdt.h> #include <usb.h> #include <usb/ehci-ci.h> #include <usb/ulpi.h>
@@ -108,7 +106,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)struct msm_ehci_priv *priv =dev_get_priv (dev); priv->ulpi_vp.port_num =0 ; - priv->ehci = (void *)devfdt_get_addr (dev); + priv->ehci =dev_read_addr_ptr (dev);if (priv->ehci == (void *)FDT_ADDR_T_NONE )return -EINVAL ;
Signature · 1 line
2.17.1
PATCH 2/10 usb: ehci-msm: Use dev interface to get device address
Quoted 33 lines · Kever Yang
Use
dev_read_addr_ptr()instead ofdevfdt_get_addr()so that we can support live DT.Signed-off-by Kever Yang <[email protected]>---
drivers/usb/host/ehci-msm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/usb/host/ehci-msm.c +1
-4@@ -10,8 +10,6 @@#include <common.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> -#include <linux/libfdt.h> #include <usb.h> #include <usb/ehci-ci.h> #include <usb/ulpi.h> @@ -108,7 +106,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)struct msm_ehci_priv *priv =dev_get_priv (dev); priv->ulpi_vp.port_num =0 ; - priv->ehci = (void *)devfdt_get_addr (dev); + priv->ehci =dev_read_addr_ptr (dev);if (priv->ehci == (void *)FDT_ADDR_T_NONE )return -EINVAL ; --
Quoted 2 lines
2.17.1
PATCH 3/10 usb: cdns3: Migrate to use ofnode API for bind function
In reply to Kever YangUse ofnode_ instead of fdt_ APIs so that the driver can support live DT.
---
drivers/usb/cdns3/core.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/usb/cdns3/core.c +6 -9
@@ -382,23 +382,21 @@ static const struct udevice_id cdns3_ids[] = {int cdns3_bind (struct udevice *parent) { -int from =dev_of_offset (parent); -const void *fdt = gd->fdt_blob;enum usb_dr_mode dr_mode;struct udevice *dev;const char *driver;const char *name; -int node; +ofnode node;int ret; - node =fdt_node_offset_by_compatible (fdt, from,"cdns,usb3" ); -if (node <0 ) { + node =ofnode_by_compatible (parent->node,"cdns,usb3" ); +if (!ofnode_valid (node)) { ret = -ENODEV ; goto fail; } - name =fdt_get_name (fdt, node,NULL ); - dr_mode =usb_get_dr_mode (node); + name =ofnode_get_name (node); + dr_mode =usb_get_dr_mode (ofnode_to_offset (node));switch (dr_mode) { #if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \
@@ -420,8 +418,7 @@ int cdns3_bind(struct udevice *parent) goto fail; }; - ret =device_bind_driver_to_node (parent, driver, name, -offset_to_ofnode (node), &dev); + ret =device_bind_driver_to_node (parent, driver, name, node, &dev);if (ret) {printf ("%s: not able to bind usb device mode\n" , __func__);
Signature · 1 line
2.17.1
PATCH 4/10 usb: dwc3-generic: Migrate to use ofnode API for bind function
In reply to Kever YangUse ofnode_ instead of fdt_ APIs so that the driver can support live DT.
---
drivers/usb/dwc3/dwc3-generic.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +5 -7
@@ -284,20 +284,18 @@ struct dwc3_glue_ops ti_ops = {static int dwc3_glue_bind (struct udevice *parent) { -const void *fdt = gd->fdt_blob; -int node; +ofnode node;int ret; -for (node =fdt_first_subnode (fdt,dev_of_offset (parent)); node >0 ; - node =fdt_next_subnode (fdt, node)) { -const char *name =fdt_get_name (fdt, node,NULL ); +ofnode_for_each_subnode (node, parent->node) { +const char *name =ofnode_get_name (node);enum usb_dr_mode dr_mode;struct udevice *dev;const char *driver =NULL ;debug ("%s: subnode name: %s\n" , __func__, name); - dr_mode =usb_get_dr_mode (node); + dr_mode =usb_get_dr_mode (ofnode_to_offset (node));switch (dr_mode) {case USB_DR_MODE_PERIPHERAL :
@@ -322,7 +320,7 @@ static int dwc3_glue_bind(struct udevice *parent)continue ; ret =device_bind_driver_to_node (parent, driver, name, -offset_to_ofnode (node), &dev); + node, &dev);if (ret) {debug ("%s: not able to bind usb device mode\n" , __func__);
Signature · 1 line
2.17.1
PATCH 5/10 usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
In reply to Kever YangUse more common API so that we can support live DT.
---
drivers/usb/dwc3/dwc3-generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/dwc3/dwc3-generic.c +4 -4
@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,static int dwc3_generic_ofdata_to_platdata (struct udevice *dev) {struct dwc3_generic_plat *plat =dev_get_platdata (dev); -int node =dev_of_offset (dev); +ofnode node = dev->node; - plat->base =devfdt_get_addr (dev); + plat->base =dev_read_addr (dev); - plat->maximum_speed =usb_get_maximum_speed (node); + plat->maximum_speed =usb_get_maximum_speed (ofnode_to_offset (node));if (plat->maximum_speed ==USB_SPEED_UNKNOWN ) {pr_info ("No USB maximum speed specified. Using super speed\n" ); plat->maximum_speed =USB_SPEED_SUPER ; } - plat->dr_mode =usb_get_dr_mode (node); + plat->dr_mode =usb_get_dr_mode (ofnode_to_offset (node));if (plat->dr_mode ==USB_DR_MODE_UNKNOWN ) {pr_err ("Invalid usb mode setup\n" );return -ENODEV ;
Signature · 1 line
2.17.1
PATCH 5/10 usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
Quoted 13 lines · Kever Yang
Use more common API so that we can support live DT.
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/usb/dwc3/dwc3-generic.c +0
-0
drivers/usb/dwc3/dwc3-generic.c static int dwc3_generic_remove(struct udevice *dev, · line 91
Quoted 5 lines
drivers/usb/dwc3/dwc3-generic.c +1
-1@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,static int dwc3_generic_ofdata_to_platdata (struct udevice *dev) {struct dwc3_generic_plat *plat =dev_get_platdata (dev); -int node =dev_of_offset (dev); +ofnode node = dev->node;
Can't you just do ofnode_of_offset() here, once , instead of having it all over the function ?
PATCH 5/10 usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
Hi Marek,
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Kever Yang
Use more common API so that we can support live DT.
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 12 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_generic_remove(struct udevice *dev, · line 91
Quoted 10 lines
drivers/usb/dwc3/dwc3-generic.c +1
-1@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,static int dwc3_generic_ofdata_to_platdata (struct udevice *dev) {struct dwc3_generic_plat *plat =dev_get_platdata (dev); -int node =dev_of_offset (dev); +ofnode node = dev->node;Can't you just do
ofnode_of_offset()here, once , instead of having it all over the function ?
The "all over the function" is only twice, and this convert will removed at follow up patch which
update the function parameter from offset to ofnode.
So I think this change is acceptable for this patch.
Thanks,
- Kever
PATCH 5/10 usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()
In reply to Kever YangHi Kever,
Quoted 22 lines · Kever Yang
Use more common API so that we can support live DT.
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/usb/dwc3/dwc3-generic.c +2
-2@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,static int dwc3_generic_ofdata_to_platdata (struct udevice *dev) {struct dwc3_generic_plat *plat =dev_get_platdata (dev); -int node =dev_of_offset (dev); +ofnode node = dev->node; - plat->base =devfdt_get_addr (dev); + plat->base =dev_read_addr (dev);
drivers/usb/dwc3/dwc3-generic.c static int dwc3_generic_remove(struct udevice *dev, · line 101
Quoted 10 lines
drivers/usb/dwc3/dwc3-generic.c +2
-2- plat->maximum_speed =usb_get_maximum_speed (node); + plat->maximum_speed =usb_get_maximum_speed (ofnode_to_offset (node));if (plat->maximum_speed ==USB_SPEED_UNKNOWN ) {pr_info ("No USB maximum speed specified. Using super speed\n" ); plat->maximum_speed =USB_SPEED_SUPER ; } - plat->dr_mode =usb_get_dr_mode (node); + plat->dr_mode =usb_get_dr_mode (ofnode_to_offset (node));
This won't work with livetree. Can you convert usb_get_dr_mode() to use livetree? Then you can pass the dev or the node.
Quoted 6 lines
drivers/usb/dwc3/dwc3-generic.c +0
-1if (plat->dr_mode ==USB_DR_MODE_UNKNOWN ) {pr_err ("Invalid usb mode setup\n" );return -ENODEV ; --2.17.1
Regards,
Simon
Re: [PATCH 05/10] usb: dwc3-generic: Use dev_read_addr() instead of devfdt_get_addr()【请注意,邮件由[email protected]代发】
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Kever,
Quoted 29 lines · Kever Yang
Use more common API so that we can support live DT.
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/dwc3/dwc3-generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/usb/dwc3/dwc3-generic.c +3
-3@@ -88,17 +88,17 @@ static int dwc3_generic_remove(struct udevice *dev,static int dwc3_generic_ofdata_to_platdata (struct udevice *dev) {struct dwc3_generic_plat *plat =dev_get_platdata (dev); -int node =dev_of_offset (dev); +ofnode node = dev->node; - plat->base =devfdt_get_addr (dev); + plat->base =dev_read_addr (dev); - plat->maximum_speed =usb_get_maximum_speed (node); + plat->maximum_speed =usb_get_maximum_speed (ofnode_to_offset (node));if (plat->maximum_speed ==USB_SPEED_UNKNOWN ) {pr_info ("No USB maximum speed specified. Using super speed\n" ); plat->maximum_speed =USB_SPEED_SUPER ; }
Quoted 4 lines
drivers/usb/dwc3/dwc3-generic.c static int dwc3_generic_remove(struct udevice *dev, · line 101
Quoted 2 lines
drivers/usb/dwc3/dwc3-generic.c +1
-1- plat->dr_mode =usb_get_dr_mode (node); + plat->dr_mode =usb_get_dr_mode (ofnode_to_offset (node));This won't work with livetree. Can you convert
usb_get_dr_mode()to use livetree? Then you can pass the dev or the node.
I do convert usb_get_dr_mode() to use livetree at 9/10 of this patch set.
I have to clean all the related code first, and then convert usb_get_dr_mode() and
usb_get_maximum_speed() to livetree one by one. If the convert happen first,
I have to merge the 3rd~10th patches into one patch and not so good for review.
Thanks,
- Kever
Quoted 11 lines
Quoted 7 lines
drivers/usb/dwc3/dwc3-generic.c +0
-1if (plat->dr_mode ==USB_DR_MODE_UNKNOWN ) {pr_err ("Invalid usb mode setup\n" );return -ENODEV ; --2.17.1
Regards,
Simon
PATCH 6/10 usb: host: dwc3-sti-glue: Migrate to use ofnode API
In reply to Kever YangUse ofnode_ instead of fdt_ or fdtdec_ APIs so that the driver can support live DT.
---
drivers/usb/host/dwc3-sti-glue.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/usb/host/dwc3-sti-glue.c +8 -14
@@ -10,8 +10,6 @@#include <asm/io.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> -#include <linux/libfdt.h> #include <dm/lists.h> #include <regmap.h> #include <reset-uclass.h>
@@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)int ret;u32 reg[4 ]; - ret =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev), -"reg" , reg,ARRAY_SIZE (reg)); + ret =ofnode_read_u32_array (dev->node,"reg" , reg,ARRAY_SIZE (reg));if (ret) {pr_err ("unable to find st,stih407-dwc3 reg property(%d)\n" , ret);return ret;
@@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)static int sti_dwc3_glue_bind (struct udevice *dev) {struct sti_dwc3_glue_platdata *plat =dev_get_platdata (dev); -int dwc3_node; +ofnode dwc3_node; -/* check if one subnode is present */ - dwc3_node =fdt_first_subnode (gd->fdt_blob,dev_of_offset (dev)); -if (dwc3_node <=0 ) { -pr_err ("Can't find subnode for %s\n" , dev->name); -return -ENODEV ; +/* Find snps,dwc3 node from subnode */ +ofnode_for_each_subnode (node, dev->node) { +if (ofnode_device_is_compatible (node,"snps,dwc3" )) + dwc3_node = node; } -/* check if the subnode compatible string is the dwc3 one*/ -if (fdt_node_check_compatible (gd->fdt_blob, dwc3_node, -"snps,dwc3" ) !=0 ) { +if (!ofnode_valid (node)) {pr_err ("Can't find dwc3 subnode for %s\n" , dev->name);return -ENODEV ; }/* retrieve the DWC3 dual role mode */ - plat->mode =usb_get_dr_mode (dwc3_node); + plat->mode =usb_get_dr_mode (ofnode_to_offset (dwc3_node));if (plat->mode ==USB_DR_MODE_UNKNOWN )/* by default set dual role mode to HOST */ plat->mode =USB_DR_MODE_HOST ;
Signature · 1 line
2.17.1
PATCH 6/10 usb: host: dwc3-sti-glue: Migrate to use ofnode API
Hi Kever
Quoted 54 lines · Kever Yang
Use
ofnode_instead offdt_orfdtdec_APIs so that the driver can support live DT.Signed-off-by Kever Yang <[email protected]>---
drivers/usb/host/dwc3-sti-glue.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)drivers/usb/host/dwc3-sti-glue.c +7
-13@@ -10,8 +10,6 @@#include <asm/io.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> -#include <linux/libfdt.h> #include <dm/lists.h> #include <regmap.h> #include <reset-uclass.h> @@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)int ret;u32 reg[4 ]; - ret =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev), -"reg" , reg,ARRAY_SIZE (reg)); + ret =ofnode_read_u32_array (dev->node,"reg" , reg,ARRAY_SIZE (reg));if (ret) {pr_err ("unable to find st,stih407-dwc3 reg property(%d)\n" , ret);return ret;@@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)static int sti_dwc3_glue_bind (struct udevice *dev) {struct sti_dwc3_glue_platdata *plat =dev_get_platdata (dev); -int dwc3_node; +ofnode dwc3_node; -/* check if one subnode is present */ - dwc3_node =fdt_first_subnode (gd->fdt_blob,dev_of_offset (dev)); -if (dwc3_node <=0 ) { -pr_err ("Can't find subnode for %s\n" , dev->name); -return -ENODEV ; +/* Find snps,dwc3 node from subnode */ +ofnode_for_each_subnode (node, dev->node) { +if (ofnode_device_is_compatible (node,"snps,dwc3" )) + dwc3_node = node; } -/* check if the subnode compatible string is the dwc3 one*/ -if (fdt_node_check_compatible (gd->fdt_blob, dwc3_node, -"snps,dwc3" ) !=0 ) { +if (!ofnode_valid (node)) {
drivers/usb/host/dwc3-sti-glue.c static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) · line 170
Quoted 10 lines
drivers/usb/host/dwc3-sti-glue.c +1
-1pr_err ("Can't find dwc3 subnode for %s\n" , dev->name);return -ENODEV ; }/* retrieve the DWC3 dual role mode */ - plat->mode =usb_get_dr_mode (dwc3_node); + plat->mode =usb_get_dr_mode (ofnode_to_offset (dwc3_node));if (plat->mode ==USB_DR_MODE_UNKNOWN )/* by default set dual role mode to HOST */ plat->mode =USB_DR_MODE_HOST ;
Using stih410-b2260_defconfig, this path doesn't compile, see below:
In file included from board/st/stih410-b2260/board.c:9:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enum usb_dr_mode usb_get_dr_mode(ofnode node); ????????????????????????????????? ^~~~~~include/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enum usb_device_speed usb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~
? CC????? drivers/spi/spi.o
? CC????? drivers/usb/common/common.oscripts/Makefile.build:278: recipe for target 'board/st/stih410-b2260/board.o' failed make[1]: *** [board/st/stih410-b2260/board.o] Error 1
? CC????? drivers/serial/serial_sti_asc.o
Makefile:1728: recipe for target 'board/st/stih410-b2260' failed
make: *** [board/st/stih410-b2260] Error 2
make: *** Waiting for unfinished jobs....
? CC????? drivers/usb/dwc3/core.o
? CC????? drivers/usb/eth/usb_ether.o
? CC????? drivers/usb/eth/asix.o
? CC????? common/main.o
? CC????? drivers/usb/eth/mcs7830.o
? CC????? drivers/usb/gadget/epautoconf.o
? CC????? drivers/fastboot/fb_getvar.o
? CC????? drivers/usb/eth/smsc95xx.o
? LD????? drivers/spi/built-in.o
? CC????? drivers/usb/dwc3/gadget.o
? CC????? cmd/version.o
? CC????? drivers/usb/dwc3/ep0.o
? CC????? drivers/usb/gadget/config.o
? LD????? drivers/usb/common/built-in.o
? LD????? drivers/serial/built-in.o
? LD????? common/built-in.o
In file included from drivers/usb/dwc3/core.h:23,
???????????????? from drivers/usb/dwc3/gadget.c:28:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enum usb_dr_mode usb_get_dr_mode(ofnode node); ????????????????????????????????? ^~~~~~
In file included from drivers/usb/dwc3/core.h:23,
???????????????? from drivers/usb/dwc3/ep0.c:25:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enum usb_dr_mode usb_get_dr_mode(ofnode node); ????????????????????????????????? ^~~~~~
? CC????? drivers/usb/gadget/usbstring.oinclude/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enum usb_device_speed usb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~ include/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enum usb_device_speed usb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~
? CC????? drivers/usb/gadget/g_dnl.oscripts/Makefile.build:278: recipe for target 'drivers/usb/dwc3/ep0.o' failed make[1]: *** [drivers/usb/dwc3/ep0.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Thanks
Patrice
PATCH 6/10 usb: host: dwc3-sti-glue: Migrate to use ofnode API
Hi Patrice,
Quoted 69 lines · Patrice CHOTARD
Hi Kever
Quoted 54 lines · Kever Yang
Use
ofnode_instead offdt_orfdtdec_APIs so that the driver can support live DT.Signed-off-by Kever Yang <[email protected]>---
drivers/usb/host/dwc3-sti-glue.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)drivers/usb/host/dwc3-sti-glue.c +7
-13@@ -10,8 +10,6 @@#include <asm/io.h> #include <dm.h> #include <errno.h> -#include <fdtdec.h> -#include <linux/libfdt.h> #include <dm/lists.h> #include <regmap.h> #include <reset-uclass.h> @@ -109,8 +107,7 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)int ret;u32 reg[4 ]; - ret =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev), -"reg" , reg,ARRAY_SIZE (reg)); + ret =ofnode_read_u32_array (dev->node,"reg" , reg,ARRAY_SIZE (reg));if (ret) {pr_err ("unable to find st,stih407-dwc3 reg property(%d)\n" , ret);return ret;@@ -153,24 +150,21 @@ static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev)static int sti_dwc3_glue_bind (struct udevice *dev) {struct sti_dwc3_glue_platdata *plat =dev_get_platdata (dev); -int dwc3_node; +ofnode dwc3_node; -/* check if one subnode is present */ - dwc3_node =fdt_first_subnode (gd->fdt_blob,dev_of_offset (dev)); -if (dwc3_node <=0 ) { -pr_err ("Can't find subnode for %s\n" , dev->name); -return -ENODEV ; +/* Find snps,dwc3 node from subnode */ +ofnode_for_each_subnode (node, dev->node) { +if (ofnode_device_is_compatible (node,"snps,dwc3" )) + dwc3_node = node; } -/* check if the subnode compatible string is the dwc3 one*/ -if (fdt_node_check_compatible (gd->fdt_blob, dwc3_node, -"snps,dwc3" ) !=0 ) { +if (!ofnode_valid (node)) {drivers/usb/host/dwc3-sti-glue.c static int sti_dwc3_glue_ofdata_to_platdata(struct udevice *dev) · line 170
Quoted 10 lines
drivers/usb/host/dwc3-sti-glue.c +1
-1pr_err ("Can't find dwc3 subnode for %s\n" , dev->name);return -ENODEV ; }/* retrieve the DWC3 dual role mode */ - plat->mode =usb_get_dr_mode (dwc3_node); + plat->mode =usb_get_dr_mode (ofnode_to_offset (dwc3_node));if (plat->mode ==USB_DR_MODE_UNKNOWN )/* by default set dual role mode to HOST */ plat->mode =USB_DR_MODE_HOST ;Using stih410-b2260_defconfig, this path doesn't compile, see below:
Quoted 3 lines
In file included from
board/st/stih410-b2260/board.c:9:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enumusb_dr_modeusb_get_dr_mode(ofnode node);
This has been fixed in the version 2.
Thanks,
- Kever
Quoted 53 lines
????????????????????????????????? ^~~~~~
include/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enumusb_device_speedusb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~
? CC?????drivers/spi/spi.o
? CC?????drivers/usb/common/common.oscripts/Makefile.build:278: recipe for target 'board/st/stih410-b2260/board.o' failed make[1]: *** [board/st/stih410-b2260/board.o] Error 1
? CC?????drivers/serial/serial_sti_asc.o
Makefile:1728: recipe for target 'board/st/stih410-b2260' failed
make: *** [board/st/stih410-b2260] Error 2
make: *** Waiting for unfinished jobs....
? CC?????drivers/usb/dwc3/core.o
? CC?????drivers/usb/eth/usb_ether.o
? CC?????drivers/usb/eth/asix.o
? CC?????common/main.o
? CC?????drivers/usb/eth/mcs7830.o
? CC?????drivers/usb/gadget/epautoconf.o
? CC?????drivers/fastboot/fb_getvar.o
? CC?????drivers/usb/eth/smsc95xx.o
? LD?????drivers/spi/built-in.o
? CC?????drivers/usb/dwc3/gadget.o
? CC?????cmd/version.o
? CC?????drivers/usb/dwc3/ep0.o
? CC?????drivers/usb/gadget/config.o
? LD?????drivers/usb/common/built-in.o
? LD?????drivers/serial/built-in.o
? LD?????common/built-in.o
In file included fromdrivers/usb/dwc3/core.h:23,
???????????????? fromdrivers/usb/dwc3/gadget.c:28:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enumusb_dr_modeusb_get_dr_mode(ofnode node); ????????????????????????????????? ^~~~~~
In file included fromdrivers/usb/dwc3/core.h:23,
???????????????? fromdrivers/usb/dwc3/ep0.c:25:include/linux/usb/otg.h:26:34: error: unknown type name ?ofnode?
?enumusb_dr_modeusb_get_dr_mode(ofnode node); ????????????????????????????????? ^~~~~~
? CC?????drivers/usb/gadget/usbstring.oinclude/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enumusb_device_speedusb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~include/linux/usb/otg.h:35:45: error: unknown type name ?ofnode?
?enumusb_device_speedusb_get_maximum_speed(ofnode node); ???????????????????????????????????????????? ^~~~~~
? CC?????drivers/usb/gadget/g_dnl.oscripts/Makefile.build:278: recipe for target 'drivers/usb/dwc3/ep0.o' failed make[1]: *** [drivers/usb/dwc3/ep0.o] Error 1
make[1]: *** Waiting for unfinished jobs....Thanks
Patrice
PATCH 7/10 usb: musb-new: Migrate to use ofnode API
In reply to Kever YangUse ofnode_ instead of fdt_ APIs so that the driver can support live DT.
---
drivers/usb/musb-new/ti-musb.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/usb/musb-new/ti-musb.c +6 -8
@@ -284,28 +284,26 @@ U_BOOT_DRIVER(ti_musb_peripheral) = {#if CONFIG_IS_ENABLED (OF_CONTROL )static int ti_musb_wrapper_bind (struct udevice *parent) { -const void *fdt = gd->fdt_blob; -int node; +ofnode node;int ret; -for (node =fdt_first_subnode (fdt,dev_of_offset (parent)); node >0 ; - node =fdt_next_subnode (fdt, node)) { +ofnode_for_each_subnode (node, parent->node) {struct udevice *dev; -const char *name =fdt_get_name (fdt, node,NULL ); +const char *name =ofnode_get_name (node);enum usb_dr_mode dr_mode;struct driver *drv;if (strncmp (name,"usb@" ,4 ))continue ; - dr_mode =usb_get_dr_mode (node); + dr_mode =usb_get_dr_mode (ofnode_to_offset (node));switch (dr_mode) {case USB_DR_MODE_PERIPHERAL :/* Bind MUSB device */ ret =device_bind_driver_to_node (parent,"ti-musb-peripheral" , name, -offset_to_ofnode (node), + node, &dev);if (ret)pr_err ("musb - not able to bind usb peripheral node\n" );
@@ -315,7 +313,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent) ret =device_bind_driver_to_node (parent,"ti-musb-host" , name, -offset_to_ofnode (node), + node, &dev);if (ret)pr_err ("musb - not able to bind usb host node\n" );
Signature · 1 line
2.17.1
PATCH 8/10 usb: dwc3: core: reorder the header file including sequence
In reply to Kever YangMake the including header file in correct sequence.
---
drivers/usb/dwc3/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/dwc3/core.c +3 -3
@@ -15,12 +15,12 @@#include <common.h> #include <cpu_func.h> -#include <malloc.h> +#include <dm.h> #include <dwc3-uboot.h> +#include <generic-phy.h> +#include <malloc.h> #include <asm/dma-mapping.h> #include <linux/ioport.h> -#include <dm.h> -#include <generic-phy.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
Signature · 1 line
2.17.1
PATCH 8/10 usb: dwc3: core: reorder the header file including sequence
Quoted 1 line · Kever Yang
Make the including header file in correct sequence.
How is this sequence more correct than the previous one ?
Quoted 27 lines
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/dwc3/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/usb/dwc3/core.c +3
-3@@ -15,12 +15,12 @@#include <common.h> #include <cpu_func.h> -#include <malloc.h> +#include <dm.h> #include <dwc3-uboot.h> +#include <generic-phy.h> +#include <malloc.h> #include <asm/dma-mapping.h> #include <linux/ioport.h> -#include <dm.h> -#include <generic-phy.h> #include <linux/usb/ch9.h> #include <linux/usb/gadget.h>
PATCH 9/10 usb: Use ofnode as usb_get_dr_mode() parameter
In reply to Kever Yangofnode is more common and no need to convert to offset after we migrate other API to use ofnode.
---
drivers/usb/cdns3/core.c | 2 +- drivers/usb/common/common.c | 7 +++---- drivers/usb/dwc3/dwc3-generic.c | 6 +++--- drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- drivers/usb/gadget/dwc2_udc_otg.c | 5 ++--- drivers/usb/host/dwc3-sti-glue.c | 2 +- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/xhci-dwc3.c | 3 +-- drivers/usb/musb-new/ti-musb.c | 2 +- include/linux/usb/otg.h | 4 ++-- 10 files changed, 16 insertions(+), 19 deletions(-)
drivers/usb/cdns3/core.c +1 -1
@@ -106,7 +106,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)enum usb_dr_mode dr_mode;int ret =0 ; - dr_mode =usb_get_dr_mode (dev_of_offset (dev)); + dr_mode =usb_get_dr_mode (dev->node); cdns->role =USB_ROLE_NONE ;/*
drivers/usb/common/common.c +3 -4
@@ -7,7 +7,7 @@*/ #include <common.h> -#include <linux/libfdt.h> +#include <dm.h> #include <linux/usb/otg.h> #include <linux/usb/ch9.h>
@@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = { [USB_DR_MODE_OTG] = "otg", }; -enum usb_dr_mode usb_get_dr_mode (int node) +enum usb_dr_mode usb_get_dr_mode (ofnode node) { -const void *fdt = gd->fdt_blob;const char *dr_mode;int i; - dr_mode =fdt_getprop (fdt, node,"dr_mode" ,NULL ); + dr_mode =ofnode_read_string (node,"dr_mode" );if (!dr_mode) {pr_err ("usb dr_mode not found\n" );return USB_DR_MODE_UNKNOWN ;
drivers/usb/dwc3/dwc3-generic.c +3 -3
@@ -98,7 +98,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice *dev) plat->maximum_speed =USB_SPEED_SUPER ; } - plat->dr_mode =usb_get_dr_mode (ofnode_to_offset (node)); + plat->dr_mode =usb_get_dr_mode (node);if (plat->dr_mode ==USB_DR_MODE_UNKNOWN ) {pr_err ("Invalid usb mode setup\n" );return -ENODEV ;
@@ -295,7 +295,7 @@ static int dwc3_glue_bind(struct udevice *parent)debug ("%s: subnode name: %s\n" , __func__, name); - dr_mode =usb_get_dr_mode (ofnode_to_offset (node)); + dr_mode =usb_get_dr_mode (node);switch (dr_mode) {case USB_DR_MODE_PERIPHERAL :
@@ -398,7 +398,7 @@ static int dwc3_glue_probe(struct udevice *dev)while (child) {enum usb_dr_mode dr_mode; - dr_mode =usb_get_dr_mode (dev_of_offset (child)); + dr_mode =usb_get_dr_mode (child->node);device_find_next_child (&child);if (ops && ops->select_dr_mode) ops->select_dr_mode (dev, index, dr_mode);
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev) }#endif - priv->otg_mode =usb_get_dr_mode (dev_of_offset (dev)); + priv->otg_mode =usb_get_dr_mode (dev->node); ret =dwc3_meson_g12a_usb_init (priv);if (ret)
drivers/usb/gadget/dwc2_udc_otg.c +2 -3
@@ -1036,13 +1036,12 @@ void dwc2_phy_shutdown(struct udevice *dev, struct phy *usb_phys, int num_phys)static int dwc2_udc_otg_ofdata_to_platdata (struct udevice *dev) {struct dwc2_plat_otg_data *platdata =dev_get_platdata (dev); -int node =dev_of_offset (dev);ulong drvdata;void (*set_params)(struct dwc2_plat_otg_data *data);int ret; -if (usb_get_dr_mode (node) !=USB_DR_MODE_PERIPHERAL && -usb_get_dr_mode (node) !=USB_DR_MODE_OTG ) { +if (usb_get_dr_mode (dev->node) !=USB_DR_MODE_PERIPHERAL && +usb_get_dr_mode (dev->node) !=USB_DR_MODE_OTG ) {dev_dbg (dev,"Invalid mode\n" );return -ENODEV ; }
drivers/usb/host/dwc3-sti-glue.c +1 -1
@@ -164,7 +164,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev) }/* retrieve the DWC3 dual role mode */ - plat->mode =usb_get_dr_mode (ofnode_to_offset (dwc3_node)); + plat->mode =usb_get_dr_mode (dwc3_node);if (plat->mode ==USB_DR_MODE_UNKNOWN )/* by default set dual role mode to HOST */ plat->mode =USB_DR_MODE_HOST ;
drivers/usb/host/ehci-mx6.c +1 -1
@@ -513,7 +513,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)struct usb_platdata *plat =dev_get_platdata (dev);enum usb_dr_mode dr_mode; - dr_mode =usb_get_dr_mode (dev_of_offset (dev)); + dr_mode =usb_get_dr_mode (dev->node);switch (dr_mode) {case USB_DR_MODE_HOST :
drivers/usb/host/xhci-dwc3.c +1 -2
@@ -9,7 +9,6 @@#include <common.h> #include <dm.h> -#include <fdtdec.h> #include <generic-phy.h> #include <usb.h> #include <dwc3-uboot.h>
@@ -155,7 +154,7 @@ static int xhci_dwc3_probe(struct udevice *dev)writel (reg, &dwc3_reg->g_usb2phycfg[0 ]); - dr_mode =usb_get_dr_mode (dev_of_offset (dev)); + dr_mode =usb_get_dr_mode (dev->node);if (dr_mode ==USB_DR_MODE_UNKNOWN )/* by default set dual role mode to HOST */ dr_mode =USB_DR_MODE_HOST ;
drivers/usb/musb-new/ti-musb.c +1 -1
@@ -296,7 +296,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)if (strncmp (name,"usb@" ,4 ))continue ; - dr_mode =usb_get_dr_mode (ofnode_to_offset (node)); + dr_mode =usb_get_dr_mode (node);switch (dr_mode) {case USB_DR_MODE_PERIPHERAL :/* Bind MUSB device */
include/linux/usb/otg.h +2 -2
@@ -18,12 +18,12 @@ enum usb_dr_mode {/** * usb_get_dr_mode() - Get dual role mode for given device -* @node: Node offset to the given device +* @node: ofnode of the given device * * The function gets phy interface string from property 'dr_mode', * and returns the correspondig enum usb_dr_mode */ -enum usb_dr_mode usb_get_dr_mode (int node); +enum usb_dr_mode usb_get_dr_mode (ofnode node);/** * usb_get_maximum_speed() - Get maximum speed for given device
Signature · 1 line
2.17.1
PATCH 9/10 usb: Use ofnode as usb_get_dr_mode() parameter
Quoted 18 lines · Kever Yang
ofnode is more common and no need to convert to offset after we migrate other API to use ofnode.
Signed-off-by Kever Yang <[email protected]>---
drivers/usb/cdns3/core.c | 2 +- drivers/usb/common/common.c | 7 +++---- drivers/usb/dwc3/dwc3-generic.c | 6 +++--- drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- drivers/usb/gadget/dwc2_udc_otg.c | 5 ++--- drivers/usb/host/dwc3-sti-glue.c | 2 +- drivers/usb/host/ehci-mx6.c | 2 +- drivers/usb/host/xhci-dwc3.c | 3 +-- drivers/usb/musb-new/ti-musb.c | 2 +- include/linux/usb/otg.h | 4 ++-- 10 files changed, 16 insertions(+), 19 deletions(-)
[...]
Quoted 31 lines
drivers/usb/common/common.c +3
-4@@ -7,7 +7,7 @@*/ #include <common.h> -#include <linux/libfdt.h> +#include <dm.h> #include <linux/usb/otg.h> #include <linux/usb/ch9.h> @@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = { [USB_DR_MODE_OTG] = "otg", }; -enum usb_dr_mode usb_get_dr_mode (int node) +enum usb_dr_mode usb_get_dr_mode (ofnode node) { -const void *fdt = gd->fdt_blob;const char *dr_mode;int i; - dr_mode =fdt_getprop (fdt, node,"dr_mode" ,NULL ); + dr_mode =ofnode_read_string (node,"dr_mode" );if (!dr_mode) {pr_err ("usb dr_mode not found\n" );return USB_DR_MODE_UNKNOWN ;drivers/usb/dwc3/dwc3-generic.c +0
-0
[..]
drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct udevice *dev) · line 399
Quoted 13 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1
-1@@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev) }#endif - priv->otg_mode =usb_get_dr_mode (dev_of_offset (dev)); + priv->otg_mode =usb_get_dr_mode (dev->node); ret =dwc3_meson_g12a_usb_init (priv);if (ret)
For drivers/usb/dwc3/dwc3-meson-g12a.c:
PATCH 10/10 usb: Use ofnode as usb_get_maximum_speed() parameter
In reply to Kever Yangofnode is more common and no need to convert to offset after we migrate other API to use ofnode.
---
drivers/usb/cdns3/gadget.c | 2 +- drivers/usb/common/common.c | 5 ++--- drivers/usb/dwc3/dwc3-generic.c | 2 +- include/linux/usb/otg.h | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-)
drivers/usb/cdns3/gadget.c +1 -1
@@ -2576,7 +2576,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)if (!priv_dev->onchip_buffers) priv_dev->onchip_buffers =256 ; - max_speed =usb_get_maximum_speed (dev_of_offset (cdns->dev)); + max_speed =usb_get_maximum_speed (dev_ofnode (cdns->dev));/* Check the maximum_speed parameter */ switch (max_speed) {
drivers/usb/common/common.c +2 -3
@@ -47,13 +47,12 @@ static const char *const speed_names[] = { [USB_SPEED_SUPER] = "super-speed", }; -enum usb_device_speed usb_get_maximum_speed (int node) +enum usb_device_speed usb_get_maximum_speed (ofnode node) { -const void *fdt = gd->fdt_blob;const char *max_speed;int i; - max_speed =fdt_getprop (fdt, node,"maximum-speed" ,NULL ); + max_speed =ofnode_read_string (node,"maximum-speed" );if (!max_speed) {pr_err ("usb maximum-speed not found\n" );return USB_SPEED_UNKNOWN ;
drivers/usb/dwc3/dwc3-generic.c +1 -1
@@ -92,7 +92,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice *dev) plat->base =dev_read_addr (dev); - plat->maximum_speed =usb_get_maximum_speed (ofnode_to_offset (node)); + plat->maximum_speed =usb_get_maximum_speed (node);if (plat->maximum_speed ==USB_SPEED_UNKNOWN ) {pr_info ("No USB maximum speed specified. Using super speed\n" ); plat->maximum_speed =USB_SPEED_SUPER ;
include/linux/usb/otg.h +2 -2
@@ -27,11 +27,11 @@ enum usb_dr_mode usb_get_dr_mode(ofnode node);/** * usb_get_maximum_speed() - Get maximum speed for given device -* @node: Node offset to the given device +* @node: ofnode of the given device * * The function gets phy interface string from property 'maximum-speed', * and returns the correspondig enum usb_device_speed */ -enum usb_device_speed usb_get_maximum_speed (int node); +enum usb_device_speed usb_get_maximum_speed (ofnode node);#endif /* __LINUX_USB_OTG_H */
Signature · 1 line
2.17.1