diff options
author | Li Jun <jun.li@freescale.com> | 2015-07-09 03:18:45 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-07-29 10:59:21 -0400 |
commit | 79742351c89b76ebcf82b73103aed50f98ac2ee4 (patch) | |
tree | 1e73312122dafe00fbc6703d3ce186efc9b44163 | |
parent | 929412d94f2b75fe2a662afa2977bfb6a233c1c3 (diff) |
usb: chipidea: set usb otg capabilities
Init and update otg capabilities by DT, set gadget's otg capabilities
accordingly.
Acked-by: Peter Chen <peter.chen@freescale.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Li Jun <jun.li@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/chipidea/core.c | 15 | ||||
-rw-r--r-- | drivers/usb/chipidea/udc.c | 7 | ||||
-rw-r--r-- | include/linux/usb/chipidea.h | 1 |
3 files changed, 22 insertions, 1 deletions
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4fa41b1..1e6d5f0c18f2 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -560,6 +560,8 @@ static irqreturn_t ci_irq(int irq, void *data) | |||
560 | static int ci_get_platdata(struct device *dev, | 560 | static int ci_get_platdata(struct device *dev, |
561 | struct ci_hdrc_platform_data *platdata) | 561 | struct ci_hdrc_platform_data *platdata) |
562 | { | 562 | { |
563 | int ret; | ||
564 | |||
563 | if (!platdata->phy_mode) | 565 | if (!platdata->phy_mode) |
564 | platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); | 566 | platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); |
565 | 567 | ||
@@ -588,6 +590,19 @@ static int ci_get_platdata(struct device *dev, | |||
588 | of_usb_host_tpl_support(dev->of_node); | 590 | of_usb_host_tpl_support(dev->of_node); |
589 | } | 591 | } |
590 | 592 | ||
593 | if (platdata->dr_mode == USB_DR_MODE_OTG) { | ||
594 | /* We can support HNP and SRP of OTG 2.0 */ | ||
595 | platdata->ci_otg_caps.otg_rev = 0x0200; | ||
596 | platdata->ci_otg_caps.hnp_support = true; | ||
597 | platdata->ci_otg_caps.srp_support = true; | ||
598 | |||
599 | /* Update otg capabilities by DT properties */ | ||
600 | ret = of_usb_update_otg_caps(dev->of_node, | ||
601 | &platdata->ci_otg_caps); | ||
602 | if (ret) | ||
603 | return ret; | ||
604 | } | ||
605 | |||
591 | if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) | 606 | if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) |
592 | platdata->flags |= CI_HDRC_FORCE_FULLSPEED; | 607 | platdata->flags |= CI_HDRC_FORCE_FULLSPEED; |
593 | 608 | ||
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 764f668d45a9..b7cca3e597bf 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) | |||
1827 | static int udc_start(struct ci_hdrc *ci) | 1827 | static int udc_start(struct ci_hdrc *ci) |
1828 | { | 1828 | { |
1829 | struct device *dev = ci->dev; | 1829 | struct device *dev = ci->dev; |
1830 | struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; | ||
1830 | int retval = 0; | 1831 | int retval = 0; |
1831 | 1832 | ||
1832 | spin_lock_init(&ci->lock); | 1833 | spin_lock_init(&ci->lock); |
@@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) | |||
1834 | ci->gadget.ops = &usb_gadget_ops; | 1835 | ci->gadget.ops = &usb_gadget_ops; |
1835 | ci->gadget.speed = USB_SPEED_UNKNOWN; | 1836 | ci->gadget.speed = USB_SPEED_UNKNOWN; |
1836 | ci->gadget.max_speed = USB_SPEED_HIGH; | 1837 | ci->gadget.max_speed = USB_SPEED_HIGH; |
1837 | ci->gadget.is_otg = ci->is_otg ? 1 : 0; | ||
1838 | ci->gadget.name = ci->platdata->name; | 1838 | ci->gadget.name = ci->platdata->name; |
1839 | ci->gadget.otg_caps = otg_caps; | ||
1840 | |||
1841 | if (otg_caps->hnp_support || otg_caps->srp_support || | ||
1842 | otg_caps->adp_support) | ||
1843 | ci->gadget.is_otg = 1; | ||
1839 | 1844 | ||
1840 | INIT_LIST_HEAD(&ci->gadget.ep_list); | 1845 | INIT_LIST_HEAD(&ci->gadget.ep_list); |
1841 | 1846 | ||
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index ab94f78c4dd1..e10cefc721ad 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h | |||
@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data { | |||
34 | #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 | 34 | #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 |
35 | void (*notify_event) (struct ci_hdrc *ci, unsigned event); | 35 | void (*notify_event) (struct ci_hdrc *ci, unsigned event); |
36 | struct regulator *reg_vbus; | 36 | struct regulator *reg_vbus; |
37 | struct usb_otg_caps ci_otg_caps; | ||
37 | bool tpl_support; | 38 | bool tpl_support; |
38 | }; | 39 | }; |
39 | 40 | ||