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