Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: twl6030: Add dt support for twl6030 usb

Add device tree support for twl6030 usb driver.
Update the Documentation with device tree binding information.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Kishon Vijay Abraham I and committed by
Felipe Balbi
ff0a1f39 0e98de67

+47 -13
+21
Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
··· 1 + USB COMPARATOR OF TWL CHIPS 2 + 3 + TWL6030 USB COMPARATOR 4 + - compatible : Should be "ti,twl6030-usb" 5 + - interrupts : Two interrupt numbers to the cpu should be specified. First 6 + interrupt number is the otg interrupt number that raises ID interrupts when 7 + the controller has to act as host and the second interrupt number is the 8 + usb interrupt number that raises VBUS interrupts when the controller has to 9 + act as device 10 + - usb-supply : phandle to the regulator device tree node. It should be vusb 11 + if it is twl6030 or ldousb if it is twl6025 subclass. 12 + 13 + twl6030-usb { 14 + compatible = "ti,twl6030-usb"; 15 + interrupts = < 4 10 >; 16 + }; 17 + 18 + Board specific device node entry 19 + &twl6030-usb { 20 + usb-supply = <&vusb>; 21 + };
+26 -13
drivers/usb/otg/twl6030-usb.c
··· 105 105 u8 asleep; 106 106 bool irq_enabled; 107 107 bool vbus_enable; 108 - unsigned long features; 108 + const char *regulator; 109 109 }; 110 110 111 111 #define comparator_to_twl(x) container_of((x), struct twl6030_usb, comparator) ··· 153 153 154 154 static int twl6030_usb_ldo_init(struct twl6030_usb *twl) 155 155 { 156 - char *regulator_name; 157 - 158 - if (twl->features & TWL6025_SUBCLASS) 159 - regulator_name = "ldousb"; 160 - else 161 - regulator_name = "vusb"; 162 - 163 156 /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ 164 157 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); 165 158 ··· 162 169 /* Program MISC2 register and set bit VUSB_IN_VBAT */ 163 170 twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); 164 171 165 - twl->usb3v3 = regulator_get(twl->dev, regulator_name); 172 + twl->usb3v3 = regulator_get(twl->dev, twl->regulator); 166 173 if (IS_ERR(twl->usb3v3)) 167 174 return -ENODEV; 168 175 ··· 315 322 u32 ret; 316 323 struct twl6030_usb *twl; 317 324 int status, err; 318 - struct twl4030_usb_data *pdata; 319 - struct device *dev = &pdev->dev; 320 - pdata = dev->platform_data; 325 + struct device_node *np = pdev->dev.of_node; 326 + struct device *dev = &pdev->dev; 327 + struct twl4030_usb_data *pdata = dev->platform_data; 321 328 322 329 twl = devm_kzalloc(dev, sizeof *twl, GFP_KERNEL); 323 330 if (!twl) ··· 326 333 twl->dev = &pdev->dev; 327 334 twl->irq1 = platform_get_irq(pdev, 0); 328 335 twl->irq2 = platform_get_irq(pdev, 1); 329 - twl->features = pdata->features; 330 336 twl->linkstat = OMAP_MUSB_UNKNOWN; 331 337 332 338 twl->comparator.set_vbus = twl6030_set_vbus; ··· 335 343 if (ret == -ENODEV) { 336 344 dev_info(&pdev->dev, "phy not ready, deferring probe"); 337 345 return -EPROBE_DEFER; 346 + } 347 + 348 + if (np) { 349 + twl->regulator = "usb"; 350 + } else if (pdata) { 351 + if (pdata->features & TWL6025_SUBCLASS) 352 + twl->regulator = "ldousb"; 353 + else 354 + twl->regulator = "vusb"; 355 + } else { 356 + dev_err(&pdev->dev, "twl6030 initialized without pdata\n"); 357 + return -EINVAL; 338 358 } 339 359 340 360 /* init spinlock for workqueue */ ··· 410 406 return 0; 411 407 } 412 408 409 + #ifdef CONFIG_OF 410 + static const struct of_device_id twl6030_usb_id_table[] = { 411 + { .compatible = "ti,twl6030-usb" }, 412 + {} 413 + }; 414 + MODULE_DEVICE_TABLE(of, twl6030_usb_id_table); 415 + #endif 416 + 413 417 static struct platform_driver twl6030_usb_driver = { 414 418 .probe = twl6030_usb_probe, 415 419 .remove = __exit_p(twl6030_usb_remove), 416 420 .driver = { 417 421 .name = "twl6030_usb", 418 422 .owner = THIS_MODULE, 423 + .of_match_table = of_match_ptr(twl6030_usb_id_table), 419 424 }, 420 425 }; 421 426