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

login
register
mail settings
Submitter ramneek mehresh
Date Feb. 7, 2012, 5:17 a.m.
Message ID <1328591877-4601-1-git-send-email-ramneek.mehresh@freescale.com>
Download mbox | patch
Permalink /patch/139875/
State Superseded
Delegated to: Andy Fleming
Headers show

Comments

ramneek mehresh - Feb. 7, 2012, 5:17 a.m.
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>
---
Changes for v2:
        - used compat_dr and compat_mph strings instead of 
	  compat[] array
        - removed unrelated changes/fixes(which are sent in a separate patch)

 arch/powerpc/cpu/mpc8xxx/fdt.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
Tabi Timur-B04825 - Feb. 7, 2012, 2:06 p.m.
On Mon, Feb 6, 2012 at 11:17 PM, Ramneek Mehresh
<ramneek.mehresh@freescale.com> wrote:
>
> +                       start_offset, compat_mph);
>        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_dr);
> +               if (node_offset < 0) {
> +                       printf("WARNING: could not find compatible"
> +                               " node %s or %s: %s.\n", compat_mph,
> +                               compat_dr, fdt_strerror(node_offset));
> +                       return -1;
> +               } else
> +                       node_type = (char *)compat_dr;
> +       } else
> +               node_type = (char *)compat_mph;

If you make node_type into a const char *, can you remove these typecasts?

Patch

diff --git a/arch/powerpc/cpu/mpc8xxx/fdt.c b/arch/powerpc/cpu/mpc8xxx/fdt.c
index bc1c30e..0dc8419 100644
--- a/arch/powerpc/cpu/mpc8xxx/fdt.c
+++ b/arch/powerpc/cpu/mpc8xxx/fdt.c
@@ -86,30 +86,39 @@  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_dr = "fsl-usb2-dr";
+	const char *compat_mph = "fsl-usb2-mph";
 	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_mph);
 	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_dr);
+		if (node_offset < 0) {
+			printf("WARNING: could not find compatible"
+				" node %s or %s: %s.\n", compat_mph,
+				compat_dr, fdt_strerror(node_offset));
+			return -1;
+		} else
+			node_type = (char *)compat_dr;
+	} else
+		node_type = (char *)compat_mph;
 
 	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 +126,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;
@@ -180,7 +189,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