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