diff mbox

[U-Boot] powerpc/8xxx:Add MPH controller support in USB device-tree fixup

Message ID 1327663369-4449-1-git-send-email-ramneek.mehresh@freescale.com
State Superseded
Delegated to: Andy Fleming
Headers show

Commit Message

ramneek mehresh Jan. 27, 2012, 11:22 a.m. UTC
Add support for fixing usb mode and phy type for 
MPH(Multi Port Host) USB controllers in device-tree nodes.
Required for socs like P3060, P5020, etc having MPH USB controller.

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
---
 arch/powerpc/cpu/mpc8xxx/fdt.c |   46 ++++++++++++++++++++++++++--------------
 include/fdt_support.h          |    4 +-
 2 files changed, 32 insertions(+), 18 deletions(-)

Comments

Marek Vasut Feb. 26, 2012, 11:11 p.m. UTC | #1
> Add support for fixing usb mode and phy type for
> MPH(Multi Port Host) USB controllers in device-tree nodes.
> Required for socs like P3060, P5020, etc having MPH USB controller.
> 
> Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> ---
>  arch/powerpc/cpu/mpc8xxx/fdt.c |   46
> ++++++++++++++++++++++++++-------------- include/fdt_support.h          | 
>   4 +-
>  2 files changed, 32 insertions(+), 18
Hi,

what's the status of this patch/patchset?

Thanks
M
Mehresh Ramneek-B31383 Feb. 27, 2012, 4:56 a.m. UTC | #2
Hi Marek,

The final version of this patch is under review, didn't get any more comments, waiting for its acceptance...

http://patchwork.ozlabs.org/patch/140557/

Thanks and Regards,
Ramneek

> -----Original Message-----
> From: Marek Vasut [mailto:marex@denx.de]
> Sent: Monday, February 27, 2012 4:42 AM
> To: u-boot@lists.denx.de
> Cc: Mehresh Ramneek-B31383
> Subject: Re: [U-Boot] [PATCH]powerpc/8xxx:Add MPH controller support in
> USB device-tree fixup
> 
> > Add support for fixing usb mode and phy type for MPH(Multi Port Host)
> > USB controllers in device-tree nodes.
> > Required for socs like P3060, P5020, etc having MPH USB controller.
> >
> > Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> > ---
> >  arch/powerpc/cpu/mpc8xxx/fdt.c |   46
> > ++++++++++++++++++++++++++-------------- include/fdt_support.h
> |
> >   4 +-
> >  2 files changed, 32 insertions(+), 18
> Hi,
> 
> what's the status of this patch/patchset?
> 
> Thanks
> M
Marek Vasut Feb. 27, 2012, 1:54 p.m. UTC | #3
> Hi Marek,
> 
> The final version of this patch is under review, didn't get any more
> comments, waiting for its acceptance...
> 
> http://patchwork.ozlabs.org/patch/140557/

Someone who knows PowerPC would be welcome to review this patch. Otherwise, 
resubmit if this is forgotten please and Cc me.

Thanks for your good work!

M
> 
> Thanks and Regards,
> Ramneek
> 
> > -----Original Message-----
> > From: Marek Vasut [mailto:marex@denx.de]
> > Sent: Monday, February 27, 2012 4:42 AM
> > To: u-boot@lists.denx.de
> > Cc: Mehresh Ramneek-B31383
> > Subject: Re: [U-Boot] [PATCH]powerpc/8xxx:Add MPH controller support in
> > USB device-tree fixup
> > 
> > > Add support for fixing usb mode and phy type for MPH(Multi Port Host)
> > > USB controllers in device-tree nodes.
> > > Required for socs like P3060, P5020, etc having MPH USB controller.
> > > 
> > > Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
> > > ---
> > > 
> > >  arch/powerpc/cpu/mpc8xxx/fdt.c |   46
> > > 
> > > ++++++++++++++++++++++++++-------------- include/fdt_support.h
> > > 
> > >   4 +-
> > >  
> > >  2 files changed, 32 insertions(+), 18
> > 
> > Hi,
> > 
> > what's the status of this patch/patchset?
> > 
> > Thanks
> > M
diff mbox

Patch

diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c
index d07ae1b..b22e0ec 100644
--- a/arch/powerpc/cpu/mpc8xxx/fdt.c
+++ b/arch/powerpc/cpu/mpc8xxx/fdt.c
@@ -1,5 +1,5 @@ 
 /*
- * Copyright 2009-2011 Freescale Semiconductor, Inc.
+ * Copyright 2009-2012 Freescale Semiconductor, Inc.
  *
  * This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and
  * arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains
@@ -86,30 +86,38 @@  void ft_fixup_num_cores(void *blob) {
 }
 #endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */
 
-#ifdef CONFIG_HAS_FSL_DR_USB
+#if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
 static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
 				const char *phy_type, int start_offset)
 {
-	const char *compat = "fsl-usb2-dr";
+	const char *compat[] = {"fsl-usb2-mph", "fsl-usb2-dr"};
 	const char *prop_mode = "dr_mode";
 	const char *prop_type = "phy_type";
+	char *node_type = NULL;
 	int node_offset;
 	int err;
 
 	node_offset = fdt_node_offset_by_compatible(blob,
-			start_offset, compat);
+				start_offset, compat[0]);
 	if (node_offset < 0) {
-		printf("WARNING: could not find compatible node %s: %s.\n",
-			compat, fdt_strerror(node_offset));
-		return -1;
-	}
+		node_offset = fdt_node_offset_by_compatible(blob,
+				start_offset, compat[1]);
+		if (node_offset < 0) {
+			printf("WARNING: could not find compatible"
+				" node %s or %s: %s.\n", compat[0],
+				compat[1], fdt_strerror(node_offset));
+			return -1;
+		} else
+			node_type = (char *)compat[1];
+	} else
+		node_type = (char *)compat[0];
 
 	if (mode) {
 		err = fdt_setprop(blob, node_offset, prop_mode, mode,
 				  strlen(mode) + 1);
 		if (err < 0)
 			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_mode, compat, fdt_strerror(err));
+			       prop_mode, node_type, fdt_strerror(err));
 	}
 
 	if (phy_type) {
@@ -117,7 +125,7 @@  static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode,
 				  strlen(phy_type) + 1);
 		if (err < 0)
 			printf("WARNING: could not set %s for %s: %s.\n",
-			       prop_type, compat, fdt_strerror(err));
+			       prop_type, node_type, fdt_strerror(err));
 	}
 
 	return node_offset;
@@ -137,28 +145,34 @@  void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 
 	for (i = 1; i <= FSL_MAX_NUM_USB_CTRLS; i++) {
 		int mode_idx = -1, phy_idx = -1;
-		sprintf(str, "%s%d", "usb", i);
+		snprintf(str, 5, "%s%d", "usb", i);
 		if (hwconfig(str)) {
-			for (j = 0; j < sizeof(modes); j++) {
+			for (j = 0; j < sizeof(modes)/sizeof(char *); j++) {
 				if (hwconfig_subarg_cmp(str, "dr_mode",
 						modes[j])) {
 					mode_idx = j;
 					break;
 				}
 			}
-			for (j = 0; j < sizeof(phys); j++) {
+			for (j = 0; j < sizeof(phys)/sizeof(char *); j++) {
 				if (hwconfig_subarg_cmp(str, "phy_type",
 						phys[j])) {
 					phy_idx = j;
 					break;
 				}
 			}
-			if (mode_idx >= 0)
+			if (mode_idx >= 0) {
 				usb_mode_off = fdt_fixup_usb_mode_phy_type(blob,
 					modes[mode_idx], NULL, usb_mode_off);
-			if (phy_idx >= 0)
+				if (usb_mode_off < 0)
+					return;
+			}
+			if (phy_idx >= 0) {
 				usb_phy_off = fdt_fixup_usb_mode_phy_type(blob,
 					NULL, phys[phy_idx], usb_phy_off);
+				if (usb_phy_off < 0)
+					return;
+			}
 			if (!strcmp(str, "usb1"))
 				usb1_defined = 1;
 			if (mode_idx < 0 && phy_idx < 0)
@@ -174,7 +188,7 @@  void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 		fdt_fixup_usb_mode_phy_type(blob, mode, phy_type, usb_off);
 	}
 }
-#endif /* CONFIG_HAS_FSL_DR_USB */
+#endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */
 
 /*
  * update crypto node properties to a specified revision of the SEC
diff --git a/include/fdt_support.h b/include/fdt_support.h
index cef3c65..4b9f84a 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -61,11 +61,11 @@  int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
 			 const void *val, int len, int create);
 void fdt_fixup_qe_firmware(void *fdt);
 
-#ifdef CONFIG_HAS_FSL_DR_USB
+#if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
 void fdt_fixup_dr_usb(void *blob, bd_t *bd);
 #else
 static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
-#endif /* CONFIG_HAS_FSL_DR_USB */
+#endif /* defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) */
 
 #if defined(CONFIG_SYS_FSL_SEC_COMPAT)
 void fdt_fixup_crypto_node(void *blob, int sec_rev);