Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2006 |
| 4 | * Markus Klotzbuecher, DENX Software Engineering <mk@denx.de> |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Markus Klotzbuecher | 301f1aa | 2006-05-23 13:38:35 +0200 | [diff] [blame] | 8 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 9 | #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 10 | # if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) |
Markus Klotzbuecher | 301f1aa | 2006-05-23 13:38:35 +0200 | [diff] [blame] | 11 | |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 12 | #include <asm/arch/pxa-regs.h> |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 13 | #include <asm/io.h> |
Jean-Christophe PLAGNIOL-VILLARD | e9d0d52 | 2007-10-19 10:55:24 +0200 | [diff] [blame] | 14 | #include <usb.h> |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 15 | |
Jean-Christophe PLAGNIOL-VILLARD | 9c4884f | 2007-10-19 08:10:15 +0200 | [diff] [blame] | 16 | int usb_cpu_init(void) |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 17 | { |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 18 | #if defined(CONFIG_CPU_MONAHANS) |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 19 | /* Enable USB host clock. */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 20 | writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA); |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 21 | udelay(100); |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 22 | #endif |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 23 | #if defined(CONFIG_CPU_PXA27X) |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 24 | /* Enable USB host clock. */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 25 | writel(readl(CKEN) | CKEN10_USBHOST, CKEN); |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 26 | #endif |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 27 | |
Markus Klotzbuecher | edf5851 | 2007-04-03 14:27:08 +0200 | [diff] [blame] | 28 | #if defined(CONFIG_CPU_MONAHANS) |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 29 | /* Configure Port 2 for Host (USB Client Registers) */ |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 30 | writel(0x3000c, UP2OCR); |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 31 | #endif |
| 32 | |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 33 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Mike Frysinger | 5b84dd6 | 2012-03-05 13:47:00 +0000 | [diff] [blame] | 34 | mdelay(11); |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 35 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 36 | |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 37 | writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR); |
| 38 | while (readl(UHCHR) & UHCHR_FSBIR) |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 39 | udelay(1); |
| 40 | |
Stefan Herbrechtsmeier | 66a1818 | 2011-10-17 17:22:47 +0200 | [diff] [blame] | 41 | #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 42 | writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR); |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 43 | #endif |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 44 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 45 | writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR); |
Rodolfo Giometti | ae00bb4 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 46 | #endif |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 47 | writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR); |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |
Jean-Christophe PLAGNIOL-VILLARD | 9c4884f | 2007-10-19 08:10:15 +0200 | [diff] [blame] | 52 | int usb_cpu_stop(void) |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 53 | { |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 54 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 55 | udelay(11); |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 56 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 57 | |
Stefan Herbrechtsmeier | 1c0a14e | 2011-10-17 17:22:46 +0200 | [diff] [blame] | 58 | writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS); |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 59 | udelay(10); |
| 60 | |
Stefan Herbrechtsmeier | 66a1818 | 2011-10-17 17:22:47 +0200 | [diff] [blame] | 61 | #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 62 | writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR); |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 63 | #endif |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 64 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 65 | writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR); |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 66 | #endif |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 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 |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 74 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 75 | /* Disable USB host clock. */ |
| 76 | writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN); |
| 77 | #endif |
Rodolfo Giometti | 4d4a945 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 78 | |
Markus Klotzbuecher | 24e3764 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 79 | return 0; |
| 80 | } |
Markus Klotzbuecher | ddf83a2 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 81 | |
Jean-Christophe PLAGNIOL-VILLARD | 9c4884f | 2007-10-19 08:10:15 +0200 | [diff] [blame] | 82 | int usb_cpu_init_fail(void) |
Markus Klotzbuecher | ddf83a2 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 83 | { |
Marek Vasut | 3ba8bf7 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 84 | return usb_cpu_stop(); |
Markus Klotzbuecher | ddf83a2 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 85 | } |
| 86 | |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 87 | # endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */ |