From patchwork Wed Sep 10 10:33:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4875911 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DF2DAC0338 for ; Wed, 10 Sep 2014 10:34:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88DD3200FE for ; Wed, 10 Sep 2014 10:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 290F3200EC for ; Wed, 10 Sep 2014 10:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbaIJKeF (ORCPT ); Wed, 10 Sep 2014 06:34:05 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:49419 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752362AbaIJKeD (ORCPT ); Wed, 10 Sep 2014 06:34:03 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 10 Sep 2014 19:34:01 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id BBC654B1ED; Wed, 10 Sep 2014 19:34:01 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id ADF328002E; Wed, 10 Sep 2014 19:34:01 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id A73888002D; Wed, 10 Sep 2014 19:34:01 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id VAT13012; Wed, 10 Sep 2014 19:34:01 +0900 X-IronPort-AV: E=Sophos;i="5.04,497,1406559600"; d="scan'208";a="168720672" Received: from mail-sg1lp0091.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.91]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 10 Sep 2014 19:34:00 +0900 Received: from [10.161.20.147] (211.11.155.147) by HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) with Microsoft SMTP Server (TLS) id 15.0.1024.12; Wed, 10 Sep 2014 10:33:59 +0000 Message-ID: <54102910.70703@renesas.com> Date: Wed, 10 Sep 2014 19:33:52 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Greg Kroah-Hartman , Felipe Balbi CC: "linux-usb@vger.kernel.org" , SH-Linux , Kuninori Morimoto , Ulrich Hecht Subject: [PATCH 2/4] usb: renesas_usbhs: gadget: fix the behavior of pullup X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKNPR04CA013.apcprd04.prod.outlook.com (10.141.16.33) To HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 033054F29A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019019)(6009001)(6049001)(199003)(189002)(76482001)(64126003)(77982001)(46102001)(54356999)(79102001)(50986999)(77096002)(65816999)(99396002)(95666004)(102836001)(83506001)(105586002)(101416001)(229853001)(107046002)(106356001)(19580405001)(19580395003)(83322001)(36756003)(20776003)(4396001)(47776003)(21056001)(85306004)(85852003)(65956001)(83072002)(66066001)(92566001)(65806001)(92726001)(86362001)(90102001)(42186005)(117636001)(23756003)(64706001)(80022001)(81342001)(97736003)(81542001)(87976001)(31966008)(50466002)(74502001)(74662001)(62816006); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB323; H:[10.161.20.147]; FPR:; MLV:nov; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that this driver always enable the D+ pullup after it detected the VBUS connection even though this usb controller can control the D+ pullup timing by software. So, this driver should enable the D+ pullup after a gadget driver called usb_gadget_connect(). Signed-off-by: Takeshi Kihara Signed-off-by: Kazuya Mizuguchi Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/common.c | 6 ++++-- drivers/usb/renesas_usbhs/mod_gadget.c | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1b9bf8d..ea89f55 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -124,13 +124,15 @@ void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable) void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) { u16 mask = DCFM | DRPD | DPRPU | HSE | USBE; - u16 val = DPRPU | HSE | USBE; + u16 val = HSE | USBE; /* * if enable * * - select Function mode - * - D+ Line Pull-up + * - D+ Line Pull-up is disabled + * When D+ Line Pull-up is enabled, + * calling usbhs_sys_function_pullup(,1) */ usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); } diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index a582222..b80c802 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -56,6 +56,8 @@ struct usbhsg_gpriv { #define USBHSG_STATUS_REGISTERD (1 << 1) #define USBHSG_STATUS_WEDGE (1 << 2) #define USBHSG_STATUS_SELF_POWERED (1 << 3) + + unsigned softconnect:1; }; struct usbhsg_recip_handle { @@ -726,6 +728,24 @@ static struct usb_ep_ops usbhsg_ep_ops = { }; /* + * pullup control + */ +static int usbhsg_can_pullup(struct usbhs_priv *priv) +{ + struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv); + + return gpriv->driver && gpriv->softconnect; +} + +static void usbhsg_update_pullup(struct usbhs_priv *priv) +{ + if (usbhsg_can_pullup(priv)) + usbhs_sys_function_pullup(priv, 1); + else + usbhs_sys_function_pullup(priv, 0); +} + +/* * usb module start/end */ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) @@ -775,6 +795,7 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) * - usb module */ usbhs_sys_function_ctrl(priv, 1); + usbhsg_update_pullup(priv); /* * enable irq callback @@ -881,8 +902,12 @@ static int usbhsg_pullup(struct usb_gadget *gadget, int is_on) { struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); + unsigned long flags; - usbhs_sys_function_pullup(priv, is_on); + usbhs_lock(priv, flags); + gpriv->softconnect = (is_on != 0); + usbhsg_update_pullup(priv); + usbhs_unlock(priv, flags); return 0; }