Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2006 |
| 3 | * Markus Klotzbuecher, DENX Software Engineering <mk@denx.de> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 25 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 26 | #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 27 | # if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) |
Markus Klotzbuecher | d0a3878 | 2006-05-23 13:38:35 +0200 | [diff] [blame] | 28 | |
| 29 | #include <asm/arch/pxa-regs.h> |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 30 | #include <asm/io.h> |
Jean-Christophe PLAGNIOL-VILLARD | bce7b14 | 2007-10-19 10:55:24 +0200 | [diff] [blame] | 31 | #include <usb.h> |
Markus Klotzbuecher | d0a3878 | 2006-05-23 13:38:35 +0200 | [diff] [blame] | 32 | |
Jean-Christophe PLAGNIOL-VILLARD | 733fc37 | 2007-10-19 08:10:15 +0200 | [diff] [blame] | 33 | int usb_cpu_init(void) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 34 | { |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 35 | #if defined(CONFIG_CPU_MONAHANS) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 36 | /* Enable USB host clock. */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 37 | writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 38 | udelay(100); |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 39 | #endif |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 40 | #if defined(CONFIG_CPU_PXA27X) |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 41 | /* Enable USB host clock. */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 42 | writel(readl(CKEN) | CKEN10_USBHOST, CKEN); |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 43 | #endif |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 44 | |
Markus Klotzbuecher | 4a7847b | 2007-04-03 14:27:08 +0200 | [diff] [blame] | 45 | #if defined(CONFIG_CPU_MONAHANS) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 46 | /* Configure Port 2 for Host (USB Client Registers) */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 47 | writel(0x3000c, UP2OCR); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 48 | #endif |
| 49 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 50 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Mike Frysinger | 60ce19a | 2012-03-05 13:47:00 +0000 | [diff] [blame^] | 51 | mdelay(11); |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 52 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 53 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 54 | writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR); |
| 55 | while (readl(UHCHR) & UHCHR_FSBIR) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 56 | udelay(1); |
| 57 | |
Stefan Herbrechtsmeier | 13d240f | 2011-10-17 17:22:47 +0200 | [diff] [blame] | 58 | #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 59 | writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR); |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 60 | #endif |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 61 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 62 | writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR); |
Rodolfo Giometti | 6659da8 | 2007-03-26 12:03:36 +0200 | [diff] [blame] | 63 | #endif |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 64 | writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR); |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
Jean-Christophe PLAGNIOL-VILLARD | 733fc37 | 2007-10-19 08:10:15 +0200 | [diff] [blame] | 69 | int usb_cpu_stop(void) |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 70 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 71 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Rodolfo Giometti | dae6b7a | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 72 | udelay(11); |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 73 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Rodolfo Giometti | dae6b7a | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 74 | |
Stefan Herbrechtsmeier | 38f79c6 | 2011-10-17 17:22:46 +0200 | [diff] [blame] | 75 | writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS); |
Rodolfo Giometti | dae6b7a | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 76 | udelay(10); |
| 77 | |
Stefan Herbrechtsmeier | 13d240f | 2011-10-17 17:22:47 +0200 | [diff] [blame] | 78 | #if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 79 | writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR); |
Rodolfo Giometti | dae6b7a | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 80 | #endif |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 81 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 82 | writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR); |
Rodolfo Giometti | dae6b7a | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 83 | #endif |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 84 | writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR); |
Rodolfo Giometti | 6416a73 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 85 | |
| 86 | #if defined(CONFIG_CPU_MONAHANS) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 87 | /* Disable USB host clock. */ |
| 88 | writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA); |
| 89 | udelay(100); |
Rodolfo Giometti | 6416a73 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 90 | #endif |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 91 | #if defined(CONFIG_CPU_PXA27X) |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 92 | /* Disable USB host clock. */ |
| 93 | writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN); |
Rodolfo Giometti | 6416a73 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 94 | #endif |
Rodolfo Giometti | 6416a73 | 2007-10-15 11:59:17 +0200 | [diff] [blame] | 95 | |
Markus Klotzbuecher | 9809551 | 2006-05-23 10:33:11 +0200 | [diff] [blame] | 96 | return 0; |
| 97 | } |
Markus Klotzbuecher | aa21921 | 2006-05-30 16:56:14 +0200 | [diff] [blame] | 98 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 99 | int usb_cpu_init_fail(void) |
| 100 | { |
| 101 | return usb_cpu_stop(); |
| 102 | } |
| 103 | |
Marek Vasut | 85cc88a | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 104 | # endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 105 | #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */ |