diff options
Diffstat (limited to 'drivers/usb/phy/phy-tahvo.c')
-rw-r--r-- | drivers/usb/phy/phy-tahvo.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c index cc61ee44b911..d391c79a542a 100644 --- a/drivers/usb/phy/phy-tahvo.c +++ b/drivers/usb/phy/phy-tahvo.c | |||
@@ -81,33 +81,35 @@ static void check_vbus_state(struct tahvo_usb *tu) | |||
81 | 81 | ||
82 | reg = retu_read(rdev, TAHVO_REG_IDSR); | 82 | reg = retu_read(rdev, TAHVO_REG_IDSR); |
83 | if (reg & TAHVO_STAT_VBUS) { | 83 | if (reg & TAHVO_STAT_VBUS) { |
84 | switch (tu->phy.state) { | 84 | switch (tu->phy.otg->state) { |
85 | case OTG_STATE_B_IDLE: | 85 | case OTG_STATE_B_IDLE: |
86 | /* Enable the gadget driver */ | 86 | /* Enable the gadget driver */ |
87 | if (tu->phy.otg->gadget) | 87 | if (tu->phy.otg->gadget) |
88 | usb_gadget_vbus_connect(tu->phy.otg->gadget); | 88 | usb_gadget_vbus_connect(tu->phy.otg->gadget); |
89 | tu->phy.state = OTG_STATE_B_PERIPHERAL; | 89 | tu->phy.otg->state = OTG_STATE_B_PERIPHERAL; |
90 | usb_phy_set_event(&tu->phy, USB_EVENT_ENUMERATED); | ||
90 | break; | 91 | break; |
91 | case OTG_STATE_A_IDLE: | 92 | case OTG_STATE_A_IDLE: |
92 | /* | 93 | /* |
93 | * Session is now valid assuming the USB hub is driving | 94 | * Session is now valid assuming the USB hub is driving |
94 | * Vbus. | 95 | * Vbus. |
95 | */ | 96 | */ |
96 | tu->phy.state = OTG_STATE_A_HOST; | 97 | tu->phy.otg->state = OTG_STATE_A_HOST; |
97 | break; | 98 | break; |
98 | default: | 99 | default: |
99 | break; | 100 | break; |
100 | } | 101 | } |
101 | dev_info(&tu->pt_dev->dev, "USB cable connected\n"); | 102 | dev_info(&tu->pt_dev->dev, "USB cable connected\n"); |
102 | } else { | 103 | } else { |
103 | switch (tu->phy.state) { | 104 | switch (tu->phy.otg->state) { |
104 | case OTG_STATE_B_PERIPHERAL: | 105 | case OTG_STATE_B_PERIPHERAL: |
105 | if (tu->phy.otg->gadget) | 106 | if (tu->phy.otg->gadget) |
106 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); | 107 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); |
107 | tu->phy.state = OTG_STATE_B_IDLE; | 108 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
109 | usb_phy_set_event(&tu->phy, USB_EVENT_NONE); | ||
108 | break; | 110 | break; |
109 | case OTG_STATE_A_HOST: | 111 | case OTG_STATE_A_HOST: |
110 | tu->phy.state = OTG_STATE_A_IDLE; | 112 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
111 | break; | 113 | break; |
112 | default: | 114 | default: |
113 | break; | 115 | break; |
@@ -132,14 +134,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu) | |||
132 | /* Power up the transceiver in USB host mode */ | 134 | /* Power up the transceiver in USB host mode */ |
133 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | | 135 | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | |
134 | USBR_MASTER_SW2 | USBR_MASTER_SW1); | 136 | USBR_MASTER_SW2 | USBR_MASTER_SW1); |
135 | tu->phy.state = OTG_STATE_A_IDLE; | 137 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
136 | 138 | ||
137 | check_vbus_state(tu); | 139 | check_vbus_state(tu); |
138 | } | 140 | } |
139 | 141 | ||
140 | static void tahvo_usb_stop_host(struct tahvo_usb *tu) | 142 | static void tahvo_usb_stop_host(struct tahvo_usb *tu) |
141 | { | 143 | { |
142 | tu->phy.state = OTG_STATE_A_IDLE; | 144 | tu->phy.otg->state = OTG_STATE_A_IDLE; |
143 | } | 145 | } |
144 | 146 | ||
145 | static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) | 147 | static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) |
@@ -151,7 +153,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) | |||
151 | /* Power up transceiver and set it in USB peripheral mode */ | 153 | /* Power up transceiver and set it in USB peripheral mode */ |
152 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | | 154 | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | |
153 | USBR_NSUSPEND | USBR_SLAVE_SW); | 155 | USBR_NSUSPEND | USBR_SLAVE_SW); |
154 | tu->phy.state = OTG_STATE_B_IDLE; | 156 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
155 | 157 | ||
156 | check_vbus_state(tu); | 158 | check_vbus_state(tu); |
157 | } | 159 | } |
@@ -160,7 +162,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu) | |||
160 | { | 162 | { |
161 | if (tu->phy.otg->gadget) | 163 | if (tu->phy.otg->gadget) |
162 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); | 164 | usb_gadget_vbus_disconnect(tu->phy.otg->gadget); |
163 | tu->phy.state = OTG_STATE_B_IDLE; | 165 | tu->phy.otg->state = OTG_STATE_B_IDLE; |
164 | } | 166 | } |
165 | 167 | ||
166 | static void tahvo_usb_power_off(struct tahvo_usb *tu) | 168 | static void tahvo_usb_power_off(struct tahvo_usb *tu) |
@@ -173,7 +175,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu) | |||
173 | 175 | ||
174 | /* Power off transceiver */ | 176 | /* Power off transceiver */ |
175 | retu_write(rdev, TAHVO_REG_USBR, 0); | 177 | retu_write(rdev, TAHVO_REG_USBR, 0); |
176 | tu->phy.state = OTG_STATE_UNDEFINED; | 178 | tu->phy.otg->state = OTG_STATE_UNDEFINED; |
177 | } | 179 | } |
178 | 180 | ||
179 | static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) | 181 | static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) |
@@ -196,7 +198,8 @@ static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) | |||
196 | 198 | ||
197 | static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | 199 | static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) |
198 | { | 200 | { |
199 | struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy); | 201 | struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb, |
202 | phy); | ||
200 | 203 | ||
201 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host); | 204 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, host); |
202 | 205 | ||
@@ -225,7 +228,8 @@ static int tahvo_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
225 | static int tahvo_usb_set_peripheral(struct usb_otg *otg, | 228 | static int tahvo_usb_set_peripheral(struct usb_otg *otg, |
226 | struct usb_gadget *gadget) | 229 | struct usb_gadget *gadget) |
227 | { | 230 | { |
228 | struct tahvo_usb *tu = container_of(otg->phy, struct tahvo_usb, phy); | 231 | struct tahvo_usb *tu = container_of(otg->usb_phy, struct tahvo_usb, |
232 | phy); | ||
229 | 233 | ||
230 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget); | 234 | dev_dbg(&tu->pt_dev->dev, "%s %p\n", __func__, gadget); |
231 | 235 | ||
@@ -379,11 +383,11 @@ static int tahvo_usb_probe(struct platform_device *pdev) | |||
379 | /* Create OTG interface */ | 383 | /* Create OTG interface */ |
380 | tahvo_usb_power_off(tu); | 384 | tahvo_usb_power_off(tu); |
381 | tu->phy.dev = &pdev->dev; | 385 | tu->phy.dev = &pdev->dev; |
382 | tu->phy.state = OTG_STATE_UNDEFINED; | 386 | tu->phy.otg->state = OTG_STATE_UNDEFINED; |
383 | tu->phy.label = DRIVER_NAME; | 387 | tu->phy.label = DRIVER_NAME; |
384 | tu->phy.set_suspend = tahvo_usb_set_suspend; | 388 | tu->phy.set_suspend = tahvo_usb_set_suspend; |
385 | 389 | ||
386 | tu->phy.otg->phy = &tu->phy; | 390 | tu->phy.otg->usb_phy = &tu->phy; |
387 | tu->phy.otg->set_host = tahvo_usb_set_host; | 391 | tu->phy.otg->set_host = tahvo_usb_set_host; |
388 | tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral; | 392 | tu->phy.otg->set_peripheral = tahvo_usb_set_peripheral; |
389 | 393 | ||