3 * Atmel Semiconductor <www.atmel.com>
4 * Written-by: Bo Shen <voice.shen@atmel.com>
6 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/at91_pmc.h>
15 #include <asm/arch/clk.h>
19 /* Enable UTMI PLL time out 500us
20 * 10 times as datasheet specified
22 #define EN_UPLL_TIMEOUT 500UL
24 int ehci_hcd_init(int index, enum usb_init_type init,
25 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
27 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
28 ulong start_time, tmp_time;
30 start_time = get_timer(0);
32 writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
33 while ((readl(&pmc->sr) & AT91_PMC_LOCKU) != AT91_PMC_LOCKU) {
35 tmp_time = get_timer(0);
36 if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
37 printf("ERROR: failed to enable UPLL\n");
42 /* Enable USB Host clock */
43 at91_periph_clk_enable(ATMEL_ID_UHPHS);
45 *hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
46 *hcor = (struct ehci_hcor *)((uint32_t)*hccr +
47 HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
52 int ehci_hcd_stop(int index)
54 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
55 ulong start_time, tmp_time;
57 /* Disable USB Host Clock */
58 at91_periph_clk_disable(ATMEL_ID_UHPHS);
60 start_time = get_timer(0);
61 /* Disable UTMI PLL */
62 writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
63 while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU) {
65 tmp_time = get_timer(0);
66 if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
67 printf("ERROR: failed to stop UPLL\n");