blob: 04778cf80d60cf0095a6311a0f19896554fb67ce [file] [log] [blame]
Hema HKc33fad02010-12-10 17:58:20 +05301/*
2 * twl6030_usb - TWL6030 USB transceiver, talking to OMAP OTG driver.
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Author: Hema HK <hemahk@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/platform_device.h>
27#include <linux/io.h>
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +053028#include <linux/usb/musb-omap.h>
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +053029#include <linux/usb/phy_companion.h>
Kishon Vijay Abraham I6284be22014-03-03 17:08:14 +053030#include <linux/phy/omap_usb.h>
Hema HKc33fad02010-12-10 17:58:20 +053031#include <linux/i2c/twl.h>
32#include <linux/regulator/consumer.h>
33#include <linux/err.h>
Hema HKc33fad02010-12-10 17:58:20 +053034#include <linux/slab.h>
Hema HK603ab522011-03-22 16:54:21 +053035#include <linux/delay.h>
Sachin Kamat80d7d8a2013-10-17 13:55:06 +053036#include <linux/of.h>
Hema HKc33fad02010-12-10 17:58:20 +053037
38/* usb register definitions */
39#define USB_VENDOR_ID_LSB 0x00
40#define USB_VENDOR_ID_MSB 0x01
41#define USB_PRODUCT_ID_LSB 0x02
42#define USB_PRODUCT_ID_MSB 0x03
43#define USB_VBUS_CTRL_SET 0x04
44#define USB_VBUS_CTRL_CLR 0x05
45#define USB_ID_CTRL_SET 0x06
46#define USB_ID_CTRL_CLR 0x07
47#define USB_VBUS_INT_SRC 0x08
48#define USB_VBUS_INT_LATCH_SET 0x09
49#define USB_VBUS_INT_LATCH_CLR 0x0A
50#define USB_VBUS_INT_EN_LO_SET 0x0B
51#define USB_VBUS_INT_EN_LO_CLR 0x0C
52#define USB_VBUS_INT_EN_HI_SET 0x0D
53#define USB_VBUS_INT_EN_HI_CLR 0x0E
54#define USB_ID_INT_SRC 0x0F
55#define USB_ID_INT_LATCH_SET 0x10
56#define USB_ID_INT_LATCH_CLR 0x11
57
58#define USB_ID_INT_EN_LO_SET 0x12
59#define USB_ID_INT_EN_LO_CLR 0x13
60#define USB_ID_INT_EN_HI_SET 0x14
61#define USB_ID_INT_EN_HI_CLR 0x15
62#define USB_OTG_ADP_CTRL 0x16
63#define USB_OTG_ADP_HIGH 0x17
64#define USB_OTG_ADP_LOW 0x18
65#define USB_OTG_ADP_RISE 0x19
66#define USB_OTG_REVISION 0x1A
67
68/* to be moved to LDO */
69#define TWL6030_MISC2 0xE5
70#define TWL6030_CFG_LDO_PD2 0xF5
71#define TWL6030_BACKUP_REG 0xFA
72
73#define STS_HW_CONDITIONS 0x21
74
75/* In module TWL6030_MODULE_PM_MASTER */
76#define STS_HW_CONDITIONS 0x21
77#define STS_USB_ID BIT(2)
78
79/* In module TWL6030_MODULE_PM_RECEIVER */
80#define VUSB_CFG_TRANS 0x71
81#define VUSB_CFG_STATE 0x72
82#define VUSB_CFG_VOLTAGE 0x73
83
84/* in module TWL6030_MODULE_MAIN_CHARGE */
85
86#define CHARGERUSB_CTRL1 0x8
87
88#define CONTROLLER_STAT1 0x03
89#define VBUS_DET BIT(2)
90
91struct twl6030_usb {
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +053092 struct phy_companion comparator;
Hema HKc33fad02010-12-10 17:58:20 +053093 struct device *dev;
94
95 /* for vbus reporting with irqs disabled */
96 spinlock_t lock;
97
98 struct regulator *usb3v3;
99
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500100 /* used to set vbus, in atomic path */
101 struct work_struct set_vbus_work;
102
Hema HKc33fad02010-12-10 17:58:20 +0530103 int irq1;
104 int irq2;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530105 enum omap_musb_vbus_id_status linkstat;
Hema HKc33fad02010-12-10 17:58:20 +0530106 u8 asleep;
107 bool irq_enabled;
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500108 bool vbus_enable;
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530109 const char *regulator;
Hema HKc33fad02010-12-10 17:58:20 +0530110};
111
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530112#define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator)
Hema HKc33fad02010-12-10 17:58:20 +0530113
114/*-------------------------------------------------------------------------*/
115
116static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module,
117 u8 data, u8 address)
118{
119 int ret = 0;
120
121 ret = twl_i2c_write_u8(module, data, address);
122 if (ret < 0)
123 dev_err(twl->dev,
124 "Write[0x%x] Error %d\n", address, ret);
125 return ret;
126}
127
128static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address)
129{
Dan Carpenter0b551492013-11-08 01:43:17 -0800130 u8 data;
131 int ret;
Hema HKc33fad02010-12-10 17:58:20 +0530132
133 ret = twl_i2c_read_u8(module, &data, address);
134 if (ret >= 0)
135 ret = data;
136 else
137 dev_err(twl->dev,
138 "readb[0x%x,0x%x] Error %d\n",
139 module, address, ret);
140 return ret;
141}
142
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530143static int twl6030_start_srp(struct phy_companion *comparator)
Hema HKc33fad02010-12-10 17:58:20 +0530144{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530145 struct twl6030_usb *twl = comparator_to_twl(comparator);
Hema HK603ab522011-03-22 16:54:21 +0530146
147 twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET);
148 twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET);
149
150 mdelay(100);
151 twl6030_writeb(twl, TWL_MODULE_USB, 0xa0, USB_VBUS_CTRL_CLR);
152
153 return 0;
154}
155
Hema HKc33fad02010-12-10 17:58:20 +0530156static int twl6030_usb_ldo_init(struct twl6030_usb *twl)
157{
Hema HKc33fad02010-12-10 17:58:20 +0530158 /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */
159 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG);
160
161 /* Program CFG_LDO_PD2 register and set VUSB bit */
162 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_CFG_LDO_PD2);
163
164 /* Program MISC2 register and set bit VUSB_IN_VBAT */
165 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2);
166
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530167 twl->usb3v3 = regulator_get(twl->dev, twl->regulator);
Hema HKc33fad02010-12-10 17:58:20 +0530168 if (IS_ERR(twl->usb3v3))
169 return -ENODEV;
170
Hema HKc33fad02010-12-10 17:58:20 +0530171 /* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */
172 twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET);
173
174 /*
175 * Program the USB_ID_CTRL_SET register to enable GND drive
176 * and the ID comparators
177 */
178 twl6030_writeb(twl, TWL_MODULE_USB, 0x14, USB_ID_CTRL_SET);
179
180 return 0;
181}
182
183static ssize_t twl6030_usb_vbus_show(struct device *dev,
184 struct device_attribute *attr, char *buf)
185{
186 struct twl6030_usb *twl = dev_get_drvdata(dev);
187 unsigned long flags;
188 int ret = -EINVAL;
189
190 spin_lock_irqsave(&twl->lock, flags);
191
192 switch (twl->linkstat) {
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530193 case OMAP_MUSB_VBUS_VALID:
Hema HKc33fad02010-12-10 17:58:20 +0530194 ret = snprintf(buf, PAGE_SIZE, "vbus\n");
195 break;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530196 case OMAP_MUSB_ID_GROUND:
Hema HKc33fad02010-12-10 17:58:20 +0530197 ret = snprintf(buf, PAGE_SIZE, "id\n");
198 break;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530199 case OMAP_MUSB_VBUS_OFF:
Hema HKc33fad02010-12-10 17:58:20 +0530200 ret = snprintf(buf, PAGE_SIZE, "none\n");
201 break;
202 default:
203 ret = snprintf(buf, PAGE_SIZE, "UNKNOWN\n");
204 }
205 spin_unlock_irqrestore(&twl->lock, flags);
206
207 return ret;
208}
209static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL);
210
211static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
212{
213 struct twl6030_usb *twl = _twl;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530214 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
Hema HKc33fad02010-12-10 17:58:20 +0530215 u8 vbus_state, hw_state;
Fabio Baltieribb545422013-04-03 16:02:27 +0200216 int ret;
Hema HKc33fad02010-12-10 17:58:20 +0530217
218 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
219
220 vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE,
221 CONTROLLER_STAT1);
222 if (!(hw_state & STS_USB_ID)) {
223 if (vbus_state & VBUS_DET) {
Fabio Baltieribb545422013-04-03 16:02:27 +0200224 ret = regulator_enable(twl->usb3v3);
225 if (ret)
226 dev_err(twl->dev, "Failed to enable usb3v3\n");
227
Hema HK6dc25032011-02-17 12:06:04 +0530228 twl->asleep = 1;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530229 status = OMAP_MUSB_VBUS_VALID;
Hema HKc33fad02010-12-10 17:58:20 +0530230 twl->linkstat = status;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530231 omap_musb_mailbox(status);
Hema HK6dc25032011-02-17 12:06:04 +0530232 } else {
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530233 if (twl->linkstat != OMAP_MUSB_UNKNOWN) {
234 status = OMAP_MUSB_VBUS_OFF;
235 twl->linkstat = status;
236 omap_musb_mailbox(status);
237 if (twl->asleep) {
238 regulator_disable(twl->usb3v3);
239 twl->asleep = 0;
240 }
Hema HK6dc25032011-02-17 12:06:04 +0530241 }
Hema HKc33fad02010-12-10 17:58:20 +0530242 }
243 }
244 sysfs_notify(&twl->dev->kobj, NULL, "vbus");
245
246 return IRQ_HANDLED;
247}
248
249static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
250{
251 struct twl6030_usb *twl = _twl;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530252 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
Hema HKc33fad02010-12-10 17:58:20 +0530253 u8 hw_state;
Fabio Baltieribb545422013-04-03 16:02:27 +0200254 int ret;
Hema HKc33fad02010-12-10 17:58:20 +0530255
256 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
257
258 if (hw_state & STS_USB_ID) {
Fabio Baltieribb545422013-04-03 16:02:27 +0200259 ret = regulator_enable(twl->usb3v3);
260 if (ret)
261 dev_err(twl->dev, "Failed to enable usb3v3\n");
Hema HKc33fad02010-12-10 17:58:20 +0530262
Hema HK6dc25032011-02-17 12:06:04 +0530263 twl->asleep = 1;
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300264 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_CLR);
265 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_SET);
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530266 status = OMAP_MUSB_ID_GROUND;
Hema HK31e99922011-02-17 12:06:05 +0530267 twl->linkstat = status;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530268 omap_musb_mailbox(status);
Hema HKc33fad02010-12-10 17:58:20 +0530269 } else {
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300270 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_CLR);
271 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET);
Hema HKc33fad02010-12-10 17:58:20 +0530272 }
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300273 twl6030_writeb(twl, TWL_MODULE_USB, status, USB_ID_INT_LATCH_CLR);
Hema HKc33fad02010-12-10 17:58:20 +0530274
275 return IRQ_HANDLED;
276}
277
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530278static int twl6030_enable_irq(struct twl6030_usb *twl)
Hema HKc33fad02010-12-10 17:58:20 +0530279{
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300280 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET);
Hema HKc33fad02010-12-10 17:58:20 +0530281 twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C);
282 twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C);
283
284 twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
285 REG_INT_MSK_LINE_C);
286 twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
287 REG_INT_MSK_STS_C);
288 twl6030_usb_irq(twl->irq2, twl);
289 twl6030_usbotg_irq(twl->irq1, twl);
290
291 return 0;
292}
293
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500294static void otg_set_vbus_work(struct work_struct *data)
Hema HKc33fad02010-12-10 17:58:20 +0530295{
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500296 struct twl6030_usb *twl = container_of(data, struct twl6030_usb,
297 set_vbus_work);
Hema HKc33fad02010-12-10 17:58:20 +0530298
299 /*
300 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
301 * register. This enables boost mode.
302 */
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500303
304 if (twl->vbus_enable)
Hema HKc33fad02010-12-10 17:58:20 +0530305 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40,
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500306 CHARGERUSB_CTRL1);
307 else
Hema HKc33fad02010-12-10 17:58:20 +0530308 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00,
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500309 CHARGERUSB_CTRL1);
310}
311
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530312static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled)
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500313{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530314 struct twl6030_usb *twl = comparator_to_twl(comparator);
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500315
316 twl->vbus_enable = enabled;
317 schedule_work(&twl->set_vbus_work);
318
Hema HKc33fad02010-12-10 17:58:20 +0530319 return 0;
320}
321
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500322static int twl6030_usb_probe(struct platform_device *pdev)
Hema HKc33fad02010-12-10 17:58:20 +0530323{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530324 u32 ret;
Hema HKc33fad02010-12-10 17:58:20 +0530325 struct twl6030_usb *twl;
326 int status, err;
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530327 struct device_node *np = pdev->dev.of_node;
328 struct device *dev = &pdev->dev;
Jingoo Han19f9e182013-07-30 17:02:13 +0900329 struct twl4030_usb_data *pdata = dev_get_platdata(dev);
Hema HKc33fad02010-12-10 17:58:20 +0530330
Sachin Kamat2ee8ff32013-12-21 15:20:09 +0530331 twl = devm_kzalloc(dev, sizeof(*twl), GFP_KERNEL);
Hema HKc33fad02010-12-10 17:58:20 +0530332 if (!twl)
333 return -ENOMEM;
334
335 twl->dev = &pdev->dev;
336 twl->irq1 = platform_get_irq(pdev, 0);
337 twl->irq2 = platform_get_irq(pdev, 1);
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530338 twl->linkstat = OMAP_MUSB_UNKNOWN;
Heikki Krogerus46b8f6b2012-02-13 13:24:12 +0200339
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530340 twl->comparator.set_vbus = twl6030_set_vbus;
341 twl->comparator.start_srp = twl6030_start_srp;
Heikki Krogerus46b8f6b2012-02-13 13:24:12 +0200342
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530343 ret = omap_usb2_set_comparator(&twl->comparator);
344 if (ret == -ENODEV) {
345 dev_info(&pdev->dev, "phy not ready, deferring probe");
346 return -EPROBE_DEFER;
347 }
Hema HKc33fad02010-12-10 17:58:20 +0530348
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530349 if (np) {
350 twl->regulator = "usb";
351 } else if (pdata) {
Graeme Gregory89ce43f2013-06-19 15:24:02 +0300352 if (pdata->features & TWL6032_SUBCLASS)
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530353 twl->regulator = "ldousb";
354 else
355 twl->regulator = "vusb";
356 } else {
357 dev_err(&pdev->dev, "twl6030 initialized without pdata\n");
358 return -EINVAL;
359 }
360
Hema HKc33fad02010-12-10 17:58:20 +0530361 /* init spinlock for workqueue */
362 spin_lock_init(&twl->lock);
363
364 err = twl6030_usb_ldo_init(twl);
365 if (err) {
366 dev_err(&pdev->dev, "ldo init failed\n");
Hema HKc33fad02010-12-10 17:58:20 +0530367 return err;
368 }
Hema HKc33fad02010-12-10 17:58:20 +0530369
370 platform_set_drvdata(pdev, twl);
371 if (device_create_file(&pdev->dev, &dev_attr_vbus))
372 dev_warn(&pdev->dev, "could not create sysfs file\n");
373
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500374 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work);
375
Hema HKc33fad02010-12-10 17:58:20 +0530376 twl->irq_enabled = true;
377 status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq,
Ming Lei8f9d9732012-05-17 11:38:24 +0800378 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Hema HKc33fad02010-12-10 17:58:20 +0530379 "twl6030_usb", twl);
380 if (status < 0) {
381 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
382 twl->irq1, status);
383 device_remove_file(twl->dev, &dev_attr_vbus);
Hema HKc33fad02010-12-10 17:58:20 +0530384 return status;
385 }
386
387 status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
Ming Lei8f9d9732012-05-17 11:38:24 +0800388 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Hema HKc33fad02010-12-10 17:58:20 +0530389 "twl6030_usb", twl);
390 if (status < 0) {
391 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
392 twl->irq2, status);
393 free_irq(twl->irq1, twl);
394 device_remove_file(twl->dev, &dev_attr_vbus);
Hema HKc33fad02010-12-10 17:58:20 +0530395 return status;
396 }
397
Hema HK6dc25032011-02-17 12:06:04 +0530398 twl->asleep = 0;
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530399 twl6030_enable_irq(twl);
Hema HKc33fad02010-12-10 17:58:20 +0530400 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");
401
402 return 0;
403}
404
Dmitry Torokhov39d35682013-02-24 00:55:07 -0800405static int twl6030_usb_remove(struct platform_device *pdev)
Hema HKc33fad02010-12-10 17:58:20 +0530406{
407 struct twl6030_usb *twl = platform_get_drvdata(pdev);
408
Hema HKc33fad02010-12-10 17:58:20 +0530409 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
410 REG_INT_MSK_LINE_C);
411 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
412 REG_INT_MSK_STS_C);
413 free_irq(twl->irq1, twl);
414 free_irq(twl->irq2, twl);
415 regulator_put(twl->usb3v3);
Hema HKc33fad02010-12-10 17:58:20 +0530416 device_remove_file(twl->dev, &dev_attr_vbus);
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500417 cancel_work_sync(&twl->set_vbus_work);
Hema HKc33fad02010-12-10 17:58:20 +0530418
419 return 0;
420}
421
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530422#ifdef CONFIG_OF
423static const struct of_device_id twl6030_usb_id_table[] = {
424 { .compatible = "ti,twl6030-usb" },
425 {}
426};
427MODULE_DEVICE_TABLE(of, twl6030_usb_id_table);
428#endif
429
Hema HKc33fad02010-12-10 17:58:20 +0530430static struct platform_driver twl6030_usb_driver = {
431 .probe = twl6030_usb_probe,
Dmitry Torokhov39d35682013-02-24 00:55:07 -0800432 .remove = twl6030_usb_remove,
Hema HKc33fad02010-12-10 17:58:20 +0530433 .driver = {
434 .name = "twl6030_usb",
435 .owner = THIS_MODULE,
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530436 .of_match_table = of_match_ptr(twl6030_usb_id_table),
Hema HKc33fad02010-12-10 17:58:20 +0530437 },
438};
439
440static int __init twl6030_usb_init(void)
441{
442 return platform_driver_register(&twl6030_usb_driver);
443}
444subsys_initcall(twl6030_usb_init);
445
446static void __exit twl6030_usb_exit(void)
447{
448 platform_driver_unregister(&twl6030_usb_driver);
449}
450module_exit(twl6030_usb_exit);
451
452MODULE_ALIAS("platform:twl6030_usb");
453MODULE_AUTHOR("Hema HK <hemahk@ti.com>");
454MODULE_DESCRIPTION("TWL6030 USB transceiver driver");
455MODULE_LICENSE("GPL");