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