23 #include <linux/module.h>
34 #include <linux/slab.h>
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
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
68 #define TWL6030_MISC2 0xE5
69 #define TWL6030_CFG_LDO_PD2 0xF5
70 #define TWL6030_BACKUP_REG 0xFA
72 #define STS_HW_CONDITIONS 0x21
75 #define STS_HW_CONDITIONS 0x21
76 #define STS_USB_ID BIT(2)
79 #define VUSB_CFG_TRANS 0x71
80 #define VUSB_CFG_STATE 0x72
81 #define VUSB_CFG_VOLTAGE 0x73
85 #define CHARGERUSB_CTRL1 0x8
87 #define CONTROLLER_STAT1 0x03
88 #define VBUS_DET BIT(2)
111 #define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator)
123 "Write[0x%x] Error %d\n", address, ret);
136 "readb[0x%x,0x%x] Error %d\n",
137 module, address, ret);
154 static int twl6030_usb_ldo_init(
struct twl6030_usb *twl)
203 spin_unlock_irqrestore(&twl->
lock, flags);
209 static irqreturn_t twl6030_usb_irq(
int irq,
void *_twl)
213 u8 vbus_state, hw_state;
243 static irqreturn_t twl6030_usbotg_irq(
int irq,
void *_twl)
251 if (hw_state & STS_USB_ID) {
269 static int twl6030_enable_irq(
struct twl6030_usb *twl)
279 twl6030_usb_irq(twl->
irq2, twl);
280 twl6030_usbotg_irq(twl->
irq1, twl);
285 static void otg_set_vbus_work(
struct work_struct *data)
332 twl->
comparator.start_srp = twl6030_start_srp;
336 dev_info(&pdev->
dev,
"phy not ready, deferring probe");
348 dev_err(&pdev->
dev,
"twl6030 initialized without pdata\n");
355 err = twl6030_usb_ldo_init(twl);
361 platform_set_drvdata(pdev, twl);
363 dev_warn(&pdev->
dev,
"could not create sysfs file\n");
372 dev_err(&pdev->
dev,
"can't get IRQ %d, err %d\n",
382 dev_err(&pdev->
dev,
"can't get IRQ %d, err %d\n",
390 twl6030_enable_irq(twl);
391 dev_info(&pdev->
dev,
"Initialized TWL6030 USB module\n");
398 struct twl6030_usb *twl = platform_get_drvdata(pdev);
414 static const struct of_device_id twl6030_usb_id_table[] = {
422 .probe = twl6030_usb_probe,
423 .remove =
__exit_p(twl6030_usb_remove),
425 .name =
"twl6030_usb",
431 static int __init twl6030_usb_init(
void)
437 static void __exit twl6030_usb_exit(
void)