xref: /openbmc/u-boot/drivers/usb/host/ohci-at91.c (revision 8ee59472)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2006
4  * DENX Software Engineering <mk@denx.de>
5  */
6 
7 #include <common.h>
8 
9 #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
10 
11 #include <asm/arch/clk.h>
12 
13 int usb_cpu_init(void)
14 {
15 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
16 	if (at91_pllb_clk_enable(get_pllb_init()))
17 		return -1;
18 
19 #ifdef CONFIG_AT91SAM9N12
20 	at91_usb_clk_init(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2);
21 #endif
22 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
23 	if (at91_upll_clk_enable())
24 		return -1;
25 
26 	at91_usb_clk_init(AT91_PMC_USBS_USB_UPLL | AT91_PMC_USBDIV_10);
27 #endif
28 
29 	at91_periph_clk_enable(ATMEL_ID_UHP);
30 
31 	at91_system_clk_enable(ATMEL_PMC_UHP);
32 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
33 	at91_system_clk_enable(AT91_PMC_HCK0);
34 #endif
35 
36 	return 0;
37 }
38 
39 int usb_cpu_stop(void)
40 {
41 	at91_periph_clk_disable(ATMEL_ID_UHP);
42 
43 	at91_system_clk_disable(ATMEL_PMC_UHP);
44 #if defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9G10)
45 	at91_system_clk_disable(AT91_PMC_HCK0);
46 #endif
47 
48 #ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
49 #ifdef CONFIG_AT91SAM9N12
50 	at91_usb_clk_init(0);
51 #endif
52 
53 	if (at91_pllb_clk_disable())
54 		return -1;
55 
56 #elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
57 	if (at91_upll_clk_disable())
58 		return -1;
59 #endif
60 
61 	return 0;
62 }
63 
64 int usb_cpu_init_fail(void)
65 {
66 	return usb_cpu_stop();
67 }
68 
69 #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
70