Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 325991
b: refs/heads/master
c: 5ec4059
h: refs/heads/master
i:
  325989: ced38b3
  325987: 9f864a8
  325983: fa10887
v: v3
  • Loading branch information
Kishon Vijay Abraham I authored and Felipe Balbi committed Sep 11, 2012
1 parent 2650985 commit 46549f1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94715d59453dd3aba588fd6b6881f4cb4fac5440
refs/heads/master: 5ec40590765b8571ae6218f1bc421ec63d3e91c2
52 changes: 45 additions & 7 deletions trunk/drivers/usb/musb/omap2430.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,34 @@ struct omap2430_glue {
struct platform_device *musb;
enum omap_musb_vbus_id_status status;
struct work_struct omap_musb_mailbox_work;
u32 __iomem *control_otghs;
};
#define glue_to_musb(g) platform_get_drvdata(g->musb)

struct omap2430_glue *_glue;

static struct timer_list musb_idle_timer;

/**
* omap4_usb_phy_mailbox - write to usb otg mailbox
* @glue: struct omap2430_glue *
* @val: the value to be written to the mailbox
*
* On detection of a device (ID pin is grounded), this API should be called
* to set AVALID, VBUSVALID and ID pin is grounded.
*
* When OMAP is connected to a host (OMAP in device mode), this API
* is called to set AVALID, VBUSVALID and ID pin in high impedance.
*
* XXX: This function will be removed once we have a seperate driver for
* control module
*/
static void omap4_usb_phy_mailbox(struct omap2430_glue *glue, u32 val)
{
if (glue->control_otghs)
writel(val, glue->control_otghs);
}

static void musb_do_idle(unsigned long _musb)
{
struct musb *musb = (void *)_musb;
Expand Down Expand Up @@ -247,6 +268,7 @@ EXPORT_SYMBOL_GPL(omap_musb_mailbox);

static void omap_musb_set_mailbox(struct omap2430_glue *glue)
{
u32 val;
struct musb *musb = glue_to_musb(glue);
struct device *dev = musb->controller;
struct musb_hdrc_platform_data *pdata = dev->platform_data;
Expand All @@ -262,7 +284,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) {
pm_runtime_get_sync(dev);
usb_phy_init(musb->xceiv);
val = AVALID | VBUSVALID;
omap4_usb_phy_mailbox(glue, val);
omap2430_musb_set_vbus(musb, 1);
}
break;
Expand All @@ -275,7 +298,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver)
pm_runtime_get_sync(dev);
usb_phy_init(musb->xceiv);
val = IDDIG | AVALID | VBUSVALID;
omap4_usb_phy_mailbox(glue, val);
break;

case OMAP_MUSB_ID_FLOAT:
Expand All @@ -292,7 +316,8 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
if (musb->xceiv->otg->set_vbus)
otg_set_vbus(musb->xceiv->otg, 0);
}
usb_phy_shutdown(musb->xceiv);
val = SESSEND | IDDIG;
omap4_usb_phy_mailbox(glue, val);
break;
default:
dev_dbg(dev, "ID float\n");
Expand Down Expand Up @@ -367,6 +392,7 @@ static int omap2430_musb_init(struct musb *musb)
static void omap2430_musb_enable(struct musb *musb)
{
u8 devctl;
u32 val;
unsigned long timeout = jiffies + msecs_to_jiffies(1000);
struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);
Expand All @@ -376,7 +402,8 @@ static void omap2430_musb_enable(struct musb *musb)
switch (glue->status) {

case OMAP_MUSB_ID_GROUND:
usb_phy_init(musb->xceiv);
val = AVALID | VBUSVALID;
omap4_usb_phy_mailbox(glue, val);
if (data->interface_type != MUSB_INTERFACE_UTMI)
break;
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
Expand All @@ -395,7 +422,8 @@ static void omap2430_musb_enable(struct musb *musb)
break;

case OMAP_MUSB_VBUS_VALID:
usb_phy_init(musb->xceiv);
val = IDDIG | AVALID | VBUSVALID;
omap4_usb_phy_mailbox(glue, val);
break;

default:
Expand All @@ -405,11 +433,14 @@ static void omap2430_musb_enable(struct musb *musb)

static void omap2430_musb_disable(struct musb *musb)
{
u32 val;
struct device *dev = musb->controller;
struct omap2430_glue *glue = dev_get_drvdata(dev->parent);

if (glue->status != OMAP_MUSB_UNKNOWN)
usb_phy_shutdown(musb->xceiv);
if (glue->status != OMAP_MUSB_UNKNOWN) {
val = SESSEND | IDDIG;
omap4_usb_phy_mailbox(glue, val);
}
}

static int omap2430_musb_exit(struct musb *musb)
Expand Down Expand Up @@ -441,6 +472,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
struct platform_device *musb;
struct omap2430_glue *glue;
struct resource *res;
int ret = -ENOMEM;

glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
Expand All @@ -463,6 +495,12 @@ static int __devinit omap2430_probe(struct platform_device *pdev)
glue->musb = musb;
glue->status = OMAP_MUSB_UNKNOWN;

res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
if (glue->control_otghs == NULL)
dev_dbg(&pdev->dev, "Failed to obtain control memory\n");

pdata->platform_ops = &omap2430_ops;

platform_set_drvdata(pdev, glue);
Expand Down
9 changes: 9 additions & 0 deletions trunk/drivers/usb/musb/omap2430.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@
#define OTG_FORCESTDBY 0x414
# define ENABLEFORCE (1 << 0)

/*
* Control Module bit definitions
* XXX: Will be removed once we have a driver for control module.
*/
#define AVALID BIT(0)
#define BVALID BIT(1)
#define VBUSVALID BIT(2)
#define SESSEND BIT(3)
#define IDDIG BIT(4)
#endif /* __MUSB_OMAP243X_H__ */

0 comments on commit 46549f1

Please sign in to comment.