From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Chen Subject: Re: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI PHYs Date: Thu, 24 Sep 2015 17:06:31 +0800 Message-ID: <20150924090629.GA27847@shlinux2> References: <1443012873-13757-1-git-send-email-sbhatta@xilinx.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Return-path: Content-Disposition: inline In-Reply-To: <1443012873-13757-1-git-send-email-sbhatta@xilinx.com> Sender: linux-kernel-owner@vger.kernel.org To: Subbaraya Sundeep Bhatta Cc: balbi@ti.com, devicetree@vger.kernel.org, kishon@ti.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, punnaia@xilinx.com, Subbaraya Sundeep Bhatta List-Id: devicetree@vger.kernel.org On Wed, Sep 23, 2015 at 06:24:33PM +0530, Subbaraya Sundeep Bhatta wrote: > Based on board design USB controller needs explicit software > access to ULPI PHY for controlling VBUS. This patch adds platform > driver support for generic ULPI PHYs and provides a USB2 PHY device > to controllers. > > Signed-off-by: Subbaraya Sundeep Bhatta > --- > drivers/usb/phy/Kconfig | 12 +++ > drivers/usb/phy/Makefile | 1 + > drivers/usb/phy/phy-platform-ulpi.c | 143 +++++++++++++++++++++++++++++++++++ > 3 files changed, 156 insertions(+), 0 deletions(-) > create mode 100644 drivers/usb/phy/phy-platform-ulpi.c > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig > index 7d3beee..2956ad4 100644 > --- a/drivers/usb/phy/Kconfig > +++ b/drivers/usb/phy/Kconfig > @@ -201,6 +201,18 @@ config USB_RCAR_PHY > To compile this driver as a module, choose M here: the > module will be called phy-rcar-usb. > > +config USB_PLATFORM_ULPI_PHY > + tristate "Platform driver support for ULPI PHYs" > + depends on ARCH_ZYNQ || COMPILE_TEST If you want this as a common driver, drop platform dependency please. > + select USB_PHY > + select USB_ULPI_VIEWPORT > + help > + Say Y here to add support for the Platform driver for ULPI PHYs. > + This adds platform driver support for all generic ULPI PHYs and is > + typically used if usb controller driver needs explicit access to PHY. > + > + To compile this driver as a module, choose M here. > + > config USB_ULPI > bool "Generic ULPI Transceiver Driver" > depends on ARM || ARM64 > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > index 19c0dcc..8431b6b 100644 > --- a/drivers/usb/phy/Makefile > +++ b/drivers/usb/phy/Makefile > @@ -24,6 +24,7 @@ obj-$(CONFIG_USB_QCOM_8X16_PHY) += phy-qcom-8x16-usb.o > obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o > obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o > obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o > +obj-$(CONFIG_USB_PLATFORM_ULPI_PHY) += phy-platform-ulpi.o > obj-$(CONFIG_USB_ULPI) += phy-ulpi.o > obj-$(CONFIG_USB_ULPI_VIEWPORT) += phy-ulpi-viewport.o > obj-$(CONFIG_KEYSTONE_USB_PHY) += phy-keystone.o > diff --git a/drivers/usb/phy/phy-platform-ulpi.c b/drivers/usb/phy/phy-platform-ulpi.c > new file mode 100644 > index 0000000..fb89363 > --- /dev/null > +++ b/drivers/usb/phy/phy-platform-ulpi.c > @@ -0,0 +1,143 @@ > +/* > + * Platform driver for generic ULPI PHYs. > + * > + * Copyright (C) 2015 Xilinx, Inc. > + * > + * Author: Subbaraya Sundeep > + * > + * This program is free software; you can redistribute it > + * and/or modify it under the terms of the GNU General Public > + * License as published by the Free Software Foundation; > + * either version 2 of the License, or (at your option) any > + * later version. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + * struct ulpi_phy - The ULPI PHY > + * @usb_phy: pointer to usb phy > + * @regs: base address of USB controller to which PHY is connected > + * @vp_offset: ulpi viewport register offset of USB controller > + * @flags: initial required settings of PHY > + */ > + > +struct ulpi_phy { > + struct usb_phy *usb_phy; > + void __iomem *regs; > + unsigned int vp_offset; > + unsigned int flags; > +}; > + > +/** > + * usbphy_set_vbus - Sets VBUS by writing to PHY. > + * @phy: pointer to PHY > + * @on: 1 - turn on VBUS > + * 0 - turn off VBUS > + * Return: 0 for success and error value on failure > + */ > +static int usbphy_set_vbus(struct usb_phy *phy, int on) > +{ > + unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); > + > + flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); > + > + if (on) { > + if (phy->flags & ULPI_OTG_DRVVBUS) > + flags |= ULPI_OTG_CTRL_DRVVBUS; > + > + if (phy->flags & ULPI_OTG_DRVVBUS_EXT) > + flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; > + } > + > + return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); > +} > + > +/** > + * ulpi_phy_probe - The device probe function for driver initialization. > + * @pdev: pointer to the platform device structure. > + * > + * Return: 0 for success and error value on failure > + */ > +static int ulpi_phy_probe(struct platform_device *pdev) > +{ > + struct device_node *np = pdev->dev.of_node; > + struct resource *res; > + struct ulpi_phy *uphy; > + bool flag; > + int ret; > + > + uphy = devm_kzalloc(&pdev->dev, sizeof(*uphy), GFP_KERNEL); > + if (!uphy) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + uphy->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); > + if (IS_ERR(uphy->regs)) > + return PTR_ERR(uphy->regs); > + > + ret = of_property_read_u32(np, "view-port", &uphy->vp_offset); > + if (IS_ERR(uphy->regs)) { > + dev_err(&pdev->dev, "view-port register not specified\n"); > + return PTR_ERR(uphy->regs); > + } > + > + flag = of_property_read_bool(np, "drv-vbus"); > + if (flag) > + uphy->flags |= ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT; > + > + uphy->usb_phy = otg_ulpi_create(&ulpi_viewport_access_ops, uphy->flags); > + > + uphy->usb_phy->set_vbus = usbphy_set_vbus; When you will call it? > + > + uphy->usb_phy->dev = &pdev->dev; > + > + uphy->usb_phy->io_priv = uphy->regs + uphy->vp_offset; > + > + ret = usb_add_phy_dev(uphy->usb_phy); > + if (ret < 0) > + return ret; > + > + return 0; > +} > + > +/** > + * ulpi_phy_remove - Releases the resources allocated during the initialization. > + * @pdev: pointer to the platform device structure. > + * > + * Return: 0 always > + */ > +static int ulpi_phy_remove(struct platform_device *pdev) > +{ > + struct ulpi_phy *uphy = platform_get_drvdata(pdev); You have not set uphy as device drvdata at probe > + > + usb_remove_phy(uphy->usb_phy); > + > + return 0; > +} > + > +/* Match table for of_platform binding */ > +static const struct of_device_id ulpi_phy_table[] = { > + { .compatible = "ulpi-phy" }, > + { /* end of list */}, > +}; > +MODULE_DEVICE_TABLE(of, ulpi_phy_table); > + > +static struct platform_driver ulpi_phy_driver = { > + .probe = ulpi_phy_probe, > + .remove = ulpi_phy_remove, > + .driver = { > + .name = "ulpi-platform-phy", > + .of_match_table = of_match_ptr(ulpi_phy_table), > + }, > +}; > +module_platform_driver(ulpi_phy_driver); > + > +MODULE_DESCRIPTION("ULPI PHY platform driver"); > +MODULE_AUTHOR("Xilinx, Inc"); > +MODULE_LICENSE("GPL v2"); > -- > 1.7.1 > -- Best Regards, Peter Chen From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752571AbbIXJGy (ORCPT ); Thu, 24 Sep 2015 05:06:54 -0400 Received: from mail-bl2on0104.outbound.protection.outlook.com ([65.55.169.104]:5656 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751073AbbIXJGs (ORCPT ); Thu, 24 Sep 2015 05:06:48 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; xilinx.com; dkim=none (message not signed) header.d=none;xilinx.com; dmarc=none action=none header.from=freescale.com; Date: Thu, 24 Sep 2015 17:06:31 +0800 From: Peter Chen To: Subbaraya Sundeep Bhatta CC: , , , , , , , "Subbaraya Sundeep Bhatta" Subject: Re: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI PHYs Message-ID: <20150924090629.GA27847@shlinux2> References: <1443012873-13757-1-git-send-email-sbhatta@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1443012873-13757-1-git-send-email-sbhatta@xilinx.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD041;1:BPQ0VMFMdG08+oz+5ec/FXM16bCM7wFYAularHe8CE5z8uYA872d0ytH1xDdT7M2aGDE2WvsHb+A9BsGUR0a0lSyQTJq1gmnUkei6xJr3pECEVmtrbVeLcjNLt4mV477ih8tVbwYZRRPqW4zPly8RJACmR0hEN8xxqLRQtrJD5xe0Mz+EIeIKDbsvajpR5wEGBqSDQGTyefBQ2pN+MOBEbthuQrbWHn4SmaQOV1e3HvQOntCnIpSfReTyQaROHT9j9WGOyiXcTlyynu1ZJDmhnOoHOKVd+XPUsKelc0uzQA/OEn3WykCi3Hh6ejmSSeOZFEKxs6IyIdAMth2HnKc0/hhYApLMNVKxfR/IYAIJgo= X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(979002)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(24454002)(33656002)(97756001)(87936001)(46102003)(85426001)(77156002)(50986999)(86362001)(575784001)(76176999)(19580395003)(19580405001)(62966003)(92566002)(54356999)(105606002)(106466001)(83506001)(33716001)(23726002)(68736005)(77096005)(5001960100002)(50466002)(2950100001)(110136002)(5001920100001)(189998001)(46406003)(11100500001)(5001860100001)(5007970100001)(6806005)(47776003)(64706001)(104016004)(97736004)(4001350100001)(81156007)(4001540100001)(5001830100001)(7059030)(2004002)(217873001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB491;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB491;2:8+hquDfeD+4vH6Gn89ACI4gbtldNw8/xIoj4XiYRu/0avxb9wucHJSh8Elb4lMluQQwHAGs2+DNlnqeRbku94IlFiYHFgiFqAHEfDP1YioBtUxd0o2LD2lIzEk2CCsufD+utuZfcjW4Ld5lWLhQ2uG34pM6VG5U6lwa+Fc+TtMM=;3:OGXpiL58zLdPuqxVUxRpCdXQKSnYSsWb3JHBSJxh4khKN2dyAiNE9ufCxNv+s1p4Mh/Sj3ntDvgXx83WBRV+QjmZcx45DtkXZ2pZBAL5F2lCbjeXVVns5HjhCt7SXBwwNShoRb7E/kmyqj0KEToXlQBAqD/vgXrTPFFVcVMtOknI+TzbF8I3iFMYslEXne69tSd3QmyrUdgXqV4SZU8GVRfb6IznulEp2ceLepBPCQA=;25:T5HZDJOQYEKYYmCZQcayOIppDNPqs7ZoIMar4j/PDJA1h07uw0I2NT0qjvzHwPnTAEaPCBCfJUSdhzyKX/F6TBwuTjh4W622824YDGLmwXzZ5bw2L283TQ4SDigmDrvDabuX4R7VKGLY3uE2gvctQn4UPXkyEW3QjSvRoEu0ck5JZMK2BAaqIgrdVKb50r266sYZnmC4aMfmBFPgC5zq1ZXSQzPZGf3k3el21jCrupAEJkpM1aWlzvfo4Qya5Gj1oKMjUG9FaJLkxt2sxS15Lg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB491; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB491;20:2Cv06NvrtN3xxuBIN+lArulgn0F+I+9Ipk2EeIpzuGJDud8myw3ZtHDRtnGDyhwrc+mbclDJEPacEvZY4pt1PEvxKBG3qasVEFamIXaVmGNuKDKt+EHk6FkhYu2P7YxvjgzGvVGbgwjuhOf3NNJ/+IKIBINWqlv+xDFsO6/m/cC/k5UDBTgvzIiMZPJOItG65/6a0P1KPArUBXhiDh+dp1YRwSgT5AJ2OchrzC9ASYtePq93yWRyZFiiu5SwzdA1u6rLFjgagi/dXjI80acorAYhu1ArRD2KeduokuqGYx+7AX5hvqo+pHuOFRwhis4asHojf0YOFyEpZSuQ0fxAeNvYa7/RxZL0GI5tR76r0eo=;4:pP0WHAOBzrFpraFUG7yW9Mis7FrdBotqOizJDpDm+d46rOoLt0Z5vd2UY5U9IaEZ3XCZRposo9NLdKtlJQUdgFmSZ6O6zkXrZ6DMGfyHS2WP9QB29BMItbZIK6Sq+HMb5G000GdJSpjlwAQTNKOmHPmNgcxK2qmTmKDbJbg6T3Fka6eVpPilWGh9cBWV0tx0VXFi/mriC7I3iGQOkGNjnHe6DnZaq/LOMSp3cEYMxgn/tqXYIw/kGIlZn6tAS7g3oDcj4nzMQxv/fwDt1ok6Z1Y0Up3mJ2pzVlb2BfXHVgvj1hHNI2OFPRAGzBCXYatkei80XGQLn7tShHZvV4UesUpy/9ZZNP8C7cpuzd7qShE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001);SRVR:BY2PR03MB491;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB491; X-Forefront-PRVS: 070912876F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB491;23:4tBizwipYhOPxDtE6/Rj0sKcilP5BXsT0zlcpA7YXC?= =?us-ascii?Q?HVyqPYYUtipEG4UYRUKXu8njqyp+vgaYTrKp3DpfdBQtPnBtMaUNFJagNF0D?= =?us-ascii?Q?4RVBUZmirIOtmaOgc5rSL5FnRX/AhpKnnMhdrVGAJWavIwlv3gt5RRAQf17C?= =?us-ascii?Q?LG6kzro3PWlv6eNeNRdgsXw5i0j6MiMqYBfOU1HnQ7ftz3u199I1h2UvbjmG?= =?us-ascii?Q?BDhP88e3sh8v0HdZiqtY3WzfqS9u7ajHeUy9hZRUmmizuetPqeZ81iGJ0JND?= =?us-ascii?Q?NMNYNikp3u+Gx8U9bOiQ5OowGiCyCP2NahxEVnN+ta5ekP0CdigJCCmOEHeg?= =?us-ascii?Q?dMk/riWdPW6KBeSy3OtkLeSmiTs1bN8cq0WWtHN/I01f445eI3X+mWoSl3/Z?= =?us-ascii?Q?XEHT8q3OKFl+/3aAHrTv64FsDbaTaCJ2icEhclzzdJ3e/ZnxA5Fi1U6KV62b?= =?us-ascii?Q?GOs4gJnHL/DVNWQJZhoe5bxRGySqElq9/6tUN1xWoqm0tdu+9uyceDm3gXsI?= =?us-ascii?Q?Zh8TJvv1LIENdHvEePL50sgkdpflST1u6Q8cEvQPe/IBgRSW7hp8/Hi2UEXf?= =?us-ascii?Q?nMheKzKxSRvqEfObyp8zeSna/nMPSyHVTpYDIpyYea3dbsSDH9aVN67r9eQM?= =?us-ascii?Q?xCtlj/9PRLyuLSKOYoyxUoKRyus0qxSsyyU4m2ximXLdCEQo9KbKx5AhN2QU?= =?us-ascii?Q?f8xb15l/BGBOIR4d7oncWkg08H5zIYRvzJJ1YL+WymGv+eie76qhSpw1WhIs?= =?us-ascii?Q?fEDsOozoXOfuRyWlKM0+q7Z82COdbCGmZCjmYFwWax0K0e5Lb8rV+Hedxqr3?= =?us-ascii?Q?D0ac0WUpfuScyLGFgtgl9jwEgVzKwg0ZJtw2VwMQ+8GcQ/Y0xzVAuCGXJq5e?= =?us-ascii?Q?3Kh2o91s2JLzf4RaL5Fzi5bvONVjjl7ZLtmVnFSB5c2HU9sHaP/AKJVwNSq6?= =?us-ascii?Q?I1ntSSljAopMlWxVNE3MTZ1Gm4lqPausLZ555E6m1klkoDrdmvS0MlnWm9/N?= =?us-ascii?Q?vesqWEeZBaRgVIn8w4owCTdle13Gw4a+QVU0081u0aq6U+tWZ/ahNO1/j9dX?= =?us-ascii?Q?uQBq+3jMGtLYfRhXBp3W8IaI20uPsUaBbJTjEvko/lejszvV4ebtWZzy1urO?= =?us-ascii?Q?9yuTglYBdIfgZ5mP+un+qu4ryZHX7iSohQF1bhxrPGmkcvhsl5wZz3Wwl17m?= =?us-ascii?Q?NB59Gob+/UyIaMuuDrVjcG7mGu4u5uMDa/6BjEpPKCXTy4S8Ncuqryn6b9bE?= =?us-ascii?Q?BFHebZwUFj72wuDqewuXvId/QmrdkWB5snpchBnrshLg5RKV4zdIHSQt/PTL?= =?us-ascii?Q?f2bLuNDiFmk2+D7/W05YcRDWAuApWTGQd+vZMkWQBEM9PQ0kQKmY9FitF9/B?= =?us-ascii?Q?+KeTCx05jjmNhKSKs9XERebrWq6qwCvJL1Ztq/Rj1kf1bUko6wo71KV4iNIx?= =?us-ascii?Q?hoUH0J8mk2mEQmNA3Q8iT4maHg9ENYLs1H/o6PaQYeOnDxJtuH?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB491;5:BtCQaECJEB2oCfko/f1LuJHVXbAnQy/IvSaPO6FBP2sorjfGE6aZ+1zf4lWfpjazV1VuHxg5qujS1LsbDZKrIyI5CqiRgFTHli76eju0TP76iwX94MB8EMUGcAQkmg4YU4TLMa7Xcb3jAJWYg4PHJg==;24:074gymlSWweVyvKAYaQ2JWYnWGeF/8jmvO7uCjBWjKg1t4HpwyKXbt/s0xfD5/mpsZwdkLiwfFym+0cuNd3FMq080BJILSe7v7qojYIr1Xc=;20:i8jGPOuU37ARysEZCfOCbm75kpuUHBkG2htaV8ZUVT71SDC2/tczUhr3XO5Qdabh03R3C9APxsg6/ZztVD/XCw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2015 09:06:45.1702 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB491 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 23, 2015 at 06:24:33PM +0530, Subbaraya Sundeep Bhatta wrote: > Based on board design USB controller needs explicit software > access to ULPI PHY for controlling VBUS. This patch adds platform > driver support for generic ULPI PHYs and provides a USB2 PHY device > to controllers. > > Signed-off-by: Subbaraya Sundeep Bhatta > --- > drivers/usb/phy/Kconfig | 12 +++ > drivers/usb/phy/Makefile | 1 + > drivers/usb/phy/phy-platform-ulpi.c | 143 +++++++++++++++++++++++++++++++++++ > 3 files changed, 156 insertions(+), 0 deletions(-) > create mode 100644 drivers/usb/phy/phy-platform-ulpi.c > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig > index 7d3beee..2956ad4 100644 > --- a/drivers/usb/phy/Kconfig > +++ b/drivers/usb/phy/Kconfig > @@ -201,6 +201,18 @@ config USB_RCAR_PHY > To compile this driver as a module, choose M here: the > module will be called phy-rcar-usb. > > +config USB_PLATFORM_ULPI_PHY > + tristate "Platform driver support for ULPI PHYs" > + depends on ARCH_ZYNQ || COMPILE_TEST If you want this as a common driver, drop platform dependency please. > + select USB_PHY > + select USB_ULPI_VIEWPORT > + help > + Say Y here to add support for the Platform driver for ULPI PHYs. > + This adds platform driver support for all generic ULPI PHYs and is > + typically used if usb controller driver needs explicit access to PHY. > + > + To compile this driver as a module, choose M here. > + > config USB_ULPI > bool "Generic ULPI Transceiver Driver" > depends on ARM || ARM64 > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile > index 19c0dcc..8431b6b 100644 > --- a/drivers/usb/phy/Makefile > +++ b/drivers/usb/phy/Makefile > @@ -24,6 +24,7 @@ obj-$(CONFIG_USB_QCOM_8X16_PHY) += phy-qcom-8x16-usb.o > obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o > obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o > obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o > +obj-$(CONFIG_USB_PLATFORM_ULPI_PHY) += phy-platform-ulpi.o > obj-$(CONFIG_USB_ULPI) += phy-ulpi.o > obj-$(CONFIG_USB_ULPI_VIEWPORT) += phy-ulpi-viewport.o > obj-$(CONFIG_KEYSTONE_USB_PHY) += phy-keystone.o > diff --git a/drivers/usb/phy/phy-platform-ulpi.c b/drivers/usb/phy/phy-platform-ulpi.c > new file mode 100644 > index 0000000..fb89363 > --- /dev/null > +++ b/drivers/usb/phy/phy-platform-ulpi.c > @@ -0,0 +1,143 @@ > +/* > + * Platform driver for generic ULPI PHYs. > + * > + * Copyright (C) 2015 Xilinx, Inc. > + * > + * Author: Subbaraya Sundeep > + * > + * This program is free software; you can redistribute it > + * and/or modify it under the terms of the GNU General Public > + * License as published by the Free Software Foundation; > + * either version 2 of the License, or (at your option) any > + * later version. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** > + * struct ulpi_phy - The ULPI PHY > + * @usb_phy: pointer to usb phy > + * @regs: base address of USB controller to which PHY is connected > + * @vp_offset: ulpi viewport register offset of USB controller > + * @flags: initial required settings of PHY > + */ > + > +struct ulpi_phy { > + struct usb_phy *usb_phy; > + void __iomem *regs; > + unsigned int vp_offset; > + unsigned int flags; > +}; > + > +/** > + * usbphy_set_vbus - Sets VBUS by writing to PHY. > + * @phy: pointer to PHY > + * @on: 1 - turn on VBUS > + * 0 - turn off VBUS > + * Return: 0 for success and error value on failure > + */ > +static int usbphy_set_vbus(struct usb_phy *phy, int on) > +{ > + unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); > + > + flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); > + > + if (on) { > + if (phy->flags & ULPI_OTG_DRVVBUS) > + flags |= ULPI_OTG_CTRL_DRVVBUS; > + > + if (phy->flags & ULPI_OTG_DRVVBUS_EXT) > + flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; > + } > + > + return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); > +} > + > +/** > + * ulpi_phy_probe - The device probe function for driver initialization. > + * @pdev: pointer to the platform device structure. > + * > + * Return: 0 for success and error value on failure > + */ > +static int ulpi_phy_probe(struct platform_device *pdev) > +{ > + struct device_node *np = pdev->dev.of_node; > + struct resource *res; > + struct ulpi_phy *uphy; > + bool flag; > + int ret; > + > + uphy = devm_kzalloc(&pdev->dev, sizeof(*uphy), GFP_KERNEL); > + if (!uphy) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + uphy->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); > + if (IS_ERR(uphy->regs)) > + return PTR_ERR(uphy->regs); > + > + ret = of_property_read_u32(np, "view-port", &uphy->vp_offset); > + if (IS_ERR(uphy->regs)) { > + dev_err(&pdev->dev, "view-port register not specified\n"); > + return PTR_ERR(uphy->regs); > + } > + > + flag = of_property_read_bool(np, "drv-vbus"); > + if (flag) > + uphy->flags |= ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT; > + > + uphy->usb_phy = otg_ulpi_create(&ulpi_viewport_access_ops, uphy->flags); > + > + uphy->usb_phy->set_vbus = usbphy_set_vbus; When you will call it? > + > + uphy->usb_phy->dev = &pdev->dev; > + > + uphy->usb_phy->io_priv = uphy->regs + uphy->vp_offset; > + > + ret = usb_add_phy_dev(uphy->usb_phy); > + if (ret < 0) > + return ret; > + > + return 0; > +} > + > +/** > + * ulpi_phy_remove - Releases the resources allocated during the initialization. > + * @pdev: pointer to the platform device structure. > + * > + * Return: 0 always > + */ > +static int ulpi_phy_remove(struct platform_device *pdev) > +{ > + struct ulpi_phy *uphy = platform_get_drvdata(pdev); You have not set uphy as device drvdata at probe > + > + usb_remove_phy(uphy->usb_phy); > + > + return 0; > +} > + > +/* Match table for of_platform binding */ > +static const struct of_device_id ulpi_phy_table[] = { > + { .compatible = "ulpi-phy" }, > + { /* end of list */}, > +}; > +MODULE_DEVICE_TABLE(of, ulpi_phy_table); > + > +static struct platform_driver ulpi_phy_driver = { > + .probe = ulpi_phy_probe, > + .remove = ulpi_phy_remove, > + .driver = { > + .name = "ulpi-platform-phy", > + .of_match_table = of_match_ptr(ulpi_phy_table), > + }, > +}; > +module_platform_driver(ulpi_phy_driver); > + > +MODULE_DESCRIPTION("ULPI PHY platform driver"); > +MODULE_AUTHOR("Xilinx, Inc"); > +MODULE_LICENSE("GPL v2"); > -- > 1.7.1 > -- Best Regards, Peter Chen