diff options
author | Felipe Balbi <balbi@ti.com> | 2012-07-19 06:50:44 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-09-10 12:29:41 -0400 |
commit | e3ec3eb79481d23b7d371b6e9567e2b6972efc92 (patch) | |
tree | 11a6d21fe4cb9b688ac5af328516fbb4a24f9b0b | |
parent | 58add6ca84c4815feef45008c41274b6df41ede8 (diff) |
usb: dwc3: pci: add nop transceiver support
We will be adding support for transceivers on
dwc3 driver but not all boards have controllable
transceivers.
For those which don't provide controllable transceivers
we will register nop transceivers.
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index a9ca9adba391..94f550e37f98 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -42,6 +42,9 @@ | |||
42 | #include <linux/pci.h> | 42 | #include <linux/pci.h> |
43 | #include <linux/platform_device.h> | 43 | #include <linux/platform_device.h> |
44 | 44 | ||
45 | #include <linux/usb/otg.h> | ||
46 | #include <linux/usb/nop-usb-xceiv.h> | ||
47 | |||
45 | #include "core.h" | 48 | #include "core.h" |
46 | 49 | ||
47 | /* FIXME define these in <linux/pci_ids.h> */ | 50 | /* FIXME define these in <linux/pci_ids.h> */ |
@@ -51,8 +54,64 @@ | |||
51 | struct dwc3_pci { | 54 | struct dwc3_pci { |
52 | struct device *dev; | 55 | struct device *dev; |
53 | struct platform_device *dwc3; | 56 | struct platform_device *dwc3; |
57 | struct platform_device *usb2_phy; | ||
58 | struct platform_device *usb3_phy; | ||
54 | }; | 59 | }; |
55 | 60 | ||
61 | static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) | ||
62 | { | ||
63 | struct nop_usb_xceiv_platform_data pdata; | ||
64 | struct platform_device *pdev; | ||
65 | int ret; | ||
66 | |||
67 | memset(&pdata, 0x00, sizeof(pdata)); | ||
68 | |||
69 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | ||
70 | if (!pdev) | ||
71 | return -ENOMEM; | ||
72 | |||
73 | glue->usb2_phy = pdev; | ||
74 | pdata.type = USB_PHY_TYPE_USB2; | ||
75 | |||
76 | ret = platform_device_add_data(glue->usb2_phy, &pdata, sizeof(pdata)); | ||
77 | if (ret) | ||
78 | goto err1; | ||
79 | |||
80 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | ||
81 | if (!pdev) { | ||
82 | ret = -ENOMEM; | ||
83 | goto err1; | ||
84 | } | ||
85 | |||
86 | glue->usb3_phy = pdev; | ||
87 | pdata.type = USB_PHY_TYPE_USB3; | ||
88 | |||
89 | ret = platform_device_add_data(glue->usb3_phy, &pdata, sizeof(pdata)); | ||
90 | if (ret) | ||
91 | goto err2; | ||
92 | |||
93 | ret = platform_device_add(glue->usb2_phy); | ||
94 | if (ret) | ||
95 | goto err2; | ||
96 | |||
97 | ret = platform_device_add(glue->usb3_phy); | ||
98 | if (ret) | ||
99 | goto err3; | ||
100 | |||
101 | return 0; | ||
102 | |||
103 | err3: | ||
104 | platform_device_del(glue->usb2_phy); | ||
105 | |||
106 | err2: | ||
107 | platform_device_put(glue->usb3_phy); | ||
108 | |||
109 | err1: | ||
110 | platform_device_put(glue->usb2_phy); | ||
111 | |||
112 | return ret; | ||
113 | } | ||
114 | |||
56 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, | 115 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, |
57 | const struct pci_device_id *id) | 116 | const struct pci_device_id *id) |
58 | { | 117 | { |
@@ -80,6 +139,12 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
80 | pci_set_power_state(pci, PCI_D0); | 139 | pci_set_power_state(pci, PCI_D0); |
81 | pci_set_master(pci); | 140 | pci_set_master(pci); |
82 | 141 | ||
142 | ret = dwc3_pci_register_phys(glue); | ||
143 | if (ret) { | ||
144 | dev_err(dev, "couldn't register PHYs\n"); | ||
145 | return ret; | ||
146 | } | ||
147 | |||
83 | devid = dwc3_get_device_id(); | 148 | devid = dwc3_get_device_id(); |
84 | if (devid < 0) { | 149 | if (devid < 0) { |
85 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
@@ -144,6 +209,8 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
144 | { | 209 | { |
145 | struct dwc3_pci *glue = pci_get_drvdata(pci); | 210 | struct dwc3_pci *glue = pci_get_drvdata(pci); |
146 | 211 | ||
212 | platform_device_unregister(glue->usb2_phy); | ||
213 | platform_device_unregister(glue->usb3_phy); | ||
147 | dwc3_put_device_id(glue->dwc3->id); | 214 | dwc3_put_device_id(glue->dwc3->id); |
148 | platform_device_unregister(glue->dwc3); | 215 | platform_device_unregister(glue->dwc3); |
149 | pci_set_drvdata(pci, NULL); | 216 | pci_set_drvdata(pci, NULL); |