aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/omap2430.c
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2012-06-22 08:10:52 -0400
committerFelipe Balbi <balbi@ti.com>2012-06-25 07:07:39 -0400
commitc9721438c009adf8e81d376839ed037c53b9b8d9 (patch)
tree3144ac8f042bd8366352e03eab530de3f9676f00 /drivers/usb/musb/omap2430.c
parent1e5acb8d6113a0f159257845e153d5b870ca618a (diff)
usb: musb: twl: use mailbox API to send VBUS or ID events
The atomic notifier from twl4030/twl6030 to notifiy VBUS and ID events, is replaced by a direct call to omap musb blue. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/omap2430.c')
-rw-r--r--drivers/usb/musb/omap2430.c94
1 files changed, 59 insertions, 35 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index f40c8053a291..063687085d1e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -34,6 +34,7 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/pm_runtime.h> 35#include <linux/pm_runtime.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/usb/musb-omap.h>
37 38
38#include "musb_core.h" 39#include "musb_core.h"
39#include "omap2430.h" 40#include "omap2430.h"
@@ -41,11 +42,13 @@
41struct omap2430_glue { 42struct omap2430_glue {
42 struct device *dev; 43 struct device *dev;
43 struct platform_device *musb; 44 struct platform_device *musb;
44 u8 xceiv_event; 45 enum omap_musb_vbus_id_status status;
45 struct work_struct omap_musb_mailbox_work; 46 struct work_struct omap_musb_mailbox_work;
46}; 47};
47#define glue_to_musb(g) platform_get_drvdata(g->musb) 48#define glue_to_musb(g) platform_get_drvdata(g->musb)
48 49
50struct omap2430_glue *_glue;
51
49static struct timer_list musb_idle_timer; 52static struct timer_list musb_idle_timer;
50 53
51static void musb_do_idle(unsigned long _musb) 54static void musb_do_idle(unsigned long _musb)
@@ -225,54 +228,58 @@ static inline void omap2430_low_level_init(struct musb *musb)
225 musb_writel(musb->mregs, OTG_FORCESTDBY, l); 228 musb_writel(musb->mregs, OTG_FORCESTDBY, l);
226} 229}
227 230
228static int musb_otg_notifications(struct notifier_block *nb, 231void omap_musb_mailbox(enum omap_musb_vbus_id_status status)
229 unsigned long event, void *unused)
230{ 232{
231 struct musb *musb = container_of(nb, struct musb, nb); 233 struct omap2430_glue *glue = _glue;
232 struct device *dev = musb->controller; 234 struct musb *musb = glue_to_musb(glue);
233 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
234 235
235 glue->xceiv_event = event; 236 glue->status = status;
236 schedule_work(&glue->omap_musb_mailbox_work); 237 if (!musb) {
238 dev_err(glue->dev, "musb core is not yet ready\n");
239 return;
240 }
237 241
238 return NOTIFY_OK; 242 schedule_work(&glue->omap_musb_mailbox_work);
239} 243}
244EXPORT_SYMBOL_GPL(omap_musb_mailbox);
240 245
241static void omap_musb_mailbox_work(struct work_struct *data_notifier_work) 246static void omap_musb_set_mailbox(struct omap2430_glue *glue)
242{ 247{
243 struct omap2430_glue *glue = container_of(data_notifier_work,
244 struct omap2430_glue, omap_musb_mailbox_work);
245 struct musb *musb = glue_to_musb(glue); 248 struct musb *musb = glue_to_musb(glue);
246 struct device *dev = musb->controller; 249 struct device *dev = musb->controller;
247 struct musb_hdrc_platform_data *pdata = dev->platform_data; 250 struct musb_hdrc_platform_data *pdata = dev->platform_data;
248 struct omap_musb_board_data *data = pdata->board_data; 251 struct omap_musb_board_data *data = pdata->board_data;
249 252
250 switch (glue->xceiv_event) { 253 switch (glue->status) {
251 case USB_EVENT_ID: 254 case OMAP_MUSB_ID_GROUND:
252 dev_dbg(musb->controller, "ID GND\n"); 255 dev_dbg(dev, "ID GND\n");
253 256
257 musb->xceiv->last_event = USB_EVENT_ID;
254 if (!is_otg_enabled(musb) || musb->gadget_driver) { 258 if (!is_otg_enabled(musb) || musb->gadget_driver) {
255 pm_runtime_get_sync(musb->controller); 259 pm_runtime_get_sync(dev);
256 usb_phy_init(musb->xceiv); 260 usb_phy_init(musb->xceiv);
257 omap2430_musb_set_vbus(musb, 1); 261 omap2430_musb_set_vbus(musb, 1);
258 } 262 }
259 break; 263 break;
260 264
261 case USB_EVENT_VBUS: 265 case OMAP_MUSB_VBUS_VALID:
262 dev_dbg(musb->controller, "VBUS Connect\n"); 266 dev_dbg(dev, "VBUS Connect\n");
263 267
268 musb->xceiv->last_event = USB_EVENT_VBUS;
264 if (musb->gadget_driver) 269 if (musb->gadget_driver)
265 pm_runtime_get_sync(musb->controller); 270 pm_runtime_get_sync(dev);
266 usb_phy_init(musb->xceiv); 271 usb_phy_init(musb->xceiv);
267 break; 272 break;
268 273
269 case USB_EVENT_NONE: 274 case OMAP_MUSB_ID_FLOAT:
270 dev_dbg(musb->controller, "VBUS Disconnect\n"); 275 case OMAP_MUSB_VBUS_OFF:
276 dev_dbg(dev, "VBUS Disconnect\n");
271 277
278 musb->xceiv->last_event = USB_EVENT_NONE;
272 if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) 279 if (is_otg_enabled(musb) || is_peripheral_enabled(musb))
273 if (musb->gadget_driver) { 280 if (musb->gadget_driver) {
274 pm_runtime_mark_last_busy(musb->controller); 281 pm_runtime_mark_last_busy(dev);
275 pm_runtime_put_autosuspend(musb->controller); 282 pm_runtime_put_autosuspend(dev);
276 } 283 }
277 284
278 if (data->interface_type == MUSB_INTERFACE_UTMI) { 285 if (data->interface_type == MUSB_INTERFACE_UTMI) {
@@ -282,15 +289,24 @@ static void omap_musb_mailbox_work(struct work_struct *data_notifier_work)
282 usb_phy_shutdown(musb->xceiv); 289 usb_phy_shutdown(musb->xceiv);
283 break; 290 break;
284 default: 291 default:
285 dev_dbg(musb->controller, "ID float\n"); 292 dev_dbg(dev, "ID float\n");
286 } 293 }
287} 294}
288 295
296
297static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
298{
299 struct omap2430_glue *glue = container_of(mailbox_work,
300 struct omap2430_glue, omap_musb_mailbox_work);
301 omap_musb_set_mailbox(glue);
302}
303
289static int omap2430_musb_init(struct musb *musb) 304static int omap2430_musb_init(struct musb *musb)
290{ 305{
291 u32 l; 306 u32 l;
292 int status = 0; 307 int status = 0;
293 struct device *dev = musb->controller; 308 struct device *dev = musb->controller;
309 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
294 struct musb_hdrc_platform_data *plat = dev->platform_data; 310 struct musb_hdrc_platform_data *plat = dev->platform_data;
295 struct omap_musb_board_data *data = plat->board_data; 311 struct omap_musb_board_data *data = plat->board_data;
296 312
@@ -330,14 +346,11 @@ static int omap2430_musb_init(struct musb *musb)
330 musb_readl(musb->mregs, OTG_INTERFSEL), 346 musb_readl(musb->mregs, OTG_INTERFSEL),
331 musb_readl(musb->mregs, OTG_SIMENABLE)); 347 musb_readl(musb->mregs, OTG_SIMENABLE));
332 348
333 musb->nb.notifier_call = musb_otg_notifications;
334 status = usb_register_notifier(musb->xceiv, &musb->nb);
335
336 if (status)
337 dev_dbg(musb->controller, "notification register failed\n");
338
339 setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); 349 setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
340 350
351 if (glue->status != OMAP_MUSB_UNKNOWN)
352 omap_musb_set_mailbox(glue);
353
341 pm_runtime_put_noidle(musb->controller); 354 pm_runtime_put_noidle(musb->controller);
342 return 0; 355 return 0;
343 356
@@ -350,12 +363,13 @@ static void omap2430_musb_enable(struct musb *musb)
350 u8 devctl; 363 u8 devctl;
351 unsigned long timeout = jiffies + msecs_to_jiffies(1000); 364 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
352 struct device *dev = musb->controller; 365 struct device *dev = musb->controller;
366 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
353 struct musb_hdrc_platform_data *pdata = dev->platform_data; 367 struct musb_hdrc_platform_data *pdata = dev->platform_data;
354 struct omap_musb_board_data *data = pdata->board_data; 368 struct omap_musb_board_data *data = pdata->board_data;
355 369
356 switch (musb->xceiv->last_event) { 370 switch (glue->status) {
357 371
358 case USB_EVENT_ID: 372 case OMAP_MUSB_ID_GROUND:
359 usb_phy_init(musb->xceiv); 373 usb_phy_init(musb->xceiv);
360 if (data->interface_type != MUSB_INTERFACE_UTMI) 374 if (data->interface_type != MUSB_INTERFACE_UTMI)
361 break; 375 break;
@@ -374,7 +388,7 @@ static void omap2430_musb_enable(struct musb *musb)
374 } 388 }
375 break; 389 break;
376 390
377 case USB_EVENT_VBUS: 391 case OMAP_MUSB_VBUS_VALID:
378 usb_phy_init(musb->xceiv); 392 usb_phy_init(musb->xceiv);
379 break; 393 break;
380 394
@@ -385,7 +399,10 @@ static void omap2430_musb_enable(struct musb *musb)
385 399
386static void omap2430_musb_disable(struct musb *musb) 400static void omap2430_musb_disable(struct musb *musb)
387{ 401{
388 if (musb->xceiv->last_event) 402 struct device *dev = musb->controller;
403 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
404
405 if (glue->status != OMAP_MUSB_UNKNOWN)
389 usb_phy_shutdown(musb->xceiv); 406 usb_phy_shutdown(musb->xceiv);
390} 407}
391 408
@@ -439,11 +456,18 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
439 456
440 glue->dev = &pdev->dev; 457 glue->dev = &pdev->dev;
441 glue->musb = musb; 458 glue->musb = musb;
459 glue->status = OMAP_MUSB_UNKNOWN;
442 460
443 pdata->platform_ops = &omap2430_ops; 461 pdata->platform_ops = &omap2430_ops;
444 462
445 platform_set_drvdata(pdev, glue); 463 platform_set_drvdata(pdev, glue);
446 464
465 /*
466 * REVISIT if we ever have two instances of the wrapper, we will be
467 * in big trouble
468 */
469 _glue = glue;
470
447 INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work); 471 INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
448 472
449 ret = platform_device_add_resources(musb, pdev->resource, 473 ret = platform_device_add_resources(musb, pdev->resource,
@@ -552,7 +576,7 @@ static int __init omap2430_init(void)
552{ 576{
553 return platform_driver_register(&omap2430_driver); 577 return platform_driver_register(&omap2430_driver);
554} 578}
555module_init(omap2430_init); 579subsys_initcall(omap2430_init);
556 580
557static void __exit omap2430_exit(void) 581static void __exit omap2430_exit(void)
558{ 582{