powerpc/85xx: Specify hwconfig usage for USB controller
PATCH 1/2 powerpc/85xx: Specify hwconfig usage for USB controller
From: Ramneek Mehresh <[email protected]>
Specify hwconfig usage for USB mode and phy change
--- doc/README.fsl-hwconfig | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
doc/README.fsl-hwconfig +26 -0
@@ -19,3 +19,29 @@ audclk 'audclk:12' Select the 12.288MHz clock + +usb + Specific to boards have USB controller + + This option specifies the following for a USB controller: + + - which controller mode to use + - which USB PHY to use + + This is used by generic USB device-tree fixup function to update + modified values of phy type and controller mode. + + Also used for configuring multiple USB controllers such that + 'usbN' (where N is 1, 2, etc. refers to controller no.) + + 'phy_type' + Select USB phy type: 'utmi' OR 'ulpi' + + 'dr_mode' + Select USB controller mode: 'host', 'peripheral' OR 'otg' + + Examples: + usb1:dr_mode=host;usb2:dr_mode=peripheral' + + usb1:dr_mode=host,phy_type=utmi;usb2:dr_mode=host' +
Signature · 1 line
1.7.2.3
Kumar Gala
AppliedPATCH 1/2 powerpc/85xx: Specify hwconfig usage for USB controller
Quoted 9 lines · Kumar Gala
From: Ramneek Mehresh <[email protected]>
Specify hwconfig usage for USB mode and phy change
Signed-off-by Ramneek Mehresh <[email protected]>Signed-off-by Kumar Gala <[email protected]>---
doc/README.fsl-hwconfig | 26 ++++++++++++++++++++++++++1 files changed, 26 insertions(+), 0 deletions(-)
applied to 85xx
- k
PATCH 2/2 powerpc/8xxx: Update USB device tree fixup
In reply to Kumar GalaFrom: Ramneek Mehresh <[email protected]>
Modify support for USB mode fixup:
* Add support for fetching USB mode and phy type via hwconfig
* Add common support for USB mode and phy type device tree fix-up for all USB controllers mentioned in hwconfig string
--- arch/powerpc/cpu/mpc8xxx/fdt.c | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 67 insertions(+), 14 deletions(-)
arch/powerpc/cpu/mpc8xxx/fdt.c +67 -14
@@ -29,6 +29,10 @@#include <asm/mp.h> #include <asm/fsl_enet.h> #include <asm/fsl_serdes.h> +#include <hwconfig.h> +#ifdef CONFIG_HAS_FSL_DR_USB +#include <usb.h> +#endif #if defined(CONFIG_MP ) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))static int ft_del_cpuhandle (void *blob,int cpuhandle)
@@ -84,25 +88,22 @@ void ft_fixup_num_cores(void *blob) {#endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ #ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb (void *blob,bd_t *bd) +static void fdt_fixup_usb_mode_phy_type (void *blob,const char *mode, +const char *phy_type) { -char *mode; -char *type;const char *compat ="fsl-usb2-dr" ;const char *prop_mode ="dr_mode" ;const char *prop_type ="phy_type" ; +static int start_offset =-1 ;int node_offset;int err; - mode =getenv ("usb_dr_mode" ); - type =getenv ("usb_phy_type" ); -if (!mode && !type) -return ; - - node_offset =fdt_node_offset_by_compatible (blob,0 , compat); + node_offset =fdt_node_offset_by_compatible (blob, + start_offset, compat);if (node_offset <0 ) { -printf ("WARNING: could not find compatible node %s: %s.\n" , - compat,fdt_strerror (node_offset)); +printf ("WARNING: could not find compatible" +"node %s: %s.\n" , compat, +fdt_strerror (node_offset));return ; }
@@ -114,14 +115,66 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) prop_mode, compat, fdt_strerror(err)); } -if (type) { - err =fdt_setprop (blob, node_offset, prop_type, type, -strlen (type) +1 ); +if (phy_type) { + err =fdt_setprop (blob, node_offset, prop_type, phy_type, +strlen (phy_type) +1 );if (err <0 )printf ("WARNING: could not set %s for %s: %s.\n" , prop_type, compat,fdt_strerror (err)); } + + start_offset = node_offset; } + +void fdt_fixup_dr_usb (void *blob,bd_t *bd) +{ +const char *modes[] = {"host" ,"peripheral" ,"otg" }; +const char *phys[] = {"ulpi" ,"umti" }; +const char *mode =NULL ; +const char *phy_type =NULL ; +char str[5 ]; +char usb1_defined =0 ; +int i, j; + +for (i =1 ; i <=USB_MAX_DEVICE ; i++) { +int mode_idx =-1 , phy_idx =-1 ; +sprintf (str,"%s%d" ,"usb" , i); +if (hwconfig (str)) { +for (j =0 ; j <sizeof (modes); j++) { +if (hwconfig_subarg_cmp (str,"dr_mode" , + modes[j])) { + mode_idx = j; +break ; + } + } +for (j =0 ; j <sizeof (phys); j++) { +if (hwconfig_subarg_cmp (str,"phy_type" , + phys[j])) { + phy_idx =-1 ; +break ; + } + } +if ((mode_idx >=0 ) || (phy_idx >=0 )) { +fdt_fixup_usb_mode_phy_type (blob, + modes[mode_idx], phys[phy_idx]); +if (!strcmp (str,"usb1" )) + usb1_defined =1 ; + }else { +printf ("WARNING: invalid phy or mode\n" ); + } + }else { +break ; + } + } +if (!usb1_defined) { + mode =getenv ("usb_dr_mode" ); + phy_type =getenv ("usb_phy_type" ); +if (!mode && !phy_type) +return ; +fdt_fixup_usb_mode_phy_type (blob, mode, phy_type); + } +} +#endif /* CONFIG_HAS_FSL_DR_USB */ /*
Signature · 1 line
1.7.2.3
PATCH v2 2/2 powerpc/8xxx: Update USB device tree fixup
From: Ramneek Mehresh <[email protected]>
Modify support for USB mode fixup:
* Add support for fetching USB mode and phy type via hwconfig
* Add common support for USB mode and phy type device tree fix-up for all USB controllers mentioned in hwconfig string
---
* minor bug fix in fdt_fixup_dr_usb logic:
mode_idx should be set to 'j'.
arch/powerpc/cpu/mpc8xxx/fdt.c | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 67 insertions(+), 14 deletions(-)
arch/powerpc/cpu/mpc8xxx/fdt.c +67 -14
@@ -29,6 +29,10 @@#include <asm/mp.h> #include <asm/fsl_enet.h> #include <asm/fsl_serdes.h> +#include <hwconfig.h> +#ifdef CONFIG_HAS_FSL_DR_USB +#include <usb.h> +#endif #if defined(CONFIG_MP ) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))static int ft_del_cpuhandle (void *blob,int cpuhandle)
@@ -84,25 +88,22 @@ void ft_fixup_num_cores(void *blob) {#endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ #ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb (void *blob,bd_t *bd) +static void fdt_fixup_usb_mode_phy_type (void *blob,const char *mode, +const char *phy_type) { -char *mode; -char *type;const char *compat ="fsl-usb2-dr" ;const char *prop_mode ="dr_mode" ;const char *prop_type ="phy_type" ; +static int start_offset =-1 ;int node_offset;int err; - mode =getenv ("usb_dr_mode" ); - type =getenv ("usb_phy_type" ); -if (!mode && !type) -return ; - - node_offset =fdt_node_offset_by_compatible (blob,0 , compat); + node_offset =fdt_node_offset_by_compatible (blob, + start_offset, compat);if (node_offset <0 ) { -printf ("WARNING: could not find compatible node %s: %s.\n" , - compat,fdt_strerror (node_offset)); +printf ("WARNING: could not find compatible" +"node %s: %s.\n" , compat, +fdt_strerror (node_offset));return ; }
@@ -114,14 +115,66 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) prop_mode, compat, fdt_strerror(err)); } -if (type) { - err =fdt_setprop (blob, node_offset, prop_type, type, -strlen (type) +1 ); +if (phy_type) { + err =fdt_setprop (blob, node_offset, prop_type, phy_type, +strlen (phy_type) +1 );if (err <0 )printf ("WARNING: could not set %s for %s: %s.\n" , prop_type, compat,fdt_strerror (err)); } + + start_offset = node_offset; } + +void fdt_fixup_dr_usb (void *blob,bd_t *bd) +{ +const char *modes[] = {"host" ,"peripheral" ,"otg" }; +const char *phys[] = {"ulpi" ,"umti" }; +const char *mode =NULL ; +const char *phy_type =NULL ; +char str[5 ]; +char usb1_defined =0 ; +int i, j; + +for (i =1 ; i <=USB_MAX_DEVICE ; i++) { +int mode_idx =-1 , phy_idx =-1 ; +sprintf (str,"%s%d" ,"usb" , i); +if (hwconfig (str)) { +for (j =0 ; j <sizeof (modes); j++) { +if (hwconfig_subarg_cmp (str,"dr_mode" , + modes[j])) { + mode_idx = j; +break ; + } + } +for (j =0 ; j <sizeof (phys); j++) { +if (hwconfig_subarg_cmp (str,"phy_type" , + phys[j])) { + phy_idx =-1 ; +break ; + } + } +if ((mode_idx >=0 ) || (phy_idx >=0 )) { +fdt_fixup_usb_mode_phy_type (blob, + modes[mode_idx], phys[phy_idx]); +if (!strcmp (str,"usb1" )) + usb1_defined =1 ; + }else { +printf ("WARNING: invalid phy or mode\n" ); + } + }else { +break ; + } + } +if (!usb1_defined) { + mode =getenv ("usb_dr_mode" ); + phy_type =getenv ("usb_phy_type" ); +if (!mode && !phy_type) +return ; +fdt_fixup_usb_mode_phy_type (blob, mode, phy_type); + } +} +#endif /* CONFIG_HAS_FSL_DR_USB */ /*
Signature · 1 line
1.7.2.3
PATCH v3 2/2 powerpc/8xxx: Update USB device tree fixup
In reply to Kumar GalaFrom: Ramneek Mehresh <[email protected]>
Modify support for USB mode fixup:
* Add support for fetching USB mode and phy type via hwconfig
* Add common support for USB mode and phy type device tree fix-up for all USB controllers mentioned in hwconfig string
---
v2:
* minor bug fix in fdt_fixup_dr_usb logic:
mode_idx should be set to 'j'.
v3:
* Same issues as v2, but for phy_idx
arch/powerpc/cpu/mpc8xxx/fdt.c | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 67 insertions(+), 14 deletions(-)
arch/powerpc/cpu/mpc8xxx/fdt.c +67 -14
@@ -29,6 +29,10 @@#include <asm/mp.h> #include <asm/fsl_enet.h> #include <asm/fsl_serdes.h> +#include <hwconfig.h> +#ifdef CONFIG_HAS_FSL_DR_USB +#include <usb.h> +#endif #if defined(CONFIG_MP ) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))static int ft_del_cpuhandle (void *blob,int cpuhandle)
@@ -84,25 +88,22 @@ void ft_fixup_num_cores(void *blob) {#endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */ #ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb (void *blob,bd_t *bd) +static void fdt_fixup_usb_mode_phy_type (void *blob,const char *mode, +const char *phy_type) { -char *mode; -char *type;const char *compat ="fsl-usb2-dr" ;const char *prop_mode ="dr_mode" ;const char *prop_type ="phy_type" ; +static int start_offset =-1 ;int node_offset;int err; - mode =getenv ("usb_dr_mode" ); - type =getenv ("usb_phy_type" ); -if (!mode && !type) -return ; - - node_offset =fdt_node_offset_by_compatible (blob,0 , compat); + node_offset =fdt_node_offset_by_compatible (blob, + start_offset, compat);if (node_offset <0 ) { -printf ("WARNING: could not find compatible node %s: %s.\n" , - compat,fdt_strerror (node_offset)); +printf ("WARNING: could not find compatible" +"node %s: %s.\n" , compat, +fdt_strerror (node_offset));return ; }
@@ -114,14 +115,66 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) prop_mode, compat, fdt_strerror(err)); } -if (type) { - err =fdt_setprop (blob, node_offset, prop_type, type, -strlen (type) +1 ); +if (phy_type) { + err =fdt_setprop (blob, node_offset, prop_type, phy_type, +strlen (phy_type) +1 );if (err <0 )printf ("WARNING: could not set %s for %s: %s.\n" , prop_type, compat,fdt_strerror (err)); } + + start_offset = node_offset; } + +void fdt_fixup_dr_usb (void *blob,bd_t *bd) +{ +const char *modes[] = {"host" ,"peripheral" ,"otg" }; +const char *phys[] = {"ulpi" ,"umti" }; +const char *mode =NULL ; +const char *phy_type =NULL ; +char str[5 ]; +char usb1_defined =0 ; +int i, j; + +for (i =1 ; i <=USB_MAX_DEVICE ; i++) { +int mode_idx =-1 , phy_idx =-1 ; +sprintf (str,"%s%d" ,"usb" , i); +if (hwconfig (str)) { +for (j =0 ; j <sizeof (modes); j++) { +if (hwconfig_subarg_cmp (str,"dr_mode" , + modes[j])) { + mode_idx = j; +break ; + } + } +for (j =0 ; j <sizeof (phys); j++) { +if (hwconfig_subarg_cmp (str,"phy_type" , + phys[j])) { + phy_idx = j; +break ; + } + } +if ((mode_idx >=0 ) || (phy_idx >=0 )) { +fdt_fixup_usb_mode_phy_type (blob, + modes[mode_idx], phys[phy_idx]); +if (!strcmp (str,"usb1" )) + usb1_defined =1 ; + }else { +printf ("WARNING: invalid phy or mode\n" ); + } + }else { +break ; + } + } +if (!usb1_defined) { + mode =getenv ("usb_dr_mode" ); + phy_type =getenv ("usb_phy_type" ); +if (!mode && !phy_type) +return ; +fdt_fixup_usb_mode_phy_type (blob, mode, phy_type); + } +} +#endif /* CONFIG_HAS_FSL_DR_USB */ /*
Signature · 1 line
1.7.2.3