3 * Atmel Semiconductor <www.atmel.com>
4 * Written-by: Bo Shen <voice.shen@atmel.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29 #include <asm/arch/hardware.h>
30 #include <asm/arch/at91_pmc.h>
31 #include <asm/arch/clk.h>
34 #include "ehci-core.h"
36 /* Enable UTMI PLL time out 500us
37 * 10 times as datasheet specified
39 #define EN_UPLL_TIMEOUT 500UL
41 int ehci_hcd_init(void)
43 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
44 ulong start_time, tmp_time;
46 start_time = get_timer(0);
48 writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
49 while (readl(&pmc->sr) & AT91_PMC_LOCKU != AT91_PMC_LOCKU) {
51 tmp_time = get_timer(0);
52 if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
53 printf("ERROR: failed to enable UPLL\n");
58 /* Enable USB Host clock */
59 writel(1 << ATMEL_ID_UHPHS, &pmc->pcer);
61 hccr = (struct ehci_hccr *)ATMEL_BASE_EHCI;
62 hcor = (struct ehci_hcor *)((uint32_t)hccr +
63 HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
68 int ehci_hcd_stop(void)
70 at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
71 ulong start_time, tmp_time;
73 /* Disable USB Host Clock */
74 writel(1 << ATMEL_ID_UHPHS, &pmc->pcdr);
76 start_time = get_timer(0);
77 /* Disable UTMI PLL */
78 writel(readl(&pmc->uckr) & ~AT91_PMC_UPLLEN, &pmc->uckr);
79 while (readl(&pmc->sr) & AT91_PMC_LOCKU == AT91_PMC_LOCKU) {
81 tmp_time = get_timer(0);
82 if ((tmp_time - start_time) > EN_UPLL_TIMEOUT) {
83 printf("ERROR: failed to stop UPLL\n");