Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030826AbdDTIvF (ORCPT ); Thu, 20 Apr 2017 04:51:05 -0400 Received: from mail-dm3nam03on0067.outbound.protection.outlook.com ([104.47.41.67]:17952 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S940478AbdDTIvA (ORCPT ); Thu, 20 Apr 2017 04:51:00 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=nxp.com; Date: Thu, 20 Apr 2017 16:50:46 +0800 From: Peter Chen To: Peter Senna Tschudin CC: Stephen Boyd , Fabien Lahoudere , Felipe Balbi , Greg Kroah-Hartman , "open list:USB PHY LAYER" , open list Subject: Re: [RFC] usb-phy-generic: Add support to SMSC USB3315 Message-ID: <20170420085046.GA11378@b29397-desktop> References: <20170419061413.20961-1-peter.senna@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170419061413.20961-1-peter.senna@collabora.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-EOPAttributedMessage: 0 X-Matching-Connectors: 131371518575338474;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39400400002)(39380400002)(39860400002)(39850400002)(39840400002)(39450400003)(39410400002)(2980300002)(1109001)(1110001)(339900001)(24454002)(199003)(189002)(9170700003)(81166006)(23726003)(104016004)(6666003)(6916009)(2950100002)(189998001)(8676002)(5660300001)(33716001)(105606002)(8936002)(575784001)(50466002)(106466001)(33656002)(55016002)(229853002)(1076002)(97756001)(76176999)(6306002)(50986999)(83506001)(9686003)(4001350100001)(4326008)(54906002)(85426001)(54356999)(86362001)(6246003)(46406003)(305945005)(47776003)(2906002)(53936002)(356003)(230783001)(110136004)(38730400002)(77096006)(18370500001)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0301MB0601;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD025;1:ZchEAsAk5DDoaqrTtWFCLXBQRCYcZEjjxPgeLl7JW5qTi+Zp4Zin7AaDzGrDFj5fr6wUPCXsLJgF5L38VjfRA4ElD0/hIiIZttGolbyg83IrNoI+ZtiidDQlAsFRqdMznmHnBzuCHBzZPyjNdr/0D3wJtER0xdtxEU6qC5VRuU2GmTYQ3Ow35QdiAFfHnhJYYUAuq9PUHtnSvsmPEXN8JplHGnlVHfwgt5tKt/lNoFoFr0RzP50/+39vJ5nU4CZRSVE+u44A1fNue6swUn7P/A32USm64haq9yPO5d72Rh2fMKeYhdQQiSOb4zUzVeNWcJhdTMho+VmMCxmv+J7rzPg5ZI56JUmy2s5U+hBV0eoGeaKG9Mk1m3UoQRZ+L9bURqaQ1WsJRFXOtlOy+2lL1P13DP3vgNL12CknBJSz6QZ1UFvvThmKRo2tukmRf/NoMxsLzIfUYWw1j1c4bUbj3rV+s7WaJgHctvFffldtGXLWxcucBnrBBVRvI3EA/c1gyWQyQIc77Os4si3UJm4lIne6WQ8GjqabUUjMQ3Y1z+RJUKc+xzSYZGM/llD5kpuJt7Sko39JyJ8Qz3PlXntBoi8lQOEuf6FiIpTOdMn3Dn0p/ibRuS/KlTXWZFCJJr6j X-MS-Office365-Filtering-Correlation-Id: 884a22c4-d587-4e23-0289-08d487ca5cbe X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:CY1PR0301MB0601; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0601;3:WZT43lR8DOpErk+W1Kno5/XcdiCydzmmEesHi0hjYFC99HlZFQc0ef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8V4S/tq05Y4jXS/rpW/ropMvZyRO8VnIhftyifQ86wb/DJRvUmqLemAvieYnQy2B2bGoS+9Vll69T8MSxE8ODw25 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(8121501046)(13015025)(5005006)(13017025)(13018025)(13024025)(13023025)(10201501046)(93006095)(93001095)(3002001)(6055026)(6096035)(20161123561025)(20161123563025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(20161123556025);SRVR:CY1PR0301MB0601;BCL:0;PCL:0;RULEID:(400006);SRVR:CY1PR0301MB0601; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0601;4:IXjRj65DfK+S2IruaJ0LPbtoByKoHg5eqi9uihELIk3UgjyXmzEy9YBomSiNFqPU7chyyIAUleY91BQqKA7TcKivwgj7mNSCU1LrLHO6G+kdZEH1oabRSb7UCj+MNZsIb2AFeeIH4mPEZzC/WZ31SrkKmQyTDHb9vjsi3NJalwHOFmapuCtxTyzDIMLJzktB30MtBpMzw8h//4vrbneZpq39zapMNRBGnYgA+Y4PhPRurjDneqxxZF/1jTpxm3eFvL/LF0R+HDXbDU8BU+gDnz2QqLOinI2mnCcorwPrfutgjbz0kJ9dysZOXlaoKLe8BWgWuLu2zn9QruTpl8S/wgcA29SWYBhMv0bQXYUJZnjJmju+RZgEaEiN/f3xxsTsfNdcZ+u2Jb7g7iHzWJ2WSCCTixSTcHZ5LMMd1fPnGsyLQ59dwjvJhN9+edYQk3G/cuQmsnV9ymJhvtOkOtOgBHQ88KBEFu40Ga3UirJZ4QIN2cIFL4wyT+I02TnZ1AnO9zBiKNRwzv2EPZjhbqNYEDGTrKk4woz18tNtULNwzUUxJhiQEjS8UvjNbIBFgdSgqBxKjeK7MjhkOTMmSfeoyAu+B7ezauYm3bqniYBd/mneY9KPACZGm5fyL9W9f0s16B6fUgbJr94oFzdnrgRlKsuGRhpTpW2QJerwmFlhDYQpd3W4IZVYek22xMkfLYUS+LACFr9cDGa7t0jA4mw/M/1Ga11NpwsfWtLfsuMYw08uiuza9zub0ZCXp+55AqVH8IOEjF0/JfXKhm2XeHDlbS2A9+JWTG5aqRfJB0WrNpBwVl41GWDmnLo4+n6v1uoIClErdAOeLapRKCDC3ezMLi5+Vp1m/qP9Zmpn7owjuQ0ZSaHXhNFcy2V9XkN+hJIk X-Forefront-PRVS: 02830F0362 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0301MB0601;23:UbWUBpn+yVzsHYrL/yiPnNF4kArwjNGhXG6qgZt?= =?us-ascii?Q?hRxz7J4F0S0+N2cbJIxbfj10K5aGitEynN1JQE5FMkvAiODPO9wgdXHRl96X?= =?us-ascii?Q?8ERl1q8BJFMwnRcAKP7bJFKDw2Z5nGaYgvUbgNlMmAyjcokAksuCZRDvOoP7?= =?us-ascii?Q?bXpAdyAiZbOyQswn1b0VbckLz7u4a8SdPVaTd9c0cEdM03jxLFypZZOh6x+p?= =?us-ascii?Q?hG8csI7SH5CAGCPTh+VCxpGA1n9WqrGe/YIslG9XVBKiBgxUJFxKeL6GneU6?= =?us-ascii?Q?vOdwiNJuTT6Fbbi2Fnbvki5XILsnXA0OlpEzYE8LbVTVi6ncbjsPHlIIWwnF?= =?us-ascii?Q?Td+GwjM1UBhD9u2z9GeijXMR62sBZvjf1FqNvdwGDRfH7AfsIyRuM9YAa897?= =?us-ascii?Q?ZGzgmE3S7Q8F4D4JSwCiBlDUiDVNV7B2n07bTS16mTfypVJmTxkH4kaAWdvq?= =?us-ascii?Q?M24kbVVcn160vnh0v39MYrigOvmSpbd65/MQSFWfwVdF0C4LNpURUvmSwwL1?= =?us-ascii?Q?vDpaatuZu6zcti2M+sZcMgxaiwyYHwycfgohroVayXNs0rTPRuUMo8IHj+xy?= =?us-ascii?Q?2QWSedbReZHoA3CZtJaV+kYzBHTe7R9pwrNWFmYbuYsKi+sEOYadXS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=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0601;6:/l2gkYoQmQjjHBAHQ5zwoxbY1HE17pFLMCK7xzSMUbzBKW8pcaneW5/4RYHiRSZPi091+CLU5s32cOSPiCh4sNXvcuVfgrPt8KftoWqGe0DJ+rT81UYd51UzZ3MCrJcWJr3Ao/uZIn53cHFMAq/AnkbKQ9GnH1/8X8cu8CPSCiiseNnI9+U7N42x060JOrF1yz7HesYoh00QZQ+/h7sIdXHvAe5ZGG0j1I/+ISH9AWUEAaQTwTwAuldwamlAY9z8YVGjgk6KWxZgbEksmRA2ETFegqwhyLa4ew6RHZ3Clw0Y5G6usJreqqdigTrlDKr+u7qMpARUksgJqNxdkJBs/6M0qTeAlZKwUr6AiZEaaPVxPRADjVQ9VX5G5B/DV9CecMVdVM7IRKC5CU3axx0om4fgKi7bbbnJ0BsBMDhCKWB7scsSuFgbZJjrlBrtFm1wCJNZlqLw5H3TlzbnXBMpUFEkHgSQn5qJkFW3igIXGEn6PVJ/pAHR353wTrnbMyVw;5:KNUH+UMDmPcHrldBSrOCgyty43SVjhLwcyztt8t1kSH/jaA9gxwugseRzxn7FMA2kpo1mXheBm07VtRne+X1nx0qsVHcztu/Sz6ixpSmZyBeGIcfYROZBaZ0mhVf1Rhg6TZWiq4ovWgtyQqkLA40+LSCnnHL27eOgruwPUtFkbj4TsQKF2YXnclZxKfhOiDV;24:syILpTlvzCWN0bhktk1h30sY6wSR3KRyvhvRDGnZ32VhDLqF0XP1N6UMLi63hxFmC0WxQxlK0/BYlBpt97VIzWP2sPv57Rj9f6zLJ11nvlI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB0601;7:5ZeNpgHtPDwZdhx8nqY//xJsG7fQsVhvauc3pENsgO5mFKqFj27A9/HWa/L5c5wEZExX9wENC1amEB7Q+DlJLgzVchOwR79TkGv8veMKOKcELeDy2Kp068yJGB2W0ypMnF3TZAc3TolAkrc1O4dPy8fVPgjHkl4MXJ9qXcUPcoyHE1oWTUKxyRRNvjuk4K/TYc7MduUszbyqLXMbwuPmpUfQRz5IDcD643e1WqnimXU/XnLcLLedAFxxGi7QCu+c6q3fj3yJ1MNmnyjaSJ4Ywtps/NN7nEHFd/dGFWw2U0Vw4QwRJLkDsYWtMK84mwlLgQ4Ej89bnfjDjj59tkbUmw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2017 08:50:57.3622 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0601 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4179 Lines: 147 On Wed, Apr 19, 2017 at 06:14:13AM +0000, Peter Senna Tschudin wrote: > We need the SMSC USB3315 clock and regulator to always be initialized. > We also need the PHY driver to take the PHY out of reset. This patch > extends the existing USB generic nop phy driver to include a new > initialization path. > > A new compatible string "smsc,usb3315" is used to decide which > initialization path to use. > Hi Peter, This is an ULPI PHY, so it is not suitable using generic USB PHY. Taking a look of drivers/phy/phy-qcom-usb-hs.c, you may have some clues. Peter > CC: Peter Chen > CC: Stephen Boyd > CC: Fabien Lahoudere > Signed-off-by: Peter Senna Tschudin > --- > > This is a follow-up of previous discussion: > https://www.spinics.net/lists/linux-usb/msg146680.html > > drivers/usb/phy/phy-generic.c | 33 +++++++++++++++++++++++++++++---- > drivers/usb/phy/phy-generic.h | 1 + > 2 files changed, 30 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c > index 89d6e7a..6ea9ce4 100644 > --- a/drivers/usb/phy/phy-generic.c > +++ b/drivers/usb/phy/phy-generic.c > @@ -151,6 +151,9 @@ int usb_gen_phy_init(struct usb_phy *phy) > struct usb_phy_generic *nop = dev_get_drvdata(phy->dev); > int ret; > > + if (nop->init_done) > + return 0; > + > if (!IS_ERR(nop->vcc)) { > if (regulator_enable(nop->vcc)) > dev_err(phy->dev, "Failed to enable power\n"); > @@ -164,6 +167,8 @@ int usb_gen_phy_init(struct usb_phy *phy) > > nop_reset(nop); > > + nop->init_done = true; > + > return 0; > } > EXPORT_SYMBOL_GPL(usb_gen_phy_init); > @@ -216,18 +221,29 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) > otg->host = host; > return 0; > } > +int smsc_usb3315_init(struct usb_phy_generic *nop) > +{ > + /* > + * If the gpio for controlling reset state is not available, try again > + * later > + */ > + if(!nop->gpiod_reset) > + return -EPROBE_DEFER; > + > + return usb_gen_phy_init(&nop->phy); > +} > > int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop, > struct usb_phy_generic_platform_data *pdata) > { > + struct device_node *node = NULL; > enum usb_phy_type type = USB_PHY_TYPE_USB2; > int err = 0; > - > u32 clk_rate = 0; > bool needs_vcc = false; > > if (dev->of_node) { > - struct device_node *node = dev->of_node; > + node = dev->of_node; > > if (of_property_read_u32(node, "clock-frequency", &clk_rate)) > clk_rate = 0; > @@ -304,6 +320,12 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop, > nop->phy.otg->set_host = nop_set_host; > nop->phy.otg->set_peripheral = nop_set_peripheral; > > + if(node && of_device_is_compatible(node, "smsc,usb3315")) { > + err = smsc_usb3315_init(nop); > + if (err) > + return err; > + } > + > return 0; > } > EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); > @@ -318,6 +340,10 @@ static int usb_phy_generic_probe(struct platform_device *pdev) > if (!nop) > return -ENOMEM; > > + platform_set_drvdata(pdev, nop); > + > + nop->init_done = false; > + > err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev)); > if (err) > return err; > @@ -346,8 +372,6 @@ static int usb_phy_generic_probe(struct platform_device *pdev) > return err; > } > > - platform_set_drvdata(pdev, nop); > - > return 0; > } > > @@ -362,6 +386,7 @@ static int usb_phy_generic_remove(struct platform_device *pdev) > > static const struct of_device_id nop_xceiv_dt_ids[] = { > { .compatible = "usb-nop-xceiv" }, > + { .compatible = "smsc,usb3315" }, > { } > }; > > diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h > index 0d0eadd..db4ade6 100644 > --- a/drivers/usb/phy/phy-generic.h > +++ b/drivers/usb/phy/phy-generic.h > @@ -14,6 +14,7 @@ struct usb_phy_generic { > struct gpio_desc *gpiod_vbus; > struct regulator *vbus_draw; > bool vbus_draw_enabled; > + bool init_done; > unsigned long mA; > unsigned int vbus; > }; > -- > 2.9.3 > -- Best Regards, Peter Chen