Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbbGBIgW (ORCPT ); Thu, 2 Jul 2015 04:36:22 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:62866 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752072AbbGBIfx convert rfc822-to-8bit (ORCPT ); Thu, 2 Jul 2015 04:35:53 -0400 X-IronPort-AV: E=Sophos;i="5.15,391,1432566000"; d="scan'208";a="189581296" From: Phil Edworthy To: Laurent Pinchart CC: Yoshihiro Shimoda , Greg Kroah-Hartman , Felipe Balbi , Ulrich Hecht , Kishon Vijay Abraham I , "Sergei Shtylyov" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-sh@vger.kernel.org" , Kuninori Morimoto Subject: RE: [PATCH v2] usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS Thread-Topic: [PATCH v2] usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS Thread-Index: AQHQtJov6QAOeJ5fNUapptyc9faHp53H1TgAgAAB+JA= Date: Thu, 2 Jul 2015 08:35:48 +0000 Message-ID: References: <1435822602-22685-1-git-send-email-phil.edworthy@renesas.com> <2896957.Pcl0CbmdvL@avalon> In-Reply-To: <2896957.Pcl0CbmdvL@avalon> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ideasonboard.com; dkim=none (message not signed) header.d=none; x-originating-ip: [193.141.220.21] x-microsoft-exchange-diagnostics: 1;SIXPR06MB0605;5:68GYZJUG64XCV9MpPbDdnj0nreqZ83cOhBewGMRiPvZrLghTrbIBXLqEcuA9MAVbNW/Shmuwfc8lURoMnPjOxLkeXKJS0aD4vr3Dl7tny5f3ZGX2qNZpbgdPRt1KtA+7PH9bFL1RbLSSVckJGZ/Wtg==;24:XUaXVjSiptVEBwr2mlGPekMdo7Gmj4FiIL11KCqUhlkP7B+rN97rzNnL63YhTpXqRZW8VyC87Hx51IToKW6i96TOd4pEoSYD2OJRSP0jWDg=;20:tmCZmqYhn4Q4TcieQRvdPMt7rXgxpyInWee7GOLeKWgTbpmsBz2vPWTfNmavkp1pcaXhzIHh/x0Udx91vSYguiZL/qQHRdteOGomgC1eRFaKCCn2nYXoGFHCuim5Kx3rlpy4/Hyo1TafawvDsohHPty9K5+n4899htQ/559c7RE= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0605; 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:SIXPR06MB0605;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0605; x-forefront-prvs: 06259BA5A2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(51704005)(19580405001)(86362001)(19580395003)(110136002)(189998001)(74316001)(5002640100001)(5003600100002)(5001960100002)(107886002)(46102003)(92566002)(76576001)(33656002)(54356999)(50986999)(76176999)(2656002)(2950100001)(62966003)(106116001)(102836002)(66066001)(87936001)(40100003)(77156002)(2900100001)(77096005)(217873001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:SIXPR06MB0605;H:SIXPR06MB0639.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: 02 Jul 2015 08:35:48.2466 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0605 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5882 Lines: 186 Hi Laurent, On 02 July 2015 09:15, Laurent wrote: > Hi Phil, > > (CC'ing Morimoto-san) > > Thank you for the patch. > > On Thursday 02 July 2015 08:36:42 Phil Edworthy wrote: > > These changes allow a PHY driver to trigger a VBUS interrupt and > > to provide the value of VBUS. > > > > Signed-off-by: Phil Edworthy > > > > --- > > v2: > > - vbus variables changed from int to bool. > > - dev_info() changed to dev_err() > > --- > > drivers/usb/renesas_usbhs/common.h | 2 ++ > > drivers/usb/renesas_usbhs/mod.c | 3 +++ > > drivers/usb/renesas_usbhs/mod_gadget.c | 38 > +++++++++++++++++++++++++++++++ > > 3 files changed, 43 insertions(+) > > > > diff --git a/drivers/usb/renesas_usbhs/common.h > > b/drivers/usb/renesas_usbhs/common.h index 8c5fc12..478700c 100644 > > --- a/drivers/usb/renesas_usbhs/common.h > > +++ b/drivers/usb/renesas_usbhs/common.h > > @@ -255,6 +255,8 @@ struct usbhs_priv { > > struct renesas_usbhs_driver_param dparam; > > > > struct delayed_work notify_hotplug_work; > > + bool vbus_is_indirect; > > + bool vbus_indirect_value; > > struct platform_device *pdev; > > > > struct extcon_dev *edev; > > diff --git a/drivers/usb/renesas_usbhs/mod.c > > b/drivers/usb/renesas_usbhs/mod.c index 9a705b1..8a2d3dd 100644 > > --- a/drivers/usb/renesas_usbhs/mod.c > > +++ b/drivers/usb/renesas_usbhs/mod.c > > @@ -42,6 +42,9 @@ static int usbhsm_autonomy_get_vbus(struct > platform_device > > *pdev) { > > struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); > > > > + if (priv->vbus_is_indirect) > > + return priv->vbus_indirect_value; > > + > > Something is bothering me. The comment block right before this function states > that "these functions are used if platform doesn't have external phy". > However, the mechanism you implement here is aimed at letting a PHY control > vbus. I have a feeling this isn't the right mechanism. I took the comment as though it was talking about an physically external PHY, but I suppose it makes no difference from the point of view of this driver. I'll have a look to see if there is a better way to hook this in. > > return VBSTS & usbhs_read(priv, INTSTS0); > > } > > > > diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c > > b/drivers/usb/renesas_usbhs/mod_gadget.c index dc2aa32..51b63f9 100644 > > --- a/drivers/usb/renesas_usbhs/mod_gadget.c > > +++ b/drivers/usb/renesas_usbhs/mod_gadget.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > #include "common.h" > > > > /* > > @@ -50,6 +51,7 @@ struct usbhsg_gpriv { > > int uep_size; > > > > struct usb_gadget_driver *driver; > > + struct usb_phy *transceiver; > > > > u32 status; > > #define USBHSG_STATUS_STARTED (1 << 0) > > @@ -882,6 +884,8 @@ static int usbhsg_gadget_start(struct usb_gadget > > *gadget, { > > struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); > > struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); > > + struct device *dev = usbhs_priv_to_dev(priv); > > + int ret; > > > > if (!driver || > > !driver->setup || > > @@ -891,6 +895,17 @@ static int usbhsg_gadget_start(struct usb_gadget > > *gadget, /* first hook up the driver ... */ > > gpriv->driver = driver; > > > > + /* connect to bus through transceiver */ > > + if (!IS_ERR_OR_NULL(gpriv->transceiver)) { > > + ret = otg_set_peripheral(gpriv->transceiver->otg, > > + &gpriv->gadget); > > + if (ret) { > > + dev_err(dev, "%s: can't bind to transceiver\n", > > + gpriv->gadget.name); > > Shouldn't gpriv->driver be set to NULL here ? Or possibly better, this code > block moved before setting gpriv->driver ? Makes sense. > > + return ret; > > + } > > + } > > + > > return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD); > > } > > > > @@ -900,6 +915,10 @@ static int usbhsg_gadget_stop(struct usb_gadget > > *gadget) struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); > > > > usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); > > + > > + if (!IS_ERR_OR_NULL(gpriv->transceiver)) > > + (void) otg_set_peripheral(gpriv->transceiver->otg, NULL); > > Is there really a need for (void) ? Oops, none at all. > > + > > gpriv->driver = NULL; > > > > return 0; > > @@ -947,12 +966,27 @@ static int usbhsg_set_selfpowered(struct usb_gadget > > *gadget, int is_self) return 0; > > } > > > > +static int usbhsg_vbus_session(struct usb_gadget *gadget, int is_active) > > +{ > > + struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); > > + struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); > > + struct platform_device *pdev = usbhs_priv_to_pdev(priv); > > + > > + priv->vbus_is_indirect = 1; > > + priv->vbus_indirect_value = !!is_active; > > + > > + renesas_usbhs_call_notify_hotplug(pdev); > > + > > + return 0; > > +} > > + > > static const struct usb_gadget_ops usbhsg_gadget_ops = { > > .get_frame = usbhsg_get_frame, > > .set_selfpowered = usbhsg_set_selfpowered, > > .udc_start = usbhsg_gadget_start, > > .udc_stop = usbhsg_gadget_stop, > > .pullup = usbhsg_pullup, > > + .vbus_session = usbhsg_vbus_session, > > }; > > > > static int usbhsg_start(struct usbhs_priv *priv) > > @@ -994,6 +1028,10 @@ int usbhs_mod_gadget_probe(struct usbhs_priv > *priv) > > goto usbhs_mod_gadget_probe_err_gpriv; > > } > > > > + gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); > > + dev_info(dev, "%s transceiver found\n", > > + gpriv->transceiver ? "" : "No"); > > + > > /* > > * CAUTION > > * > > -- > Regards, > > Laurent Pinchart Thanks Phil -- 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/