[U-Boot] [PATCH 0/4] EHCI support for Panasonic UniPhier SoCs

This series includes both USB parts and Panasonic SoC-specific parts to resolve the patch dependency.
Marek, please review at least 3/4 and issue your Ack if it is OK.
After it is Ack'ed, I will apply this series to my repo.
Masahiro Yamada (4): usb: add basic USB configs in Kconfig ARM: UniPhier: add MIO register file usb: UniPhier: add UniPhier on-chip EHCI host driver support ARM: UniPhier: enable USB features
arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c | 13 +++++ arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c | 10 ++++ arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c | 13 +++++ arch/arm/include/asm/arch-uniphier/ehci-uniphier.h | 33 +++++++++++++ arch/arm/include/asm/arch-uniphier/mio-regs.h | 20 ++++++++ arch/arm/include/asm/arch-uniphier/platdevice.h | 2 + configs/ph1_ld4_defconfig | 3 ++ configs/ph1_pro4_defconfig | 3 ++ configs/ph1_sld8_defconfig | 3 ++ drivers/usb/Kconfig | 46 ++++++++++++++++++ drivers/usb/host/Kconfig | 56 ++++++++++++++++++++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-uniphier.c | 39 +++++++++++++++ include/configs/uniphier-common.h | 7 +++ 14 files changed, 249 insertions(+) create mode 100644 arch/arm/include/asm/arch-uniphier/ehci-uniphier.h create mode 100644 arch/arm/include/asm/arch-uniphier/mio-regs.h create mode 100644 drivers/usb/host/Kconfig create mode 100644 drivers/usb/host/ehci-uniphier.c

Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Marek Vasut marex@denx.de ---
drivers/usb/Kconfig | 46 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/host/Kconfig | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 drivers/usb/host/Kconfig
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index e69de29..b4a9442 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig @@ -0,0 +1,46 @@ +config USB_ARCH_HAS_HCD + def_bool y + +config USB + bool "Support for Host-side USB" + depends on USB_ARCH_HAS_HCD + ---help--- + Universal Serial Bus (USB) is a specification for a serial bus + subsystem which offers higher speeds and more features than the + traditional PC serial port. The bus supplies power to peripherals + and allows for hot swapping. Up to 127 USB peripherals can be + connected to a single USB host in a tree structure. + + The USB host is the root of the tree, the peripherals are the + leaves and the inner nodes are special USB devices called hubs. + Most PCs now have USB host ports, used to connect peripherals + such as scanners, keyboards, mice, modems, cameras, disks, + flash memory, network links, and printers to the PC. + + Say Y here if your computer has a host-side USB port and you want + to use USB devices. You then need to say Y to at least one of the + Host Controller Driver (HCD) options below. Choose a USB 1.1 + controller, such as "UHCI HCD support" or "OHCI HCD support", + and "EHCI HCD (USB 2.0) support" except for older systems that + do not have USB 2.0 support. It doesn't normally hurt to select + them all if you are not certain. + + If your system has a device-side USB port, used in the peripheral + side of the USB protocol, see the "USB Gadget" framework instead. + + After choosing your HCD, then select drivers for the USB peripherals + you'll be using. You may want to check out the information provided + in file:Documentation/usb/ and especially the links given in + file:Documentation/usb/usb-help.txt. + +if USB + +source "drivers/usb/host/Kconfig" + +config USB_STORAGE + bool "USB Mass Storage support" + ---help--- + Say Y here if you want to connect USB mass storage devices to your + board's USB port. + +endif diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig new file mode 100644 index 0000000..8a6496a --- /dev/null +++ b/drivers/usb/host/Kconfig @@ -0,0 +1,48 @@ +# +# USB Host Controller Drivers +# +comment "USB Host Controller Drivers" + +config USB_XHCI_HCD + bool "xHCI HCD (USB 3.0) support" + ---help--- + The eXtensible Host Controller Interface (xHCI) is standard for USB 3.0 + "SuperSpeed" host controller hardware. + +config USB_XHCI + bool + default USB_XHCI_HCD + ---help--- + TODO: rename after most boards switch to Kconfig + +if USB_XHCI_HCD + +endif + +config USB_EHCI_HCD + bool "EHCI HCD (USB 2.0) support" + ---help--- + The Enhanced Host Controller Interface (EHCI) is standard for USB 2.0 + "high speed" (480 Mbit/sec, 60 Mbyte/sec) host controller hardware. + If your USB host controller supports USB 2.0, you will likely want to + configure this Host Controller Driver. + + EHCI controllers are packaged with "companion" host controllers (OHCI + or UHCI) to handle USB 1.1 devices connected to root hub ports. Ports + will connect to EHCI if the device is high speed, otherwise they + connect to a companion controller. If you configure EHCI, you should + probably configure the OHCI (for NEC and some other vendors) USB Host + Controller Driver or UHCI (for Via motherboards) Host Controller + Driver too. + + You may want to read file:Documentation/usb/ehci.txt. + +config USB_EHCI + bool + default USB_EHCI_HCD + ---help--- + TODO: rename after most boards switch to Kconfig + +if USB_EHCI_HCD + +endif

This commit adds register defines of MIO (Media I/O) block of UniPhier platform. This file is necessary to control the reset signals of the USB cores.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
arch/arm/include/asm/arch-uniphier/mio-regs.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 arch/arm/include/asm/arch-uniphier/mio-regs.h
diff --git a/arch/arm/include/asm/arch-uniphier/mio-regs.h b/arch/arm/include/asm/arch-uniphier/mio-regs.h new file mode 100644 index 0000000..3306934 --- /dev/null +++ b/arch/arm/include/asm/arch-uniphier/mio-regs.h @@ -0,0 +1,20 @@ +/* + * UniPhier MIO (Media I/O) registers + * + * Copyright (C) 2014 Panasonic Corporation + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef ARCH_MIO_REGS_H +#define ARCH_MIO_REGS_H + +#define MIO_BASE 0x59810000 + +#define MIO_CLKCTRL(i) (MIO_BASE + 0x200 * (i) + 0x0020) +#define MIO_RSTCTRL(i) (MIO_BASE + 0x200 * (i) + 0x0110) +#define MIO_USB_RSTCTRL(i) (MIO_BASE + 0x200 * (i) + 0x0114) + +#define MIO_USB_RSTCTRL_XRST (0x1 << 0) + +#endif /* ARCH_MIO_REGS_H */

Support EHCI host driver used on Panasonic UniPhier platform. Since Device Tree is not supported on UniPhier yet, the base address of USB cores are passed from board files (platdevice.c).
TODO for me: Move the base address to device trees.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Cc: Marek Vasut marex@denx.de ---
arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c | 13 ++++++++ arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c | 10 ++++++ arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c | 13 ++++++++ arch/arm/include/asm/arch-uniphier/ehci-uniphier.h | 33 ++++++++++++++++++ arch/arm/include/asm/arch-uniphier/platdevice.h | 2 ++ drivers/usb/host/Kconfig | 8 +++++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-uniphier.c | 39 ++++++++++++++++++++++ 8 files changed, 119 insertions(+) create mode 100644 arch/arm/include/asm/arch-uniphier/ehci-uniphier.h create mode 100644 drivers/usb/host/ehci-uniphier.c
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c index 0047223..62f5b01 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c +++ b/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c @@ -13,3 +13,16 @@ SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK) SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK) SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK) SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK) + +/* USB : TODO for Masahiro Yamada: move base address to Device Tree */ +struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = { + { + .base = 0x5a800100, + }, + { + .base = 0x5a810100, + }, + { + .base = 0x5a820100, + }, +}; diff --git a/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c index 6da921e..1843d04 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c +++ b/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c @@ -13,3 +13,13 @@ SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK) SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK) SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK) SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK) + +/* USB : TODO for Masahiro Yamada: move base address to Device Tree */ +struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = { + { + .base = 0x5a800100, + }, + { + .base = 0x5a810100, + }, +}; diff --git a/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c index 59d054a..72ec599 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c +++ b/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c @@ -13,3 +13,16 @@ SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK) SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK) SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK) SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK) + +/* USB : TODO for Masahiro Yamada: move base address to Device Tree */ +struct uniphier_ehci_platform_data uniphier_ehci_platdata[] = { + { + .base = 0x5a800100, + }, + { + .base = 0x5a810100, + }, + { + .base = 0x5a820100, + }, +}; diff --git a/arch/arm/include/asm/arch-uniphier/ehci-uniphier.h b/arch/arm/include/asm/arch-uniphier/ehci-uniphier.h new file mode 100644 index 0000000..e9c5fb4 --- /dev/null +++ b/arch/arm/include/asm/arch-uniphier/ehci-uniphier.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __PLAT_UNIPHIER_EHCI_H +#define __PLAT_UNIPHIER_EHCI_H + +#include <linux/types.h> +#include <asm/io.h> +#include "mio-regs.h" + +struct uniphier_ehci_platform_data { + unsigned long base; +}; + +extern struct uniphier_ehci_platform_data uniphier_ehci_platdata[]; + +static inline void uniphier_ehci_reset(int index, int on) +{ + u32 tmp; + + tmp = readl(MIO_USB_RSTCTRL(index)); + if (on) + tmp &= ~MIO_USB_RSTCTRL_XRST; + else + tmp |= MIO_USB_RSTCTRL_XRST; + writel(tmp, MIO_USB_RSTCTRL(index)); +} + +#endif /* __PLAT_UNIPHIER_EHCI_H */ diff --git a/arch/arm/include/asm/arch-uniphier/platdevice.h b/arch/arm/include/asm/arch-uniphier/platdevice.h index cdf7d13..62a5126 100644 --- a/arch/arm/include/asm/arch-uniphier/platdevice.h +++ b/arch/arm/include/asm/arch-uniphier/platdevice.h @@ -21,4 +21,6 @@ U_BOOT_DEVICE(serial##n) = { \ .platdata = &serial_device##n \ };
+#include <asm/arch/ehci-uniphier.h> + #endif /* ARCH_PLATDEVICE_H */ diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 8a6496a..30d1457 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -45,4 +45,12 @@ config USB_EHCI
if USB_EHCI_HCD
+config USB_EHCI_UNIPHIER + bool "Support for Panasonic UniPhier on-chip EHCI USB controller" + depends on ARCH_UNIPHIER + default y + ---help--- + Enables support for the on-chip EHCI controller on Panasonic + UniPhier SoCs. + endif diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 1c35929..c11b551 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -37,6 +37,7 @@ 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_UNIPHIER) += ehci-uniphier.o obj-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o obj-$(CONFIG_USB_EHCI_RMOBILE) += ehci-rmobile.o obj-$(CONFIG_USB_EHCI_ZYNQ) += ehci-zynq.o diff --git a/drivers/usb/host/ehci-uniphier.c b/drivers/usb/host/ehci-uniphier.c new file mode 100644 index 0000000..77f6c9d --- /dev/null +++ b/drivers/usb/host/ehci-uniphier.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <usb.h> +#include <asm/arch/ehci-uniphier.h> +#include "ehci.h" + +/* + * Create the appropriate control structures to manage + * a new EHCI host controller. + */ +int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, + struct ehci_hcor **hcor) +{ + struct ehci_hccr *cr; + struct ehci_hcor *or; + + uniphier_ehci_reset(index, 0); + + cr = (struct ehci_hccr *)(uniphier_ehci_platdata[index].base); + or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase)); + + *hccr = cr; + *hcor = or; + + return 0; +} + +int ehci_hcd_stop(int index) +{ + uniphier_ehci_reset(index, 1); + + return 0; +}

FAT-formated USB storage device access is available.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
configs/ph1_ld4_defconfig | 3 +++ configs/ph1_pro4_defconfig | 3 +++ configs/ph1_sld8_defconfig | 3 +++ include/configs/uniphier-common.h | 7 +++++++ 4 files changed, 16 insertions(+)
diff --git a/configs/ph1_ld4_defconfig b/configs/ph1_ld4_defconfig index e6aba42..f54b15f 100644 --- a/configs/ph1_ld4_defconfig +++ b/configs/ph1_ld4_defconfig @@ -8,4 +8,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_DM_SERIAL=y CONFIG_UNIPHIER_SERIAL=y +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_STORAGE=y S:CONFIG_SPL_NAND_DENALI=y diff --git a/configs/ph1_pro4_defconfig b/configs/ph1_pro4_defconfig index 334ec4b..e795752 100644 --- a/configs/ph1_pro4_defconfig +++ b/configs/ph1_pro4_defconfig @@ -8,4 +8,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_DM_SERIAL=y CONFIG_UNIPHIER_SERIAL=y +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_STORAGE=y S:CONFIG_SPL_NAND_DENALI=y diff --git a/configs/ph1_sld8_defconfig b/configs/ph1_sld8_defconfig index 4e8f354..6510937 100644 --- a/configs/ph1_sld8_defconfig +++ b/configs/ph1_sld8_defconfig @@ -8,4 +8,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 CONFIG_DM_SERIAL=y CONFIG_UNIPHIER_SERIAL=y +CONFIG_USB=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_STORAGE=y S:CONFIG_SPL_NAND_DENALI=y diff --git a/include/configs/uniphier-common.h b/include/configs/uniphier-common.h index b18ae6d..c779c9f 100644 --- a/include/configs/uniphier-common.h +++ b/include/configs/uniphier-common.h @@ -166,6 +166,13 @@ are defined. Select only one of them." #define CONFIG_SYS_NAND_USE_FLASH_BBT #define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
+/* USB */ +#define CONFIG_CMD_USB +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 +#define CONFIG_CMD_FAT +#define CONFIG_FAT_WRITE +#define CONFIG_DOS_PARTITION + /* memtest works on */ #define CONFIG_SYS_MEMTEST_START CONFIG_SYS_SDRAM_BASE #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE + 0x01000000)

On Friday, November 07, 2014 at 10:48:30 AM, Masahiro Yamada wrote:
This series includes both USB parts and Panasonic SoC-specific parts to resolve the patch dependency.
Marek, please review at least 3/4 and issue your Ack if it is OK.
For the whole series: Acked-by: Marek Vasut marex@denx.de
Do you want to pick this yourself or shall I pick it via u-boot-usb ?
Best regards, Marek Vasut

Hi Marek,
On Fri, 7 Nov 2014 11:45:48 +0100 Marek Vasut marex@denx.de wrote:
On Friday, November 07, 2014 at 10:48:30 AM, Masahiro Yamada wrote:
This series includes both USB parts and Panasonic SoC-specific parts to resolve the patch dependency.
Marek, please review at least 3/4 and issue your Ack if it is OK.
For the whole series: Acked-by: Marek Vasut marex@denx.de
Do you want to pick this yourself or shall I pick it via u-boot-usb ?
Thank you for your quick review!
I am planning to apply this series along with some other uniphier patches and send a pull request to Tom.
Best Regards Masahiro Yamada

On Friday, November 07, 2014 at 12:08:45 PM, Masahiro Yamada wrote:
Hi Marek,
Hi!
On Fri, 7 Nov 2014 11:45:48 +0100
Marek Vasut marex@denx.de wrote:
On Friday, November 07, 2014 at 10:48:30 AM, Masahiro Yamada wrote:
This series includes both USB parts and Panasonic SoC-specific parts to resolve the patch dependency.
Marek, please review at least 3/4 and issue your Ack if it is OK.
For the whole series: Acked-by: Marek Vasut marex@denx.de
Do you want to pick this yourself or shall I pick it via u-boot-usb ?
Thank you for your quick review!
I am planning to apply this series along with some other uniphier patches and send a pull request to Tom.
Please do.
Thank you!
Best regards, Marek Vasut

2014-11-07 18:48 GMT+09:00 Masahiro Yamada yamada.m@jp.panasonic.com:
This series includes both USB parts and Panasonic SoC-specific parts to resolve the patch dependency.
Marek, please review at least 3/4 and issue your Ack if it is OK.
After it is Ack'ed, I will apply this series to my repo.
Masahiro Yamada (4): usb: add basic USB configs in Kconfig ARM: UniPhier: add MIO register file usb: UniPhier: add UniPhier on-chip EHCI host driver support ARM: UniPhier: enable USB features
Series, applied to u-boot-uniphier/master.
participants (3)
-
Marek Vasut
-
Masahiro YAMADA
-
Masahiro Yamada