arm: vf610: fix double iomux configuration for vf610twr board
[u-boot/qq2440-u-boot.git] / drivers / usb / host / ohci-at91.c
blobc24505e78eaa29eb60ab63c14b671b0d60bb5cd9
1 /*
2 * (C) Copyright 2006
3 * DENX Software Engineering <mk@denx.de>
5 * SPDX-License-Identifier: GPL-2.0+
6 */
8 #include <common.h>
10 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
12 #include <asm/io.h>
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/at91_pmc.h>
15 #include <asm/arch/clk.h>
17 int usb_cpu_init(void)
19 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
21 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
22 /* Enable PLLB */
23 writel(get_pllb_init(), &pmc->pllbr);
24 while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
26 #ifdef CONFIG_AT91SAM9N12
27 writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
28 #endif
29 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
30 /* Enable UPLL */
31 writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
32 &pmc->uckr);
33 while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU)
36 /* Select PLLA as input clock of OHCI */
37 writel(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10, &pmc->usb);
38 #endif
40 /* Enable USB host clock. */
41 #ifdef CONFIG_SAMA5D3
42 writel(1 << (ATMEL_ID_UHP - 32), &pmc->pcer1);
43 #else
44 writel(1 << ATMEL_ID_UHP, &pmc->pcer);
45 #endif
47 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
48 writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
49 #else
50 writel(ATMEL_PMC_UHP, &pmc->scer);
51 #endif
53 return 0;
56 int usb_cpu_stop(void)
58 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
60 /* Disable USB host clock. */
61 #ifdef CONFIG_SAMA5D3
62 writel(1 << (ATMEL_ID_UHP - 32), &pmc->pcdr1);
63 #else
64 writel(1 << ATMEL_ID_UHP, &pmc->pcdr);
65 #endif
67 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
68 writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
69 #else
70 writel(ATMEL_PMC_UHP, &pmc->scdr);
71 #endif
73 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
74 #ifdef CONFIG_AT91SAM9N12
75 writel(0, &pmc->usb);
76 #endif
77 /* Disable PLLB */
78 writel(0, &pmc->pllbr);
79 while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
81 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
82 /* Disable UPLL */
83 writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
84 while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
86 #endif
88 return 0;
91 int usb_cpu_init_fail(void)
93 return usb_cpu_stop();
96 #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */