blob: c31c2d73390eef5fefa6d135c649fce04db888d7 [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Markus Klotzbuecher24e37642006-05-23 10:33:11 +02006 */
7
8#include <common.h>
Markus Klotzbuecher301f1aa2006-05-23 13:38:35 +02009
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020010#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
Marek Vasutabc20ab2011-11-26 07:20:07 +010011# if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X)
Markus Klotzbuecher301f1aa2006-05-23 13:38:35 +020012
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020013#include <asm/arch/pxa-regs.h>
Marek Vasut3ba8bf72010-09-09 09:50:39 +020014#include <asm/io.h>
Jean-Christophe PLAGNIOL-VILLARDe9d0d522007-10-19 10:55:24 +020015#include <usb.h>
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020016
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020017int usb_cpu_init(void)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020018{
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020019#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020020 /* Enable USB host clock. */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020021 writel(readl(CKENA) | CKENA_2_USBHOST | CKENA_20_UDC, CKENA);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020022 udelay(100);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020023#endif
Marek Vasutabc20ab2011-11-26 07:20:07 +010024#if defined(CONFIG_CPU_PXA27X)
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020025 /* Enable USB host clock. */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020026 writel(readl(CKEN) | CKEN10_USBHOST, CKEN);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020027#endif
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020028
Markus Klotzbuecheredf58512007-04-03 14:27:08 +020029#if defined(CONFIG_CPU_MONAHANS)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020030 /* Configure Port 2 for Host (USB Client Registers) */
Marek Vasut3ba8bf72010-09-09 09:50:39 +020031 writel(0x3000c, UP2OCR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020032#endif
33
Marek Vasut3ba8bf72010-09-09 09:50:39 +020034 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Mike Frysinger5b84dd62012-03-05 13:47:00 +000035 mdelay(11);
Marek Vasut3ba8bf72010-09-09 09:50:39 +020036 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020037
Marek Vasut3ba8bf72010-09-09 09:50:39 +020038 writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
39 while (readl(UHCHR) & UHCHR_FSBIR)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020040 udelay(1);
41
Stefan Herbrechtsmeier66a18182011-10-17 17:22:47 +020042#if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020043 writel(readl(UHCHR) & ~UHCHR_SSEP0, UHCHR);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020044#endif
Marek Vasutabc20ab2011-11-26 07:20:07 +010045#if defined(CONFIG_CPU_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020046 writel(readl(UHCHR) & ~UHCHR_SSEP2, UHCHR);
Rodolfo Giomettiae00bb42007-03-26 12:03:36 +020047#endif
Marek Vasut3ba8bf72010-09-09 09:50:39 +020048 writel(readl(UHCHR) & ~(UHCHR_SSEP1 | UHCHR_SSE), UHCHR);
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020049
50 return 0;
51}
52
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020053int usb_cpu_stop(void)
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020054{
Marek Vasut3ba8bf72010-09-09 09:50:39 +020055 writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020056 udelay(11);
Marek Vasut3ba8bf72010-09-09 09:50:39 +020057 writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020058
Stefan Herbrechtsmeier1c0a14e2011-10-17 17:22:46 +020059 writel(readl(UHCCOMS) | UHCCOMS_HCR, UHCCOMS);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020060 udelay(10);
61
Stefan Herbrechtsmeier66a18182011-10-17 17:22:47 +020062#if defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020063 writel(readl(UHCHR) | UHCHR_SSEP0, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020064#endif
Marek Vasutabc20ab2011-11-26 07:20:07 +010065#if defined(CONFIG_CPU_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020066 writel(readl(UHCHR) | UHCHR_SSEP2, UHCHR);
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020067#endif
Marek Vasut3ba8bf72010-09-09 09:50:39 +020068 writel(readl(UHCHR) | UHCHR_SSEP1 | UHCHR_SSE, UHCHR);
69
70#if defined(CONFIG_CPU_MONAHANS)
71 /* Disable USB host clock. */
72 writel(readl(CKENA) & ~(CKENA_2_USBHOST | CKENA_20_UDC), CKENA);
73 udelay(100);
74#endif
Marek Vasutabc20ab2011-11-26 07:20:07 +010075#if defined(CONFIG_CPU_PXA27X)
Marek Vasut3ba8bf72010-09-09 09:50:39 +020076 /* Disable USB host clock. */
77 writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
78#endif
Rodolfo Giometti4d4a9452007-10-15 11:59:17 +020079
Markus Klotzbuecher24e37642006-05-23 10:33:11 +020080 return 0;
81}
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +020082
Jean-Christophe PLAGNIOL-VILLARD9c4884f2007-10-19 08:10:15 +020083int usb_cpu_init_fail(void)
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +020084{
Marek Vasut3ba8bf72010-09-09 09:50:39 +020085 return usb_cpu_stop();
Markus Klotzbuecherddf83a22006-05-30 16:56:14 +020086}
87
Marek Vasutabc20ab2011-11-26 07:20:07 +010088# endif /* defined(CONFIG_CPU_MONAHANS) || defined(CONFIG_CPU_PXA27X) */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020089#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT) */