Patchwork [U-Boot,RFC,02/10] nvidia, tegra: new USB hardware init interface

login
register
mail settings
Submitter Mateusz Zalega
Date Aug. 6, 2013, 10:50 a.m.
Message ID <1375786242-11734-3-git-send-email-m.zalega@samsung.com>
Download mbox | patch
Permalink /patch/265011/
State RFC
Headers show

Comments

Mateusz Zalega - Aug. 6, 2013, 10:50 a.m.
This commit postpones initialization of USB hardware until
usb_board_init() is called by a command implementation
(ie. do_dfu()) or a driver.

Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Tom Warren <twarren@nvidia.com>
---
 arch/arm/include/asm/arch-tegra/usb.h |  3 +--
 board/nvidia/common/board.c           | 14 ++++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)
Stephen Warren - Aug. 7, 2013, 4:26 p.m.
On 08/06/2013 04:50 AM, Mateusz Zalega wrote:
> This commit postpones initialization of USB hardware until
> usb_board_init() is called by a command implementation
> (ie. do_dfu()) or a driver.

> diff --git a/arch/arm/include/asm/arch-tegra/usb.h b/arch/arm/include/asm/arch-tegra/usb.h

>  /* Setup USB on the board */
> -int board_usb_init(const void *blob);
> +int usb_process_devicetree(const void *blob);

This needs to be part of the previous patch (or part of that patch needs
to be split out and put into this patch) so that this prototype change
happens in the same patch that the implementation is renamed. Perhaps
this can happen before the current patch 1?

> diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c

> @@ -151,10 +152,6 @@ int board_init(void)
>  # endif /* CONFIG_TEGRA_PMU */
>  #endif /* CONFIG_SYS_I2C_TEGRA */
>  
> -#ifdef CONFIG_USB_EHCI_TEGRA
> -	pin_mux_usb();
> -	board_usb_init(gd->fdt_blob);
> -#endif

> +#ifdef CONFIG_USB_EHCI_TEGRA
> +int board_usb_init(enum board_usb_init_type what_to_init)
> +{
> +	pin_mux_usb();
> +	usb_process_devicetree(gd->fdt_blob);
> +	return 0;
> +}
> +#endif

Moving the pinmux initialization might be dangerous; pin_mux_usb() might
prevent the pins used for USB having a mux function selected that
conflicts with some other pins selected mux function. We really do need
to initialize all of the pinmux early, and not defer it.

Patch

diff --git a/arch/arm/include/asm/arch-tegra/usb.h b/arch/arm/include/asm/arch-tegra/usb.h
index f66257c..a1efd07 100644
--- a/arch/arm/include/asm/arch-tegra/usb.h
+++ b/arch/arm/include/asm/arch-tegra/usb.h
@@ -131,8 +131,7 @@ 
 /* USB3_IF_USB_PHY_VBUS_SENSORS_0 */
 #define VBUS_VLD_STS			(1 << 26)
 
-
 /* Setup USB on the board */
-int board_usb_init(const void *blob);
+int usb_process_devicetree(const void *blob);
 
 #endif	/* _TEGRA_USB_H_ */
diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index 126e56e..cdb02ee 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -32,6 +32,7 @@ 
 #ifdef CONFIG_USB_EHCI_TEGRA
 #include <asm/arch-tegra/usb.h>
 #include <asm/arch/usb.h>
+#include <usb.h>
 #endif
 #ifdef CONFIG_TEGRA_MMC
 #include <asm/arch-tegra/tegra_mmc.h>
@@ -151,10 +152,6 @@  int board_init(void)
 # endif /* CONFIG_TEGRA_PMU */
 #endif /* CONFIG_SYS_I2C_TEGRA */
 
-#ifdef CONFIG_USB_EHCI_TEGRA
-	pin_mux_usb();
-	board_usb_init(gd->fdt_blob);
-#endif
 #ifdef CONFIG_LCD
 	tegra_lcd_check_next_stage(gd->fdt_blob, 0);
 #endif
@@ -257,3 +254,12 @@  void pad_init_mmc(struct mmc_host *host)
 #endif	/* T30 */
 }
 #endif	/* MMC */
+
+#ifdef CONFIG_USB_EHCI_TEGRA
+int board_usb_init(enum board_usb_init_type what_to_init)
+{
+	pin_mux_usb();
+	usb_process_devicetree(gd->fdt_blob);
+	return 0;
+}
+#endif