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

usb: twl4030: Add device tree support for twl4030 usb

Add device tree support for twl4030 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
f8515f06 ff0a1f39

+39 -6
+19
Documentation/devicetree/bindings/usb/twlxxxx-usb.txt
··· 19 19 &twl6030-usb { 20 20 usb-supply = <&vusb>; 21 21 }; 22 + 23 + TWL4030 USB PHY AND COMPARATOR 24 + - compatible : Should be "ti,twl4030-usb" 25 + - interrupts : The interrupt numbers to the cpu should be specified. First 26 + interrupt number is the otg interrupt number that raises ID interrupts 27 + and VBUS interrupts. The second interrupt number is optional. 28 + - <supply-name>-supply : phandle to the regulator device tree node. 29 + <supply-name> should be vusb1v5, vusb1v8 and vusb3v1 30 + - usb_mode : The mode used by the phy to connect to the controller. "1" 31 + specifies "ULPI" mode and "2" specifies "CEA2011_3PIN" mode. 32 + 33 + twl4030-usb { 34 + compatible = "ti,twl4030-usb"; 35 + interrupts = < 10 4 >; 36 + usb1v5-supply = <&vusb1v5>; 37 + usb1v8-supply = <&vusb1v8>; 38 + usb3v1-supply = <&vusb3v1>; 39 + usb_mode = <1>; 40 + };
+20 -6
drivers/usb/otg/twl4030-usb.c
··· 585 585 struct twl4030_usb *twl; 586 586 int status, err; 587 587 struct usb_otg *otg; 588 - 589 - if (!pdata) { 590 - dev_dbg(&pdev->dev, "platform_data not available\n"); 591 - return -EINVAL; 592 - } 588 + struct device_node *np = pdev->dev.of_node; 593 589 594 590 twl = devm_kzalloc(&pdev->dev, sizeof *twl, GFP_KERNEL); 595 591 if (!twl) 596 592 return -ENOMEM; 593 + 594 + if (np) 595 + of_property_read_u32(np, "usb_mode", 596 + (enum twl4030_usb_mode *)&twl->usb_mode); 597 + else if (pdata) 598 + twl->usb_mode = pdata->usb_mode; 599 + else { 600 + dev_err(&pdev->dev, "twl4030 initialized without pdata\n"); 601 + return -EINVAL; 602 + } 597 603 598 604 otg = devm_kzalloc(&pdev->dev, sizeof *otg, GFP_KERNEL); 599 605 if (!otg) ··· 607 601 608 602 twl->dev = &pdev->dev; 609 603 twl->irq = platform_get_irq(pdev, 0); 610 - twl->usb_mode = pdata->usb_mode; 611 604 twl->vbus_supplied = false; 612 605 twl->asleep = 1; 613 606 twl->linkstat = OMAP_MUSB_UNKNOWN; ··· 695 690 return 0; 696 691 } 697 692 693 + #ifdef CONFIG_OF 694 + static const struct of_device_id twl4030_usb_id_table[] = { 695 + { .compatible = "ti,twl4030-usb" }, 696 + {} 697 + }; 698 + MODULE_DEVICE_TABLE(of, twl4030_usb_id_table); 699 + #endif 700 + 698 701 static struct platform_driver twl4030_usb_driver = { 699 702 .probe = twl4030_usb_probe, 700 703 .remove = __exit_p(twl4030_usb_remove), 701 704 .driver = { 702 705 .name = "twl4030_usb", 703 706 .owner = THIS_MODULE, 707 + .of_match_table = of_match_ptr(twl4030_usb_id_table), 704 708 }, 705 709 }; 706 710