3 * DENX Software Engineering <mk@denx.de>
5 * SPDX-License-Identifier: GPL-2.0+
10 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
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
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
);
29 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
31 writel(readl(&pmc
->uckr
) | AT91_PMC_UPLLEN
| AT91_PMC_BIASEN
,
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
);
40 /* Enable USB host clock. */
42 writel(1 << (ATMEL_ID_UHP
- 32), &pmc
->pcer1
);
44 writel(1 << ATMEL_ID_UHP
, &pmc
->pcer
);
47 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
48 writel(ATMEL_PMC_UHP
| AT91_PMC_HCK0
, &pmc
->scer
);
50 writel(ATMEL_PMC_UHP
, &pmc
->scer
);
56 int usb_cpu_stop(void)
58 at91_pmc_t
*pmc
= (at91_pmc_t
*)ATMEL_BASE_PMC
;
60 /* Disable USB host clock. */
62 writel(1 << (ATMEL_ID_UHP
- 32), &pmc
->pcdr1
);
64 writel(1 << ATMEL_ID_UHP
, &pmc
->pcdr
);
67 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
68 writel(ATMEL_PMC_UHP
| AT91_PMC_HCK0
, &pmc
->scdr
);
70 writel(ATMEL_PMC_UHP
, &pmc
->scdr
);
73 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
74 #ifdef CONFIG_AT91SAM9N12
78 writel(0, &pmc
->pllbr
);
79 while ((readl(&pmc
->sr
) & AT91_PMC_LOCKB
) != 0)
81 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
83 writel(readl(&pmc
->uckr
) & (~AT91_PMC_UPLLEN
), &pmc
->uckr
);
84 while ((readl(&pmc
->sr
) & AT91_PMC_LOCKU
) == AT91_PMC_LOCKU
)
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) */