From faf3bffe092ae302fbb7e18655c70c8d26c692d2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 26 Nov 2008 16:44:47 -0800 Subject: [PATCH] twl4030-usb: get rid of OMAP1 OTG hooks Remove incomplete/broken support for OMAP1 OTG controller. Update the otg.state field in some more code paths. Let IRQ logic handle PHY suspend/resume. Fix an unlikely memory leak. Signed-off-by: David Brownell Signed-off-by: Tony Lindgren --- drivers/i2c/chips/twl4030-usb.c | 75 ++++++++------------------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/drivers/i2c/chips/twl4030-usb.c b/drivers/i2c/chips/twl4030-usb.c index ee54e4b84aa..a000fb38b8d 100644 --- a/drivers/i2c/chips/twl4030-usb.c +++ b/drivers/i2c/chips/twl4030-usb.c @@ -34,7 +34,7 @@ #include #include #include -#include + /* Register defines */ @@ -234,19 +234,6 @@ #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, @@ -371,6 +358,10 @@ static enum linkstat twl4030_usb_linkstat(struct twl4030_usb *twl) 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) { @@ -397,13 +388,12 @@ static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode) 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; }; } @@ -577,30 +567,14 @@ static int twl4030_set_peripheral(struct otg_transceiver *x, 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; } @@ -613,24 +587,9 @@ static int twl4030_set_host(struct otg_transceiver *x, struct usb_bus *host) 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; } @@ -641,15 +600,15 @@ static int __init twl4030_usb_probe(struct platform_device *pdev) 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; -- 2.41.1