aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2013-01-25 05:24:00 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-25 05:27:24 -0500
commitca784be36cc725bca9b526eba342de7550329731 (patch)
tree23f0da8e88f81d73587e06a6d295260d50494eb7 /drivers/usb/musb
parent01658f0f8d1322dbf94f289aa610731d539bf888 (diff)
usb: start using the control module driver
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/Kconfig1
-rw-r--r--drivers/usb/musb/omap2430.c68
-rw-r--r--drivers/usb/musb/omap2430.h9
3 files changed, 24 insertions, 54 deletions
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 23a0b7f0892d..de6e5ce26316 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC
11 select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX) 11 select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX)
12 select TWL4030_USB if MACH_OMAP_3430SDP 12 select TWL4030_USB if MACH_OMAP_3430SDP
13 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA 13 select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
14 select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
14 select USB_OTG_UTILS 15 select USB_OTG_UTILS
15 help 16 help
16 Say Y here if your system has a dual role high speed USB 17 Say Y here if your system has a dual role high speed USB
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index da00af460794..779862d24590 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -37,6 +37,7 @@
37#include <linux/err.h> 37#include <linux/err.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/usb/musb-omap.h> 39#include <linux/usb/musb-omap.h>
40#include <linux/usb/omap_control_usb.h>
40 41
41#include "musb_core.h" 42#include "musb_core.h"
42#include "omap2430.h" 43#include "omap2430.h"
@@ -46,7 +47,7 @@ struct omap2430_glue {
46 struct platform_device *musb; 47 struct platform_device *musb;
47 enum omap_musb_vbus_id_status status; 48 enum omap_musb_vbus_id_status status;
48 struct work_struct omap_musb_mailbox_work; 49 struct work_struct omap_musb_mailbox_work;
49 u32 __iomem *control_otghs; 50 struct device *control_otghs;
50}; 51};
51#define glue_to_musb(g) platform_get_drvdata(g->musb) 52#define glue_to_musb(g) platform_get_drvdata(g->musb)
52 53
@@ -54,26 +55,6 @@ struct omap2430_glue *_glue;
54 55
55static struct timer_list musb_idle_timer; 56static struct timer_list musb_idle_timer;
56 57
57/**
58 * omap4_usb_phy_mailbox - write to usb otg mailbox
59 * @glue: struct omap2430_glue *
60 * @val: the value to be written to the mailbox
61 *
62 * On detection of a device (ID pin is grounded), this API should be called
63 * to set AVALID, VBUSVALID and ID pin is grounded.
64 *
65 * When OMAP is connected to a host (OMAP in device mode), this API
66 * is called to set AVALID, VBUSVALID and ID pin in high impedance.
67 *
68 * XXX: This function will be removed once we have a seperate driver for
69 * control module
70 */
71static void omap4_usb_phy_mailbox(struct omap2430_glue *glue, u32 val)
72{
73 if (glue->control_otghs)
74 writel(val, glue->control_otghs);
75}
76
77static void musb_do_idle(unsigned long _musb) 58static void musb_do_idle(unsigned long _musb)
78{ 59{
79 struct musb *musb = (void *)_musb; 60 struct musb *musb = (void *)_musb;
@@ -269,7 +250,6 @@ EXPORT_SYMBOL_GPL(omap_musb_mailbox);
269 250
270static void omap_musb_set_mailbox(struct omap2430_glue *glue) 251static void omap_musb_set_mailbox(struct omap2430_glue *glue)
271{ 252{
272 u32 val;
273 struct musb *musb = glue_to_musb(glue); 253 struct musb *musb = glue_to_musb(glue);
274 struct device *dev = musb->controller; 254 struct device *dev = musb->controller;
275 struct musb_hdrc_platform_data *pdata = dev->platform_data; 255 struct musb_hdrc_platform_data *pdata = dev->platform_data;
@@ -285,8 +265,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
285 musb->xceiv->last_event = USB_EVENT_ID; 265 musb->xceiv->last_event = USB_EVENT_ID;
286 if (musb->gadget_driver) { 266 if (musb->gadget_driver) {
287 pm_runtime_get_sync(dev); 267 pm_runtime_get_sync(dev);
288 val = AVALID | VBUSVALID; 268 omap_control_usb_set_mode(glue->control_otghs,
289 omap4_usb_phy_mailbox(glue, val); 269 USB_MODE_HOST);
290 omap2430_musb_set_vbus(musb, 1); 270 omap2430_musb_set_vbus(musb, 1);
291 } 271 }
292 break; 272 break;
@@ -299,8 +279,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
299 musb->xceiv->last_event = USB_EVENT_VBUS; 279 musb->xceiv->last_event = USB_EVENT_VBUS;
300 if (musb->gadget_driver) 280 if (musb->gadget_driver)
301 pm_runtime_get_sync(dev); 281 pm_runtime_get_sync(dev);
302 val = IDDIG | AVALID | VBUSVALID; 282 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
303 omap4_usb_phy_mailbox(glue, val);
304 break; 283 break;
305 284
306 case OMAP_MUSB_ID_FLOAT: 285 case OMAP_MUSB_ID_FLOAT:
@@ -317,8 +296,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
317 if (musb->xceiv->otg->set_vbus) 296 if (musb->xceiv->otg->set_vbus)
318 otg_set_vbus(musb->xceiv->otg, 0); 297 otg_set_vbus(musb->xceiv->otg, 0);
319 } 298 }
320 val = SESSEND | IDDIG; 299 omap_control_usb_set_mode(glue->control_otghs,
321 omap4_usb_phy_mailbox(glue, val); 300 USB_MODE_DISCONNECT);
322 break; 301 break;
323 default: 302 default:
324 dev_dbg(dev, "ID float\n"); 303 dev_dbg(dev, "ID float\n");
@@ -415,7 +394,6 @@ err1:
415static void omap2430_musb_enable(struct musb *musb) 394static void omap2430_musb_enable(struct musb *musb)
416{ 395{
417 u8 devctl; 396 u8 devctl;
418 u32 val;
419 unsigned long timeout = jiffies + msecs_to_jiffies(1000); 397 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
420 struct device *dev = musb->controller; 398 struct device *dev = musb->controller;
421 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 399 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
@@ -425,8 +403,7 @@ static void omap2430_musb_enable(struct musb *musb)
425 switch (glue->status) { 403 switch (glue->status) {
426 404
427 case OMAP_MUSB_ID_GROUND: 405 case OMAP_MUSB_ID_GROUND:
428 val = AVALID | VBUSVALID; 406 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_HOST);
429 omap4_usb_phy_mailbox(glue, val);
430 if (data->interface_type != MUSB_INTERFACE_UTMI) 407 if (data->interface_type != MUSB_INTERFACE_UTMI)
431 break; 408 break;
432 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 409 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
@@ -445,8 +422,7 @@ static void omap2430_musb_enable(struct musb *musb)
445 break; 422 break;
446 423
447 case OMAP_MUSB_VBUS_VALID: 424 case OMAP_MUSB_VBUS_VALID:
448 val = IDDIG | AVALID | VBUSVALID; 425 omap_control_usb_set_mode(glue->control_otghs, USB_MODE_DEVICE);
449 omap4_usb_phy_mailbox(glue, val);
450 break; 426 break;
451 427
452 default: 428 default:
@@ -456,14 +432,12 @@ static void omap2430_musb_enable(struct musb *musb)
456 432
457static void omap2430_musb_disable(struct musb *musb) 433static void omap2430_musb_disable(struct musb *musb)
458{ 434{
459 u32 val;
460 struct device *dev = musb->controller; 435 struct device *dev = musb->controller;
461 struct omap2430_glue *glue = dev_get_drvdata(dev->parent); 436 struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
462 437
463 if (glue->status != OMAP_MUSB_UNKNOWN) { 438 if (glue->status != OMAP_MUSB_UNKNOWN)
464 val = SESSEND | IDDIG; 439 omap_control_usb_set_mode(glue->control_otghs,
465 omap4_usb_phy_mailbox(glue, val); 440 USB_MODE_DISCONNECT);
466 }
467} 441}
468 442
469static int omap2430_musb_exit(struct musb *musb) 443static int omap2430_musb_exit(struct musb *musb)
@@ -498,7 +472,6 @@ static int omap2430_probe(struct platform_device *pdev)
498 struct omap2430_glue *glue; 472 struct omap2430_glue *glue;
499 struct device_node *np = pdev->dev.of_node; 473 struct device_node *np = pdev->dev.of_node;
500 struct musb_hdrc_config *config; 474 struct musb_hdrc_config *config;
501 struct resource *res;
502 int ret = -ENOMEM; 475 int ret = -ENOMEM;
503 476
504 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); 477 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
@@ -521,12 +494,6 @@ static int omap2430_probe(struct platform_device *pdev)
521 glue->musb = musb; 494 glue->musb = musb;
522 glue->status = OMAP_MUSB_UNKNOWN; 495 glue->status = OMAP_MUSB_UNKNOWN;
523 496
524 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
525
526 glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
527 if (glue->control_otghs == NULL)
528 dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
529
530 if (np) { 497 if (np) {
531 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 498 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
532 if (!pdata) { 499 if (!pdata) {
@@ -558,11 +525,22 @@ static int omap2430_probe(struct platform_device *pdev)
558 of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits); 525 of_property_read_u32(np, "ram_bits", (u32 *)&config->ram_bits);
559 of_property_read_u32(np, "power", (u32 *)&pdata->power); 526 of_property_read_u32(np, "power", (u32 *)&pdata->power);
560 config->multipoint = of_property_read_bool(np, "multipoint"); 527 config->multipoint = of_property_read_bool(np, "multipoint");
528 pdata->has_mailbox = of_property_read_bool(np,
529 "ti,has-mailbox");
561 530
562 pdata->board_data = data; 531 pdata->board_data = data;
563 pdata->config = config; 532 pdata->config = config;
564 } 533 }
565 534
535 if (pdata->has_mailbox) {
536 glue->control_otghs = omap_get_control_dev();
537 if (IS_ERR(glue->control_otghs)) {
538 dev_vdbg(&pdev->dev, "Failed to get control device\n");
539 return -ENODEV;
540 }
541 } else {
542 glue->control_otghs = ERR_PTR(-ENODEV);
543 }
566 pdata->platform_ops = &omap2430_ops; 544 pdata->platform_ops = &omap2430_ops;
567 545
568 platform_set_drvdata(pdev, glue); 546 platform_set_drvdata(pdev, glue);
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index 8ef656659fcb..1b5e83a9840e 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -49,13 +49,4 @@
49#define OTG_FORCESTDBY 0x414 49#define OTG_FORCESTDBY 0x414
50# define ENABLEFORCE (1 << 0) 50# define ENABLEFORCE (1 << 0)
51 51
52/*
53 * Control Module bit definitions
54 * XXX: Will be removed once we have a driver for control module.
55 */
56#define AVALID BIT(0)
57#define BVALID BIT(1)
58#define VBUSVALID BIT(2)
59#define SESSEND BIT(3)
60#define IDDIG BIT(4)
61#endif /* __MUSB_OMAP243X_H__ */ 52#endif /* __MUSB_OMAP243X_H__ */