Skip to contentSkip to conversation

PATCH: ARM: S5PV210: Add USB EHCI support for SMDKV210 board

PATCH Angus Gratton 1 participant 3 messages Dec 24, 2011 – Dec 27, 2011

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

---
(This is my first kernel patch submission, so apologies in advance for any mistakes.)

Support is adapted from in EHCI in an older kernel & from the current mach-exynos EHCI support. I've tried to duplicate the mach-exynos code layout.

I don't actually have an SMDKV210 board to test on, this is tested on a SMDKV210-derived product called a Flexiview FV-1. I believe this should work on SMDKV210, and probably other S5PV210 boards, though.

 arch/arm/mach-s5pv210/Kconfig             |    9 +++
 arch/arm/mach-s5pv210/Makefile            |    1 +
 arch/arm/mach-s5pv210/clock.c             |    2 +-
 arch/arm/mach-s5pv210/include/mach/irqs.h |    2 +-
 arch/arm/mach-s5pv210/include/mach/map.h  |    5 ++
 arch/arm/mach-s5pv210/mach-smdkv210.c     |    9 +++
 arch/arm/mach-s5pv210/setup-usb-phy.c     |   83 +++++++++++++++++++++++++++++
 drivers/usb/host/ehci-s5p.c               |    1 -
 8 files changed, 109 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-s5pv210/setup-usb-phy.c
arch/arm/mach-s5pv210/Kconfig +9 -0
index 646057a..bf7f70c 100644
@@ -60,6 +60,13 @@ config S5PV210_SETUP_FIMC
 	help
 	  Common setup code for the camera interfaces.
 
+config S5PV210_SETUP_USB_PHY
+	bool
+	help
+	  Common setup code for USB PHY controller
+
+
+
 menu "S5PC110 Machines"
 
 config MACH_AQUILA
@@ -143,12 +150,14 @@ config MACH_SMDKV210
 	select SAMSUNG_DEV_KEYPAD
 	select SAMSUNG_DEV_PWM
 	select SAMSUNG_DEV_TS
+	select S5P_DEV_USB_EHCI
 	select S5PV210_SETUP_FB_24BPP
 	select S5PV210_SETUP_I2C1
 	select S5PV210_SETUP_I2C2
 	select S5PV210_SETUP_IDE
 	select S5PV210_SETUP_KEYPAD
 	select S5PV210_SETUP_SDHCI
+	select S5PV210_SETUP_USB_PHY
 	help
 	  Machine support for Samsung SMDKV210
 
arch/arm/mach-s5pv210/Makefile +1 -0
index 009fbe5..4d0af14 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_S5PV210_SETUP_IDE)		+= setup-ide.o
 obj-$(CONFIG_S5PV210_SETUP_KEYPAD)	+= setup-keypad.o
 obj-$(CONFIG_S5PV210_SETUP_SDHCI)       += setup-sdhci.o
 obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO)	+= setup-sdhci-gpio.o
+obj-$(CONFIG_S5PV210_SETUP_USB_PHY)     += setup-usb-phy.o
arch/arm/mach-s5pv210/clock.c +1 -1
index 4c5ac7a..2aaa259 100644
@@ -384,7 +384,7 @@ static struct clk init_clocks_off[] = {
 		.enable		= s5pv210_clk_ip1_ctrl,
 		.ctrlbit	= (1<<16),
 	}, {
-		.name		= "usb-host",
+		.name		= "usbhost",
 		.parent		= &clk_hclk_psys.clk,
 		.enable		= s5pv210_clk_ip1_ctrl,
 		.ctrlbit	= (1<<17),
arch/arm/mach-s5pv210/include/mach/irqs.h +1 -1
index 5e0de3a..b62b060 100644
@@ -59,7 +59,7 @@
 #define IRQ_IIC_HDMIPHY		S5P_IRQ_VIC1(20)
 #define IRQ_HSIRX		S5P_IRQ_VIC1(21)
 #define IRQ_HSITX		S5P_IRQ_VIC1(22)
-#define IRQ_UHOST		S5P_IRQ_VIC1(23)
+#define IRQ_USB_HOST		S5P_IRQ_VIC1(23)
 #define IRQ_OTG			S5P_IRQ_VIC1(24)
 #define IRQ_MSM			S5P_IRQ_VIC1(25)
 #define IRQ_HSMMC0		S5P_IRQ_VIC1(26)
arch/arm/mach-s5pv210/include/mach/map.h +5 -0
index 7ff609f..9f9ffe7 100644
@@ -66,6 +66,9 @@
 #define S5PV210_PA_HSOTG		0xEC000000
 #define S5PV210_PA_HSPHY		0xEC100000
 
+#define S5PV210_PA_USB_EHCI		0xEC200000
+#define S5PV210_PA_USB_OHCI		0xEC300000
+
 #define S5PV210_PA_IIS0			0xEEE30000
 #define S5PV210_PA_IIS1			0xE2100000
 #define S5PV210_PA_IIS2			0xE2A00000
@@ -111,6 +114,8 @@
 #define S3C_PA_WDT			S5PV210_PA_WATCHDOG
 
 #define S5P_PA_CHIPID			S5PV210_PA_CHIPID
+#define S5P_PA_EHCI			S5PV210_PA_USB_EHCI
+#define S5P_PA_OHCI			S5PV210_PA_USB_OHCI
 #define S5P_PA_FIMC0			S5PV210_PA_FIMC0
 #define S5P_PA_FIMC1			S5PV210_PA_FIMC1
 #define S5P_PA_FIMC2			S5PV210_PA_FIMC2
arch/arm/mach-s5pv210/mach-smdkv210.c +9 -0
index 8662ef6..72fd925 100644
@@ -46,6 +46,8 @@
 #include <plat/s5p-time.h>
 #include <plat/backlight.h>
 #include <plat/regs-fb-v4.h>
+#include <plat/clock.h>
+#include <plat/ehci.h>
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define SMDKV210_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
@@ -115,6 +117,8 @@ static struct samsung_keypad_platdata smdkv210_keypad_data __initdata = {
 	.cols		= 8,
 };
 
+static struct s5p_ehci_platdata smdkv210_ehci_pdata;
+
 static struct resource smdkv210_dm9000_resources[] = {
 	[0] = {
 		.start	= S5PV210_PA_SROM_BANK5,
@@ -227,6 +231,7 @@ static struct platform_device *smdkv210_devices[] __initdata = {
 	&s3c_device_wdt,
 	&s5pv210_device_ac97,
 	&s5pv210_device_iis0,
+	&s5p_device_ehci,
 	&s5pv210_device_spdif,
 	&samsung_asoc_dma,
 	&samsung_asoc_idma,
@@ -307,8 +312,12 @@ static void __init smdkv210_machine_init(void)
 
 	s3c_fb_set_platdata(&smdkv210_lcd0_pdata);
 
+	s5p_ehci_set_platdata(&smdkv210_ehci_pdata);
+
 	samsung_bl_set(&smdkv210_bl_gpio_info, &smdkv210_bl_data);
 
+	clk_xusbxti.rate = 24000000;
+
 	platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));
 }
 
arch/arm/mach-s5pv210/setup-usb-phy.c new file +83 -0

83 lines not on this page · raw message

drivers/usb/host/ehci-s5p.c +0 -1
index 024b65c..99f4710 100644
@@ -14,7 +14,6 @@
 
 #include <linux/clk.h>
 #include <linux/platform_device.h>
-#include <mach/regs-pmu.h>
 #include <plat/cpu.h>
 #include <plat/ehci.h>
 #include <plat/usb-phy.h>
Signature · 1 line
1.7.7.3
#1 lore raw
Quoted 6 lines · Angus Gratton

---
(This is my first kernel patch submission, so apologies in advance for any mistakes.)

Quoted 7 lines

Support is adapted from in EHCI in an older kernel & from the current mach-exynos EHCI support. I've tried to duplicate the mach-exynos code layout.

I don't actually have an SMDKV210 board to test on, this is tested on a SMDKV210-derived product called a Flexiview FV-1. I believe this should work on SMDKV210, and probably other S5PV210 boards, though.

Eck, sorry I might have sent this patch a bit early. Please disregard for now.

On my hardware USB devices initially come up happily, but sustained reads or writes eventually cause unexpected device resets and errors.

This doesn't happen with $vendorblobkernel so I must be doing something wrong. Will keep trying.

Sorry again,

Angus

#2 lore raw
Quoted 9 lines · Angus Gratton

*snip*

Quoted 7 lines

Support is adapted from in EHCI in an older kernel & from the current mach-exynos EHCI support. I've tried to duplicate the mach-exynos code layout.

I don't actually have an SMDKV210 board to test on, this is tested on a SMDKV210-derived product called a Flexiview FV-1. I believe this should work on SMDKV210, and probably other S5PV210 boards, though.

Quoted 7 lines

Eck, sorry I might have sent this patch a bit early. Please disregard for now.

On my hardware USB devices initially come up happily, but sustained reads or writes eventually cause unexpected device resets and errors.

*snip*

I found the solution in another set of old kernel source, it seems like a hardware issue where fix depends on SoC errata (my board seems to be EVT1.)

Below is the change which corrects it on my board. I'd really like to clean this up for inclusion in the kernel, if anyone can give advice on best way to do this?

* I noticed a proposal for s5pv210_revision(EVTx) from last year, but it was dropped?

* Would CONFIG_CPU_S5PV210_EVTx macros and a multichoice config item be appropriate? With defaults for each board?

* Any clues as to how to describe the addresses listed below? They seem to be above the GPIO address space, but below any addresses in mach/map.h ? Is it appropriate for them to be left as "magic numbers"?

Thanks for any/all tips.

- Angus

drivers/usb/host/ehci-s5p.c +9 -0
index 99f4710..668654c 100644
@@ -135,6 +135,15 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
        /* cache this readonly data; minimize chip reads */
        ehci->hcs_params = readl(&ehci->caps->hcs_params);
 
+       #ifdef CONFIG_CPU_S5PV210_EVT1
+       	writel(0x000E0000, hcd->regs + 0x90);
+       	writel(0x00400040, hcd->regs + 0x94);
+       #else
+       	writel(0x00600040, hcd->regs + 0x94);
+       #endif
+
+
+
        err = usb_add_hcd(hcd, irq, IRQF_SHARED);
        if (err) {
                dev_err(&pdev->dev, "Failed to add USB HCD\n");