Commit c031a7d4 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent a0b311ef
...@@ -127,7 +127,7 @@ control@44e10000 { ...@@ -127,7 +127,7 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay"; status = "okay";
}; };
......
...@@ -178,11 +178,11 @@ control@44e10000 { ...@@ -178,11 +178,11 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay"; status = "okay";
}; };
phy@47401b00 { usb-phy@47401b00 {
status = "okay"; status = "okay";
}; };
...@@ -194,7 +194,7 @@ usb@47401800 { ...@@ -194,7 +194,7 @@ usb@47401800 {
status = "okay"; status = "okay";
}; };
dma@07402000 { dma-controller@07402000 {
status = "okay"; status = "okay";
}; };
}; };
......
...@@ -214,7 +214,7 @@ control@44e10000 { ...@@ -214,7 +214,7 @@ control@44e10000 {
status = "okay"; status = "okay";
}; };
phy@47401300 { usb-phy@47401300 {
status = "okay"; status = "okay";
}; };
......
...@@ -354,7 +354,7 @@ ctrl_mod: control@44e10000 { ...@@ -354,7 +354,7 @@ ctrl_mod: control@44e10000 {
status = "disabled"; status = "disabled";
}; };
usb0_phy: phy@47401300 { usb0_phy: usb-phy@47401300 {
compatible = "ti,am335x-usb-phy"; compatible = "ti,am335x-usb-phy";
reg = <0x47401300 0x100>; reg = <0x47401300 0x100>;
reg-names = "phy"; reg-names = "phy";
...@@ -364,25 +364,19 @@ usb0_phy: phy@47401300 { ...@@ -364,25 +364,19 @@ usb0_phy: phy@47401300 {
usb0: usb@47401000 { usb0: usb@47401000 {
compatible = "ti,musb-am33xx"; compatible = "ti,musb-am33xx";
ranges;
#address-cells = <1>;
#size-cells = <1>;
reg = <0x47401000 0x200>;
reg-names = "control";
status = "disabled"; status = "disabled";
reg = <0x47401400 0x400
musb0: usb@47401400 { 0x47401000 0x200>;
compatible = "mg,musbmhdrc"; reg-names = "mc", "control";
reg = <0x47401400 0x400>;
reg-names = "mc"; interrupts = <18>;
interrupts = <18>; interrupt-names = "mc";
interrupt-names = "mc"; dr_mode = "otg";
multipoint = <1>; mentor,multipoint = <1>;
num-eps = <16>; mentor,num-eps = <16>;
ram-bits = <12>; mentor,ram-bits = <12>;
port-mode = <3>; mentor,power = <500>;
power = <250>; phys = <&usb0_phy>;
phys = <&usb0_phy>;
dmas = <&cppi41dma 0 0 &cppi41dma 1 0 dmas = <&cppi41dma 0 0 &cppi41dma 1 0
&cppi41dma 2 0 &cppi41dma 3 0 &cppi41dma 2 0 &cppi41dma 3 0
...@@ -406,10 +400,9 @@ &cppi41dma 11 1 &cppi41dma 12 1 ...@@ -406,10 +400,9 @@ &cppi41dma 11 1 &cppi41dma 12 1
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15"; "tx14", "tx15";
};
}; };
usb1_phy: phy@47401b00 { usb1_phy: usb-phy@47401b00 {
compatible = "ti,am335x-usb-phy"; compatible = "ti,am335x-usb-phy";
reg = <0x47401b00 0x100>; reg = <0x47401b00 0x100>;
reg-names = "phy"; reg-names = "phy";
...@@ -419,25 +412,18 @@ usb1_phy: phy@47401b00 { ...@@ -419,25 +412,18 @@ usb1_phy: phy@47401b00 {
usb1: usb@47401800 { usb1: usb@47401800 {
compatible = "ti,musb-am33xx"; compatible = "ti,musb-am33xx";
ranges;
#address-cells = <1>;
#size-cells = <1>;
reg = <0x47401800 0x200>;
reg-names = "control";
status = "disabled"; status = "disabled";
reg = <0x47401c00 0x400
musb1: usb@47401c00 { 0x47401800 0x200>;
compatible = "mg,musbmhdrc"; reg-names = "mc", "control";
reg = <0x47401c00 0x400>; interrupts = <19>;
reg-names = "mc"; interrupt-names = "mc";
interrupts = <19>; dr_mode = "otg";
interrupt-names = "mc"; mentor,multipoint = <1>;
multipoint = <1>; mentor,num-eps = <16>;
num-eps = <16>; mentor,ram-bits = <12>;
ram-bits = <12>; mentor,power = <500>;
port-mode = <3>; phys = <&usb1_phy>;
power = <250>;
phys = <&usb1_phy>;
dmas = <&cppi41dma 15 0 &cppi41dma 16 0 dmas = <&cppi41dma 15 0 &cppi41dma 16 0
&cppi41dma 17 0 &cppi41dma 18 0 &cppi41dma 17 0 &cppi41dma 18 0
...@@ -461,10 +447,9 @@ &cppi41dma 26 1 &cppi41dma 27 1 ...@@ -461,10 +447,9 @@ &cppi41dma 26 1 &cppi41dma 27 1
"tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7",
"tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13",
"tx14", "tx15"; "tx14", "tx15";
};
}; };
cppi41dma: dma@07402000 { cppi41dma: dma-controller@07402000 {
compatible = "ti,am3359-cppi41"; compatible = "ti,am3359-cppi41";
reg = <0x47400000 0x1000 reg = <0x47400000 0x1000
0x47402000 0x1000 0x47402000 0x1000
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/usb/of.h>
#include "musb_core.h" #include "musb_core.h"
...@@ -425,35 +426,51 @@ static int get_int_prop(struct device_node *dn, const char *s) ...@@ -425,35 +426,51 @@ static int get_int_prop(struct device_node *dn, const char *s)
return val; return val;
} }
static int get_musb_port_mode(struct device *dev)
{
enum usb_dr_mode mode;
mode = of_usb_get_dr_mode(dev->of_node);
switch (mode) {
case USB_DR_MODE_HOST:
return MUSB_PORT_MODE_HOST;
case USB_DR_MODE_PERIPHERAL:
return MUSB_PORT_MODE_GADGET;
case USB_DR_MODE_UNKNOWN:
case USB_DR_MODE_OTG:
default:
return MUSB_PORT_MODE_DUAL_ROLE;
};
}
static int dsps_create_musb_pdev(struct dsps_glue *glue, static int dsps_create_musb_pdev(struct dsps_glue *glue,
struct platform_device *parent) struct platform_device *parent)
{ {
struct musb_hdrc_platform_data pdata; struct musb_hdrc_platform_data pdata;
struct resource resources[2]; struct resource resources[2];
struct resource *res;
struct device *dev = &parent->dev; struct device *dev = &parent->dev;
struct musb_hdrc_config *config; struct musb_hdrc_config *config;
struct platform_device *musb; struct platform_device *musb;
struct device_node *dn = parent->dev.of_node; struct device_node *dn = parent->dev.of_node;
struct device_node *child_node;
int ret; int ret;
child_node = of_get_child_by_name(dn, "usb");
if (!child_node)
return -EINVAL;
memset(resources, 0, sizeof(resources)); memset(resources, 0, sizeof(resources));
ret = of_address_to_resource(child_node, 0, &resources[0]); res = platform_get_resource_byname(parent, IORESOURCE_MEM, "mc");
if (ret) { if (!res) {
dev_err(dev, "failed to get memory.\n"); dev_err(dev, "failed to get memory.\n");
return ret; return -EINVAL;
} }
resources[0] = *res;
ret = of_irq_to_resource(child_node, 0, &resources[1]); res = platform_get_resource_byname(parent, IORESOURCE_IRQ, "mc");
if (ret == 0) { if (!res) {
dev_err(dev, "failed to get irq.\n"); dev_err(dev, "failed to get irq.\n");
ret = -EINVAL; return -EINVAL;
return ret;
} }
resources[1] = *res;
/* allocate the child platform device */ /* allocate the child platform device */
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
...@@ -465,7 +482,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, ...@@ -465,7 +482,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
musb->dev.parent = dev; musb->dev.parent = dev;
musb->dev.dma_mask = &musb_dmamask; musb->dev.dma_mask = &musb_dmamask;
musb->dev.coherent_dma_mask = musb_dmamask; musb->dev.coherent_dma_mask = musb_dmamask;
musb->dev.of_node = of_node_get(child_node); musb->dev.of_node = of_node_get(dn);
glue->musb = musb; glue->musb = musb;
...@@ -485,11 +502,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, ...@@ -485,11 +502,12 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
pdata.config = config; pdata.config = config;
pdata.platform_ops = &dsps_ops; pdata.platform_ops = &dsps_ops;
config->num_eps = get_int_prop(child_node, "num-eps"); config->num_eps = get_int_prop(dn, "mentor,num-eps");
config->ram_bits = get_int_prop(child_node, "ram-bits"); config->ram_bits = get_int_prop(dn, "mentor,ram-bits");
pdata.mode = get_int_prop(child_node, "port-mode"); pdata.mode = get_musb_port_mode(dev);
pdata.power = get_int_prop(child_node, "power"); /* DT keeps this entry in mA, musb expects it as per USB spec */
config->multipoint = of_property_read_bool(child_node, "multipoint"); pdata.power = get_int_prop(dn, "mentor,power") / 2;
config->multipoint = of_property_read_bool(dn, "mentor,multipoint");
ret = platform_device_add_data(musb, &pdata, sizeof(pdata)); ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment