mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jan Luebbe <jlu@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 06/12] mach-davinci: support the USB 1.1 host controller (based on OHCI)
Date: Tue, 26 Jun 2012 11:51:48 +0200	[thread overview]
Message-ID: <1340704314-12593-7-git-send-email-jlu@pengutronix.de> (raw)
In-Reply-To: <1340704314-12593-1-git-send-email-jlu@pengutronix.de>

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
 arch/arm/mach-davinci/Makefile           |    1 +
 arch/arm/mach-davinci/include/mach/usb.h |   37 +++++++++++++++++
 arch/arm/mach-davinci/usb.c              |   66 ++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 arch/arm/mach-davinci/include/mach/usb.h
 create mode 100644 arch/arm/mach-davinci/usb.c

diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile
index 0ac8f9b..0df1e92 100644
--- a/arch/arm/mach-davinci/Makefile
+++ b/arch/arm/mach-davinci/Makefile
@@ -4,3 +4,4 @@ obj-y += da850.o
 obj-y += gpio.o
 obj-y += mux.o
 obj-y += psc.o
+obj-y += usb.o
diff --git a/arch/arm/mach-davinci/include/mach/usb.h b/arch/arm/mach-davinci/include/mach/usb.h
new file mode 100644
index 0000000..d0fb412
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/usb.h
@@ -0,0 +1,37 @@
+/*
+ * USB related definitions
+ *
+ * Copyright (C) 2009 MontaVista Software, Inc. <source@mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifndef __ASM_ARCH_USB_H
+#define __ASM_ARCH_USB_H
+
+/* DA8xx CFGCHIP2 (USB 2.0 PHY Control) register bits */
+#define CFGCHIP2_PHYCLKGD	(1 << 17)
+#define CFGCHIP2_VBUSSENSE	(1 << 16)
+#define CFGCHIP2_RESET		(1 << 15)
+#define CFGCHIP2_OTGMODE	(3 << 13)
+#define CFGCHIP2_NO_OVERRIDE	(0 << 13)
+#define CFGCHIP2_FORCE_HOST	(1 << 13)
+#define CFGCHIP2_FORCE_DEVICE 	(2 << 13)
+#define CFGCHIP2_FORCE_HOST_VBUS_LOW (3 << 13)
+#define CFGCHIP2_USB1PHYCLKMUX	(1 << 12)
+#define CFGCHIP2_USB2PHYCLKMUX	(1 << 11)
+#define CFGCHIP2_PHYPWRDN	(1 << 10)
+#define CFGCHIP2_OTGPWRDN	(1 << 9)
+#define CFGCHIP2_DATPOL 	(1 << 8)
+#define CFGCHIP2_USB1SUSPENDM	(1 << 7)
+#define CFGCHIP2_PHY_PLLON	(1 << 6)	/* override PLL suspend */
+#define CFGCHIP2_SESENDEN	(1 << 5)	/* Vsess_end comparator */
+#define CFGCHIP2_VBDTCTEN	(1 << 4)	/* Vbus comparator */
+#define CFGCHIP2_REFFREQ	(0xf << 0)
+#define CFGCHIP2_REFFREQ_12MHZ	(1 << 0)
+#define CFGCHIP2_REFFREQ_24MHZ	(2 << 0)
+#define CFGCHIP2_REFFREQ_48MHZ	(3 << 0)
+
+#endif	/* ifndef __ASM_ARCH_USB_H */
diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c
new file mode 100644
index 0000000..43dcd37
--- /dev/null
+++ b/arch/arm/mach-davinci/usb.c
@@ -0,0 +1,66 @@
+#include <common.h>
+#include <console.h>
+#include <driver.h>
+#include <init.h>
+#include <io.h>
+#include <mach/hardware.h>
+#include <mach/usb.h>
+#include <mach/da8xx.h>
+
+#define DA8XX_USB0_BASE 	0x01e00000
+#define DA8XX_USB1_BASE 	0x01e25000
+
+static int da8xx_usb11_init(void)
+{
+	u32 cfgchip2;
+
+	lpsc_on(DAVINCI_LPSC_USB20);
+	lpsc_on(DAVINCI_LPSC_USB11);
+
+	/*
+	 * Set up USB clock/mode in the CFGCHIP2 register.
+	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
+	*/
+	cfgchip2 = readl(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG);
+
+	/* USB2.0 PHY reference clock is 24 MHz */
+	cfgchip2 &= ~CFGCHIP2_REFFREQ;
+	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
+
+	/*
+	 * Select internal reference clock for USB 2.0 PHY
+	 * and use it as a clock source for USB 1.1 PHY
+	 * (this is the default setting anyway).
+	*/
+	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
+	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
+
+	/*
+	 * We have to override VBUS/ID signals when MUSB is configured into the
+	 * host-only mode -- ID pin will float if no cable is connected, so the
+	 * controller won't be able to drive VBUS thinking that it's a B-device.
+	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
+	 */
+	cfgchip2 &= ~CFGCHIP2_OTGMODE;
+	cfgchip2 |=  CFGCHIP2_FORCE_HOST;
+
+	cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN);
+	cfgchip2 |= CFGCHIP2_PHY_PLLON;
+
+	/*
+	 * Enable USB 1.1 PHY
+	 */
+	cfgchip2 |= CFGCHIP2_USB1SUSPENDM;
+
+	writel(cfgchip2, DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG);
+
+	printf("waiting for USB PHY clock...\n");
+	while (!(readl(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG) & CFGCHIP2_PHYCLKGD))
+		continue;
+
+	add_generic_device("ohci", 0, NULL, DA8XX_USB1_BASE, 0x100,
+			   IORESOURCE_MEM, NULL);
+	return 0;
+}
+
+device_initcall(da8xx_usb11_init);
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-06-26  9:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26  9:51 Add basic support for the OMAP-L138/DA850 Jan Luebbe
2012-06-26  9:51 ` [PATCH 01/12] mach-davinci: add platform and minimal board file for HMI10 Jan Luebbe
2012-06-26  9:51 ` [PATCH 02/12] mach-davinci: add GPIO support Jan Luebbe
2012-06-26  9:51 ` [PATCH 03/12] mach-davinci: add pin mux support Jan Luebbe
2012-06-26 18:59   ` Sascha Hauer
2012-06-26  9:51 ` [PATCH 04/12] mach-davinci: setup pin mux for da850 Jan Luebbe
2012-06-26 19:00   ` Sascha Hauer
2012-06-26  9:51 ` [PATCH 05/12] mach-davinci: add support for the PSC (Power and Sleep Controller) Jan Luebbe
2012-06-26 19:02   ` Sascha Hauer
2012-06-26  9:51 ` Jan Luebbe [this message]
2012-06-26 19:05   ` [PATCH 06/12] mach-davinci: support the USB 1.1 host controller (based on OHCI) Sascha Hauer
2012-06-26  9:51 ` [PATCH 07/12] mach-davinci: add support for AEMIF (NAND flash) Jan Luebbe
2012-06-26  9:51 ` [PATCH 08/12] drivers/mtd/nand: add driver for the davinci NAND flash controller Jan Luebbe
2012-06-26 19:19   ` Sascha Hauer
2012-06-26  9:51 ` [PATCH 09/12] board hmi10: enable support for NAND Jan Luebbe
2012-06-26  9:51 ` [PATCH 10/12] drivers/spi: add driver for the davinci SPI master Jan Luebbe
2012-06-26  9:51 ` [PATCH 11/12] board hmi10: enable support for SPI Jan Luebbe
2012-06-26  9:51 ` [PATCH 12/12] board hmi10: add default config Jan Luebbe
2012-06-26 11:59 ` Add basic support for the OMAP-L138/DA850 Yegor Yefremov
2012-06-26 12:06   ` Jan Lübbe
2012-06-26 20:52     ` Yegor Yefremov
2012-06-29 11:42       ` [PATCH] Initial BeagleBone support for second stage Jan Luebbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340704314-12593-7-git-send-email-jlu@pengutronix.de \
    --to=jlu@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox