All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikita Kiryanov <nikita@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 15/18] arm: mx6: cm_fx6: add usb support
Date: Sun,  3 Aug 2014 10:34:45 +0300	[thread overview]
Message-ID: <1407051288-17324-16-git-send-email-nikita@compulab.co.il> (raw)
In-Reply-To: <1407051288-17324-1-git-send-email-nikita@compulab.co.il>

Add USB and USB OTG host support for Compulab CM-FX6 CoM.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
---
 board/compulab/cm_fx6/cm_fx6.c | 75 ++++++++++++++++++++++++++++++++++++++++++
 board/compulab/cm_fx6/common.h |  3 ++
 include/configs/cm_fx6.h       | 10 ++++++
 3 files changed, 88 insertions(+)

diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index d074af4..f8b3ad8 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -14,12 +14,87 @@
 #include <fdt_support.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/sys_proto.h>
+#include <asm/arch/iomux.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include "common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_USB_EHCI_MX6
+#define WEAK_PULLDOWN	(PAD_CTL_PUS_100K_DOWN |		\
+			PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm |	\
+			PAD_CTL_HYS | PAD_CTL_SRE_SLOW)
+
+static int cm_fx6_usb_hub_reset(void)
+{
+	int err;
+
+	err = gpio_request(CM_FX6_USB_HUB_RST, "usb hub rst");
+	if (err) {
+		printf("USB hub rst gpio request failed: %d\n", err);
+		return -1;
+	}
+
+	SETUP_IOMUX_PAD(PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL));
+	gpio_direction_output(CM_FX6_USB_HUB_RST, 0);
+	udelay(10);
+	gpio_direction_output(CM_FX6_USB_HUB_RST, 1);
+	mdelay(1);
+
+	return 0;
+}
+
+static void cm_fx6_init_usb_otg(void)
+{
+	int ret;
+	struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
+
+	ret = gpio_request(SB_FX6_USB_OTG_PWR, "usb-pwr");
+	if (ret)
+		printf("USB OTG pwr gpio request failed: %d\n", ret);
+
+	SETUP_IOMUX_PAD(PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL));
+	SETUP_IOMUX_PAD(PAD_ENET_RX_ER__USB_OTG_ID |
+						MUX_PAD_CTRL(WEAK_PULLDOWN));
+	clrbits_le32(&iomux->gpr[1], IOMUXC_GPR1_OTG_ID_MASK);
+	/* disable ext. charger detect, or it'll affect signal quality at dp. */
+	gpio_direction_output(SB_FX6_USB_OTG_PWR, 0);
+}
+
+#define MX6_USBNC_BASEADDR	0x2184800
+#define USBNC_USB_H1_PWR_POL	(1 << 9)
+int board_ehci_hcd_init(int port)
+{
+	u32 *usbnc_usb_uh1_ctrl = (u32 *)(MX6_USBNC_BASEADDR + 4);
+	u32 val;
+
+	switch (port) {
+	case 0:
+		cm_fx6_init_usb_otg();
+		break;
+	case 1:
+		SETUP_IOMUX_PAD(PAD_GPIO_0__USB_H1_PWR |
+						MUX_PAD_CTRL(NO_PAD_CTRL));
+
+		/* Set PWR polarity to match power switch's enable polarity */
+		val = __raw_readl(usbnc_usb_uh1_ctrl);
+		val |= USBNC_USB_H1_PWR_POL;
+		__raw_writel(val, usbnc_usb_uh1_ctrl);
+		return cm_fx6_usb_hub_reset();
+	default:
+		break;
+	}
+
+	return 0;
+}
+
+int board_ehci_power(int port, int on)
+{
+	return port ? 0 : gpio_direction_output(SB_FX6_USB_OTG_PWR, on);
+}
+#endif
+
 #ifdef CONFIG_FEC_MXC
 #define ENET_PAD_CTRL		(PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
 				 PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
diff --git a/board/compulab/cm_fx6/common.h b/board/compulab/cm_fx6/common.h
index 94ff39e..bd04d62 100644
--- a/board/compulab/cm_fx6/common.h
+++ b/board/compulab/cm_fx6/common.h
@@ -16,6 +16,9 @@
 #define CM_FX6_ECSPI_BUS0_CS0	IMX_GPIO_NR(2, 30)
 #define CM_FX6_GREEN_LED	IMX_GPIO_NR(2, 31)
 #define CM_FX6_ENET_NRST	IMX_GPIO_NR(2, 8)
+#define CM_FX6_ENET_NRST	IMX_GPIO_NR(2, 8)
+#define CM_FX6_USB_HUB_RST	IMX_GPIO_NR(7, 8)
+#define SB_FX6_USB_OTG_PWR	IMX_GPIO_NR(3, 22)
 
 #if defined(CONFIG_FSL_ESDHC)
 #include <fsl_esdhc.h>
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index 1923214..7ad2eb9 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -204,6 +204,16 @@
 #define CONFIG_NETMASK			255.255.255.0
 #define CONFIG_NET_RETRY_COUNT		5
 
+/* USB */
+#define CONFIG_CMD_USB
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_MX6
+#define CONFIG_USB_STORAGE
+#define CONFIG_MXC_USB_PORTSC		(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS		0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	2
+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET	/* For OTG port */
+
 /* GPIO */
 #define CONFIG_MXC_GPIO
 
-- 
1.9.1

  parent reply	other threads:[~2014-08-03  7:34 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-03  7:34 [U-Boot] [PATCH 00/18] Introduce cm-fx6 board Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 01/18] spl: improve spi configuration Nikita Kiryanov
2014-08-03 13:44   ` Marek Vasut
2014-08-05 13:28     ` Nikita Kiryanov
2014-08-05 14:11       ` Marek Vasut
2014-08-06 10:53         ` Nikita Kiryanov
2014-08-06 11:32           ` Marek Vasut
2014-08-03  7:34 ` [U-Boot] [PATCH 02/18] mx6: add clock enabling functions Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 03/18] sf: fix sf probe Nikita Kiryanov
2014-08-03 13:46   ` Marek Vasut
2014-08-04 12:48     ` Nikita Kiryanov
2014-08-04 13:10       ` Marek Vasut
2014-08-04 13:45         ` Nikita Kiryanov
2014-08-04 13:51           ` Marek Vasut
2014-08-04 14:11             ` Nikita Kiryanov
2014-08-04 14:20               ` Marek Vasut
2014-08-04 14:02           ` Tom Rini
2014-08-04 14:09             ` Marek Vasut
2014-08-04 14:19             ` Nikita Kiryanov
2014-08-04 14:58               ` Tom Rini
2014-08-03  7:34 ` [U-Boot] [PATCH 04/18] mtd: spi: add support for M25PE16 and M25PX16 Nikita Kiryanov
2014-08-03 13:47   ` Marek Vasut
2014-08-03  7:34 ` [U-Boot] [PATCH 05/18] compulab: eeprom: add support for defining eeprom i2c bus Nikita Kiryanov
2014-08-03 13:48   ` Marek Vasut
2014-08-04 12:49     ` Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 06/18] sata: dwc_ahsata: implement sata_port_status Nikita Kiryanov
2014-08-03 13:49   ` Marek Vasut
2014-08-04 12:49     ` Nikita Kiryanov
2014-08-04 13:10       ` Marek Vasut
2014-08-03  7:34 ` [U-Boot] [PATCH 07/18] i2c: imx: add macros to setup pads for multiple SoC types Nikita Kiryanov
2014-08-04  4:28   ` Tim Harvey
2014-08-03  7:34 ` [U-Boot] [PATCH 08/18] arm: mx6: ddr: cleanup Nikita Kiryanov
2014-08-04  5:26   ` Tim Harvey
2014-08-03  7:34 ` [U-Boot] [PATCH 09/18] arm: mx6: ddr: do not write into reserved bit Nikita Kiryanov
2014-08-04  5:43   ` Tim Harvey
2014-08-04 12:49     ` Nikita Kiryanov
2014-08-06  8:18       ` Tim Harvey
2014-08-06  8:31         ` Stefano Babic
2014-08-03  7:34 ` [U-Boot] [PATCH 10/18] arm: mx6: ddr: configure MMDC for slow_pd Nikita Kiryanov
2014-08-04  5:42   ` Tim Harvey
2014-08-04 12:49     ` Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 11/18] arm: mx6: ddr: fix cs0_end calculation Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 12/18] arm: mx6: add support for Compulab cm-fx6 CoM Nikita Kiryanov
2014-08-03 14:09   ` Marek Vasut
2014-08-04 14:41     ` Nikita Kiryanov
2014-08-04 15:12       ` Marek Vasut
2014-08-05  7:36         ` Nikita Kiryanov
2014-08-05  7:58           ` Marek Vasut
2014-08-04  4:45   ` Tim Harvey
2014-08-04 13:36     ` Nikita Kiryanov
2014-08-06 17:29       ` Nikita Kiryanov
2014-08-08  7:19         ` Tim Harvey
2014-08-10 16:20           ` Nikita Kiryanov
2014-08-04  6:02   ` Tim Harvey
2014-08-04 14:24     ` Nikita Kiryanov
2014-08-07 11:27       ` Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 13/18] arm: mx6: cm_fx6: add nand support Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 14/18] arm: mx6: cm_fx6: add ethernet support Nikita Kiryanov
2014-08-03  7:34 ` Nikita Kiryanov [this message]
2014-08-03  7:34 ` [U-Boot] [PATCH 16/18] arm: mx6: cm_fx6: add i2c support Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 17/18] arm: mx6: cm_fx6: use eeprom Nikita Kiryanov
2014-08-03  7:34 ` [U-Boot] [PATCH 18/18] arm: mx6: cm_fx6: add sata support Nikita Kiryanov
2014-08-03 14:10   ` Marek Vasut
2014-08-04  7:23     ` Igor Grinberg
2014-08-04  8:27       ` Marek Vasut
2014-08-04 10:47         ` Igor Grinberg
2014-08-04 10:53           ` Marek Vasut

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=1407051288-17324-16-git-send-email-nikita@compulab.co.il \
    --to=nikita@compulab.co.il \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.