blob: 80a5977415502d2301ead921cdbfc6ebeb14dfad [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Markus Klotzbuecher98095512006-05-23 10:33:11 +02002/*
3 * (C) Copyright 2006
4 * Markus Klotzbuecher, DENX Software Engineering <mk@denx.de>
Markus Klotzbuecher98095512006-05-23 10:33:11 +02005 */
6
7#include <common.h>
Markus Klotzbuecher98095512006-05-23 10:33:11 +02008
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +02009#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Marek Vasut85cc88a2011-11-26 07:20:07 +010010# if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X)
Markus Klotzbuecherd0a38782006-05-23 13:38:35 +020011
12#include <asm/arch/pxa-regs.h>
Marek Vasut2db1e962010-09-09 09:50:39 +020013#include <asm/io.h>
Jean-Christophe PLAGNIOL-VILLARDbce7b142007-10-19 10:55:24 +020014#include <usb.h>
Markus Klotzbuecherd0a38782006-05-23 13:38:35 +020015
Jean-Christophe PLAGNIOL-VILLARD733fc372007-10-19 08:10:15 +020016int usb_cpu_init(void)
Markus Klotzbuecher98095512006-05-23 10:33:11 +020017{
Rodolfo Giometti6659da82007-03-26 12:03:36 +020018#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher98095512006-05-23 10:33:11 +020019 /* Enable USB host clock. */
Marek Vasut2db1e962010-09-09 09:50:39 +020020 writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA);
Markus Klotzbuecher98095512006-05-23 10:33:11 +020021 udelay(100);
Rodolfo Giometti6659da82007-03-26 12:03:36 +020022#endif
Marek Vasut85cc88a2011-11-26 07:20:07 +010023#if defined(CONFIG_CPU_PXA27X)
Rodolfo Giometti6659da82007-03-26 12:03:36 +020024 /* Enable USB host clock. */
Marek Vasut2db1e962010-09-09 09:50:39 +020025 writel(readl(CKEN) | CKEN10_USBHOST, CKEN);
Rodolfo Giometti6659da82007-03-26 12:03:36 +020026#endif
Markus Klotzbuecher98095512006-05-23 10:33:11 +020027
Markus Klotzbuecher4a7847b2007-04-03 14:27:08 +020028#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher98095512006-05-23 10:33:11 +020029 /* Configure Port 2 for Host (USB Client Registers) */
Marek Vasut2db1e962010-09-09 09:50:39 +020030 writel(0x3000c, UP2OCR);
Markus Klotzbuecher98095512006-05-23 10:33:11 +020031#endif
32
Marek Vasut2db1e962010-09-09 09:50:39 +020033 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Mike Frysinger60ce19a2012-03-05 13:47:00 +000034 mdelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +020035 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Markus Klotzbuecher98095512006-05-23 10:33:11 +020036
Marek Vasut2db1e962010-09-09 09:50:39 +020037 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
38 while (readl(UHCHR) & UHCHR_FSBIR)
Markus Klotzbuecher98095512006-05-23 10:33:11 +020039 udelay(1);
40
Stefan Herbrechtsmeier13d240f2011-10-17 17:22:47 +020041#if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
Marek Vasut2db1e962010-09-09 09:50:39 +020042 writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR);
Rodolfo Giometti6659da82007-03-26 12:03:36 +020043#endif
Marek Vasut85cc88a2011-11-26 07:20:07 +010044#if defined(CONFIG_CPU_PXA27X)
Marek Vasut2db1e962010-09-09 09:50:39 +020045 writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR);
Rodolfo Giometti6659da82007-03-26 12:03:36 +020046#endif
Marek Vasut2db1e962010-09-09 09:50:39 +020047 writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR);
Markus Klotzbuecher98095512006-05-23 10:33:11 +020048
49 return 0;
50}
51
Jean-Christophe PLAGNIOL-VILLARD733fc372007-10-19 08:10:15 +020052int usb_cpu_stop(void)
Markus Klotzbuecher98095512006-05-23 10:33:11 +020053{
Marek Vasut2db1e962010-09-09 09:50:39 +020054 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Rodolfo Giomettidae6b7a2007-10-15 11:59:17 +020055 udelay(11);
Marek Vasut2db1e962010-09-09 09:50:39 +020056 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Rodolfo Giomettidae6b7a2007-10-15 11:59:17 +020057
Stefan Herbrechtsmeier38f79c62011-10-17 17:22:46 +020058 writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS);
Rodolfo Giomettidae6b7a2007-10-15 11:59:17 +020059 udelay(10);
60
Stefan Herbrechtsmeier13d240f2011-10-17 17:22:47 +020061#if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
Marek Vasut2db1e962010-09-09 09:50:39 +020062 writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR);
Rodolfo Giomettidae6b7a2007-10-15 11:59:17 +020063#endif
Marek Vasut85cc88a2011-11-26 07:20:07 +010064#if defined(CONFIG_CPU_PXA27X)
Marek Vasut2db1e962010-09-09 09:50:39 +020065 writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR);
Rodolfo Giomettidae6b7a2007-10-15 11:59:17 +020066#endif
Marek Vasut2db1e962010-09-09 09:50:39 +020067 writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR);
Rodolfo Giometti6416a732007-10-15 11:59:17 +020068
69#if defined(CONFIG_CPU_MONAHANS)
Marek Vasut2db1e962010-09-09 09:50:39 +020070 /* Disable USB host clock. */
71 writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA);
72 udelay(100);
Rodolfo Giometti6416a732007-10-15 11:59:17 +020073#endif
Marek Vasut85cc88a2011-11-26 07:20:07 +010074#if defined(CONFIG_CPU_PXA27X)
Marek Vasut2db1e962010-09-09 09:50:39 +020075 /* Disable USB host clock. */
76 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
Rodolfo Giometti6416a732007-10-15 11:59:17 +020077#endif
Rodolfo Giometti6416a732007-10-15 11:59:17 +020078
Markus Klotzbuecher98095512006-05-23 10:33:11 +020079 return 0;
80}
Markus Klotzbuecheraa219212006-05-30 16:56:14 +020081
Marek Vasut2db1e962010-09-09 09:50:39 +020082int usb_cpu_init_fail(void)
83{
84 return usb_cpu_stop();
85}
86
Marek Vasut85cc88a2011-11-26 07:20:07 +010087# endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020088#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */