#include <linux/delay.h>
#include <linux/usb/otg.h>
#include <linux/i2c/twl4030.h>
-#include <mach/usb.h>
+
/* Register defines */
#define GPIO_USB_4PIN_ULPI_2430C (3 << 0)
-/* bits in OTG_CTRL */
-#define OTG_XCEIV_OUTPUTS \
- (OTG_ASESSVLD|OTG_BSESSEND|OTG_BSESSVLD|OTG_VBUSVLD|OTG_ID)
-#define OTG_XCEIV_INPUTS \
- (OTG_PULLDOWN|OTG_PULLUP|OTG_DRV_VBUS|OTG_PD_VBUS|OTG_PU_VBUS|OTG_PU_ID)
-#define OTG_CTRL_BITS \
- (OTG_A_BUSREQ|OTG_A_SETB_HNPEN|OTG_B_BUSREQ|OTG_B_HNPEN|OTG_BUSDROP)
- /* and OTG_PULLUP is sometimes written */
-
-#define OTG_CTRL_MASK (OTG_DRIVER_SEL| \
- OTG_XCEIV_OUTPUTS|OTG_XCEIV_INPUTS| \
- OTG_CTRL_BITS)
-
enum linkstat {
USB_LINK_UNKNOWN = 0,
dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n",
status, status, linkstat);
+ /* REVISIT this assumes host and peripheral controllers
+ * are registered, and that both are active...
+ */
+
spin_lock_irq(&twl->lock);
twl->linkstat = linkstat;
if (linkstat == USB_LINK_ID) {
FUNC_CTRL_XCVRSELECT_MASK |
FUNC_CTRL_OPMODE_MASK);
break;
-/*
- case T2_USB_MODE_CEA2011_3PIN:
- twl4030_cea2011_3_pin_FS_setup(twl);
+ case -1:
+ /* FIXME: power on defaults */
break;
-*/
default:
- /* FIXME: power on defaults */
+ dev_err(twl->dev, "unsupported T2 transceiver mode %d\n",
+ mode);
break;
};
}
struct usb_gadget *gadget)
{
struct twl4030_usb *twl;
- u32 l;
if (!x)
return -ENODEV;
twl = xceiv_to_twl(x);
-
- if (!gadget) {
- omap_writew(0, OTG_IRQ_EN);
- twl4030_phy_suspend(twl, 1);
- twl->otg.gadget = NULL;
-
- return -ENODEV;
- }
-
twl->otg.gadget = gadget;
- twl4030_phy_resume(twl);
-
- l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK;
- l &= ~(OTG_XCEIV_OUTPUTS|OTG_CTRL_BITS);
- l |= OTG_ID;
- omap_writel(l, OTG_CTRL);
-
- twl->otg.state = OTG_STATE_B_IDLE;
+ if (!gadget)
+ twl->otg.state = OTG_STATE_UNDEFINED;
return 0;
}
return -ENODEV;
twl = xceiv_to_twl(x);
-
- if (!host) {
- omap_writew(0, OTG_IRQ_EN);
- twl4030_phy_suspend(twl, 1);
- twl->otg.host = NULL;
-
- return -ENODEV;
- }
-
twl->otg.host = host;
- twl4030_phy_resume(twl);
-
- twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL,
- TWL4030_OTG_CTRL_DMPULLDOWN
- | TWL4030_OTG_CTRL_DPPULLDOWN);
-
- twl4030_usb_set_bits(twl, FUNC_CTRL, FUNC_CTRL_SUSPENDM);
- twl4030_usb_set_bits(twl, TWL4030_OTG_CTRL, TWL4030_OTG_CTRL_DRVVBUS);
+ if (!host)
+ twl->otg.state = OTG_STATE_UNDEFINED;
return 0;
}
struct twl4030_usb *twl;
int status;
- twl = kzalloc(sizeof *twl, GFP_KERNEL);
- if (!twl)
- return -ENOMEM;
-
if (!pdata) {
dev_dbg(&pdev->dev, "platform_data not available\n");
return -EINVAL;
}
+ twl = kzalloc(sizeof *twl, GFP_KERNEL);
+ if (!twl)
+ return -ENOMEM;
+
twl->dev = &pdev->dev;
twl->irq = platform_get_irq(pdev, 0);
twl->otg.dev = twl->dev;