blob: 9de7ada90a8b9717d096e3fb9852015dc1199ed4 [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>
30#include <linux/usb/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>
Hema HKc33fad02010-12-10 17:58:20 +053036
37/* usb register definitions */
38#define USB_VENDOR_ID_LSB 0x00
39#define USB_VENDOR_ID_MSB 0x01
40#define USB_PRODUCT_ID_LSB 0x02
41#define USB_PRODUCT_ID_MSB 0x03
42#define USB_VBUS_CTRL_SET 0x04
43#define USB_VBUS_CTRL_CLR 0x05
44#define USB_ID_CTRL_SET 0x06
45#define USB_ID_CTRL_CLR 0x07
46#define USB_VBUS_INT_SRC 0x08
47#define USB_VBUS_INT_LATCH_SET 0x09
48#define USB_VBUS_INT_LATCH_CLR 0x0A
49#define USB_VBUS_INT_EN_LO_SET 0x0B
50#define USB_VBUS_INT_EN_LO_CLR 0x0C
51#define USB_VBUS_INT_EN_HI_SET 0x0D
52#define USB_VBUS_INT_EN_HI_CLR 0x0E
53#define USB_ID_INT_SRC 0x0F
54#define USB_ID_INT_LATCH_SET 0x10
55#define USB_ID_INT_LATCH_CLR 0x11
56
57#define USB_ID_INT_EN_LO_SET 0x12
58#define USB_ID_INT_EN_LO_CLR 0x13
59#define USB_ID_INT_EN_HI_SET 0x14
60#define USB_ID_INT_EN_HI_CLR 0x15
61#define USB_OTG_ADP_CTRL 0x16
62#define USB_OTG_ADP_HIGH 0x17
63#define USB_OTG_ADP_LOW 0x18
64#define USB_OTG_ADP_RISE 0x19
65#define USB_OTG_REVISION 0x1A
66
67/* to be moved to LDO */
68#define TWL6030_MISC2 0xE5
69#define TWL6030_CFG_LDO_PD2 0xF5
70#define TWL6030_BACKUP_REG 0xFA
71
72#define STS_HW_CONDITIONS 0x21
73
74/* In module TWL6030_MODULE_PM_MASTER */
75#define STS_HW_CONDITIONS 0x21
76#define STS_USB_ID BIT(2)
77
78/* In module TWL6030_MODULE_PM_RECEIVER */
79#define VUSB_CFG_TRANS 0x71
80#define VUSB_CFG_STATE 0x72
81#define VUSB_CFG_VOLTAGE 0x73
82
83/* in module TWL6030_MODULE_MAIN_CHARGE */
84
85#define CHARGERUSB_CTRL1 0x8
86
87#define CONTROLLER_STAT1 0x03
88#define VBUS_DET BIT(2)
89
90struct twl6030_usb {
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +053091 struct phy_companion comparator;
Hema HKc33fad02010-12-10 17:58:20 +053092 struct device *dev;
93
94 /* for vbus reporting with irqs disabled */
95 spinlock_t lock;
96
97 struct regulator *usb3v3;
98
Moiz Sonasath5bf54502011-06-27 10:01:01 -050099 /* used to set vbus, in atomic path */
100 struct work_struct set_vbus_work;
101
Hema HKc33fad02010-12-10 17:58:20 +0530102 int irq1;
103 int irq2;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530104 enum omap_musb_vbus_id_status linkstat;
Hema HKc33fad02010-12-10 17:58:20 +0530105 u8 asleep;
106 bool irq_enabled;
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500107 bool vbus_enable;
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530108 const char *regulator;
Hema HKc33fad02010-12-10 17:58:20 +0530109};
110
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530111#define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator)
Hema HKc33fad02010-12-10 17:58:20 +0530112
113/*-------------------------------------------------------------------------*/
114
115static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module,
116 u8 data, u8 address)
117{
118 int ret = 0;
119
120 ret = twl_i2c_write_u8(module, data, address);
121 if (ret < 0)
122 dev_err(twl->dev,
123 "Write[0x%x] Error %d\n", address, ret);
124 return ret;
125}
126
127static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address)
128{
129 u8 data, ret = 0;
130
131 ret = twl_i2c_read_u8(module, &data, address);
132 if (ret >= 0)
133 ret = data;
134 else
135 dev_err(twl->dev,
136 "readb[0x%x,0x%x] Error %d\n",
137 module, address, ret);
138 return ret;
139}
140
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530141static int twl6030_start_srp(struct phy_companion *comparator)
Hema HKc33fad02010-12-10 17:58:20 +0530142{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530143 struct twl6030_usb *twl = comparator_to_twl(comparator);
Hema HK603ab522011-03-22 16:54:21 +0530144
145 twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET);
146 twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET);
147
148 mdelay(100);
149 twl6030_writeb(twl, TWL_MODULE_USB, 0xa0, USB_VBUS_CTRL_CLR);
150
151 return 0;
152}
153
Hema HKc33fad02010-12-10 17:58:20 +0530154static int twl6030_usb_ldo_init(struct twl6030_usb *twl)
155{
Hema HKc33fad02010-12-10 17:58:20 +0530156 /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */
157 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG);
158
159 /* Program CFG_LDO_PD2 register and set VUSB bit */
160 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_CFG_LDO_PD2);
161
162 /* Program MISC2 register and set bit VUSB_IN_VBAT */
163 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2);
164
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530165 twl->usb3v3 = regulator_get(twl->dev, twl->regulator);
Hema HKc33fad02010-12-10 17:58:20 +0530166 if (IS_ERR(twl->usb3v3))
167 return -ENODEV;
168
Hema HKc33fad02010-12-10 17:58:20 +0530169 /* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */
170 twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET);
171
172 /*
173 * Program the USB_ID_CTRL_SET register to enable GND drive
174 * and the ID comparators
175 */
176 twl6030_writeb(twl, TWL_MODULE_USB, 0x14, USB_ID_CTRL_SET);
177
178 return 0;
179}
180
181static ssize_t twl6030_usb_vbus_show(struct device *dev,
182 struct device_attribute *attr, char *buf)
183{
184 struct twl6030_usb *twl = dev_get_drvdata(dev);
185 unsigned long flags;
186 int ret = -EINVAL;
187
188 spin_lock_irqsave(&twl->lock, flags);
189
190 switch (twl->linkstat) {
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530191 case OMAP_MUSB_VBUS_VALID:
Hema HKc33fad02010-12-10 17:58:20 +0530192 ret = snprintf(buf, PAGE_SIZE, "vbus\n");
193 break;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530194 case OMAP_MUSB_ID_GROUND:
Hema HKc33fad02010-12-10 17:58:20 +0530195 ret = snprintf(buf, PAGE_SIZE, "id\n");
196 break;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530197 case OMAP_MUSB_VBUS_OFF:
Hema HKc33fad02010-12-10 17:58:20 +0530198 ret = snprintf(buf, PAGE_SIZE, "none\n");
199 break;
200 default:
201 ret = snprintf(buf, PAGE_SIZE, "UNKNOWN\n");
202 }
203 spin_unlock_irqrestore(&twl->lock, flags);
204
205 return ret;
206}
207static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL);
208
209static irqreturn_t twl6030_usb_irq(int irq, void *_twl)
210{
211 struct twl6030_usb *twl = _twl;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530212 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
Hema HKc33fad02010-12-10 17:58:20 +0530213 u8 vbus_state, hw_state;
Fabio Baltieribb545422013-04-03 16:02:27 +0200214 int ret;
Hema HKc33fad02010-12-10 17:58:20 +0530215
216 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
217
218 vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE,
219 CONTROLLER_STAT1);
220 if (!(hw_state & STS_USB_ID)) {
221 if (vbus_state & VBUS_DET) {
Fabio Baltieribb545422013-04-03 16:02:27 +0200222 ret = regulator_enable(twl->usb3v3);
223 if (ret)
224 dev_err(twl->dev, "Failed to enable usb3v3\n");
225
Hema HK6dc25032011-02-17 12:06:04 +0530226 twl->asleep = 1;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530227 status = OMAP_MUSB_VBUS_VALID;
Hema HKc33fad02010-12-10 17:58:20 +0530228 twl->linkstat = status;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530229 omap_musb_mailbox(status);
Hema HK6dc25032011-02-17 12:06:04 +0530230 } else {
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530231 if (twl->linkstat != OMAP_MUSB_UNKNOWN) {
232 status = OMAP_MUSB_VBUS_OFF;
233 twl->linkstat = status;
234 omap_musb_mailbox(status);
235 if (twl->asleep) {
236 regulator_disable(twl->usb3v3);
237 twl->asleep = 0;
238 }
Hema HK6dc25032011-02-17 12:06:04 +0530239 }
Hema HKc33fad02010-12-10 17:58:20 +0530240 }
241 }
242 sysfs_notify(&twl->dev->kobj, NULL, "vbus");
243
244 return IRQ_HANDLED;
245}
246
247static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl)
248{
249 struct twl6030_usb *twl = _twl;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530250 enum omap_musb_vbus_id_status status = OMAP_MUSB_UNKNOWN;
Hema HKc33fad02010-12-10 17:58:20 +0530251 u8 hw_state;
Fabio Baltieribb545422013-04-03 16:02:27 +0200252 int ret;
Hema HKc33fad02010-12-10 17:58:20 +0530253
254 hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS);
255
256 if (hw_state & STS_USB_ID) {
Fabio Baltieribb545422013-04-03 16:02:27 +0200257 ret = regulator_enable(twl->usb3v3);
258 if (ret)
259 dev_err(twl->dev, "Failed to enable usb3v3\n");
Hema HKc33fad02010-12-10 17:58:20 +0530260
Hema HK6dc25032011-02-17 12:06:04 +0530261 twl->asleep = 1;
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300262 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_CLR);
263 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_SET);
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530264 status = OMAP_MUSB_ID_GROUND;
Hema HK31e99922011-02-17 12:06:05 +0530265 twl->linkstat = status;
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530266 omap_musb_mailbox(status);
Hema HKc33fad02010-12-10 17:58:20 +0530267 } else {
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300268 twl6030_writeb(twl, TWL_MODULE_USB, 0x10, USB_ID_INT_EN_HI_CLR);
269 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET);
Hema HKc33fad02010-12-10 17:58:20 +0530270 }
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300271 twl6030_writeb(twl, TWL_MODULE_USB, status, USB_ID_INT_LATCH_CLR);
Hema HKc33fad02010-12-10 17:58:20 +0530272
273 return IRQ_HANDLED;
274}
275
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530276static int twl6030_enable_irq(struct twl6030_usb *twl)
Hema HKc33fad02010-12-10 17:58:20 +0530277{
Moiz Sonasathdc8738d2012-06-12 20:17:12 +0300278 twl6030_writeb(twl, TWL_MODULE_USB, 0x1, USB_ID_INT_EN_HI_SET);
Hema HKc33fad02010-12-10 17:58:20 +0530279 twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C);
280 twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C);
281
282 twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
283 REG_INT_MSK_LINE_C);
284 twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
285 REG_INT_MSK_STS_C);
286 twl6030_usb_irq(twl->irq2, twl);
287 twl6030_usbotg_irq(twl->irq1, twl);
288
289 return 0;
290}
291
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500292static void otg_set_vbus_work(struct work_struct *data)
Hema HKc33fad02010-12-10 17:58:20 +0530293{
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500294 struct twl6030_usb *twl = container_of(data, struct twl6030_usb,
295 set_vbus_work);
Hema HKc33fad02010-12-10 17:58:20 +0530296
297 /*
298 * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1
299 * register. This enables boost mode.
300 */
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500301
302 if (twl->vbus_enable)
Hema HKc33fad02010-12-10 17:58:20 +0530303 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40,
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500304 CHARGERUSB_CTRL1);
305 else
Hema HKc33fad02010-12-10 17:58:20 +0530306 twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00,
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500307 CHARGERUSB_CTRL1);
308}
309
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530310static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled)
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500311{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530312 struct twl6030_usb *twl = comparator_to_twl(comparator);
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500313
314 twl->vbus_enable = enabled;
315 schedule_work(&twl->set_vbus_work);
316
Hema HKc33fad02010-12-10 17:58:20 +0530317 return 0;
318}
319
Bill Pemberton41ac7b32012-11-19 13:21:48 -0500320static int twl6030_usb_probe(struct platform_device *pdev)
Hema HKc33fad02010-12-10 17:58:20 +0530321{
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530322 u32 ret;
Hema HKc33fad02010-12-10 17:58:20 +0530323 struct twl6030_usb *twl;
324 int status, err;
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530325 struct device_node *np = pdev->dev.of_node;
326 struct device *dev = &pdev->dev;
327 struct twl4030_usb_data *pdata = dev->platform_data;
Hema HKc33fad02010-12-10 17:58:20 +0530328
Kishon Vijay Abraham Ib8a3efa2012-06-22 17:40:55 +0530329 twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL);
Hema HKc33fad02010-12-10 17:58:20 +0530330 if (!twl)
331 return -ENOMEM;
332
333 twl->dev = &pdev->dev;
334 twl->irq1 = platform_get_irq(pdev, 0);
335 twl->irq2 = platform_get_irq(pdev, 1);
Kishon Vijay Abraham Ic9721432012-06-22 17:40:52 +0530336 twl->linkstat = OMAP_MUSB_UNKNOWN;
Heikki Krogerus46b8f6b2012-02-13 13:24:12 +0200337
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530338 twl->comparator.set_vbus = twl6030_set_vbus;
339 twl->comparator.start_srp = twl6030_start_srp;
Heikki Krogerus46b8f6b2012-02-13 13:24:12 +0200340
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530341 ret = omap_usb2_set_comparator(&twl->comparator);
342 if (ret == -ENODEV) {
343 dev_info(&pdev->dev, "phy not ready, deferring probe");
344 return -EPROBE_DEFER;
345 }
Hema HKc33fad02010-12-10 17:58:20 +0530346
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530347 if (np) {
348 twl->regulator = "usb";
349 } else if (pdata) {
350 if (pdata->features & TWL6025_SUBCLASS)
351 twl->regulator = "ldousb";
352 else
353 twl->regulator = "vusb";
354 } else {
355 dev_err(&pdev->dev, "twl6030 initialized without pdata\n");
356 return -EINVAL;
357 }
358
Hema HKc33fad02010-12-10 17:58:20 +0530359 /* init spinlock for workqueue */
360 spin_lock_init(&twl->lock);
361
362 err = twl6030_usb_ldo_init(twl);
363 if (err) {
364 dev_err(&pdev->dev, "ldo init failed\n");
Hema HKc33fad02010-12-10 17:58:20 +0530365 return err;
366 }
Hema HKc33fad02010-12-10 17:58:20 +0530367
368 platform_set_drvdata(pdev, twl);
369 if (device_create_file(&pdev->dev, &dev_attr_vbus))
370 dev_warn(&pdev->dev, "could not create sysfs file\n");
371
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500372 INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work);
373
Hema HKc33fad02010-12-10 17:58:20 +0530374 twl->irq_enabled = true;
375 status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq,
Ming Lei8f9d9732012-05-17 11:38:24 +0800376 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Hema HKc33fad02010-12-10 17:58:20 +0530377 "twl6030_usb", twl);
378 if (status < 0) {
379 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
380 twl->irq1, status);
381 device_remove_file(twl->dev, &dev_attr_vbus);
Hema HKc33fad02010-12-10 17:58:20 +0530382 return status;
383 }
384
385 status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq,
Ming Lei8f9d9732012-05-17 11:38:24 +0800386 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Hema HKc33fad02010-12-10 17:58:20 +0530387 "twl6030_usb", twl);
388 if (status < 0) {
389 dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
390 twl->irq2, status);
391 free_irq(twl->irq1, twl);
392 device_remove_file(twl->dev, &dev_attr_vbus);
Hema HKc33fad02010-12-10 17:58:20 +0530393 return status;
394 }
395
Hema HK6dc25032011-02-17 12:06:04 +0530396 twl->asleep = 0;
Kishon Vijay Abraham I0e98de62012-09-06 20:27:07 +0530397 twl6030_enable_irq(twl);
Hema HKc33fad02010-12-10 17:58:20 +0530398 dev_info(&pdev->dev, "Initialized TWL6030 USB module\n");
399
400 return 0;
401}
402
Dmitry Torokhov39d35682013-02-24 00:55:07 -0800403static int twl6030_usb_remove(struct platform_device *pdev)
Hema HKc33fad02010-12-10 17:58:20 +0530404{
405 struct twl6030_usb *twl = platform_get_drvdata(pdev);
406
Hema HKc33fad02010-12-10 17:58:20 +0530407 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
408 REG_INT_MSK_LINE_C);
409 twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,
410 REG_INT_MSK_STS_C);
411 free_irq(twl->irq1, twl);
412 free_irq(twl->irq2, twl);
413 regulator_put(twl->usb3v3);
Hema HKc33fad02010-12-10 17:58:20 +0530414 device_remove_file(twl->dev, &dev_attr_vbus);
Moiz Sonasath5bf54502011-06-27 10:01:01 -0500415 cancel_work_sync(&twl->set_vbus_work);
Hema HKc33fad02010-12-10 17:58:20 +0530416
417 return 0;
418}
419
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530420#ifdef CONFIG_OF
421static const struct of_device_id twl6030_usb_id_table[] = {
422 { .compatible = "ti,twl6030-usb" },
423 {}
424};
425MODULE_DEVICE_TABLE(of, twl6030_usb_id_table);
426#endif
427
Hema HKc33fad02010-12-10 17:58:20 +0530428static struct platform_driver twl6030_usb_driver = {
429 .probe = twl6030_usb_probe,
Dmitry Torokhov39d35682013-02-24 00:55:07 -0800430 .remove = twl6030_usb_remove,
Hema HKc33fad02010-12-10 17:58:20 +0530431 .driver = {
432 .name = "twl6030_usb",
433 .owner = THIS_MODULE,
Kishon Vijay Abraham Iff0a1f32012-09-06 20:27:08 +0530434 .of_match_table = of_match_ptr(twl6030_usb_id_table),
Hema HKc33fad02010-12-10 17:58:20 +0530435 },
436};
437
438static int __init twl6030_usb_init(void)
439{
440 return platform_driver_register(&twl6030_usb_driver);
441}
442subsys_initcall(twl6030_usb_init);
443
444static void __exit twl6030_usb_exit(void)
445{
446 platform_driver_unregister(&twl6030_usb_driver);
447}
448module_exit(twl6030_usb_exit);
449
450MODULE_ALIAS("platform:twl6030_usb");
451MODULE_AUTHOR("Hema HK <hemahk@ti.com>");
452MODULE_DESCRIPTION("TWL6030 USB transceiver driver");
453MODULE_LICENSE("GPL");