Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752784AbbGFHSd (ORCPT ); Mon, 6 Jul 2015 03:18:33 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:27617 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751314AbbGFHSa convert rfc822-to-8bit (ORCPT ); Mon, 6 Jul 2015 03:18:30 -0400 X-IronPort-AV: E=Sophos;i="5.15,413,1432566000"; d="scan'208";a="189771865" From: Yoshihiro Shimoda To: Phil Edworthy CC: Rob Herring , Pawel Moll , "Mark Rutland" , Ian Campbell , Kumar Gala , Sergei Shtylyov , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-sh@vger.kernel.org" , Phil Edworthy , "Kishon Vijay Abraham I" Subject: RE: [PATCH v2] phy: rcar-gen2 usb: Add Host/Function switching for USB0 Thread-Topic: [PATCH v2] phy: rcar-gen2 usb: Add Host/Function switching for USB0 Thread-Index: AQHQtJ5Ck4bt3c9xbE6b1dNQtbyc0p3ODMQw Date: Mon, 6 Jul 2015 07:18:24 +0000 Message-ID: References: <1435824347-22732-1-git-send-email-phil.edworthy@renesas.com> In-Reply-To: <1435824347-22732-1-git-send-email-phil.edworthy@renesas.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: renesas.com; dkim=none (message not signed) header.d=none; x-originating-ip: [211.11.155.144] x-microsoft-exchange-diagnostics: 1;SIXPR06MB0639;5:SRaZ6p3GedNn3V3YCOG7BUxgBPX81J0vpjy4SHx3RfwE69B9wKoqEubrm1skiUbLrWP2anVas4xgRMlvAG9xd8heBeBexLUNhbm8jDKD8M3NoFZhUGOt1X37EeASg/QcYuxCN7ydbkjfdYbzb4k78w==;24:XtKLwu8VAHLjQcU8v/7xQZeNJkq52jT1c4wSlUoAJtyoWsvvjdAmds5dvkBxeGO1Ge82Bni6d6jrbE5g4GzcD8uhBgoY93zYEkNL4A+JSnw=;20:dbPu3VY882FI2tdawu68e7eo8u48Ig4GTAUyxw+8sLavf6PATwtM9lEt0EmsqIUcCFnLEtJOxgeK4FjtNeXr4GxL8AJmTemcAK8Ke7STxuA2EAm6R22irJqagN/PGu41z24KJM0AuV2DwXdBVMyW29nQGokCKCHdOzZ2DPsaIJ8= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0639; sixpr06mb0639: X-MS-Exchange-Organization-RulesExecuted x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:SIXPR06MB0639;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0639; x-forefront-prvs: 06290ECA9D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(51704005)(45984002)(377454003)(92566002)(66066001)(77156002)(106116001)(86362001)(54356999)(19580395003)(87936001)(62966003)(2656002)(50986999)(76176999)(77096005)(5001960100002)(40100003)(2950100001)(2900100001)(189998001)(46102003)(122556002)(110136002)(5002640100001)(74316001)(5003600100002)(76576001)(33656002)(102836002)(5001920100001)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:SIXPR06MB0639;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jul 2015 07:18:24.9515 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0639 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3420 Lines: 127 Hi Phil-san, Thank you very much for the patch! > Sent: Thursday, July 02, 2015 5:06 PM < snip > > +/* VBUS change IRQ handler */ > +static irqreturn_t gpio_vbus_irq(int irq, void *data) > +{ > + struct rcar_gen2_channel *channel = data; > + > + /* Wait 20ms before doing anything as VBUS needs to settle */ > + schedule_delayed_work(&channel->work, msecs_to_jiffies(20)); > + > + return IRQ_HANDLED; > +} > + > +static int probe_otg(struct platform_device *pdev, > + struct rcar_gen2_phy_driver *drv) > +{ > + struct device *dev = &pdev->dev; > + struct rcar_gen2_channel *ch = drv->channels; > + int irq; > + int ret; > + > + /* GPIOs for Host/Fn switching */ > + ch->gpio_id = of_get_named_gpio_flags(dev->of_node, > + "renesas,id-gpio", 0, NULL); > + ch->gpio_vbus = of_get_named_gpio_flags(dev->of_node, > + "renesas,vbus-gpio", 0, NULL); > + > + /* Need valid ID and VBUS gpios for Host/Fn switching */ > + if (gpio_is_valid(ch->gpio_id) && gpio_is_valid(ch->gpio_vbus)) { > + ch->use_otg = 1; > + > + /* GPIO for ID input */ > + ret = devm_gpio_request_one(dev, ch->gpio_id, GPIOF_IN, "id"); > + if (ret) > + return ret; > + > + /* GPIO for VBUS input */ > + ret = devm_gpio_request_one(dev, ch->gpio_vbus, GPIOF_IN, "vbus"); According to the checkpatch.pl, "line over 80 characters". > + if (ret) > + return ret; > + > + irq = gpio_to_irq(ch->gpio_vbus); > + ret = devm_request_irq(dev, irq, gpio_vbus_irq, VBUS_IRQ_FLAGS, > + "vbus_detect", ch); > + if (ret) > + return ret; > + > + /* Optional GPIO for VBUS power */ > + ch->gpio_vbus_pwr = of_get_named_gpio_flags(dev->of_node, > + "renesas,vbus-pwr-gpio", 0, NULL); Same above. > + if (gpio_is_valid(ch->gpio_id)) { > + ret = devm_gpio_request_one(dev, ch->gpio_vbus_pwr, > + GPIOF_OUT_INIT_LOW, "vbus-pwr"); > + if (ret) > + return ret; > + } > + > + } else if (gpio_is_valid(ch->gpio_id)) { > + dev_err(dev, "Failed to get VBUS gpio\n"); > + return ch->gpio_vbus; > + } else if (gpio_is_valid(ch->gpio_vbus)) { > + dev_err(dev, "Failed to get ID gpio\n"); > + return ch->gpio_id; > + } > + > + return 0; > +} > + > +/* bind/unbind the peripheral controller */ > +static int rcar_gen2_usb_set_peripheral(struct usb_otg *otg, > + struct usb_gadget *gadget) > +{ > + otg->gadget = gadget; > + if (!gadget) { > + usb_gadget_vbus_disconnect(otg->gadget); Since the otg->gadget is NULL, this driver should not call this function here. > + otg->state = OTG_STATE_UNDEFINED; > + } > + > + return 0; > +} > + > static int rcar_gen2_phy_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; < snip > > @@ -323,6 +540,14 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) > > dev_set_drvdata(dev, drv); > > + /* > + * If we already have something plugged into USB0, we won't get an edge > + * on VBUS, so we have to manually schedule work to look at the VBUS > + * and ID signals. > + */ > + if (drv->channels->use_otg) > + schedule_delayed_work(&drv->channels->work, msecs_to_jiffies(100)); This line is also "line over 80 characters". Best regards, Yoshihiro Shimoda > + > return 0; > } > > -- > 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/