1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * (C) Copyright 2006
4 * Markus Klotzbuecher, 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 # if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X)
11
12 #include <asm/arch/pxa-regs.h>
13 #include <asm/io.h>
14 #include <usb.h>
15
usb_cpu_init(void)16 int usb_cpu_init(void)
17 {
18 #if defined(CONFIG_CPU_MONAHANS)
19 /* Enable USB host clock. */
20 writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA);
21 udelay(100);
22 #endif
23 #if defined(CONFIG_CPU_PXA27X)
24 /* Enable USB host clock. */
25 writel(readl(CKEN) | CKEN10_USBHOST, CKEN);
26 #endif
27
28 #if defined(CONFIG_CPU_MONAHANS)
29 /* Configure Port 2 for Host (USB Client Registers) */
30 writel(0x3000c, UP2OCR);
31 #endif
32
33 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
34 mdelay(11);
35 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
36
37 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
38 while (readl(UHCHR) & UHCHR_FSBIR)
39 udelay(1);
40
41 #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
42 writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR);
43 #endif
44 #if defined(CONFIG_CPU_PXA27X)
45 writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR);
46 #endif
47 writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR);
48
49 return 0;
50 }
51
usb_cpu_stop(void)52 int usb_cpu_stop(void)
53 {
54 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
55 udelay(11);
56 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
57
58 writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS);
59 udelay(10);
60
61 #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
62 writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR);
63 #endif
64 #if defined(CONFIG_CPU_PXA27X)
65 writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR);
66 #endif
67 writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR);
68
69 #if defined(CONFIG_CPU_MONAHANS)
70 /* Disable USB host clock. */
71 writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA);
72 udelay(100);
73 #endif
74 #if defined(CONFIG_CPU_PXA27X)
75 /* Disable USB host clock. */
76 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
77 #endif
78
79 return 0;
80 }
81
usb_cpu_init_fail(void)82 int usb_cpu_init_fail(void)
83 {
84 return usb_cpu_stop();
85 }
86
87 # endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */
88 #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */
89