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