diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-08-20 12:35:47 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-08-27 15:18:32 -0400 |
commit | c031a7d419340f30e66dc18fab4373ad646ca7e6 (patch) | |
tree | 35157398d0314f6b36355046c443ab540ca0860f | |
parent | a0b311ef17fb5d98e2c8d0aee450c1b9030873e0 (diff) |
usb: usb: dsps: update code according to the binding document
This relfects the code and dts requires changes due to recent .dts
binding updates:
- use mg prefix for the Metor Graphics specific attributes
- use power in mA not in mA/2 as specifed in the USB2.0 specification
- remove the child node for USB. This is driver specific on won't be
reflected in the device tree
- use the "mentor" prefix instead of "mg".
- use "dr_mode" istead of "mg,port-mode" for the port mode. The former
is used by a few other drivers.
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | arch/arm/boot/dts/am335x-bone.dts | 2 | ||||
-rw-r--r-- | arch/arm/boot/dts/am335x-evm.dts | 6 | ||||
-rw-r--r-- | arch/arm/boot/dts/am335x-evmsk.dts | 2 | ||||
-rw-r--r-- | arch/arm/boot/dts/am33xx.dtsi | 67 | ||||
-rw-r--r-- | drivers/usb/musb/musb_dsps.c | 54 |
5 files changed, 67 insertions, 64 deletions
diff --git a/arch/arm/boot/dts/am335x-bone.dts b/arch/arm/boot/dts/am335x-bone.dts index a8907b57c75c..e8447a79dc7e 100644 --- a/arch/arm/boot/dts/am335x-bone.dts +++ b/arch/arm/boot/dts/am335x-bone.dts | |||
@@ -127,7 +127,7 @@ | |||
127 | status = "okay"; | 127 | status = "okay"; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | phy@47401300 { | 130 | usb-phy@47401300 { |
131 | status = "okay"; | 131 | status = "okay"; |
132 | }; | 132 | }; |
133 | 133 | ||
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index c26c16cace3c..648a67e74d1b 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts | |||
@@ -178,11 +178,11 @@ | |||
178 | status = "okay"; | 178 | status = "okay"; |
179 | }; | 179 | }; |
180 | 180 | ||
181 | phy@47401300 { | 181 | usb-phy@47401300 { |
182 | status = "okay"; | 182 | status = "okay"; |
183 | }; | 183 | }; |
184 | 184 | ||
185 | phy@47401b00 { | 185 | usb-phy@47401b00 { |
186 | status = "okay"; | 186 | status = "okay"; |
187 | }; | 187 | }; |
188 | 188 | ||
@@ -194,7 +194,7 @@ | |||
194 | status = "okay"; | 194 | status = "okay"; |
195 | }; | 195 | }; |
196 | 196 | ||
197 | dma@07402000 { | 197 | dma-controller@07402000 { |
198 | status = "okay"; | 198 | status = "okay"; |
199 | }; | 199 | }; |
200 | }; | 200 | }; |
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index e92446c6846e..a6c5033be442 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts | |||
@@ -214,7 +214,7 @@ | |||
214 | status = "okay"; | 214 | status = "okay"; |
215 | }; | 215 | }; |
216 | 216 | ||
217 | phy@47401300 { | 217 | usb-phy@47401300 { |
218 | status = "okay"; | 218 | status = "okay"; |
219 | }; | 219 | }; |
220 | 220 | ||
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index a38f8d362a86..f9c5da9c7fe1 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi | |||
@@ -354,7 +354,7 @@ | |||
354 | status = "disabled"; | 354 | status = "disabled"; |
355 | }; | 355 | }; |
356 | 356 | ||
357 | usb0_phy: phy@47401300 { | 357 | usb0_phy: usb-phy@47401300 { |
358 | compatible = "ti,am335x-usb-phy"; | 358 | compatible = "ti,am335x-usb-phy"; |
359 | reg = <0x47401300 0x100>; | 359 | reg = <0x47401300 0x100>; |
360 | reg-names = "phy"; | 360 | reg-names = "phy"; |
@@ -364,25 +364,19 @@ | |||
364 | 364 | ||
365 | usb0: usb@47401000 { | 365 | usb0: usb@47401000 { |
366 | compatible = "ti,musb-am33xx"; | 366 | compatible = "ti,musb-am33xx"; |
367 | ranges; | ||
368 | #address-cells = <1>; | ||
369 | #size-cells = <1>; | ||
370 | reg = <0x47401000 0x200>; | ||
371 | reg-names = "control"; | ||
372 | status = "disabled"; | 367 | status = "disabled"; |
373 | 368 | reg = <0x47401400 0x400 | |
374 | musb0: usb@47401400 { | 369 | 0x47401000 0x200>; |
375 | compatible = "mg,musbmhdrc"; | 370 | reg-names = "mc", "control"; |
376 | reg = <0x47401400 0x400>; | 371 | |
377 | reg-names = "mc"; | 372 | interrupts = <18>; |
378 | interrupts = <18>; | 373 | interrupt-names = "mc"; |
379 | interrupt-names = "mc"; | 374 | dr_mode = "otg"; |
380 | multipoint = <1>; | 375 | mentor,multipoint = <1>; |
381 | num-eps = <16>; | 376 | mentor,num-eps = <16>; |
382 | ram-bits = <12>; | 377 | mentor,ram-bits = <12>; |
383 | port-mode = <3>; | 378 | mentor,power = <500>; |
384 | power = <250>; | 379 | phys = <&usb0_phy>; |
385 | phys = <&usb0_phy>; | ||
386 | 380 | ||
387 | dmas = <&cppi41dma 0 0 &cppi41dma 1 0 | 381 | dmas = <&cppi41dma 0 0 &cppi41dma 1 0 |
388 | &cppi41dma 2 0 &cppi41dma 3 0 | 382 | &cppi41dma 2 0 &cppi41dma 3 0 |
@@ -406,10 +400,9 @@ | |||
406 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", | 400 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", |
407 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", | 401 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", |
408 | "tx14", "tx15"; | 402 | "tx14", "tx15"; |
409 | }; | ||
410 | }; | 403 | }; |
411 | 404 | ||
412 | usb1_phy: phy@47401b00 { | 405 | usb1_phy: usb-phy@47401b00 { |
413 | compatible = "ti,am335x-usb-phy"; | 406 | compatible = "ti,am335x-usb-phy"; |
414 | reg = <0x47401b00 0x100>; | 407 | reg = <0x47401b00 0x100>; |
415 | reg-names = "phy"; | 408 | reg-names = "phy"; |
@@ -419,25 +412,18 @@ | |||
419 | 412 | ||
420 | usb1: usb@47401800 { | 413 | usb1: usb@47401800 { |
421 | compatible = "ti,musb-am33xx"; | 414 | compatible = "ti,musb-am33xx"; |
422 | ranges; | ||
423 | #address-cells = <1>; | ||
424 | #size-cells = <1>; | ||
425 | reg = <0x47401800 0x200>; | ||
426 | reg-names = "control"; | ||
427 | status = "disabled"; | 415 | status = "disabled"; |
428 | 416 | reg = <0x47401c00 0x400 | |
429 | musb1: usb@47401c00 { | 417 | 0x47401800 0x200>; |
430 | compatible = "mg,musbmhdrc"; | 418 | reg-names = "mc", "control"; |
431 | reg = <0x47401c00 0x400>; | 419 | interrupts = <19>; |
432 | reg-names = "mc"; | 420 | interrupt-names = "mc"; |
433 | interrupts = <19>; | 421 | dr_mode = "otg"; |
434 | interrupt-names = "mc"; | 422 | mentor,multipoint = <1>; |
435 | multipoint = <1>; | 423 | mentor,num-eps = <16>; |
436 | num-eps = <16>; | 424 | mentor,ram-bits = <12>; |
437 | ram-bits = <12>; | 425 | mentor,power = <500>; |
438 | port-mode = <3>; | 426 | phys = <&usb1_phy>; |
439 | power = <250>; | ||
440 | phys = <&usb1_phy>; | ||
441 | 427 | ||
442 | dmas = <&cppi41dma 15 0 &cppi41dma 16 0 | 428 | dmas = <&cppi41dma 15 0 &cppi41dma 16 0 |
443 | &cppi41dma 17 0 &cppi41dma 18 0 | 429 | &cppi41dma 17 0 &cppi41dma 18 0 |
@@ -461,10 +447,9 @@ | |||
461 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", | 447 | "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", |
462 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", | 448 | "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", |
463 | "tx14", "tx15"; | 449 | "tx14", "tx15"; |
464 | }; | ||
465 | }; | 450 | }; |
466 | 451 | ||
467 | cppi41dma: dma@07402000 { | 452 | cppi41dma: dma-controller@07402000 { |
468 | compatible = "ti,am3359-cppi41"; | 453 | compatible = "ti,am3359-cppi41"; |
469 | reg = <0x47400000 0x1000 | 454 | reg = <0x47400000 0x1000 |
470 | 0x47402000 0x1000 | 455 | 0x47402000 0x1000 |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 4ad52e76c4dd..4ead0f5f1f4c 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
45 | #include <linux/of_address.h> | 45 | #include <linux/of_address.h> |
46 | #include <linux/of_irq.h> | 46 | #include <linux/of_irq.h> |
47 | #include <linux/usb/of.h> | ||
47 | 48 | ||
48 | #include "musb_core.h" | 49 | #include "musb_core.h" |
49 | 50 | ||
@@ -425,35 +426,51 @@ static int get_int_prop(struct device_node *dn, const char *s) | |||
425 | return val; | 426 | return val; |
426 | } | 427 | } |
427 | 428 | ||
429 | static int get_musb_port_mode(struct device *dev) | ||
430 | { | ||
431 | enum usb_dr_mode mode; | ||
432 | |||
433 | mode = of_usb_get_dr_mode(dev->of_node); | ||
434 | switch (mode) { | ||
435 | case USB_DR_MODE_HOST: | ||
436 | return MUSB_PORT_MODE_HOST; | ||
437 | |||
438 | case USB_DR_MODE_PERIPHERAL: | ||
439 | return MUSB_PORT_MODE_GADGET; | ||
440 | |||
441 | case USB_DR_MODE_UNKNOWN: | ||
442 | case USB_DR_MODE_OTG: | ||
443 | default: | ||
444 | return MUSB_PORT_MODE_DUAL_ROLE; | ||
445 | }; | ||
446 | } | ||
447 | |||
428 | static int dsps_create_musb_pdev(struct dsps_glue *glue, | 448 | static int dsps_create_musb_pdev(struct dsps_glue *glue, |
429 | struct platform_device *parent) | 449 | struct platform_device *parent) |
430 | { | 450 | { |
431 | struct musb_hdrc_platform_data pdata; | 451 | struct musb_hdrc_platform_data pdata; |
432 | struct resource resources[2]; | 452 | struct resource resources[2]; |
453 | struct resource *res; | ||
433 | struct device *dev = &parent->dev; | 454 | struct device *dev = &parent->dev; |
434 | struct musb_hdrc_config *config; | 455 | struct musb_hdrc_config *config; |
435 | struct platform_device *musb; | 456 | struct platform_device *musb; |
436 | struct device_node *dn = parent->dev.of_node; | 457 | struct device_node *dn = parent->dev.of_node; |
437 | struct device_node *child_node; | ||
438 | int ret; | 458 | int ret; |
439 | 459 | ||
440 | child_node = of_get_child_by_name(dn, "usb"); | ||
441 | if (!child_node) | ||
442 | return -EINVAL; | ||
443 | |||
444 | memset(resources, 0, sizeof(resources)); | 460 | memset(resources, 0, sizeof(resources)); |
445 | ret = of_address_to_resource(child_node, 0, &resources[0]); | 461 | res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc"); |
446 | if (ret) { | 462 | if (!res) { |
447 | dev_err(dev, "failed to get memory.\n"); | 463 | dev_err(dev, "failed to get memory.\n"); |
448 | return ret; | 464 | return -EINVAL; |
449 | } | 465 | } |
466 | resources[0] = *res; | ||
450 | 467 | ||
451 | ret = of_irq_to_resource(child_node, 0, &resources[1]); | 468 | res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc"); |
452 | if (ret == 0) { | 469 | if (!res) { |
453 | dev_err(dev, "failed to get irq.\n"); | 470 | dev_err(dev, "failed to get irq.\n"); |
454 | ret = -EINVAL; | 471 | return -EINVAL; |
455 | return ret; | ||
456 | } | 472 | } |
473 | resources[1] = *res; | ||
457 | 474 | ||
458 | /* allocate the child platform device */ | 475 | /* allocate the child platform device */ |
459 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); | 476 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
@@ -465,7 +482,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, | |||
465 | musb->dev.parent = dev; | 482 | musb->dev.parent = dev; |
466 | musb->dev.dma_mask = &musb_dmamask; | 483 | musb->dev.dma_mask = &musb_dmamask; |
467 | musb->dev.coherent_dma_mask = musb_dmamask; | 484 | musb->dev.coherent_dma_mask = musb_dmamask; |
468 | musb->dev.of_node = of_node_get(child_node); | 485 | musb->dev.of_node = of_node_get(dn); |
469 | 486 | ||
470 | glue->musb = musb; | 487 | glue->musb = musb; |
471 | 488 | ||
@@ -485,11 +502,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, | |||
485 | pdata.config = config; | 502 | pdata.config = config; |
486 | pdata.platform_ops = &dsps_ops; | 503 | pdata.platform_ops = &dsps_ops; |
487 | 504 | ||
488 | config->num_eps = get_int_prop(child_node, "num-eps"); | 505 | config->num_eps = get_int_prop(dn, "mentor,num-eps"); |
489 | config->ram_bits = get_int_prop(child_node, "ram-bits"); | 506 | config->ram_bits = get_int_prop(dn, "mentor,ram-bits"); |
490 | pdata.mode = get_int_prop(child_node, "port-mode"); | 507 | pdata.mode = get_musb_port_mode(dev); |
491 | pdata.power = get_int_prop(child_node, "power"); | 508 | /* DT keeps this entry in mA, musb expects it as per USB spec */ |
492 | config->multipoint = of_property_read_bool(child_node, "multipoint"); | 509 | pdata.power = get_int_prop(dn, "mentor,power") / 2; |
510 | config->multipoint = of_property_read_bool(dn, "mentor,multipoint"); | ||
493 | 511 | ||
494 | ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); | 512 | ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); |
495 | if (ret) { | 513 | if (ret) { |