Patchwork [U-Boot,PATCHv3,2/4] at91sam9x5: enable USB support for 9x5ek board.

login
register
mail settings
Submitter Richard Genoud
Date Nov. 30, 2012, 9:18 a.m.
Message ID <50b879f9.0652b40a.733e.74b1@mx.google.com>
Download mbox | patch
Permalink /patch/202898/
State Accepted
Delegated to: Andreas Bießmann
Headers show

Comments

Richard Genoud - Nov. 30, 2012, 9:18 a.m.
From: Richard Genoud <richard.genoud@gmail.com>

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
 arch/arm/include/asm/arch-at91/at91sam9x5.h      |    2 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c          |    3 +++
 drivers/usb/host/ohci-at91.c                     |    6 ++++--
 4 files changed, 22 insertions(+), 2 deletions(-)
Bo Shen - Nov. 30, 2012, 9:37 a.m.
On 11/30/2012 17:18, richard.genoud@gmail.com wrote:
> From: Richard Genoud <richard.genoud@gmail.com>
>
> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>

Acked-by: Bo Shen <voice.shen@atmel.com

> ---
>   arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>   arch/arm/include/asm/arch-at91/at91sam9x5.h      |    2 ++
>   board/atmel/at91sam9x5ek/at91sam9x5ek.c          |    3 +++
>   drivers/usb/host/ohci-at91.c                     |    6 ++++--
>   4 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> index 9348552..0448c0b 100644
> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> @@ -193,6 +193,19 @@ void at91_spi1_hw_init(unsigned long cs_mask)
>   }
>   #endif
>
> +#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
> +void at91_uhp_hw_init(void)
> +{
> +	/* Enable VBus on UHP ports */
> +	at91_set_pio_output(AT91_PIO_PORTD, 18, 0); /* port A */
> +	at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* port B */
> +#if defined(CONFIG_USB_OHCI_NEW)
> +	/* port C is OHCI only */
> +	at91_set_pio_output(AT91_PIO_PORTD, 20, 0); /* port C */
> +#endif
> +}
> +#endif
> +
>   #ifdef CONFIG_MACB
>   void at91_macb_hw_init(void)
>   {
> diff --git a/arch/arm/include/asm/arch-at91/at91sam9x5.h b/arch/arm/include/asm/arch-at91/at91sam9x5.h
> index 0e728c9..de0f1b1 100644
> --- a/arch/arm/include/asm/arch-at91/at91sam9x5.h
> +++ b/arch/arm/include/asm/arch-at91/at91sam9x5.h
> @@ -154,6 +154,8 @@
>   #define ATMEL_PIO_PORTS         4
>   #define CPU_HAS_PIO3
>   #define PIO_SCDR_DIV            (0x3fff <<  0)  /* Slow Clock Divider Mask */
> +#define ATMEL_PMC_UHP		AT91SAM926x_PMC_UHP
> +#define ATMEL_ID_UHP		ATMEL_ID_UHPHS
>
>   /*
>    * at91sam9x5 specific prototypes
> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> index edb0886..8773e6f 100644
> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> @@ -295,6 +295,9 @@ int board_init(void)
>   	at91_macb_hw_init();
>   #endif
>
> +#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
> +	at91_uhp_hw_init();
> +#endif
>   #ifdef CONFIG_LCD
>   	at91sam9x5ek_lcd_hw_init();
>   #endif
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 9532dd9..efd711d 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -41,7 +41,8 @@ int usb_cpu_init(void)
>   	writel(get_pllb_init(), &pmc->pllbr);
>   	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
>   		;
> -#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
> +#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
> +	defined(CONFIG_AT91SAM9X5)
>   	/* Enable UPLL */
>   	writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
>   		&pmc->uckr);
> @@ -81,7 +82,8 @@ int usb_cpu_stop(void)
>   	writel(0, &pmc->pllbr);
>   	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
>   		;
> -#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
> +#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
> +	defined(CONFIG_AT91SAM9X5)
>   	/* Disable UPLL */
>   	writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
>   	while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
>
Andreas Bießmann - Dec. 9, 2012, 9:43 p.m.
Dear richard.genoud@gmail.com,

On 30.11.2012 10:18, richard.genoud@gmail.com wrote:
> From: Richard Genoud <richard.genoud@gmail.com>
>
> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
> ---
>   arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +++++++++++++
>   arch/arm/include/asm/arch-at91/at91sam9x5.h      |    2 ++
>   board/atmel/at91sam9x5ek/at91sam9x5ek.c          |    3 +++
>   drivers/usb/host/ohci-at91.c                     |    6 ++++--
>   4 files changed, 22 insertions(+), 2 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards

Andreas Bießmann

Patch

diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
index 9348552..0448c0b 100644
--- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
@@ -193,6 +193,19 @@  void at91_spi1_hw_init(unsigned long cs_mask)
 }
 #endif
 
+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+void at91_uhp_hw_init(void)
+{
+	/* Enable VBus on UHP ports */
+	at91_set_pio_output(AT91_PIO_PORTD, 18, 0); /* port A */
+	at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* port B */
+#if defined(CONFIG_USB_OHCI_NEW)
+	/* port C is OHCI only */
+	at91_set_pio_output(AT91_PIO_PORTD, 20, 0); /* port C */
+#endif
+}
+#endif
+
 #ifdef CONFIG_MACB
 void at91_macb_hw_init(void)
 {
diff --git a/arch/arm/include/asm/arch-at91/at91sam9x5.h b/arch/arm/include/asm/arch-at91/at91sam9x5.h
index 0e728c9..de0f1b1 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9x5.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9x5.h
@@ -154,6 +154,8 @@ 
 #define ATMEL_PIO_PORTS         4
 #define CPU_HAS_PIO3
 #define PIO_SCDR_DIV            (0x3fff <<  0)  /* Slow Clock Divider Mask */
+#define ATMEL_PMC_UHP		AT91SAM926x_PMC_UHP
+#define ATMEL_ID_UHP		ATMEL_ID_UHPHS
 
 /*
  * at91sam9x5 specific prototypes
diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index edb0886..8773e6f 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -295,6 +295,9 @@  int board_init(void)
 	at91_macb_hw_init();
 #endif
 
+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+	at91_uhp_hw_init();
+#endif
 #ifdef CONFIG_LCD
 	at91sam9x5ek_lcd_hw_init();
 #endif
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 9532dd9..efd711d 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -41,7 +41,8 @@  int usb_cpu_init(void)
 	writel(get_pllb_init(), &pmc->pllbr);
 	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
 		;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+	defined(CONFIG_AT91SAM9X5)
 	/* Enable UPLL */
 	writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
 		&pmc->uckr);
@@ -81,7 +82,8 @@  int usb_cpu_stop(void)
 	writel(0, &pmc->pllbr);
 	while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
 		;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+	defined(CONFIG_AT91SAM9X5)
 	/* Disable UPLL */
 	writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
 	while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)