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 /drivers/usb/musb/musb_dsps.c | |
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>
Diffstat (limited to 'drivers/usb/musb/musb_dsps.c')
-rw-r--r-- | drivers/usb/musb/musb_dsps.c | 54 |
1 files changed, 36 insertions, 18 deletions
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) { |