blob: 0311d5e9978480630223ae7c2df68a4226e91521 [file] [log] [blame]
Markus Klotzbuecher24e37642006-05-23 10:33:11 +02001/*
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 Klotzbuecher301f1aa2006-05-23 13:38:35 +020025
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020026#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020027# if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
Markus Klotzbuecher301f1aa2006-05-23 13:38:35 +020028
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020029#include <asm/arch/pxa-regs.h>
Marek Vasut3ba8bf72010-09-09 09:50:39 +020030#include <asm/io.h>
Jean-Christophe PLAGNIOL-VILLARDe9d0d522007-10-19 10:55:24 +020031#include <usb.h>
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020032
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020033int usb_cpu_init(void)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020034{
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020035#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020036 /* Enable USB host clock. */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020037 writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020038 udelay(100);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020039#endif
40#if defined(CONFIG_PXA27X)
41 /* Enable USB host clock. */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020042 writel(readl(CKEN) | CKEN10_USBHOST, CKEN);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020043#endif
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020044
Markus Klotzbuecheredf58512007-04-03 14:27:08 +020045#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020046 /* Configure Port 2 for Host (USB Client Registers) */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020047 writel(0x3000c, UP2OCR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020048#endif
49
Marek Vasut3ba8bf72010-09-09 09:50:39 +020050 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020051 wait_ms(11);
Marek Vasut3ba8bf72010-09-09 09:50:39 +020052 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020053
Marek Vasut3ba8bf72010-09-09 09:50:39 +020054 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
55 while (readl(UHCHR) & UHCHR_FSBIR)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020056 udelay(1);
57
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020058#if defined(CONFIG_CPU_MONAHANS)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020059 writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020060#endif
61#if defined(CONFIG_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020062 writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020063#endif
Marek Vasut3ba8bf72010-09-09 09:50:39 +020064 writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020065
66 return 0;
67}
68
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020069int usb_cpu_stop(void)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020070{
Marek Vasut3ba8bf72010-09-09 09:50:39 +020071 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020072 udelay(11);
Marek Vasut3ba8bf72010-09-09 09:50:39 +020073 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020074
Marek Vasut3ba8bf72010-09-09 09:50:39 +020075 writel(readl(UHCCOMS) | UHCHR_FHR, UHCCOMS);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020076 udelay(10);
77
78#if defined(CONFIG_CPU_MONAHANS)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020079 writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020080#endif
81#if defined(CONFIG_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020082 writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020083#endif
Marek Vasut3ba8bf72010-09-09 09:50:39 +020084 writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR);
85
86#if defined(CONFIG_CPU_MONAHANS)
87 /* Disable USB host clock. */
88 writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA);
89 udelay(100);
90#endif
91#if defined(CONFIG_PXA27X)
92 /* Disable USB host clock. */
93 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
94#endif
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020095
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020096 return 0;
97}
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +020098
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020099int usb_cpu_init_fail(void)
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +0200100{
Marek Vasut3ba8bf72010-09-09 09:50:39 +0200101 return usb_cpu_stop();
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +0200102}
103
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +0200104# endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X) */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200105#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */