* [PATCH 0/4] Add USB support to R8A7778/BOCK-W
@ 2013-04-09 22:47 Sergei Shtylyov
2013-04-09 22:52 ` [PATCH 2/4] ARM: shmobile: R8A7778: add USB support Sergei Shtylyov
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2013-04-09 22:47 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
'renesas-next-20130410' tag. It was created to add support of R8A7778/BOCK-W
USB to the platform code and the USB common PHY driver, and so spans both
arch/arm/mach-shmobile/ and drivers/usb/phy/ subtrees.
[1/4] rcar-phy: add R8A7778 support
[2/4] ARM: shmobile: R8A7778: add USB support
[3/4] ARM: shmobile: BOCK-W: add USB support
[4/4] ARM: shmobile: BOCK-W: enable USB in defconfig
I'm not sure thru which tree this patchset should be merged, however it turns
out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10
(which would have been most convenient probably), and it's probably too late to
merge thru Simon's tree for 3.10 too. So it now have to be postponed to 3.11,
unfortunately...
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] ARM: shmobile: R8A7778: add USB support
2013-04-09 22:47 [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
@ 2013-04-09 22:52 ` Sergei Shtylyov
2013-04-09 22:54 ` [PATCH 3/4] ARM: shmobile: BOCK-W: " Sergei Shtylyov
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2013-04-09 22:52 UTC (permalink / raw)
To: linux-arm-kernel
Add USB clock and EHCI, OHCI, and USB PHY platform devices for R8A7778 SoC; add
a function to register PHY device with board-specific platform data and register
EHCI and OHCI platfrom devices from the init_late() board method.
Also, don't forget to enable CONFIG_ARCH_HAS_[EO]HCI options for R8A7778 SoC in
Kconfig...
The patch has been tested on the BOCK-W board.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
arch/arm/mach-shmobile/Kconfig | 2
arch/arm/mach-shmobile/clock-r8a7778.c | 4
arch/arm/mach-shmobile/include/mach/r8a7778.h | 3
arch/arm/mach-shmobile/setup-r8a7778.c | 108 ++++++++++++++++++++++++++
4 files changed, 117 insertions(+)
Index: renesas/arch/arm/mach-shmobile/Kconfig
===================================================================
--- renesas.orig/arch/arm/mach-shmobile/Kconfig
+++ renesas/arch/arm/mach-shmobile/Kconfig
@@ -40,6 +40,8 @@ config ARCH_R8A7778
select CPU_V7
select SH_CLK_CPG
select ARM_GIC
+ select USB_ARCH_HAS_EHCI
+ select USB_ARCH_HAS_OHCI
config ARCH_R8A7779
bool "R-Car H1 (R8A77790)"
Index: renesas/arch/arm/mach-shmobile/clock-r8a7778.c
===================================================================
--- renesas.orig/arch/arm/mach-shmobile/clock-r8a7778.c
+++ renesas/arch/arm/mach-shmobile/clock-r8a7778.c
@@ -59,12 +59,14 @@ static struct clk *main_clks[] = {
enum {
MSTP114,
+ MSTP100,
MSTP026, MSTP025, MSTP024, MSTP023, MSTP022, MSTP021,
MSTP016, MSTP015,
MSTP_NR };
static struct clk mstp_clks[MSTP_NR] = {
[MSTP114] = SH_CLK_MSTP32(&clkp, MSTPCR1, 14, 0), /* Ether */
+ [MSTP100] = SH_CLK_MSTP32(&clkp, MSTPCR1, 0, 0), /* USB0/1 */
[MSTP026] = SH_CLK_MSTP32(&clkp, MSTPCR0, 26, 0), /* SCIF0 */
[MSTP025] = SH_CLK_MSTP32(&clkp, MSTPCR0, 25, 0), /* SCIF1 */
[MSTP024] = SH_CLK_MSTP32(&clkp, MSTPCR0, 24, 0), /* SCIF2 */
@@ -78,6 +80,8 @@ static struct clk mstp_clks[MSTP_NR] = {
static struct clk_lookup lookups[] = {
/* MSTP32 clocks */
CLKDEV_DEV_ID("sh-eth", &mstp_clks[MSTP114]), /* Ether */
+ CLKDEV_DEV_ID("ehci-platform", &mstp_clks[MSTP100]), /* USB EHCI port0/1 */
+ CLKDEV_DEV_ID("ohci-platform", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */
CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */
CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */
CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */
Index: renesas/arch/arm/mach-shmobile/include/mach/r8a7778.h
===================================================================
--- renesas.orig/arch/arm/mach-shmobile/include/mach/r8a7778.h
+++ renesas/arch/arm/mach-shmobile/include/mach/r8a7778.h
@@ -19,10 +19,13 @@
#define __ASM_R8A7778_H__
#include <linux/sh_eth.h>
+#include <linux/usb/rcar-phy.h>
extern void r8a7778_add_standard_devices(void);
extern void r8a7778_add_standard_devices_dt(void);
extern void r8a7778_add_ether_device(struct sh_eth_plat_data *pdata);
+extern void r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata);
+extern void r8a7778_init_late(void);
extern void r8a7778_init_delay(void);
extern void r8a7778_init_irq(void);
extern void r8a7778_init_irq_dt(void);
Index: renesas/arch/arm/mach-shmobile/setup-r8a7778.c
===================================================================
--- renesas.orig/arch/arm/mach-shmobile/setup-r8a7778.c
+++ renesas/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -29,6 +29,12 @@
#include <linux/irqchip.h>
#include <linux/serial_sci.h>
#include <linux/sh_timer.h>
+#include <linux/pm_runtime.h>
+#include <linux/usb/phy.h>
+#include <linux/usb/hcd.h>
+#include <linux/usb/ehci_pdriver.h>
+#include <linux/usb/ohci_pdriver.h>
+#include <linux/dma-mapping.h>
#include <mach/irqs.h>
#include <mach/r8a7778.h>
#include <mach/common.h>
@@ -88,6 +94,99 @@ static struct sh_timer_config sh_tmu1_pl
&sh_tmu##idx##_platform_data, \
sizeof(sh_tmu##idx##_platform_data))
+/* USB PHY */
+static struct resource usb_phy_resources[] = {
+ DEFINE_RES_MEM(0xffe70800, 0x100),
+ DEFINE_RES_MEM(0xffe76000, 0x100),
+};
+
+void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata)
+{
+ platform_device_register_resndata(&platform_bus, "rcar_usb_phy", -1,
+ usb_phy_resources,
+ ARRAY_SIZE(usb_phy_resources),
+ pdata, sizeof(*pdata));
+}
+
+/* USB */
+static struct usb_phy *phy;
+
+static int usb_power_on(struct platform_device *pdev)
+{
+ if (!phy)
+ return -EIO;
+
+ pm_runtime_enable(&pdev->dev);
+ pm_runtime_get_sync(&pdev->dev);
+
+ usb_phy_init(phy);
+
+ return 0;
+}
+
+static void usb_power_off(struct platform_device *pdev)
+{
+ if (!phy)
+ return;
+
+ usb_phy_shutdown(phy);
+
+ pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+}
+
+static int ehci_init_internal_buffer(struct usb_hcd *hcd)
+{
+ /*
+ * Below are recommended values from the datasheet;
+ * see [USB :: Setting of EHCI Internal Buffer].
+ */
+ /* EHCI IP internal buffer setting */
+ iowrite32(0x00ff0040, hcd->regs + 0x0094);
+ /* EHCI IP internal buffer enable */
+ iowrite32(0x00000001, hcd->regs + 0x009C);
+
+ return 0;
+}
+
+static struct usb_ehci_pdata ehci_pdata = {
+ .power_on = usb_power_on,
+ .power_off = usb_power_off,
+ .power_suspend = usb_power_off,
+ .pre_setup = ehci_init_internal_buffer,
+};
+
+static struct resource ehci_resources[] = {
+ DEFINE_RES_MEM(0xffe70000, 0x400),
+ DEFINE_RES_IRQ(gic_iid(0x4c)),
+};
+
+static struct usb_ohci_pdata ohci_pdata = {
+ .power_on = usb_power_on,
+ .power_off = usb_power_off,
+ .power_suspend = usb_power_off,
+};
+
+static struct resource ohci_resources[] = {
+ DEFINE_RES_MEM(0xffe70400, 0x400),
+ DEFINE_RES_IRQ(gic_iid(0x4c)),
+};
+
+#define USB_PLATFORM_INFO(hci) \
+static struct platform_device_info hci##_info = { \
+ .parent = &platform_bus, \
+ .name = #hci "-platform", \
+ .id = -1, \
+ .res = hci##_resources, \
+ .num_res = ARRAY_SIZE(hci##_resources), \
+ .data = &hci##_pdata, \
+ .size_data = sizeof(hci##_pdata), \
+ .dma_mask = DMA_BIT_MASK(32), \
+}
+
+USB_PLATFORM_INFO(ehci);
+USB_PLATFORM_INFO(ohci);
+
/* Ether */
static struct resource ether_resources[] = {
DEFINE_RES_MEM(0xfde00000, 0x400),
@@ -126,6 +225,14 @@ void __init r8a7778_add_standard_devices
r8a7778_register_tmu(1);
}
+void __init r8a7778_init_late(void)
+{
+ phy = usb_get_phy(USB_PHY_TYPE_USB2);
+
+ platform_device_register_full(&ehci_info);
+ platform_device_register_full(&ohci_info);
+}
+
static struct renesas_intc_irqpin_config irqpin_platform_data = {
.irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
.sense_bitfield_width = 2,
@@ -239,6 +346,7 @@ DT_MACHINE_START(R8A7778_DT, "Generic R8
.init_machine = r8a7778_add_standard_devices_dt,
.init_time = shmobile_timer_init,
.dt_compat = r8a7778_compat_dt,
+ .init_late = r8a7778_init_late,
MACHINE_END
#endif /* CONFIG_USE_OF */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] ARM: shmobile: BOCK-W: add USB support
2013-04-09 22:47 [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
2013-04-09 22:52 ` [PATCH 2/4] ARM: shmobile: R8A7778: add USB support Sergei Shtylyov
@ 2013-04-09 22:54 ` Sergei Shtylyov
2013-04-09 22:59 ` [PATCH 4/4] ARM: shmobile: BOCK-W: enable USB in defconfig Sergei Shtylyov
2013-04-10 12:46 ` [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
3 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2013-04-09 22:54 UTC (permalink / raw)
To: linux-arm-kernel
Register the USB PHY device from bockw_init(), passing the platform data to it.
Set machine's init_late() method to r8a7778_init_late() in order for [EO]HCI to
get registered too...
The patch has been tested on the BOCK-W board.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
arch/arm/mach-shmobile/board-bockw.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: renesas/arch/arm/mach-shmobile/board-bockw.c
===================================================================
--- renesas.orig/arch/arm/mach-shmobile/board-bockw.c
+++ renesas/arch/arm/mach-shmobile/board-bockw.c
@@ -53,6 +53,11 @@ static struct resource smsc911x_resource
DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
};
+static struct rcar_phy_platform_data usb_phy_platform_data = {
+ .usbpctrl0 = 0,
+ .ferrite_bead = true, /* ??? */
+};
+
#define IRQ0MR 0x30
static void __init bockw_init(void)
{
@@ -61,6 +66,7 @@ static void __init bockw_init(void)
r8a7778_clock_init();
r8a7778_init_irq_extpin(1);
r8a7778_add_standard_devices();
+ r8a7778_add_usb_phy_device(&usb_phy_platform_data);
fpga = ioremap_nocache(0x18200000, SZ_1M);
if (fpga) {
@@ -97,4 +103,5 @@ DT_MACHINE_START(BOCKW_DT, "bockw")
.init_machine = bockw_init,
.init_time = shmobile_timer_init,
.dt_compat = bockw_boards_compat_dt,
+ .init_late = r8a7778_init_late,
MACHINE_END
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] ARM: shmobile: BOCK-W: enable USB in defconfig
2013-04-09 22:47 [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
2013-04-09 22:52 ` [PATCH 2/4] ARM: shmobile: R8A7778: add USB support Sergei Shtylyov
2013-04-09 22:54 ` [PATCH 3/4] ARM: shmobile: BOCK-W: " Sergei Shtylyov
@ 2013-04-09 22:59 ` Sergei Shtylyov
2013-04-10 12:46 ` [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
3 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2013-04-09 22:59 UTC (permalink / raw)
To: linux-arm-kernel
Enable USB platform EHCI/OHCI and common PHY drivers in 'bockw_defconfig'.
Enable USB storage driver and SCSI disk driver that it needs as well...
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
arch/arm/configs/bockw_defconfig | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Index: renesas/arch/arm/configs/bockw_defconfig
===================================================================
--- renesas.orig/arch/arm/configs/bockw_defconfig
+++ renesas/arch/arm/configs/bockw_defconfig
@@ -48,6 +48,8 @@ CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
# CONFIG_FW_LOADER is not set
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
CONFIG_NETDEVICES=y
# CONFIG_NET_CADENCE is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
@@ -71,7 +73,14 @@ CONFIG_SERIAL_SH_SCI_NR_UARTS=6
CONFIG_SERIAL_SH_SCI_CONSOLE=y
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
-# CONFIG_USB_SUPPORT is not set
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_HCD_PLATFORM=y
+CONFIG_USB_EHCI_HCD_PLATFORM=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_RCAR_PHY=y
CONFIG_UIO=y
CONFIG_UIO_PDRV_GENIRQ=y
# CONFIG_IOMMU_SUPPORT is not set
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/4] Add USB support to R8A7778/BOCK-W
2013-04-09 22:47 [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
` (2 preceding siblings ...)
2013-04-09 22:59 ` [PATCH 4/4] ARM: shmobile: BOCK-W: enable USB in defconfig Sergei Shtylyov
@ 2013-04-10 12:46 ` Sergei Shtylyov
2013-04-11 0:53 ` Simon Horman
3 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2013-04-10 12:46 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 10-04-2013 2:47, Sergei Shtylyov wrote:
> Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
> 'renesas-next-20130410' tag.
Sorry, forgot to mention that it is atop the previous R8A7779/Marzen USB
patchset.
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/4] Add USB support to R8A7778/BOCK-W
2013-04-10 12:46 ` [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
@ 2013-04-11 0:53 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2013-04-11 0:53 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Apr 10, 2013 at 04:46:31PM +0400, Sergei Shtylyov wrote:
> Hello.
>
> On 10-04-2013 2:47, Sergei Shtylyov wrote:
>
> > Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
> >'renesas-next-20130410' tag.
>
> Sorry, forgot to mention that it is atop the previous
> R8A7779/Marzen USB patchset.
Thanks, got it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-11 0:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 22:47 [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
2013-04-09 22:52 ` [PATCH 2/4] ARM: shmobile: R8A7778: add USB support Sergei Shtylyov
2013-04-09 22:54 ` [PATCH 3/4] ARM: shmobile: BOCK-W: " Sergei Shtylyov
2013-04-09 22:59 ` [PATCH 4/4] ARM: shmobile: BOCK-W: enable USB in defconfig Sergei Shtylyov
2013-04-10 12:46 ` [PATCH 0/4] Add USB support to R8A7778/BOCK-W Sergei Shtylyov
2013-04-11 0:53 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).