Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'renesas-phy-rcar-usb-for-v3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas into next/soc

From Simon Horman:
Renesas USB updates for v3.11

These updates are by Sergei Shtylyov to clean-up USB support
present for R8A7779/Marzen and then extend USB support coverage to
R8A7778/BOCK-W.

* tag 'renesas-phy-rcar-usb-for-v3.11' of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas:
ARM: shmobile: BOCK-W: add USB support
ARM: shmobile: r8a7778: add USB support
phy-rcar-usb: add R8A7778 support
phy-rcar-usb: handle platform data
ARM: shmobile: Marzen: pass platform data to USB PHY device
phy-rcar-usb: add platform data
phy-rcar-usb: correct base address
ARM: shmobile: r8a7779: remove USB PHY 2nd memory resource
phy-rcar-usb: remove EHCI internal buffer setup
ARM: shmobile: r8a7779: setup EHCI internal buffer
ehci-platform: add pre_setup() method to platform data
ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 code

Conflicts:
arch/arm/mach-shmobile/board-marzen.c
arch/arm/mach-shmobile/setup-r8a7778.c

Signed-off-by: Olof Johansson <olof@lixom.net>

+448 -229
+2
arch/arm/mach-shmobile/Kconfig
··· 41 41 select CPU_V7 42 42 select SH_CLK_CPG 43 43 select ARM_GIC 44 + select USB_ARCH_HAS_EHCI 45 + select USB_ARCH_HAS_OHCI 44 46 45 47 config ARCH_R8A7779 46 48 bool "R-Car H1 (R8A77790)"
+8
arch/arm/mach-shmobile/board-bockw.c
··· 38 38 DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */ 39 39 }; 40 40 41 + static struct rcar_phy_platform_data usb_phy_platform_data __initdata; 42 + 41 43 static const struct pinctrl_map bockw_pinctrl_map[] = { 42 44 /* SCIF0 */ 43 45 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778", 44 46 "scif0_data_a", "scif0"), 45 47 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778", 46 48 "scif0_ctrl", "scif0"), 49 + PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", 50 + "usb0", "usb0"), 51 + PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", 52 + "usb1", "usb1"), 47 53 }; 48 54 49 55 #define IRQ0MR 0x30 ··· 60 54 r8a7778_clock_init(); 61 55 r8a7778_init_irq_extpin(1); 62 56 r8a7778_add_standard_devices(); 57 + r8a7778_add_usb_phy_device(&usb_phy_platform_data); 63 58 64 59 pinctrl_register_mappings(bockw_pinctrl_map, 65 60 ARRAY_SIZE(bockw_pinctrl_map)); ··· 98 91 .init_machine = bockw_init, 99 92 .init_time = shmobile_timer_init, 100 93 .dt_compat = bockw_boards_compat_dt, 94 + .init_late = r8a7778_init_late, 101 95 MACHINE_END
+4 -177
arch/arm/mach-shmobile/board-marzen.c
··· 37 37 #include <linux/mmc/host.h> 38 38 #include <linux/mmc/sh_mobile_sdhi.h> 39 39 #include <linux/mfd/tmio.h> 40 - #include <linux/usb/otg.h> 41 - #include <linux/usb/ehci_pdriver.h> 42 - #include <linux/usb/ohci_pdriver.h> 43 - #include <linux/pm_runtime.h> 44 40 #include <mach/hardware.h> 45 41 #include <mach/r8a7779.h> 46 42 #include <mach/common.h> ··· 56 60 REGULATOR_SUPPLY("vddvario", "smsc911x"), 57 61 REGULATOR_SUPPLY("vdd33a", "smsc911x"), 58 62 }; 63 + 64 + static struct rcar_phy_platform_data usb_phy_platform_data __initdata; 59 65 60 66 /* SMSC LAN89218 */ 61 67 static struct resource smsc911x_resources[] = { ··· 148 150 .num_resources = ARRAY_SIZE(hspi_resources), 149 151 }; 150 152 151 - /* USB PHY */ 152 - static struct resource usb_phy_resources[] = { 153 - [0] = { 154 - .start = 0xffe70000, 155 - .end = 0xffe70900 - 1, 156 - .flags = IORESOURCE_MEM, 157 - }, 158 - [1] = { 159 - .start = 0xfff70000, 160 - .end = 0xfff70900 - 1, 161 - .flags = IORESOURCE_MEM, 162 - }, 163 - }; 164 - 165 - static struct platform_device usb_phy_device = { 166 - .name = "rcar_usb_phy", 167 - .resource = usb_phy_resources, 168 - .num_resources = ARRAY_SIZE(usb_phy_resources), 169 - }; 170 - 171 153 /* LEDS */ 172 154 static struct gpio_led marzen_leds[] = { 173 155 { ··· 183 205 &sdhi0_device, 184 206 &thermal_device, 185 207 &hspi_device, 186 - &usb_phy_device, 187 208 &leds_device, 188 209 }; 189 - 190 - /* USB */ 191 - static struct usb_phy *phy; 192 - static int usb_power_on(struct platform_device *pdev) 193 - { 194 - if (IS_ERR(phy)) 195 - return PTR_ERR(phy); 196 - 197 - pm_runtime_enable(&pdev->dev); 198 - pm_runtime_get_sync(&pdev->dev); 199 - 200 - usb_phy_init(phy); 201 - 202 - return 0; 203 - } 204 - 205 - static void usb_power_off(struct platform_device *pdev) 206 - { 207 - if (IS_ERR(phy)) 208 - return; 209 - 210 - usb_phy_shutdown(phy); 211 - 212 - pm_runtime_put_sync(&pdev->dev); 213 - pm_runtime_disable(&pdev->dev); 214 - } 215 - 216 - static struct usb_ehci_pdata ehcix_pdata = { 217 - .power_on = usb_power_on, 218 - .power_off = usb_power_off, 219 - .power_suspend = usb_power_off, 220 - }; 221 - 222 - static struct resource ehci0_resources[] = { 223 - [0] = { 224 - .start = 0xffe70000, 225 - .end = 0xffe70400 - 1, 226 - .flags = IORESOURCE_MEM, 227 - }, 228 - [1] = { 229 - .start = gic_iid(0x4c), 230 - .flags = IORESOURCE_IRQ, 231 - }, 232 - }; 233 - 234 - static struct platform_device ehci0_device = { 235 - .name = "ehci-platform", 236 - .id = 0, 237 - .dev = { 238 - .dma_mask = &ehci0_device.dev.coherent_dma_mask, 239 - .coherent_dma_mask = 0xffffffff, 240 - .platform_data = &ehcix_pdata, 241 - }, 242 - .num_resources = ARRAY_SIZE(ehci0_resources), 243 - .resource = ehci0_resources, 244 - }; 245 - 246 - static struct resource ehci1_resources[] = { 247 - [0] = { 248 - .start = 0xfff70000, 249 - .end = 0xfff70400 - 1, 250 - .flags = IORESOURCE_MEM, 251 - }, 252 - [1] = { 253 - .start = gic_iid(0x4d), 254 - .flags = IORESOURCE_IRQ, 255 - }, 256 - }; 257 - 258 - static struct platform_device ehci1_device = { 259 - .name = "ehci-platform", 260 - .id = 1, 261 - .dev = { 262 - .dma_mask = &ehci1_device.dev.coherent_dma_mask, 263 - .coherent_dma_mask = 0xffffffff, 264 - .platform_data = &ehcix_pdata, 265 - }, 266 - .num_resources = ARRAY_SIZE(ehci1_resources), 267 - .resource = ehci1_resources, 268 - }; 269 - 270 - static struct usb_ohci_pdata ohcix_pdata = { 271 - .power_on = usb_power_on, 272 - .power_off = usb_power_off, 273 - .power_suspend = usb_power_off, 274 - }; 275 - 276 - static struct resource ohci0_resources[] = { 277 - [0] = { 278 - .start = 0xffe70400, 279 - .end = 0xffe70800 - 1, 280 - .flags = IORESOURCE_MEM, 281 - }, 282 - [1] = { 283 - .start = gic_iid(0x4c), 284 - .flags = IORESOURCE_IRQ, 285 - }, 286 - }; 287 - 288 - static struct platform_device ohci0_device = { 289 - .name = "ohci-platform", 290 - .id = 0, 291 - .dev = { 292 - .dma_mask = &ohci0_device.dev.coherent_dma_mask, 293 - .coherent_dma_mask = 0xffffffff, 294 - .platform_data = &ohcix_pdata, 295 - }, 296 - .num_resources = ARRAY_SIZE(ohci0_resources), 297 - .resource = ohci0_resources, 298 - }; 299 - 300 - static struct resource ohci1_resources[] = { 301 - [0] = { 302 - .start = 0xfff70400, 303 - .end = 0xfff70800 - 1, 304 - .flags = IORESOURCE_MEM, 305 - }, 306 - [1] = { 307 - .start = gic_iid(0x4d), 308 - .flags = IORESOURCE_IRQ, 309 - }, 310 - }; 311 - 312 - static struct platform_device ohci1_device = { 313 - .name = "ohci-platform", 314 - .id = 1, 315 - .dev = { 316 - .dma_mask = &ohci1_device.dev.coherent_dma_mask, 317 - .coherent_dma_mask = 0xffffffff, 318 - .platform_data = &ohcix_pdata, 319 - }, 320 - .num_resources = ARRAY_SIZE(ohci1_resources), 321 - .resource = ohci1_resources, 322 - }; 323 - 324 - static struct platform_device *marzen_late_devices[] __initdata = { 325 - &ehci0_device, 326 - &ehci1_device, 327 - &ohci0_device, 328 - &ohci1_device, 329 - }; 330 - 331 - void __init marzen_init_late(void) 332 - { 333 - /* get usb phy */ 334 - phy = usb_get_phy(USB_PHY_TYPE_USB2); 335 - 336 - shmobile_init_late(); 337 - platform_add_devices(marzen_late_devices, 338 - ARRAY_SIZE(marzen_late_devices)); 339 - } 340 210 341 211 static const struct pinctrl_map marzen_pinctrl_map[] = { 342 212 /* HSPI0 */ ··· 233 407 r8a7779_pinmux_init(); 234 408 235 409 r8a7779_add_standard_devices(); 410 + r8a7779_add_usb_phy_device(&usb_phy_platform_data); 236 411 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices)); 237 412 } 238 413 ··· 244 417 .nr_irqs = NR_IRQS_LEGACY, 245 418 .init_irq = r8a7779_init_irq, 246 419 .init_machine = marzen_init, 247 - .init_late = marzen_init_late, 420 + .init_late = r8a7779_init_late, 248 421 .init_time = r8a7779_earlytimer_init, 249 422 MACHINE_END
+4
arch/arm/mach-shmobile/clock-r8a7778.c
··· 105 105 enum { 106 106 MSTP323, MSTP322, MSTP321, 107 107 MSTP114, 108 + MSTP100, 108 109 MSTP026, MSTP025, MSTP024, MSTP023, MSTP022, MSTP021, 109 110 MSTP016, MSTP015, 110 111 MSTP_NR }; ··· 115 114 [MSTP322] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 22, 0), /* SDHI1 */ 116 115 [MSTP321] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 21, 0), /* SDHI2 */ 117 116 [MSTP114] = SH_CLK_MSTP32(&p_clk, MSTPCR1, 14, 0), /* Ether */ 117 + [MSTP100] = SH_CLK_MSTP32(&p_clk, MSTPCR1, 0, 0), /* USB0/1 */ 118 118 [MSTP026] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 26, 0), /* SCIF0 */ 119 119 [MSTP025] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 25, 0), /* SCIF1 */ 120 120 [MSTP024] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 24, 0), /* SCIF2 */ ··· 132 130 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP322]), /* SDHI1 */ 133 131 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP321]), /* SDHI2 */ 134 132 CLKDEV_DEV_ID("sh-eth", &mstp_clks[MSTP114]), /* Ether */ 133 + CLKDEV_DEV_ID("ehci-platform", &mstp_clks[MSTP100]), /* USB EHCI port0/1 */ 134 + CLKDEV_DEV_ID("ohci-platform", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */ 135 135 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */ 136 136 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */ 137 137 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */
+3
arch/arm/mach-shmobile/include/mach/r8a7778.h
··· 20 20 21 21 #include <linux/mmc/sh_mobile_sdhi.h> 22 22 #include <linux/sh_eth.h> 23 + #include <linux/platform_data/usb-rcar-phy.h> 23 24 24 25 extern void r8a7778_add_standard_devices(void); 25 26 extern void r8a7778_add_standard_devices_dt(void); 26 27 extern void r8a7778_add_ether_device(struct sh_eth_plat_data *pdata); 28 + extern void r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata); 29 + extern void r8a7778_init_late(void); 27 30 extern void r8a7778_init_delay(void); 28 31 extern void r8a7778_init_irq(void); 29 32 extern void r8a7778_init_irq_dt(void);
+3
arch/arm/mach-shmobile/include/mach/r8a7779.h
··· 4 4 #include <linux/sh_clk.h> 5 5 #include <linux/pm_domain.h> 6 6 #include <linux/sh_eth.h> 7 + #include <linux/platform_data/usb-rcar-phy.h> 7 8 8 9 struct platform_device; 9 10 ··· 34 33 extern void r8a7779_add_standard_devices(void); 35 34 extern void r8a7779_add_standard_devices_dt(void); 36 35 extern void r8a7779_add_ether_device(struct sh_eth_plat_data *pdata); 36 + extern void r8a7779_add_usb_phy_device(struct rcar_phy_platform_data *pdata); 37 + extern void r8a7779_init_late(void); 37 38 extern void r8a7779_clock_init(void); 38 39 extern void r8a7779_pinmux_init(void); 39 40 extern void r8a7779_pm_init(void);
+108
arch/arm/mach-shmobile/setup-r8a7778.c
··· 30 30 #include <linux/irqchip.h> 31 31 #include <linux/serial_sci.h> 32 32 #include <linux/sh_timer.h> 33 + #include <linux/pm_runtime.h> 34 + #include <linux/usb/phy.h> 35 + #include <linux/usb/hcd.h> 36 + #include <linux/usb/ehci_pdriver.h> 37 + #include <linux/usb/ohci_pdriver.h> 38 + #include <linux/dma-mapping.h> 33 39 #include <mach/irqs.h> 34 40 #include <mach/r8a7778.h> 35 41 #include <mach/common.h> ··· 94 88 ARRAY_SIZE(sh_tmu##idx##_resources), \ 95 89 &sh_tmu##idx##_platform_data, \ 96 90 sizeof(sh_tmu##idx##_platform_data)) 91 + 92 + /* USB PHY */ 93 + static struct resource usb_phy_resources[] __initdata = { 94 + DEFINE_RES_MEM(0xffe70800, 0x100), 95 + DEFINE_RES_MEM(0xffe76000, 0x100), 96 + }; 97 + 98 + void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata) 99 + { 100 + platform_device_register_resndata(&platform_bus, "rcar_usb_phy", -1, 101 + usb_phy_resources, 102 + ARRAY_SIZE(usb_phy_resources), 103 + pdata, sizeof(*pdata)); 104 + } 105 + 106 + /* USB */ 107 + static struct usb_phy *phy; 108 + 109 + static int usb_power_on(struct platform_device *pdev) 110 + { 111 + if (IS_ERR(phy)) 112 + return PTR_ERR(phy); 113 + 114 + pm_runtime_enable(&pdev->dev); 115 + pm_runtime_get_sync(&pdev->dev); 116 + 117 + usb_phy_init(phy); 118 + 119 + return 0; 120 + } 121 + 122 + static void usb_power_off(struct platform_device *pdev) 123 + { 124 + if (IS_ERR(phy)) 125 + return; 126 + 127 + usb_phy_shutdown(phy); 128 + 129 + pm_runtime_put_sync(&pdev->dev); 130 + pm_runtime_disable(&pdev->dev); 131 + } 132 + 133 + static int ehci_init_internal_buffer(struct usb_hcd *hcd) 134 + { 135 + /* 136 + * Below are recommended values from the datasheet; 137 + * see [USB :: Setting of EHCI Internal Buffer]. 138 + */ 139 + /* EHCI IP internal buffer setting */ 140 + iowrite32(0x00ff0040, hcd->regs + 0x0094); 141 + /* EHCI IP internal buffer enable */ 142 + iowrite32(0x00000001, hcd->regs + 0x009C); 143 + 144 + return 0; 145 + } 146 + 147 + static struct usb_ehci_pdata ehci_pdata __initdata = { 148 + .power_on = usb_power_on, 149 + .power_off = usb_power_off, 150 + .power_suspend = usb_power_off, 151 + .pre_setup = ehci_init_internal_buffer, 152 + }; 153 + 154 + static struct resource ehci_resources[] __initdata = { 155 + DEFINE_RES_MEM(0xffe70000, 0x400), 156 + DEFINE_RES_IRQ(gic_iid(0x4c)), 157 + }; 158 + 159 + static struct usb_ohci_pdata ohci_pdata __initdata = { 160 + .power_on = usb_power_on, 161 + .power_off = usb_power_off, 162 + .power_suspend = usb_power_off, 163 + }; 164 + 165 + static struct resource ohci_resources[] __initdata = { 166 + DEFINE_RES_MEM(0xffe70400, 0x400), 167 + DEFINE_RES_IRQ(gic_iid(0x4c)), 168 + }; 169 + 170 + #define USB_PLATFORM_INFO(hci) \ 171 + static struct platform_device_info hci##_info __initdata = { \ 172 + .parent = &platform_bus, \ 173 + .name = #hci "-platform", \ 174 + .id = -1, \ 175 + .res = hci##_resources, \ 176 + .num_res = ARRAY_SIZE(hci##_resources), \ 177 + .data = &hci##_pdata, \ 178 + .size_data = sizeof(hci##_pdata), \ 179 + .dma_mask = DMA_BIT_MASK(32), \ 180 + } 181 + 182 + USB_PLATFORM_INFO(ehci); 183 + USB_PLATFORM_INFO(ohci); 97 184 98 185 /* Ether */ 99 186 static struct resource ether_resources[] = { ··· 294 195 295 196 r8a7778_register_tmu(0); 296 197 r8a7778_register_tmu(1); 198 + } 199 + 200 + void __init r8a7778_init_late(void) 201 + { 202 + phy = usb_get_phy(USB_PHY_TYPE_USB2); 203 + 204 + platform_device_register_full(&ehci_info); 205 + platform_device_register_full(&ohci_info); 297 206 } 298 207 299 208 static struct renesas_intc_irqpin_config irqpin_platform_data = { ··· 417 310 .init_machine = r8a7778_add_standard_devices_dt, 418 311 .init_time = shmobile_timer_init, 419 312 .dt_compat = r8a7778_compat_dt, 313 + .init_late = r8a7778_init_late, 420 314 MACHINE_END 421 315 422 316 #endif /* CONFIG_USE_OF */
+193 -3
arch/arm/mach-shmobile/setup-r8a7779.c
··· 32 32 #include <linux/sh_intc.h> 33 33 #include <linux/sh_timer.h> 34 34 #include <linux/dma-mapping.h> 35 + #include <linux/usb/otg.h> 36 + #include <linux/usb/hcd.h> 37 + #include <linux/usb/ehci_pdriver.h> 38 + #include <linux/usb/ohci_pdriver.h> 39 + #include <linux/pm_runtime.h> 35 40 #include <mach/hardware.h> 36 41 #include <mach/irqs.h> 37 42 #include <mach/r8a7779.h> ··· 388 383 }, 389 384 }; 390 385 386 + /* USB PHY */ 387 + static struct resource usb_phy_resources[] __initdata = { 388 + [0] = { 389 + .start = 0xffe70800, 390 + .end = 0xffe70900 - 1, 391 + .flags = IORESOURCE_MEM, 392 + }, 393 + }; 394 + 395 + /* USB */ 396 + static struct usb_phy *phy; 397 + 398 + static int usb_power_on(struct platform_device *pdev) 399 + { 400 + if (IS_ERR(phy)) 401 + return PTR_ERR(phy); 402 + 403 + pm_runtime_enable(&pdev->dev); 404 + pm_runtime_get_sync(&pdev->dev); 405 + 406 + usb_phy_init(phy); 407 + 408 + return 0; 409 + } 410 + 411 + static void usb_power_off(struct platform_device *pdev) 412 + { 413 + if (IS_ERR(phy)) 414 + return; 415 + 416 + usb_phy_shutdown(phy); 417 + 418 + pm_runtime_put_sync(&pdev->dev); 419 + pm_runtime_disable(&pdev->dev); 420 + } 421 + 422 + static int ehci_init_internal_buffer(struct usb_hcd *hcd) 423 + { 424 + /* 425 + * Below are recommended values from the datasheet; 426 + * see [USB :: Setting of EHCI Internal Buffer]. 427 + */ 428 + /* EHCI IP internal buffer setting */ 429 + iowrite32(0x00ff0040, hcd->regs + 0x0094); 430 + /* EHCI IP internal buffer enable */ 431 + iowrite32(0x00000001, hcd->regs + 0x009C); 432 + 433 + return 0; 434 + } 435 + 436 + static struct usb_ehci_pdata ehcix_pdata = { 437 + .power_on = usb_power_on, 438 + .power_off = usb_power_off, 439 + .power_suspend = usb_power_off, 440 + .pre_setup = ehci_init_internal_buffer, 441 + }; 442 + 443 + static struct resource ehci0_resources[] = { 444 + [0] = { 445 + .start = 0xffe70000, 446 + .end = 0xffe70400 - 1, 447 + .flags = IORESOURCE_MEM, 448 + }, 449 + [1] = { 450 + .start = gic_iid(0x4c), 451 + .flags = IORESOURCE_IRQ, 452 + }, 453 + }; 454 + 455 + static struct platform_device ehci0_device = { 456 + .name = "ehci-platform", 457 + .id = 0, 458 + .dev = { 459 + .dma_mask = &ehci0_device.dev.coherent_dma_mask, 460 + .coherent_dma_mask = 0xffffffff, 461 + .platform_data = &ehcix_pdata, 462 + }, 463 + .num_resources = ARRAY_SIZE(ehci0_resources), 464 + .resource = ehci0_resources, 465 + }; 466 + 467 + static struct resource ehci1_resources[] = { 468 + [0] = { 469 + .start = 0xfff70000, 470 + .end = 0xfff70400 - 1, 471 + .flags = IORESOURCE_MEM, 472 + }, 473 + [1] = { 474 + .start = gic_iid(0x4d), 475 + .flags = IORESOURCE_IRQ, 476 + }, 477 + }; 478 + 479 + static struct platform_device ehci1_device = { 480 + .name = "ehci-platform", 481 + .id = 1, 482 + .dev = { 483 + .dma_mask = &ehci1_device.dev.coherent_dma_mask, 484 + .coherent_dma_mask = 0xffffffff, 485 + .platform_data = &ehcix_pdata, 486 + }, 487 + .num_resources = ARRAY_SIZE(ehci1_resources), 488 + .resource = ehci1_resources, 489 + }; 490 + 491 + static struct usb_ohci_pdata ohcix_pdata = { 492 + .power_on = usb_power_on, 493 + .power_off = usb_power_off, 494 + .power_suspend = usb_power_off, 495 + }; 496 + 497 + static struct resource ohci0_resources[] = { 498 + [0] = { 499 + .start = 0xffe70400, 500 + .end = 0xffe70800 - 1, 501 + .flags = IORESOURCE_MEM, 502 + }, 503 + [1] = { 504 + .start = gic_iid(0x4c), 505 + .flags = IORESOURCE_IRQ, 506 + }, 507 + }; 508 + 509 + static struct platform_device ohci0_device = { 510 + .name = "ohci-platform", 511 + .id = 0, 512 + .dev = { 513 + .dma_mask = &ohci0_device.dev.coherent_dma_mask, 514 + .coherent_dma_mask = 0xffffffff, 515 + .platform_data = &ohcix_pdata, 516 + }, 517 + .num_resources = ARRAY_SIZE(ohci0_resources), 518 + .resource = ohci0_resources, 519 + }; 520 + 521 + static struct resource ohci1_resources[] = { 522 + [0] = { 523 + .start = 0xfff70400, 524 + .end = 0xfff70800 - 1, 525 + .flags = IORESOURCE_MEM, 526 + }, 527 + [1] = { 528 + .start = gic_iid(0x4d), 529 + .flags = IORESOURCE_IRQ, 530 + }, 531 + }; 532 + 533 + static struct platform_device ohci1_device = { 534 + .name = "ohci-platform", 535 + .id = 1, 536 + .dev = { 537 + .dma_mask = &ohci1_device.dev.coherent_dma_mask, 538 + .coherent_dma_mask = 0xffffffff, 539 + .platform_data = &ohcix_pdata, 540 + }, 541 + .num_resources = ARRAY_SIZE(ohci1_resources), 542 + .resource = ohci1_resources, 543 + }; 544 + 391 545 /* Ether */ 392 546 static struct resource ether_resources[] = { 393 547 { ··· 570 406 &tmu01_device, 571 407 }; 572 408 573 - static struct platform_device *r8a7779_late_devices[] __initdata = { 409 + static struct platform_device *r8a7779_standard_devices[] __initdata = { 574 410 &i2c0_device, 575 411 &i2c1_device, 576 412 &i2c2_device, ··· 590 426 591 427 platform_add_devices(r8a7779_devices_dt, 592 428 ARRAY_SIZE(r8a7779_devices_dt)); 593 - platform_add_devices(r8a7779_late_devices, 594 - ARRAY_SIZE(r8a7779_late_devices)); 429 + platform_add_devices(r8a7779_standard_devices, 430 + ARRAY_SIZE(r8a7779_standard_devices)); 595 431 } 596 432 597 433 void __init r8a7779_add_ether_device(struct sh_eth_plat_data *pdata) ··· 599 435 platform_device_register_resndata(&platform_bus, "sh_eth", -1, 600 436 ether_resources, 601 437 ARRAY_SIZE(ether_resources), 438 + pdata, sizeof(*pdata)); 439 + } 440 + 441 + void __init r8a7779_add_usb_phy_device(struct rcar_phy_platform_data *pdata) 442 + { 443 + platform_device_register_resndata(&platform_bus, "rcar_usb_phy", -1, 444 + usb_phy_resources, 445 + ARRAY_SIZE(usb_phy_resources), 602 446 pdata, sizeof(*pdata)); 603 447 } 604 448 ··· 642 470 */ 643 471 } 644 472 473 + static struct platform_device *r8a7779_late_devices[] __initdata = { 474 + &ehci0_device, 475 + &ehci1_device, 476 + &ohci0_device, 477 + &ohci1_device, 478 + }; 479 + 480 + void __init r8a7779_init_late(void) 481 + { 482 + /* get USB PHY */ 483 + phy = usb_get_phy(USB_PHY_TYPE_USB2); 484 + 485 + shmobile_init_late(); 486 + platform_add_devices(r8a7779_late_devices, 487 + ARRAY_SIZE(r8a7779_late_devices)); 488 + } 489 + 645 490 #ifdef CONFIG_USE_OF 646 491 void __init r8a7779_init_delay(void) 647 492 { ··· 692 503 .init_irq = r8a7779_init_irq_dt, 693 504 .init_machine = r8a7779_add_standard_devices_dt, 694 505 .init_time = shmobile_timer_init, 506 + .init_late = r8a7779_init_late, 695 507 .dt_compat = r8a7779_compat_dt, 696 508 MACHINE_END 697 509 #endif /* CONFIG_USE_OF */
+6
drivers/usb/host/ehci-platform.c
··· 48 48 ehci->big_endian_desc = pdata->big_endian_desc; 49 49 ehci->big_endian_mmio = pdata->big_endian_mmio; 50 50 51 + if (pdata->pre_setup) { 52 + retval = pdata->pre_setup(hcd); 53 + if (retval < 0) 54 + return retval; 55 + } 56 + 51 57 ehci->caps = hcd->regs + pdata->caps_offset; 52 58 retval = ehci_setup(hcd); 53 59 if (retval)
+5 -5
drivers/usb/phy/Kconfig
··· 180 180 MXS Phy is used by some of the i.MX SoCs, for example imx23/28/6x. 181 181 182 182 config USB_RCAR_PHY 183 - tristate "Renesas R-Car USB phy support" 183 + tristate "Renesas R-Car USB PHY support" 184 184 depends on USB || USB_GADGET 185 185 help 186 - Say Y here to add support for the Renesas R-Car USB phy driver. 187 - This chip is typically used as USB phy for USB host, gadget. 188 - This driver supports: R8A7779 186 + Say Y here to add support for the Renesas R-Car USB common PHY driver. 187 + This chip is typically used as USB PHY for USB host, gadget. 188 + This driver supports R8A7778 and R8A7779. 189 189 190 190 To compile this driver as a module, choose M here: the 191 - module will be called rcar-phy. 191 + module will be called phy-rcar-usb. 192 192 193 193 config USB_ULPI 194 194 bool "Generic ULPI Transceiver Driver"
+80 -44
drivers/usb/phy/phy-rcar-usb.c
··· 1 1 /* 2 2 * Renesas R-Car USB phy driver 3 3 * 4 - * Copyright (C) 2012 Renesas Solutions Corp. 4 + * Copyright (C) 2012-2013 Renesas Solutions Corp. 5 5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 6 + * Copyright (C) 2013 Cogent Embedded, Inc. 6 7 * 7 8 * This program is free software; you can redistribute it and/or modify 8 9 * it under the terms of the GNU General Public License version 2 as ··· 16 15 #include <linux/platform_device.h> 17 16 #include <linux/spinlock.h> 18 17 #include <linux/module.h> 18 + #include <linux/platform_data/usb-rcar-phy.h> 19 19 20 - /* USBH common register */ 21 - #define USBPCTRL0 0x0800 22 - #define USBPCTRL1 0x0804 23 - #define USBST 0x0808 24 - #define USBEH0 0x080C 25 - #define USBOH0 0x081C 26 - #define USBCTL0 0x0858 27 - #define EIIBC1 0x0094 28 - #define EIIBC2 0x009C 20 + /* REGS block */ 21 + #define USBPCTRL0 0x00 22 + #define USBPCTRL1 0x04 23 + #define USBST 0x08 24 + #define USBEH0 0x0C 25 + #define USBOH0 0x1C 26 + #define USBCTL0 0x58 29 27 28 + /* High-speed signal quality characteristic control registers (R8A7778 only) */ 29 + #define HSQCTL1 0x24 30 + #define HSQCTL2 0x28 31 + 32 + /* USBPCTRL0 */ 33 + #define OVC2 (1 << 10) /* (R8A7779 only) */ 34 + /* Switches the OVC input pin for port 2: */ 35 + /* 1: USB_OVC2, 0: OVC2 */ 36 + #define OVC1_VBUS1 (1 << 9) /* Switches the OVC input pin for port 1: */ 37 + /* 1: USB_OVC1, 0: OVC1/VBUS1 */ 38 + /* Function mode: set to 0 */ 39 + #define OVC0 (1 << 8) /* Switches the OVC input pin for port 0: */ 40 + /* 1: USB_OVC0 pin, 0: OVC0 */ 41 + #define OVC2_ACT (1 << 6) /* (R8A7779 only) */ 42 + /* Host mode: OVC2 polarity: */ 43 + /* 1: active-high, 0: active-low */ 44 + #define PENC (1 << 4) /* Function mode: output level of PENC1 pin: */ 45 + /* 1: high, 0: low */ 46 + #define OVC0_ACT (1 << 3) /* Host mode: OVC0 polarity: */ 47 + /* 1: active-high, 0: active-low */ 48 + #define OVC1_ACT (1 << 1) /* Host mode: OVC1 polarity: */ 49 + /* 1: active-high, 0: active-low */ 50 + /* Function mode: be sure to set to 1 */ 51 + #define PORT1 (1 << 0) /* Selects port 1 mode: */ 52 + /* 1: function, 0: host */ 30 53 /* USBPCTRL1 */ 31 54 #define PHY_RST (1 << 2) 32 55 #define PLL_ENB (1 << 1) ··· 83 58 { 84 59 struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy); 85 60 struct device *dev = phy->dev; 61 + struct rcar_phy_platform_data *pdata = dev->platform_data; 86 62 void __iomem *reg0 = priv->reg0; 87 63 void __iomem *reg1 = priv->reg1; 64 + static const u8 ovcn_act[] = { OVC0_ACT, OVC1_ACT, OVC2_ACT }; 88 65 int i; 89 66 u32 val; 90 67 unsigned long flags; ··· 104 77 /* (2) start USB-PHY internal PLL */ 105 78 iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1)); 106 79 107 - /* (3) USB module status check */ 80 + /* (3) set USB-PHY in accord with the conditions of usage */ 81 + if (reg1) { 82 + u32 hsqctl1 = pdata->ferrite_bead ? 0x41 : 0; 83 + u32 hsqctl2 = pdata->ferrite_bead ? 0x0d : 7; 84 + 85 + iowrite32(hsqctl1, reg1 + HSQCTL1); 86 + iowrite32(hsqctl2, reg1 + HSQCTL2); 87 + } 88 + 89 + /* (4) USB module status check */ 108 90 for (i = 0; i < 1024; i++) { 109 91 udelay(10); 110 92 val = ioread32(reg0 + USBST); ··· 126 90 goto phy_init_end; 127 91 } 128 92 129 - /* (4) USB-PHY reset clear */ 93 + /* (5) USB-PHY reset clear */ 130 94 iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1)); 131 95 132 - /* set platform specific port settings */ 133 - iowrite32(0x00000000, (reg0 + USBPCTRL0)); 134 - 135 - /* 136 - * EHCI IP internal buffer setting 137 - * EHCI IP internal buffer enable 138 - * 139 - * These are recommended value of a datasheet 140 - * see [USB :: EHCI internal buffer setting] 141 - */ 142 - iowrite32(0x00ff0040, (reg0 + EIIBC1)); 143 - iowrite32(0x00ff0040, (reg1 + EIIBC1)); 144 - 145 - iowrite32(0x00000001, (reg0 + EIIBC2)); 146 - iowrite32(0x00000001, (reg1 + EIIBC2)); 96 + /* Board specific port settings */ 97 + val = 0; 98 + if (pdata->port1_func) 99 + val |= PORT1; 100 + if (pdata->penc1) 101 + val |= PENC; 102 + for (i = 0; i < 3; i++) { 103 + /* OVCn bits follow each other in the right order */ 104 + if (pdata->ovc_pin[i].select_3_3v) 105 + val |= OVC0 << i; 106 + /* OVCn_ACT bits are spaced by irregular intervals */ 107 + if (pdata->ovc_pin[i].active_high) 108 + val |= ovcn_act[i]; 109 + } 110 + iowrite32(val, (reg0 + USBPCTRL0)); 147 111 148 112 /* 149 113 * Bus alignment settings ··· 170 134 171 135 spin_lock_irqsave(&priv->lock, flags); 172 136 173 - if (priv->counter-- == 1) { /* last user */ 174 - iowrite32(0x00000000, (reg0 + USBPCTRL0)); 137 + if (priv->counter-- == 1) /* last user */ 175 138 iowrite32(0x00000000, (reg0 + USBPCTRL1)); 176 - } 177 139 178 140 spin_unlock_irqrestore(&priv->lock, flags); 179 141 } ··· 181 147 struct rcar_usb_phy_priv *priv; 182 148 struct resource *res0, *res1; 183 149 struct device *dev = &pdev->dev; 184 - void __iomem *reg0, *reg1; 150 + void __iomem *reg0, *reg1 = NULL; 185 151 int ret; 186 152 153 + if (!pdev->dev.platform_data) { 154 + dev_err(dev, "No platform data\n"); 155 + return -EINVAL; 156 + } 157 + 187 158 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 188 - res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 189 - if (!res0 || !res1) { 159 + if (!res0) { 190 160 dev_err(dev, "Not enough platform resources\n"); 191 161 return -EINVAL; 192 162 } 193 163 194 - /* 195 - * CAUTION 196 - * 197 - * Because this phy address is also mapped under OHCI/EHCI address area, 198 - * this driver can't use devm_request_and_ioremap(dev, res) here 199 - */ 200 - reg0 = devm_ioremap_nocache(dev, res0->start, resource_size(res0)); 201 - reg1 = devm_ioremap_nocache(dev, res1->start, resource_size(res1)); 202 - if (!reg0 || !reg1) { 203 - dev_err(dev, "ioremap error\n"); 204 - return -ENOMEM; 164 + reg0 = devm_ioremap_resource(dev, res0); 165 + if (IS_ERR(reg0)) 166 + return PTR_ERR(reg0); 167 + 168 + res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 169 + if (res1) { 170 + reg1 = devm_ioremap_resource(dev, res1); 171 + if (IS_ERR(reg1)) 172 + return PTR_ERR(reg1); 205 173 } 206 174 207 175 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+28
include/linux/platform_data/usb-rcar-phy.h
··· 1 + /* 2 + * Copyright (C) 2013 Renesas Solutions Corp. 3 + * Copyright (C) 2013 Cogent Embedded, Inc. 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #ifndef __USB_RCAR_PHY_H 11 + #define __USB_RCAR_PHY_H 12 + 13 + #include <linux/types.h> 14 + 15 + struct rcar_phy_platform_data { 16 + bool ferrite_bead:1; /* (R8A7778 only) */ 17 + 18 + bool port1_func:1; /* true: port 1 used by function, false: host */ 19 + unsigned penc1:1; /* Output of the PENC1 pin in function mode */ 20 + struct { /* Overcurrent pin control for ports 0..2 */ 21 + bool select_3_3v:1; /* true: USB_OVCn pin, false: OVCn pin */ 22 + /* Set to false on port 1 in function mode */ 23 + bool active_high:1; /* true: active high, false: active low */ 24 + /* Set to true on port 1 in function mode */ 25 + } ovc_pin[3]; /* (R8A7778 only has 2 ports) */ 26 + }; 27 + 28 + #endif /* __USB_RCAR_PHY_H */
+4
include/linux/usb/ehci_pdriver.h
··· 19 19 #ifndef __USB_CORE_EHCI_PDRIVER_H 20 20 #define __USB_CORE_EHCI_PDRIVER_H 21 21 22 + struct platform_device; 23 + struct usb_hcd; 24 + 22 25 /** 23 26 * struct usb_ehci_pdata - platform_data for generic ehci driver 24 27 * ··· 53 50 /* Turn on only VBUS suspend power and hotplug detection, 54 51 * turn off everything else */ 55 52 void (*power_suspend)(struct platform_device *pdev); 53 + int (*pre_setup)(struct usb_hcd *hcd); 56 54 }; 57 55 58 56 #endif /* __USB_CORE_EHCI_PDRIVER_H */