aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/board-bockw.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-08-04 20:43:37 -0400
committerSimon Horman <horms+renesas@verge.net.au>2013-09-30 03:56:18 -0400
commit81a0d9062d5c93490b215d2440bbd7deb3918707 (patch)
tree28c76e64ed3912bf93c49df797b40fff6a1ac581 /arch/arm/mach-shmobile/board-bockw.c
parent1f52c65975ba16cdba1830ba216776111197a3ee (diff)
ARM: shmobile: bockw: add USB Function support
Bock-W USB1 (CN29) can be USB Host/Func by SW98/SW99 settings. USB Func will be enabled if CONFIG_USB_RENESAS_USBHS_UDC[_MODULE] was selected on this patch Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm/mach-shmobile/board-bockw.c')
-rw-r--r--arch/arm/mach-shmobile/board-bockw.c81
1 files changed, 78 insertions, 3 deletions
diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c
index 7ad868d0a047..330e84c14f8e 100644
--- a/arch/arm/mach-shmobile/board-bockw.c
+++ b/arch/arm/mach-shmobile/board-bockw.c
@@ -32,6 +32,7 @@
32#include <linux/smsc911x.h> 32#include <linux/smsc911x.h>
33#include <linux/spi/spi.h> 33#include <linux/spi/spi.h>
34#include <linux/spi/flash.h> 34#include <linux/spi/flash.h>
35#include <linux/usb/renesas_usbhs.h>
35#include <media/soc_camera.h> 36#include <media/soc_camera.h>
36#include <mach/common.h> 37#include <mach/common.h>
37#include <mach/irqs.h> 38#include <mach/irqs.h>
@@ -99,6 +100,16 @@ static void __iomem *fpga;
99 * # amixer set "LINEOUT Mixer DACL" on 100 * # amixer set "LINEOUT Mixer DACL" on
100 */ 101 */
101 102
103/*
104 * USB
105 *
106 * USB1 (CN29) can be Host/Function
107 *
108 * Host Func
109 * SW98 1 2
110 * SW99 1 3
111 */
112
102/* Dummy supplies, where voltage doesn't matter */ 113/* Dummy supplies, where voltage doesn't matter */
103static struct regulator_consumer_supply dummy_supplies[] = { 114static struct regulator_consumer_supply dummy_supplies[] = {
104 REGULATOR_SUPPLY("vddvario", "smsc911x"), 115 REGULATOR_SUPPLY("vddvario", "smsc911x"),
@@ -117,13 +128,71 @@ static struct resource smsc911x_resources[] __initdata = {
117 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */ 128 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */
118}; 129};
119 130
131#if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC)
132/*
133 * When USB1 is Func
134 */
135static int usbhsf_get_id(struct platform_device *pdev)
136{
137 return USBHS_GADGET;
138}
139
140#define SUSPMODE 0x102
141static int usbhsf_power_ctrl(struct platform_device *pdev,
142 void __iomem *base, int enable)
143{
144 enable = !!enable;
145
146 r8a7778_usb_phy_power(enable);
147
148 iowrite16(enable << 14, base + SUSPMODE);
149
150 return 0;
151}
152
153static struct resource usbhsf_resources[] __initdata = {
154 DEFINE_RES_MEM(0xffe60000, 0x110),
155 DEFINE_RES_IRQ(gic_iid(0x4f)),
156};
157
158static struct renesas_usbhs_platform_info usbhs_info __initdata = {
159 .platform_callback = {
160 .get_id = usbhsf_get_id,
161 .power_ctrl = usbhsf_power_ctrl,
162 },
163 .driver_param = {
164 .buswait_bwait = 4,
165 },
166};
167
168#define USB_PHY_SETTING {.port1_func = 1, .ovc_pin[1].active_high = 1,}
169#define USB1_DEVICE "renesas_usbhs"
170#define ADD_USB_FUNC_DEVICE_IF_POSSIBLE() \
171 platform_device_register_resndata( \
172 &platform_bus, "renesas_usbhs", -1, \
173 usbhsf_resources, \
174 ARRAY_SIZE(usbhsf_resources), \
175 &usbhs_info, sizeof(struct renesas_usbhs_platform_info))
176
177#else
178/*
179 * When USB1 is Host
180 */
181#define USB_PHY_SETTING { }
182#define USB1_DEVICE "ehci-platform"
183#define ADD_USB_FUNC_DEVICE_IF_POSSIBLE()
184
185#endif
186
120/* USB */ 187/* USB */
121static struct resource usb_phy_resources[] __initdata = { 188static struct resource usb_phy_resources[] __initdata = {
122 DEFINE_RES_MEM(0xffe70800, 0x100), 189 DEFINE_RES_MEM(0xffe70800, 0x100),
123 DEFINE_RES_MEM(0xffe76000, 0x100), 190 DEFINE_RES_MEM(0xffe76000, 0x100),
124}; 191};
125 192
126static struct rcar_phy_platform_data usb_phy_platform_data __initdata; 193static struct rcar_phy_platform_data usb_phy_platform_data __initdata =
194 USB_PHY_SETTING;
195
127 196
128/* SDHI */ 197/* SDHI */
129static struct sh_mobile_sdhi_info sdhi0_info __initdata = { 198static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
@@ -445,7 +514,7 @@ static const struct pinctrl_map bockw_pinctrl_map[] = {
445 /* USB */ 514 /* USB */
446 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", 515 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778",
447 "usb0", "usb0"), 516 "usb0", "usb0"),
448 PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", 517 PIN_MAP_MUX_GROUP_DEFAULT(USB1_DEVICE, "pfc-r8a7778",
449 "usb1", "usb1"), 518 "usb1", "usb1"),
450 /* SDHI0 */ 519 /* SDHI0 */
451 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778", 520 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
@@ -583,6 +652,12 @@ static void __init bockw_init(void)
583 } 652 }
584} 653}
585 654
655static void __init bockw_init_late(void)
656{
657 r8a7778_init_late();
658 ADD_USB_FUNC_DEVICE_IF_POSSIBLE();
659}
660
586static const char *bockw_boards_compat_dt[] __initdata = { 661static const char *bockw_boards_compat_dt[] __initdata = {
587 "renesas,bockw", 662 "renesas,bockw",
588 NULL, 663 NULL,
@@ -593,5 +668,5 @@ DT_MACHINE_START(BOCKW_DT, "bockw")
593 .init_irq = r8a7778_init_irq_dt, 668 .init_irq = r8a7778_init_irq_dt,
594 .init_machine = bockw_init, 669 .init_machine = bockw_init,
595 .dt_compat = bockw_boards_compat_dt, 670 .dt_compat = bockw_boards_compat_dt,
596 .init_late = r8a7778_init_late, 671 .init_late = bockw_init_late,
597MACHINE_END 672MACHINE_END