arm: atmel: at91sam9n12ek: add usb host support
Subsystems (4)
PATCH 1/2 arm: atmel: at91sam9n12ek: add usb host support
Add usb host support for at91sam9n12ek board.
--- arch/arm/include/asm/arch-at91/at91_pmc.h | 2 ++ board/atmel/at91sam9n12ek/at91sam9n12ek.c | 11 +++++++++++ drivers/usb/host/ohci-at91.c | 11 +++++++++-- include/configs/at91sam9n12ek.h | 12 ++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-at91/at91_pmc.h +2 -0
@@ -233,6 +233,8 @@ typedef struct at91_pmc {#endif #define AT91_PMC_USBS_USB_PLLA (0x0)/* USB Clock Input is PLLA */ #define AT91_PMC_USBS_USB_UPLL (0x1)/* USB Clock Input is UPLL */ +#define AT91_PMC_USBS_USB_PLLB (0x1)/* USB Clock Input is PLLB, AT91SAM9N12 only */ +#define AT91_PMC_USB_DIV_2 (0x1 << 8)/* USB Clock divided by 2 */ #define AT91_PMC_USBDIV_8 (0x7 << 8)/* USB Clock divided by 8 */ #define AT91_PMC_USBDIV_10 (0x9 << 8)/* USB Clock divided by 10 */
board/atmel/at91sam9n12ek/at91sam9n12ek.c +11 -0
@@ -199,6 +199,13 @@ void at91sam9n12ek_ks8851_hw_init(void) }#endif +#ifdef CONFIG_USB_ATMEL +void at91sam9n12ek_usb_hw_init (void ) +{ +at91_set_pio_output (AT91_PIO_PORTB ,7 ,0 ); +} +#endif +int board_early_init_f (void ) {/* Enable clocks for all PIOs */
@@ -230,6 +237,10 @@ int board_init(void)at91sam9n12ek_ks8851_hw_init ();#endif +#ifdef CONFIG_USB_ATMEL +at91sam9n12ek_usb_hw_init (); +#endif +return 0 ; }
drivers/usb/host/ohci-at91.c +9 -2
@@ -20,11 +20,14 @@ int usb_cpu_init(void)#if defined(CONFIG_AT91CAP9 ) || defined(CONFIG_AT91SAM9260 ) || \ defined(CONFIG_AT91SAM9263 ) || defined(CONFIG_AT91SAM9G20 ) || \ - defined(CONFIG_AT91SAM9261 ) + defined(CONFIG_AT91SAM9261 ) || defined(CONFIG_AT91SAM9N12 )/* Enable PLLB */ writel (get_pllb_init (), &pmc->pllbr);while ((readl (&pmc->sr) &AT91_PMC_LOCKB ) !=AT91_PMC_LOCKB ) ; +#ifdef CONFIG_AT91SAM9N12 +writel (AT91_PMC_USBS_USB_PLLB |AT91_PMC_USB_DIV_2 , &pmc->usb); +#endif #elif defined(CONFIG_AT91SAM9G45 ) || defined(CONFIG_AT91SAM9M10G45 ) || \ defined(CONFIG_AT91SAM9X5 ) || defined(CONFIG_SAMA5D3 )/* Enable UPLL */
@@ -71,7 +74,11 @@ int usb_cpu_stop(void)#endif #if defined(CONFIG_AT91CAP9 ) || defined(CONFIG_AT91SAM9260 ) || \ - defined(CONFIG_AT91SAM9263 ) || defined(CONFIG_AT91SAM9G20 ) + defined(CONFIG_AT91SAM9263 ) || defined(CONFIG_AT91SAM9G20 ) || \ + defined(CONFIG_AT91SAM9N12 ) +#ifdef CONFIG_AT91SAM9N12 +writel (0 , &pmc->usb); +#endif /* Disable PLLB */ writel (0 , &pmc->pllbr);while ((readl (&pmc->sr) &AT91_PMC_LOCKB ) !=0 )
include/configs/at91sam9n12ek.h +12 -0
@@ -83,6 +83,7 @@#define CONFIG_CMD_SF #define CONFIG_CMD_MMC #define CONFIG_CMD_FAT +#define CONFIG_CMD_USB #define CONFIG_NR_DRAM_BANKS 1#define CONFIG_SYS_SDRAM_BASE 0x20000000
@@ -163,6 +164,17 @@#define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE#define CONFIG_SYS_MEMTEST_END 0x26e00000 +/* USB host */ +#ifdef CONFIG_CMD_USB +#define CONFIG_USB_ATMEL +#define CONFIG_USB_OHCI_NEW +#define CONFIG_SYS_USB_OHCI_CPU_INIT +#define CONFIG_SYS_USB_OHCI_REGS_BASE ATMEL_BASE_OHCI +#define CONFIG_SYS_USB_OHCI_SLOT_NAME "at91sam9n12" +#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1 +#define CONFIG_USB_STORAGE +#endif +#ifdef CONFIG_SYS_USE_SPIFLASH /* bootstrap + u-boot + env + linux in dataflash on CS0 */
Signature · 1 line
1.7.9.5
PATCH 2/2 arm: atmel: get rid of too many ifdeffery
Get rid of too many ifdeffery in usb ohci driver
Add following two configuration for USB clock selecting
- CONFIG_USB_ATMEL_CLK_SEL_PLLB: using PLLB as usb ohci input clock
- CONFIG_USB_ATMEL_CLK_SEL_UPLL: using UPLL as usb ohci input clock
--- drivers/usb/host/ohci-at91.c | 14 ++++---------- include/configs/afeb9260.h | 1 + include/configs/at91rm9200ek.h | 1 + include/configs/at91sam9260ek.h | 1 + include/configs/at91sam9261ek.h | 1 + include/configs/at91sam9263ek.h | 1 + include/configs/at91sam9n12ek.h | 1 + include/configs/at91sam9x5ek.h | 3 ++- include/configs/cpu9260.h | 1 + include/configs/cpuat91.h | 1 + include/configs/eb_cpux9k2.h | 1 + include/configs/ethernut5.h | 1 + include/configs/meesc.h | 1 + include/configs/otc570.h | 1 + include/configs/pm9261.h | 1 + include/configs/pm9263.h | 1 + include/configs/pm9g45.h | 1 + include/configs/sama5d3xek.h | 1 + include/configs/sbc35_a9g20.h | 1 + include/configs/snapper9260.h | 1 + include/configs/stamp9g20.h | 1 + include/configs/top9000.h | 1 + include/configs/vl_ma2sc.h | 1 + 23 files changed, 27 insertions(+), 11 deletions(-)
drivers/usb/host/ohci-at91.c +4 -10
@@ -18,9 +18,7 @@ int usb_cpu_init(void) {at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC ; -#if defined(CONFIG_AT91CAP9 ) || defined(CONFIG_AT91SAM9260 ) || \ - defined(CONFIG_AT91SAM9263 ) || defined(CONFIG_AT91SAM9G20 ) || \ - defined(CONFIG_AT91SAM9261 ) || defined(CONFIG_AT91SAM9N12 ) +#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB /* Enable PLLB */ writel (get_pllb_init (), &pmc->pllbr);while ((readl (&pmc->sr) &AT91_PMC_LOCKB ) !=AT91_PMC_LOCKB )
@@ -28,8 +26,7 @@ int usb_cpu_init(void)#ifdef CONFIG_AT91SAM9N12 writel (AT91_PMC_USBS_USB_PLLB |AT91_PMC_USB_DIV_2 , &pmc->usb);#endif -#elif defined(CONFIG_AT91SAM9G45 ) || defined(CONFIG_AT91SAM9M10G45 ) || \ - defined(CONFIG_AT91SAM9X5 ) || defined(CONFIG_SAMA5D3 ) +#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL )/* Enable UPLL */ writel (readl (&pmc->uckr) |AT91_PMC_UPLLEN |AT91_PMC_BIASEN , &pmc->uckr);
@@ -73,9 +70,7 @@ int usb_cpu_stop(void)writel (ATMEL_PMC_UHP , &pmc->scdr);#endif -#if defined(CONFIG_AT91CAP9 ) || defined(CONFIG_AT91SAM9260 ) || \ - defined(CONFIG_AT91SAM9263 ) || defined(CONFIG_AT91SAM9G20 ) || \ - defined(CONFIG_AT91SAM9N12 ) +#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB #ifdef CONFIG_AT91SAM9N12 writel (0 , &pmc->usb);#endif
@@ -83,8 +78,7 @@ int usb_cpu_stop(void)writel (0 , &pmc->pllbr);while ((readl (&pmc->sr) &AT91_PMC_LOCKB ) !=0 ) ; -#elif defined(CONFIG_AT91SAM9G45 ) || defined(CONFIG_AT91SAM9M10G45 ) || \ - defined(CONFIG_AT91SAM9X5 ) || defined(CONFIG_SAMA5D3 ) +#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL )/* Disable UPLL */ writel (readl (&pmc->uckr) & (~AT91_PMC_UPLLEN ), &pmc->uckr);while ((readl (&pmc->sr) &AT91_PMC_LOCKU ) ==AT91_PMC_LOCKU )
include/configs/afeb9260.h +1 -0
@@ -112,6 +112,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/at91rm9200ek.h +1 -0
@@ -154,6 +154,7 @@* USB Config */ #define CONFIG_USB_ATMEL 1 +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW 1#define CONFIG_USB_KEYBOARD 1#define CONFIG_USB_STORAGE 1
include/configs/at91sam9260ek.h +1 -0
@@ -185,6 +185,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW 1#define CONFIG_SYS_USB_OHCI_CPU_INIT 1#define CONFIG_SYS_USB_OHCI_REGS_BASE 0x00500000/* AT91SAM9260_UHP_BASE */
include/configs/at91sam9261ek.h +1 -0
@@ -146,6 +146,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/at91sam9263ek.h +1 -0
@@ -279,6 +279,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW 1#define CONFIG_DOS_PARTITION 1#define CONFIG_SYS_USB_OHCI_CPU_INIT 1
include/configs/at91sam9n12ek.h +1 -0
@@ -167,6 +167,7 @@/* USB host */ #ifdef CONFIG_CMD_USB #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_CPU_INIT #define CONFIG_SYS_USB_OHCI_REGS_BASE ATMEL_BASE_OHCI
include/configs/at91sam9x5ek.h +2 -1
@@ -159,13 +159,14 @@#define CONFIG_USB_EHCI_ATMEL #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2#else +#define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_UPLL #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_CPU_INIT #define CONFIG_SYS_USB_OHCI_REGS_BASE ATMEL_BASE_OHCI#define CONFIG_SYS_USB_OHCI_SLOT_NAME "at91sam9x5"#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 3#endif -#define CONFIG_USB_ATMEL #define CONFIG_USB_STORAGE #endif
include/configs/cpu9260.h +1 -0
@@ -346,6 +346,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/cpuat91.h +1 -0
@@ -160,6 +160,7 @@#if defined(CONFIG_CMD_USB )#define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_USB_STORAGE #define CONFIG_DOS_PARTITION
include/configs/eb_cpux9k2.h +1 -0
@@ -162,6 +162,7 @@* Hardware drivers */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_AT91C_PQFP_UHPBUG #define CONFIG_USB_STORAGE
include/configs/ethernut5.h +1 -0
@@ -178,6 +178,7 @@/* USB */ #ifdef CONFIG_CMD_USB #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_CPU_INIT #define CONFIG_SYS_USB_OHCI_REGS_BASE 0x00500000
include/configs/meesc.h +1 -0
@@ -157,6 +157,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/otc570.h +1 -0
@@ -207,6 +207,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/pm9261.h +1 -0
@@ -245,6 +245,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW 1#define CONFIG_DOS_PARTITION 1#define CONFIG_SYS_USB_OHCI_CPU_INIT 1
include/configs/pm9263.h +1 -0
@@ -272,6 +272,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW 1#define CONFIG_DOS_PARTITION 1#define CONFIG_SYS_USB_OHCI_CPU_INIT 1
include/configs/pm9g45.h +1 -0
@@ -120,6 +120,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_UPLL #define CONFIG_USB_OHCI_NEW 1#define CONFIG_DOS_PARTITION 1#define CONFIG_SYS_USB_OHCI_CPU_INIT 1
include/configs/sama5d3xek.h +1 -0
@@ -153,6 +153,7 @@#ifdef CONFIG_CMD_USB #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_UPLL #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_CPU_INIT #define CONFIG_SYS_USB_OHCI_REGS_BASE ATMEL_BASE_OHCI
include/configs/sbc35_a9g20.h +1 -0
@@ -119,6 +119,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/snapper9260.h +1 -0
@@ -65,6 +65,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/stamp9g20.h +1 -0
@@ -165,6 +165,7 @@/* USB configuration */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_USB_STORAGE #define CONFIG_DOS_PARTITION
include/configs/top9000.h +1 -0
@@ -174,6 +174,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
include/configs/vl_ma2sc.h +1 -0
@@ -116,6 +116,7 @@/* USB */ #define CONFIG_USB_ATMEL +#define CONFIG_USB_ATMEL_CLK_SEL_PLLB #define CONFIG_USB_OHCI_NEW #define CONFIG_DOS_PARTITION #define CONFIG_SYS_USB_OHCI_CPU_INIT
Signature · 1 line
1.7.9.5
PATCH 2/2 arm: atmel: get rid of too many ifdeffery
Dear Bo Shen,
Quoted 25 lines · Bo Shen
Get rid of too many ifdeffery in usb ohci driver
Add following two configuration for USB clock selecting
-CONFIG_USB_ATMEL_CLK_SEL_PLLB: using PLLB as usb ohci input clock
-CONFIG_USB_ATMEL_CLK_SEL_UPLL: using UPLL as usb ohci input clockSigned-off-by Bo Shen <[email protected]>---
drivers/usb/host/ohci-at91.c | 14 ++++---------- include/configs/afeb9260.h | 1 + include/configs/at91rm9200ek.h | 1 + include/configs/at91sam9260ek.h | 1 + include/configs/at91sam9261ek.h | 1 + include/configs/at91sam9263ek.h | 1 + include/configs/at91sam9n12ek.h | 1 + include/configs/at91sam9x5ek.h | 3 ++- include/configs/cpu9260.h | 1 + include/configs/cpuat91.h | 1 + include/configs/eb_cpux9k2.h | 1 + include/configs/ethernut5.h | 1 + include/configs/meesc.h | 1 + include/configs/otc570.h | 1 + include/configs/pm9261.h | 1 + include/configs/pm9263.h | 1 +
Quoted 8 lines
include/configs/pm9g45.h | 1 + include/configs/sama5d3xek.h | 1 + include/configs/sbc35_a9g20.h | 1 + include/configs/snapper9260.h | 1 + include/configs/stamp9g20.h | 1 + include/configs/top9000.h | 1 + include/configs/vl_ma2sc.h | 1 + 23 files changed, 27 insertions(+), 11 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann
PATCH 1/2 arm: atmel: at91sam9n12ek: add usb host support
In reply to Bo ShenDear Bo Shen,
Quoted 10 lines · Bo Shen
Add usb host support for at91sam9n12ek board.
Signed-off-by Bo Shen <[email protected]>---
arch/arm/include/asm/arch-at91/at91_pmc.h | 2 ++ board/atmel/at91sam9n12ek/at91sam9n12ek.c | 11 +++++++++++ drivers/usb/host/ohci-at91.c | 11 +++++++++-- include/configs/at91sam9n12ek.h | 12 ++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards,
Andreas Bie?mann