From: Quanyang Wang <quanyang.w...@windriver.com>

This driver is for generic ulpi usb phys.

Signed-off-by: Quanyang Wang <quanyang.w...@windriver.com>
---
 drivers/usb/phy/Kconfig            |  8 ++++
 drivers/usb/phy/Makefile           |  1 +
 drivers/usb/phy/phy-ulpi-generic.c | 76 ++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/usb/phy/phy-ulpi-generic.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 52eebcb88c1f..d602269019e6 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -62,6 +62,14 @@ config NOP_USB_XCEIV
          built-in with usb ip or which are autonomous and doesn't require any
          phy programming such as ISP1x04 etc.
 
+config USB_ULPI_GENERIC
+       tristate "USB ULPI Generic Transceiver Driver"
+       depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, NOP can't be 
built-in
+       select USB_ULPI
+       select USB_PHY
+       help
+         This driver is for USB ulpi phys.
+
 config AM335X_CONTROL_USB
        tristate
 
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b352bdbe8712..02337f143fd0 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_USB_ULPI)                        += phy-ulpi.o
 obj-$(CONFIG_USB_ULPI_VIEWPORT)                += phy-ulpi-viewport.o
 obj-$(CONFIG_KEYSTONE_USB_PHY)         += phy-keystone.o
 obj-$(CONFIG_JZ4770_PHY)               += phy-jz4770.o
+obj-$(CONFIG_USB_ULPI_GENERIC)         += phy-ulpi-generic.o
diff --git a/drivers/usb/phy/phy-ulpi-generic.c 
b/drivers/usb/phy/phy-ulpi-generic.c
new file mode 100644
index 000000000000..a54512a4e1b2
--- /dev/null
+++ b/drivers/usb/phy/phy-ulpi-generic.c
@@ -0,0 +1,76 @@
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/usb/ulpi.h>
+
+static int ulpi_generic_probe(struct platform_device *pdev)
+{
+       struct usb_phy *phy;
+       int flags = 0;
+       int ret;
+
+       ret = of_property_read_u32(pdev->dev.of_node, "usb-ulpi-flags", &flags);
+       if (ret) {
+               dev_warn(&pdev->dev, "No usb-ulpi-flags property!\n");
+       }
+
+       phy = devm_otg_ulpi_create(&pdev->dev, &ulpi_viewport_access_ops, 
flags);
+       if (!phy) {
+               dev_err(&pdev->dev, "Failed to create ULPI OTG phy.\n");
+               return -ENOMEM;
+       }
+
+       phy->dev = &pdev->dev;
+
+       ret = usb_add_phy_dev(phy);
+       if (ret) {
+               dev_err(&pdev->dev, "Failed to add ULPI OTG phy.\n");
+               return ret;
+       }
+
+       platform_set_drvdata(pdev, phy);
+
+       return 0;
+}
+
+static int ulpi_generic_remove(struct platform_device *pdev)
+{
+       struct usb_phy *phy = platform_get_drvdata(pdev);
+
+       usb_remove_phy(phy);
+
+       return 0;
+}
+
+static const struct of_device_id generic_ulpi_dt_ids[] = {
+       { .compatible = "usb-phy-ulpi-generic" },
+       { }
+};
+
+MODULE_DEVICE_TABLE(of, generic_ulpi_dt_ids);
+
+static struct platform_driver ulpi_generic_driver = {
+       .probe          = ulpi_generic_probe,
+       .remove         = ulpi_generic_remove,
+       .driver         = {
+               .name   = "usb_phy_ulpi_generic",
+               .of_match_table = generic_ulpi_dt_ids,
+       },
+};
+
+static int __init ulpi_generic_init(void)
+{
+       return platform_driver_register(&ulpi_generic_driver);
+}
+subsys_initcall(ulpi_generic_init);
+
+static void __exit ulpi_generic_exit(void)
+{
+       platform_driver_unregister(&ulpi_generic_driver);
+}
+module_exit(ulpi_generic_exit);
+
+MODULE_ALIAS("platform:usb_phy_ulpi_generic");
+MODULE_AUTHOR("Wind River Systems Inc");
+MODULE_DESCRIPTION("Generic ULPI PHY Transceiver driver");
+MODULE_LICENSE("GPL");
-- 
2.36.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#11484): 
https://lists.yoctoproject.org/g/linux-yocto/message/11484
Mute This Topic: https://lists.yoctoproject.org/mt/92454291/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to