ARM: Allwinner sunxi USB Host EHCI support
Subsystems (4)
v3 cover ARM: Allwinner sunxi USB Host EHCI support
This patch series adds USB Host EHCI support to the sunxi SoCs. 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.
Best,
Roman Byshko
Changes since v2:
- improved commit messages
- removed BIT macro
- added get_io_base function
- removed unnecessary verboseness when defining sunxi_echi_hcd array
- the EHCI driver is now based on [2] and uses GPIO driver
- possible failure is ruled out by introducing enabled_hcd_count
Changes since v1:
- fixed erroneous copyright author
- used SPDX tag instead of the full license
- used setbits_le32/clrbits_le32 instead of direct bit poking
- usage of setbits_le32/clrbits_le32 automatically fixed bug where usbc_bit was clobbered unintentionally
- added more info about commented out gpio_direction_output, it will be used once [1] is applied against upstream
[1] http://patchwork.ozlabs.org/patch/356566/
[2] http://git.denx.de/u-boot-sunxi.git/
Roman Byshko (5):
sunxi: add defines to control USB Host clocks/resets
sunxi: add USB EHCI driver
sunxi: add general USB settings
sun7i: add USB EHCI settings
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 | 196 ++++++++++++++++++++++++++ include/configs/sun7i.h | 8 ++ include/configs/sunxi-common.h | 6 + 6 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/host/ehci-sunxi.c
Signature · 1 line
2.0.0
PATCH v3 1/5 sunxi: add defines to control USB Host clocks/resets
The commit adds three defines which will be used in the EHCI driver to enable USB clock and assert reset controllers of the corresponding PHYs.
--- 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
@@ -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
PATCH v3 2/5 sunxi: add USB EHCI driver
In reply to Roman ByshkoThe Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
--- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 196 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 drivers/usb/host/ehci-sunxi.c
drivers/usb/host/Makefile +1 -0
@@ -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 +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v3 3/5 sunxi: add general USB settings
In reply to Roman ByshkoGeneral configuration settings to be set if CONFIG_USB_EHCI is enabled for an Allwinner aka sunxi SoC.
--- include/configs/sunxi-common.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/configs/sunxi-common.h +6 -0
@@ -204,6 +204,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
PATCH v3 4/5 sun7i: add USB EHCI settings
In reply to Roman ByshkoSpecific USB EHCI settings to be set for sun7i ifCONFIG_USB_EHCI is enabled.
--- include/configs/sun7i.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/configs/sun7i.h +8 -0
@@ -17,6 +17,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
PATCH v3 5/5 sun7i: cubietruck: enable USB EHCI
In reply to Roman ByshkoCubietruck has two USB host controllers. This makes them usable by enabling the EHCI driver for them.
--- boards.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
boards.cfg +1 -1
@@ -381,7 +381,7 @@ Active arm armv7 sunxi - sunxi Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubieboard2 sun7i:CUBIEBOARD2,SPL,SUNXI_GMAC Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubieboard2_FEL sun7i:CUBIEBOARD2,SPL_FEL,SUNXI_GMAC Ian Campbell <[email protected]>:Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII,USB_EHCI Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi r7-tv-dongle sun5i:R7DONGLE,SPL,AXP152_POWER Hans de Goede <[email protected]> Active arm armv7 u8500 st-ericsson snowball snowball - Mathieu Poirier <[email protected]>
Signature · 1 line
2.0.0
v3 cover ARM: Allwinner sunxi USB Host EHCI support
In reply to Roman ByshkoHi Marek,
Quoted 44 lines · Roman Byshko
This patch series adds USB Host EHCI support to the sunxi SoCs. 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.
Best,
Roman ByshkoChanges since v2:
- improved commit messages
- removed BIT macro
- addedget_io_basefunction
- removed unnecessary verboseness when definingsunxi_echi_hcdarray
- the EHCI driver is now based on [2] and uses GPIO driver
- possible failure is ruled out by introducingenabled_hcd_count
Changes since v1:
- fixed erroneous copyright author
- used SPDX tag instead of the full license
- used setbits_le32/clrbits_le32 instead of direct bit poking
- usage of setbits_le32/clrbits_le32 automatically fixed bug whereusbc_bitwas clobbered unintentionally
- added more info about commented outgpio_direction_output, it will be used once [1] is applied against upstream[1] http://patchwork.ozlabs.org/patch/356566/
[2] http://git.denx.de/u-boot-sunxi.git/Roman Byshko (5):
sunxi: add defines to control USB Host clocks/resets
sunxi: add USB EHCI driver
sunxi: add general USB settings
sun7i: add USB EHCI settings
sun7i: cubietruck: enable USB EHCIarch/arm/include/asm/arch-sunxi/clock_sun4i.h | 4 + boards.cfg | 2 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 196 ++++++++++++++++++++++++++ include/configs/sun7i.h | 8 ++ include/configs/sunxi-common.h | 6 + 6 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/host/ehci-sunxi.c
Quoted 3 lines
--
2.0.0
I'm sorry I've again forgot to add you to the CC of this patchset. Should not happen again.
So here it is:
https://www.mail-archive.com/u-boot at lists.denx.de/msg142969.html
Thanks,
Roman
PATCH v3 2/5 sunxi: add USB EHCI driver
In reply to Roman ByshkoQuoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>
Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
CHECK: No space is necessary after a cast
#170: FILE: drivers/usb/host/ehci-sunxi.c:43:
+ .gpio_vbus = CONFIG_SUNXI_USB_VBUS0_GPIO,
+ .csr = (void*) SUNXI_USB_CSR,
ERROR: "(foo*)" should be "(foo *)"
#170: FILE: drivers/usb/host/ehci-sunxi.c:43:
+ .csr = (void*) SUNXI_USB_CSR,
CHECK: No space is necessary after a cast
#179: FILE: drivers/usb/host/ehci-sunxi.c:52:
+ .gpio_vbus = CONFIG_SUNXI_USB_VBUS1_GPIO,
+ .csr = (void*) SUNXI_USB_CSR,
ERROR: "(foo*)" should be "(foo *)"
#179: FILE: drivers/usb/host/ehci-sunxi.c:52:
+ .csr = (void*) SUNXI_USB_CSR,
ERROR: do not initialise statics to 0 or NULL
#186: FILE: drivers/usb/host/ehci-sunxi.c:59:
+static int enabled_hcd_count = 0;
ERROR: "foo* bar" should be "foo *bar"
#188: FILE: drivers/usb/host/ehci-sunxi.c:61:
+static void* get_io_base(int hcd_id)
CHECK: No space is necessary after a cast
#191: FILE: drivers/usb/host/ehci-sunxi.c:64:
+ if (hcd_id == 1)
+ return (void*) SUNXI_USB1_IO_BASE;
ERROR: "(foo*)" should be "(foo *)"
#191: FILE: drivers/usb/host/ehci-sunxi.c:64:
+ return (void*) SUNXI_USB1_IO_BASE;
CHECK: No space is necessary after a cast
#193: FILE: drivers/usb/host/ehci-sunxi.c:66:
+ else if (hcd_id == 2)
+ return (void*) SUNXI_USB2_IO_BASE;
ERROR: "(foo*)" should be "(foo *)"
#193: FILE: drivers/usb/host/ehci-sunxi.c:66:
+ return (void*) SUNXI_USB2_IO_BASE;
ERROR: trailing statements should be on next line
#194: FILE: drivers/usb/host/ehci-sunxi.c:67:
+ else return NULL;
ERROR: trailing whitespace
#195: FILE: drivers/usb/host/ehci-sunxi.c:68:
+}^I$
CHECK: Alignment should match open parenthesis
#301: FILE: drivers/usb/host/ehci-sunxi.c:174:
+ debug("sunxi-ehci: init hccr %x and hcor %x hc_length %d\n",
+ (uint32_t)*hccr, (uint32_t)*hcor,
total: 8 errors, 0 warnings, 5 checks, 203 lines checked
NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or
scripts/cleanfile
NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE USLEEP_RANGE
/tmp/[U-Boot] [PATCH v3 2_5] sunxi_add USB EHCI driver.mbox has style problems, please review.
Best regards,
Marek Vasut
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 9 lines · Marek Vasut
Quoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
Are you planning to take the whole series via u-boot-usb? That's OK by me of course.
Ian.
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>
Quoted 7 lines
Quoted 4 lines
Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
Are you planning to take the whole series via u-boot-usb? That's OK by me of course.
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Best regards,
Marek Vasut
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 13 lines · Marek Vasut
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Marek Vasut
Quoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
Quoted 6 lines
Quoted 2 lines
Are you planning to take the whole series via u-boot-usb? That's OK by me of course.
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Some patches (e.g. #5) don't make much sense without #2, but they are harmless and when things eventually meet in whichever upstream tree it should all (hopefully!) burst into life. Does that sound ok?
Ian.
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 17 lines · Ian Campbell
Quoted 16 lines · Marek Vasut
Quoted 14 lines · Ian Campbell
Quoted 10 lines · Marek Vasut
Quoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
Are you planning to take the whole series via u-boot-usb? That's OK by me of course.
Quoted 7 lines
Quoted 3 lines
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Some patches (e.g. #5) don't make much sense without #2, but they are harmless and when things eventually meet in whichever upstream tree it should all (hopefully!) burst into life. Does that sound ok?
Yes, let's do it this way please. I will pick a new version of 2/5 only, you pick the rest now.
Thank you !
Best regards,
Marek Vasut
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 22 lines · Marek Vasut
Quoted 21 lines · Ian Campbell
Quoted 19 lines · Marek Vasut
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>Quoted 7 lines
Quoted 4 lines
Did you verify the patches to be checkpatch clean please ? Also, they don't apply to u-boot-usb/master , so I will wait for V4 with this cleanup and rebase on top of u-boot-usb. Otherwise they are good, thanks !
Are you planning to take the whole series via u-boot-usb? That's OK by me of course.
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Quoted 6 lines
Quoted 3 lines
Some patches (e.g. #5) don't make much sense without #2, but they are harmless and when things eventually meet in whichever upstream tree it should all (hopefully!) burst into life. Does that sound ok?
Yes, let's do it this way please. I will pick a new version of 2/5 only, you pick the rest now.
Ack, will do.
PATCH v3 5/5 sun7i: cubietruck: enable USB EHCI
In reply to Roman ByshkoQuoted 2 lines · Roman Byshko
Cubietruck has two USB host controllers. This makes them usable by enabling the EHCI driver for them.
Did you not want to enable for the Cubietruck_FEL config too?
What about other boards with A20 on them? And does this same driver work for sun4i, sun5i or sun6i?
The wiki seems to suggest yes for sun4i and sun5i at least. I don't necessarily expect you will want to add the cfg for boards you can't test yourself but I'm wondering if I should prod people (well, mainly Hans so far ;-)) to enable on their boards.
There's a minor conflict with the updated boards.cfg in u-boot-sunxi.git#next. I can pretty easily resolve it but if you need to resend the series for some other reason you could save me the trouble and base it one branch instead of master.
Cheers,
Ian.
Quoted 19 lines
Signed-off-by Roman Byshko <[email protected]>Acked-by Ian Campbell <[email protected]>--- boards.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)boards.cfg +1
-1@@ -381,7 +381,7 @@ Active arm armv7 sunxi - sunxi Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubieboard2 sun7i:CUBIEBOARD2,SPL,SUNXI_GMAC Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubieboard2_FEL sun7i:CUBIEBOARD2,SPL_FEL,SUNXI_GMAC Ian Campbell <[email protected]>:Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII,USB_EHCI Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi r7-tv-dongle sun5i:R7DONGLE,SPL,AXP152_POWER Hans de Goede <[email protected]> Active arm armv7 u8500 st-ericsson snowball snowball - Mathieu Poirier <[email protected]>
PATCH v3 2/5 sunxi: add USB EHCI driver
In reply to Roman ByshkoHi,
Quoted 125 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>--- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 196 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)create mode 100644
drivers/usb/host/ehci-sunxi.cdrivers/usb/host/Makefile +1
-0@@ -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.odrivers/usb/host/ehci-sunxi.c new file +97
-0@@ -0,0 +1,196 @@ +/* +* Copyright (C) 2014 Roman Byshko +* +* Roman Byshko <[email protected]> +* +* Based on code from +* Allwinner Technology Co., Ltd. <www.allwinnertech.com> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <asm/arch/clock.h> +#include <asm/gpio.h> +#include <asm/io.h> +#include <common.h> +#include "ehci.h" + +#define SUNXI_USB1_IO_BASE 0x01c14000 +#define SUNXI_USB2_IO_BASE 0x01c1c000 + +#define SUNXI_USB_PMU_IRQ_ENABLE 0x800 +#define SUNXI_USB_CSR 0x01c13404 +#define SUNXI_USB_PASSBY_EN 1 + +#define SUNXI_EHCI_AHB_ICHR8_EN (1 << 10) +#define SUNXI_EHCI_AHB_INCR4_BURST_EN (1 << 9) +#define SUNXI_EHCI_AHB_INCRX_ALIGN_EN (1 << 8) +#define SUNXI_EHCI_ULPI_BYPASS_EN (1 << 0) + +static struct sunxi_ehci_hcd { +struct usb_hcd *hcd; +int usb_rst_mask; +int ahb_clk_mask; +int gpio_vbus; +void *csr; +int irq; +int id; +} sunxi_echi_hcd[] = { + { + .usb_rst_mask =CCM_USB_CTRL_PHY1_RST , + .ahb_clk_mask =1 <<AHB_GATE_OFFSET_USB_EHCI0 , + .gpio_vbus =CONFIG_SUNXI_USB_VBUS0_GPIO , + .csr = (void *)SUNXI_USB_CSR , + .irq =39 , + .id =1 , + }, +#if (CONFIG_USB_MAX_CONTROLLER_COUNT > 1) + { + .usb_rst_mask =CCM_USB_CTRL_PHY2_RST , + .ahb_clk_mask =1 <<AHB_GATE_OFFSET_USB_EHCI1 , + .gpio_vbus =CONFIG_SUNXI_USB_VBUS1_GPIO , + .csr = (void *)SUNXI_USB_CSR , + .irq =40 , + .id =2 , + } +#endif +}; + +static int enabled_hcd_count =0 ; + +static void *get_io_base (int hcd_id) +{ +if (hcd_id ==1 ) +return (void *)SUNXI_USB1_IO_BASE ; +else if (hcd_id ==2 ) +return (void *)SUNXI_USB2_IO_BASE ; +else return NULL ; +} + +static void usb_phy_write (struct sunxi_ehci_hcd *sunxi_ehci,int addr, +int data,int len) +{ +int j =0 , usbc_bit =0 ; +void *dest = sunxi_ehci->csr; + + usbc_bit =1 << (sunxi_ehci->id *2 ); +for (j =0 ; j < len; j++) { +/* set the bit address to be written */ +clrbits_le32 (dest,0xff <<8 ); +setbits_le32 (dest, (addr + j) <<8 ); + +clrbits_le32 (dest, usbc_bit); +/* set data bit */ +if (data &0x1 ) +setbits_le32 (dest,1 <<7 ); +else +clrbits_le32 (dest,1 <<7 ); + +setbits_le32 (dest, usbc_bit); + +clrbits_le32 (dest, usbc_bit); + + data >>=1 ; + } +} + +static void sunxi_usb_phy_init (struct sunxi_ehci_hcd *sunxi_ehci)
drivers/usb/host/ehci-sunxi.c line 107
Quoted 10 lines
drivers/usb/host/ehci-sunxi.c new file +10
-0+{ +/* The following comments are machine +* translated from Chinese, you have been warned! +*/ + +/* adjust PHY's magnitude and rate */ +usb_phy_write (sunxi_ehci,0x20 ,0x14 ,5 ); + +/* threshold adjustment disconnect */ +usb_phy_write (sunxi_ehci,0x2a ,3 ,2 );
This only should be set to 3 for sun4i, for sun5i and sun7i it should be 2, otherwise usb disconnection does not get detected reliable. IOW this should be:
/* threshold adjustment disconnect */ #ifdef CONFIG_SUN4I usb_phy_write(sunxi_ehci, 0x2a, 3, 2); #else usb_phy_write(sunxi_ehci, 0x2a, 2, 2);
#endif
As the kernel driver does.
Please fix this before submitting the next version of this patch.
Regards,
Hans
PATCH v3 2/5 sunxi: add USB EHCI driver
In reply to Roman ByshkoHi,
Quoted 2 lines · Marek Vasut
Quoted 1 line · Ian Campbell
On Fri, 2014-07-25 at 17:41 +0200, Marek Vasut wrote:
<snip>
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Some patches (e.g. #5) don't make much sense without #2, but they are harmless and when things eventually meet in whichever upstream tree it should all (hopefully!) burst into life. Does that sound ok?
Yes, let's do it this way please. I will pick a new version of 2/5 only, you pick the rest now.
I've been working on u-boot-sunxi next today to add support for more boards upstream, and I thought it would be good to cherry pick this set first so that I can add the necessary CONFIG_USB_EHCI in boards.cfg for boards which support this right away, but this causes builds to fail, e.g. :
drivers/usb/host/built-in.o: In function `usb_lowlevel_stop':/home/hans/projects/sunxi/u-boot/drivers/usb/host/ehci-hcd.c:923: undefined reference to ehci_hcd_stop' drivers/usb/host/built-in.o: In function usb_lowlevel_init':/home/hans/projects/sunxi/u-boot/drivers/usb/host/ehci-hcd.c:935: undefined reference to `ehci_hcd_init' arm-linux-gnu-ld.bfd: BFD version 2.24.0-4.fc21 20140613 assertion fail ../../binutils-2.24/bfd/elf32-arm.c:7696 arm-linux-gnu-ld.bfd: BFD version 2.24.0-4.fc21 20140613 assertion fail ../../binutils-2.24/bfd/elf32-arm.c:7696 arm-linux-gnu-ld.bfd: error: required section '.rel.plt' not found in the linker script arm-linux-gnu-ld.bfd: final link failed: Invalid operation
Makefile:986: recipe for target 'u-boot' failed
So merging 1 and 3-5 to the sunxi tree while merging 2 through your (Marek's) tree does not seem to be the best idea. I think it would be best to take this patch (patch 2) through the sunxi tree too, with your ack (once your happy with it).
Roman, this means that it would be nice to get a v4 from you soon, so that we can line up the next bunch of patches for mainline.
Thanks & Regards,
Hans
PATCH v3 5/5 sun7i: cubietruck: enable USB EHCI
In reply to Ian CampbellHi,
Quoted 8 lines · Ian Campbell
Quoted 2 lines · Roman Byshko
Cubietruck has two USB host controllers. This makes them usable by enabling the EHCI driver for them.
Did you not want to enable for the
Cubietruck_FELconfig too?What about other boards with A20 on them? And does this same driver work for sun4i, sun5i or sun6i?
It should work on sun4i, sun5i and sun7i with one very small modification (which is actually needed for sun5i and sun7i not for sun4i).
See my reply to the 2nd patch of this series.
Quoted 10 lines
The wiki seems to suggest yes for sun4i and sun5i at least. I don't necessarily expect you will want to add the cfg for boards you can't test yourself but I'm wondering if I should prod people (well, mainly Hans so far ;-)) to enable on their boards.
There's a minor conflict with the updated boards.cfg in u-boot-sunxi.git#next. I can pretty easily resolve it but if you need to resend the series for some other reason you could save me the trouble and base it one branch instead of master.
I've already cherry picked this patch for adding it to u-boot-sunxi next branch, resolving the conflict myself. Unfortunately we cannot take this patch in sunxi next without also taking the 2nd patch otherwise the build breaks. See my other reply to the 2nd patch in the series on this.
Regards,
Hans
PATCH v3 2/5 sunxi: add USB EHCI driver
In reply to Hans de GoedeQuoted 37 lines · Hans de Goede
Hi,
Quoted 2 lines · Marek Vasut
Quoted 1 line · Ian Campbell
On Fri, 2014-07-25 at 17:41 +0200, Marek Vasut wrote:
<snip>
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
If you pick all but 2/5 right now, I am happy with that. It will prevent conflicts. I will pick 2/5 only after that . Let's do it like that. Roman will also have to resend only 2/5 once fixed.
Some patches (e.g. #5) don't make much sense without #2, but they are harmless and when things eventually meet in whichever upstream tree it should all (hopefully!) burst into life. Does that sound ok?
Yes, let's do it this way please. I will pick a new version of 2/5 only, you pick the rest now.
I've been working on u-boot-sunxi next today to add support for more boards upstream, and I thought it would be good to cherry pick this set first so that I can add the necessary
CONFIG_USB_EHCIin boards.cfg for boards which support this right away, but this causes builds to fail, e.g. :
drivers/usb/host/built-in.o: In function `usb_lowlevel_stop':/home/hans/projects/sunxi/u-boot/drivers/usb/host/ehci-hcd.c:923: undefined reference toehci_hcd_stop' drivers/usb/host/built-in.o: In functionusb_lowlevel_init':/home/hans/projects/sunxi/u-boot/drivers/usb/host/ehci-hcd.c:935: undefined reference to `ehci_hcd_init' arm-linux-gnu-ld.bfd: BFD version 2.24.0-4.fc21 20140613 assertion fail../../binutils-2.24/bfd/elf32-arm.c:7696arm-linux-gnu-ld.bfd: BFD version 2.24.0-4.fc21 20140613 assertion fail../../binutils-2.24/bfd/elf32-arm.c:7696arm-linux-gnu-ld.bfd: error:
required section '.rel.plt' not found in the linker script arm-linux-gnu-ld.bfd: final link failed: Invalid operation Makefile:986: recipe for target 'u-boot' failed
Quoted 7 lines
So merging 1 and 3-5 to the sunxi tree while merging 2 through your (Marek's) tree does not seem to be the best idea. I think it would be best to take this patch (patch 2) through the sunxi tree too, with your ack (once your happy with it).
Roman, this means that it would be nice to get a v4 from you soon, so that we can line up the next bunch of patches for mainline.
OK, then please pick them all up.
Best regards,
Marek Vasut
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 9 lines · Marek Vasut
Quoted 7 lines
So merging 1 and 3-5 to the sunxi tree while merging 2 through your (Marek's) tree does not seem to be the best idea. I think it would be best to take this patch (patch 2) through the sunxi tree too, with your ack (once your happy with it).
Roman, this means that it would be nice to get a v4 from you soon, so that we can line up the next bunch of patches for mainline.
OK, then please pick them all up.
Will do. To be clear we are still waiting for a v4 and for your ack.
Ian.
PATCH v3 2/5 sunxi: add USB EHCI driver
Hi,
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
Quoted 5 lines
So merging 1 and 3-5 to the sunxi tree while merging 2 through your (Marek's) tree does not seem to be the best idea. I think it would be best to take this patch (patch 2) through the sunxi tree too, with your ack (once your happy with it).
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Roman, this means that it would be nice to get a v4 from you soon, so that we can line up the next bunch of patches for mainline.
OK, then please pick them all up.
Will do. To be clear we are still waiting for a v4 and for your ack.
Right.
Roman, note I've already merged your v3 series (with some conflict resolution + minor fixes) here:
https://github.com/jwrdegoede/u-boot-sunxi/commits/next
As I've been working on enabling the EHCI code on additional boards + adding support for more boards in general.
So we only need a v4 of "[PATCH v3 2/5] sunxi: add USB EHCI driver" with all Mareks's + my remarks fixed, and then I'll drop that in place of the one which is currently in that tree, and move things over to
http://git.denx.de/?p=u-boot/u-boot-sunxi.git;a=shortlog;h=refs/heads/next
Thanks,
Hans
PATCH v3 2/5 sunxi: add USB EHCI driver
Quoted 23 lines · Hans de Goede
Hi,
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Marek Vasut
Quoted 5 lines
So merging 1 and 3-5 to the sunxi tree while merging 2 through your (Marek's) tree does not seem to be the best idea. I think it would be best to take this patch (patch 2) through the sunxi tree too, with your ack (once your happy with it).
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Roman, this means that it would be nice to get a v4 from you soon, so that we can line up the next bunch of patches for mainline.
OK, then please pick them all up.
Will do. To be clear we are still waiting for a v4 and for your ack.
Right.
Roman, note I've already merged your v3 series (with some conflict resolution + minor fixes) here:
Quoted 7 lines
As I've been working on enabling the EHCI code on additional boards + adding support for more boards in general.
So we only need a v4 of "[PATCH v3 2/5] sunxi: add USB EHCI driver" with all Mareks's + my remarks fixed, and then I'll drop that in place of the one which is currently in that tree, and move things over to
http://git.denx.de/?p=u-boot/u-boot-sunxi.git;a=shortlog;h=refs/heads/next
Thanks for taking care of this.
Best regards,
Marek Vasut
PATCH v4 2/5 sunxi: add USB EHCI driver
In reply to Hans de GoedeThe Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
--- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 201 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 drivers/usb/host/ehci-sunxi.c
drivers/usb/host/Makefile +1 -0
@@ -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 +201 -0
201 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v4 2/5 sunxi: add USB EHCI driver
Quoted 10 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>--- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 201 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 drivers/usb/host/ehci-sunxi.c
Best regards,
Marek Vasut
PATCH v4 2/5 sunxi: add USB EHCI driver
Hi,
Quoted 12 lines · Marek Vasut
Quoted 10 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>--- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 201 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 drivers/usb/host/ehci-sunxi.c
Quoted 1 line
Acked-by Marek Vasut <[email protected]>
Roman, Marek,
Thanks this patch-set is now queued up in the u-boot-sunxi custodian git repo next branch and will be part of the next pull-req send to Albert.
Regards,
Hans
PATCH v4 2/5 sunxi: add USB EHCI driver
Quoted 18 lines · Hans de Goede
Hi,
Quoted 15 lines · Marek Vasut
Quoted 13 lines · Roman Byshko
The Allwinner aka sunxi SoCs have one or more USB host controllers. This adds a driver for their EHCI.
Signed-off-by Roman Byshko <[email protected]>---
drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-sunxi.c | 201++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+)
create mode 100644 drivers/usb/host/ehci-sunxi.c
Quoted 7 lines
Quoted 1 line
Acked-by Marek Vasut <[email protected]>Roman, Marek,
Thanks this patch-set is now queued up in the u-boot-sunxi custodian git repo next branch and will be part of the next pull-req send to Albert.
Thanks for taking care of this :)
Best regards,
Marek Vasut