Skip to contentSkip to conversation

ARM: Allwinner sun7i (A20) USB Host EHCI support

PATCH New Roman Byshko 3 participants 13 messages Jul 8, 2014 – Jul 16, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

This patch series adds USB Host EHCI support to the sun7i SoC. It was tested on Cubietruck. Now you could boot from a USB stick or use a compatible Ethernet dongle to add a second Ethernet port in U-Boot.

ehci-sunxi.c contains some code for poking GPIOs. This code will go away once some other patches for sunXi SoCs are applied against upstream. For now this patch series is self-contained and has no dependencies.

Best,
Roman Byshko

Roman Byshko (5):
sunxi: add defines to control USB Host clocks/resets
sunxi: add USB EHCI driver
sunxi: add USB options to configs
sun7i: add USB EHCI configuration
sun7i: cubietruck: enable USB EHCI

 arch/arm/include/asm/arch-sunxi/clock_sun4i.h |   4 +
 boards.cfg                                    |   2 +-
 drivers/usb/host/Makefile                     |   1 +
 drivers/usb/host/ehci-sunxi.c                 | 236 ++++++++++++++++++++++++++
 include/configs/sun7i.h                       |   8 +
 include/configs/sunxi-common.h                |   6 +
 6 files changed, 256 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/host/ehci-sunxi.c
Signature · 1 line
2.0.0
#1 lore raw

PATCH 1/5 sunxi: add defines to control USB Host clocks/resets

---
 arch/arm/include/asm/arch-sunxi/clock_sun4i.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/arch-sunxi/clock_sun4i.h +4 -0
index 928f3f2..fe7348a 100644
@@ -253,4 +253,8 @@ struct sunxi_ccm_reg {
 #define CCM_GMAC_CTRL_GPIT_MII (0x0 << 2)
 #define CCM_GMAC_CTRL_GPIT_RGMII (0x1 << 2)
 
+#define CCM_USB_CTRL_PHY1_RST (0x1 << 1)
+#define CCM_USB_CTRL_PHY2_RST (0x1 << 2)
+#define CCM_USB_CTRL_PHYGATE (0x1 << 8)
+
 #endif /* _SUNXI_CLOCK_SUN4I_H */
Signature · 1 line
2.0.0
#2 lore raw

PATCH 2/5 sunxi: add USB EHCI driver

In reply to Roman Byshko
---
 drivers/usb/host/Makefile     |   1 +
 drivers/usb/host/ehci-sunxi.c | 236 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 237 insertions(+)
 create mode 100644 drivers/usb/host/ehci-sunxi.c
drivers/usb/host/Makefile +1 -0
index 04c1a64..c4f5157 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o
 obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_SPEAR) += ehci-spear.o
+obj-$(CONFIG_USB_EHCI_SUNXI) += ehci-sunxi.o
 obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o
 obj-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o
 obj-$(CONFIG_USB_EHCI_RMOBILE) += ehci-rmobile.o
drivers/usb/host/ehci-sunxi.c new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.0.0
#3 lore raw

PATCH 2/5 sunxi: add USB EHCI driver

drivers/usb/host/ehci-sunxi.c line 4

Quoted 10 lines · Roman Byshko
drivers/usb/host/ehci-sunxi.c new file +4 -0
new file mode 100644
index 0000000..5817fc7
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2014 arokux
+ *
+ * arokux <[email protected]>

The authorship info here contradicts the authorship suggested by the commit email metadata and the S-o-b.

If arokux wrote this patch then the commit message should begin with

From: Arokux X <[email protected]>

on the first line and arokux needs to have Signed-off on the patch.

I'm not sure what u-boot policy says about pseudonyms.

drivers/usb/host/ehci-sunxi.c line 15

Quoted 11 lines
drivers/usb/host/ehci-sunxi.c new file +11 -0
+ *
+ * Based on code from
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.

Please use the SPDX tag instead of the full license.

drivers/usb/host/ehci-sunxi.c line 96

Quoted 7 lines
drivers/usb/host/ehci-sunxi.c new file +7 -0
+	dat = readl(&pio->dat);
+	if (val)
+		dat |= 0x1 << num;
+	else
+		dat &= ~(0x1 << num);
+
+	writel(dat, &pio->dat);

This is

	if (val)
		setbits_le32(&pio->dat, 1<<num);
	else
		clrbits_le32(&pio->dat, 1<<num);

It seems like there are a bunch of similar constructs around the place.

Quoted 6 lines
drivers/usb/host/ehci-sunxi.c new file +6 -0
+	return 0;
+}
+
+static void usb_phy_write(struct sunxi_ehci_hcd *sunxi_ehci, int addr,
+			  int data, int len)
+{

drivers/usb/host/ehci-sunxi.c line 113

Quoted 10 lines
drivers/usb/host/ehci-sunxi.c new file +10 -0
+	int temp = 0, j = 0, usbc_bit = 0;
+	void *dest = sunxi_ehci->csr;
+
+	usbc_bit = BIT(sunxi_ehci->id * 2);
+	for (j = 0; j < len; j++) {
+		/* set the bit address to be written */
+		temp = readl(dest);
+		temp &= ~(0xff << 8);
+		temp |= ((addr + j) << 8);
+		writel(temp, dest);

clrsetbits?

drivers/usb/host/ehci-sunxi.c line 121

Quoted 8 lines
drivers/usb/host/ehci-sunxi.c new file +8 -0
+
+		clrbits_le32(dest, usbc_bit);
+		/* set data bit */
+		if (data & 0x1)
+			temp |= BIT(7);
+		else
+			temp &= ~BIT(7);
+		writeb(temp, dest);

AFAICT this will clobber the clearing of usbc_bit which you just did, since temp was read before that, is that right?

This should probably use the clr/setbits_le32 stuff and if it really is deliberately clobbering usbc_bit I think it needs a comment.

drivers/usb/host/ehci-sunxi.c line 125

Quoted 4 lines
drivers/usb/host/ehci-sunxi.c new file +4 -0
+
+		setbits_le32(dest, usbc_bit);
+
+		clrbits_le32( dest, usbc_bit);

Extra space in this line.

drivers/usb/host/ehci-sunxi.c line 181

Quoted 1 line
drivers/usb/host/ehci-sunxi.c new file +1 -0
+	/* gpio_direction_output(sunxi_ehci->gpio_vbus, 1); */

???

drivers/usb/host/ehci-sunxi.c line 190

Quoted 5 lines
drivers/usb/host/ehci-sunxi.c new file +5 -0
+static void sunxi_ehci_disable(struct sunxi_ehci_hcd *sunxi_ehci)
+{
+	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+	/* gpio_direction_output(sunxi_ehci->gpio_vbus, 0); */

???

Ian.

#4 lore raw

PATCH 3/5 sunxi: add USB options to configs

In reply to Roman Byshko
---
 include/configs/sunxi-common.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/configs/sunxi-common.h +6 -0
index 5d72d62..c7746bb 100644
@@ -181,6 +181,12 @@
 #define CONFIG_BOOTP_SEND_HOSTNAME
 #endif
 
+#ifdef CONFIG_USB_EHCI
+#define CONFIG_CMD_USB
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1
+#define CONFIG_USB_STORAGE
+#endif
+
 #if !defined CONFIG_ENV_IS_IN_MMC && \
     !defined CONFIG_ENV_IS_IN_NAND && \
     !defined CONFIG_ENV_IS_IN_FAT && \
Signature · 1 line
2.0.0
#5 lore raw

PATCH 4/5 sun7i: add USB EHCI configuration

In reply to Roman Byshko
---
 include/configs/sun7i.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/configs/sun7i.h +8 -0
index 9b693f7..0a1d83e 100644
@@ -16,6 +16,14 @@
 
 #define CONFIG_SYS_PROMPT		"sun7i# "
 
+#ifdef CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_SUNXI
+
+#define CONFIG_USB_MAX_CONTROLLER_COUNT	2
+#define CONFIG_SUNXI_USB_VBUS0_GPIO	230
+#define CONFIG_SUNXI_USB_VBUS1_GPIO	227
+#endif
+
 /*
  * Include common sunxi configuration where most the settings are
  */
Signature · 1 line
2.0.0
#6 lore raw

PATCH 5/5 sun7i: cubietruck: enable USB EHCI

In reply to Roman Byshko
---
 boards.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boards.cfg +1 -1
index f16a0e6..e039d4c 100644
@@ -377,7 +377,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                              -                                                                                                                                 Robert Baldyga <[email protected]>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                              -                                                                                                                                 Minkyu Kang <[email protected]>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                      -                                                                                                                                 -
-Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII                                                                                             -
+Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII,USB_EHCI                                                                                    -
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                              -                                                                                                                                 Mathieu Poirier <[email protected]>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                            -                                                                                                                                 -
Signature · 1 line
2.0.0
#7 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

In reply to Roman Byshko
Quoted 1 line · Roman Byshko

This patch series adds USB Host EHCI support to the sun7i SoC.

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

Quoted 7 lines

It was
tested on Cubietruck. Now you could boot from a USB stick or use a compatible Ethernet dongle to add a second Ethernet port in U-Boot.

ehci-sunxi.c contains some code for poking GPIOs. This code will go away once some other patches for sunXi SoCs are applied against upstream. For now this patch series is self-contained and has no dependencies.

Which specific patches are required?
http://patchwork.ozlabs.org/patch/356566/ Perhaps?

Ian.

author
#8 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

Quoted 10 lines · Ian Campbell
Quoted 1 line · Roman Byshko

This patch series adds USB Host EHCI support to the sun7i SoC.

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

Quoted 4 lines

It was
tested on Cubietruck. Now you could boot from a USB stick or use a compatible Ethernet dongle to add a second Ethernet port in U-Boot.

Quoted 6 lines
Quoted 3 lines

ehci-sunxi.c contains some code for poking GPIOs. This code will go away once some other patches for sunXi SoCs are applied against upstream. For now this patch series is self-contained and has no dependencies.

Which specific patches are required?
http://patchwork.ozlabs.org/patch/356566/ Perhaps?

Yes, exactly.

Roman

#9 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

Quoted 6 lines · Roman B.
Quoted 5 lines · Ian Campbell
Quoted 1 line · Roman Byshko

This patch series adds USB Host EHCI support to the sun7i SoC.

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

You haven't done this in v2.

Ian.

#10 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

Quoted 9 lines · Ian Campbell
Quoted 6 lines · Roman B.
Quoted 5 lines · Ian Campbell
Quoted 1 line · Roman Byshko

This patch series adds USB Host EHCI support to the sun7i SoC.

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

You haven't done this in v2.

NM, I see you followed up already to correct that mistake.

Ian.

#11 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

Quoted 4 lines · Ian Campbell
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Roman B.
Quoted 1 line · Ian Campbell

On Tue, 2014-07-08 at 22:21 +0200, Roman Byshko wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

This patch series adds USB Host EHCI support to the sun7i SoC.

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

You haven't done this in v2.

NM, I see you followed up already to correct that mistake.

Where is the V2 ?

Best regards,
Marek Vasut

author
#12 lore raw

cover ARM: Allwinner sun7i (A20) USB Host EHCI support

Quoted 7 lines · Marek Vasut
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Roman B.
Quoted 3 lines · Ian Campbell
Quoted 1 line · Roman Byshko

This patch series adds USB Host EHCI support to the sun7i SoC.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

When you repost this please could you CC the USB custodian (Marek Vasut, marex {AT} denx {DOT} de) for his input on the glue code.

You haven't done this in v2.

NM, I see you followed up already to correct that mistake.

Where is the V2 ?

It is here

http://lists.denx.de/pipermail/u-boot/2014-July/thread.html#183792

Best,
Roman