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