From patchwork Thu Mar 30 02:16:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9652859 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 277856034C for ; Thu, 30 Mar 2017 02:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14D232856E for ; Thu, 30 Mar 2017 02:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04F4128579; Thu, 30 Mar 2017 02:18:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 506A12856E for ; Thu, 30 Mar 2017 02:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753583AbdC3CSY (ORCPT ); Wed, 29 Mar 2017 22:18:24 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:45827 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753170AbdC3CSX (ORCPT ); Wed, 29 Mar 2017 22:18:23 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 30 Mar 2017 11:18:20 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id AD4B03D271; Thu, 30 Mar 2017 11:18:20 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id A7C8F28076; Thu, 30 Mar 2017 11:18:20 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 9F73928070; Thu, 30 Mar 2017 11:18:20 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id MAF04671; Thu, 30 Mar 2017 11:18:20 +0900 X-IronPort-AV: E=Sophos;i="5.36,244,1486393200"; d="scan'208";a="239032491" Received: from mail-sg2apc01lp0246.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.246]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 30 Mar 2017 11:18:19 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6DpvGM/UQiDZXFwZt+tXYc4m4frcEuT0oVhEPzbSB3s=; b=W8+Fbg0TdYacj/w0SRAZHsIjtxGIsL54EpfAcJK3MiFFu0cNH8oAuvA42jO5dpM9xHwOtjHTCFojQUOBxuejUeh3/CBm8x09cEWvi2f7mFESDyNtNGtpiSp59Mz2BSz+IN7B8MMCmGyF2IL7OalYMbLmhBN8Z0ruTUTH4NNnjfs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.144) by SG2PR06MB1693.apcprd06.prod.outlook.com (10.167.82.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Thu, 30 Mar 2017 02:18:17 +0000 From: Yoshihiro Shimoda To: CC: , , , Yoshihiro Shimoda Subject: [PATCH v3 1/3] usb: gadget: udc: add USB ID signal monitoring Date: Thu, 30 Mar 2017 11:16:04 +0900 Message-ID: <1490840166-18449-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490840166-18449-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1490840166-18449-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0042.apcprd02.prod.outlook.com (10.164.90.180) To SG2PR06MB1693.apcprd06.prod.outlook.com (10.167.82.135) X-MS-Office365-Filtering-Correlation-Id: 9480d54e-96c7-4bce-9c44-08d477130760 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SG2PR06MB1693; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1693; 3:LJGatukWzfGjF9PT7Pqaf7Kjo94ea/Cew2yWSswGnopHa141WeaJtaiqiQO3TEoGHQJeEw1S3M2ZwLzAMdNoGqrlJaI4rYwJtJEH2qpxVFovD12Usi1/zptE+zVZvGAoRN0TAFmyp3NrwrHHRwJeUstvUsPQ4q2kQ/43MmxmFSoZ5NwnfRgsqlYZoLLANqLxId/Lsrvpea8m4dyP9SqstCdduq972/IYb1vaAbjozzLBM9Dm/4zaN4ny/yJgd3PvvZzym6eZfEiCOSY6iN1kJ2dg4cNyi9/wxt2Ka+GPMhUfSRE+GWy6OALtIij5wF+q4u+XCFFpN429tXA98eZXFllanPnnldyTnvoSiLORgc4=; 25:hkNbqk9gua2/K4pTBcCIhyan/ChPb9M75LvLqDDGf+vpxrpXqeQal6bWrxAf7ZSIde9HoL3RV78qHYnwURuZ2mmdAI5H+FzyydlqDecNnsJ+0E5MxH4cxvGcYO4viFCnqt3LktRhKtX5g1/gPQ1UKRMur5GISz2SN6fth+ZU+DG3whdpW5zepImGqL77X0joZ8BdC8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change-Antispam-Report-Test: UriScan:(72170088055959); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(201703131423075)(201702281528075)(201703061421075)(201703061750075)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:SG2PR06MB1693; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1693; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1693; 4:CLaycVhK+S7hyxczB8MlhvXnPRnNiqxLZk5HEUthp5Ix5D4JQrVDdyfCx4MsaYGr650Q5otoSOWQO/XiGhY2eApcT+7Orxk+4gySp3ndttaBMgo8XaI2ci3dTEtcx82aLGmdQXXMJ8dlKZlM9qsEUCs7zgtapzC2QPzb8BYF00PxU3Ekv2Bbe0+JjQ3KwOqoK2AW+6VAxgrQhENzZss7lp3Ta8zLhU5kSnLuDnhD+EmJD8/1N4b8Eww9KGulB6CNJcCRrzTZ4A6RMm9vY7Gfa943nDjn5a6Lw1ZTQnmlqvol0hnd9NDbfSA8Mw6TBv4Ff5ZPgFy3ZaBMwxIl/s7dB3UTM/U2JXk/zoP3mfh+HPEsYy6VsjzadGaZncLacxlAqm7cXS5KV5pWldD/Nm8pHEC8nnCrIA7OJ4NchD/D/QNUyJEst2/aJwdZBzeVEmS0nzrag75UggKCSpW4+dViW4WGS1bMZ+6mR/BgWHOrFuC+NnSHiKy3ZZ+X6p+HQCecyMqshIbietPCDjXcHYSyOM6C+IffBk9oRu6Al8w7eE8enp00Z3C2kyqYVw+RyNf81FH+9yTQRaBjLkiPcWsPgzLtXCcvZh2CB7/YNSs/lo1Uvt9ZrtL3PR08DXMoOiobAgCMF4zWEE8nL4tITvoVFOP6vQk4z9IUrws5Vwfws1FtG6Ie3oUCENsEZ2y1z6BBp8eNXGpKKxltL+PQRXRQINO0VtxtV9pICxaCrRiRrw61aNt6PWADSA31uFLIB7Ku1D04Jal84+nNV0QdVYhWIl1jw0CJTZDrMAaCI2QZ4X9w+/mS2eXve0T5LMuQJo0B X-Forefront-PRVS: 02622CEF0A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39840400002)(39860400002)(39450400003)(39400400002)(39410400002)(39850400002)(6486002)(110136004)(107886003)(38730400002)(5003940100001)(25786009)(6506006)(2906002)(6666003)(36756003)(2950100002)(42882006)(6916009)(33646002)(4326008)(6512007)(5660300001)(3846002)(6116002)(78352004)(76176999)(8676002)(81166006)(7736002)(48376002)(50466002)(50226002)(2351001)(50986999)(305945005)(47776003)(53936002)(54906002)(66066001)(189998001)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1693; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1693; 23:TtoUh6kuqCKKvI4FdI+Q4sE4NCdHektsDxnZBsa2j?= =?us-ascii?Q?6jupzlS+etHNBCfMHigXgaDHk5+mhj2D/4Q0Us8B7xIe/HbH5WdEJ9cmQdcq?= =?us-ascii?Q?YFZ5mZ2UiotUSPKkcKIlNUl3eVLEcCZ++epVoqpOZF69N8kZXus8gXG8C2ER?= =?us-ascii?Q?ZochIbpv0qu9fyQPzDELgGtn8I7JbkuXBqcnLqcOgEUVH7aTdFbV0cE15oZ0?= =?us-ascii?Q?y+10nhz1exrL5muqefiPZCBEE9M4mtKG7FCjNu5USi5BS6xNf4uFilO92bYT?= =?us-ascii?Q?Ve59aAuPsZNI0fnIPk+LYhUffoTaJGuhWedCnEZfAS7kc+Z+ztlO11z9SQzy?= =?us-ascii?Q?Co00hyRA5sdhVZo2fozvu2v70h0KsQXGZj+D5U+F7TQXlvGX4CFZyH6uFS1c?= =?us-ascii?Q?4PnGswzeQCotd2kJB8ayDv4eB409gqCTyKP9J/ZQbC22YW4wqpMhdFHRwqqD?= =?us-ascii?Q?b89l0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GNVH8VHbf1VesEb+53iewJV5qGtjFAehAJatorMHW2EyAN0U= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2017 02:18:17.2469 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1693 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This usb 3.0 peripheral controller has a register (USB_OTG_STA) to monitor the USB ID signal. So, this patch adds the ID signal monitoring to change the mode to host (A-Host) or peripheral (B-Peripheral). This patch also removes hardcoded setting as B-Peripheral mode. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/gadget/udc/renesas_usb3.c | 67 ++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 2218f91..3e96c56 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -37,6 +37,9 @@ #define USB3_USB_INT_ENA_2 0x22c #define USB3_STUP_DAT_0 0x230 #define USB3_STUP_DAT_1 0x234 +#define USB3_USB_OTG_STA 0x268 +#define USB3_USB_OTG_INT_STA 0x26c +#define USB3_USB_OTG_INT_ENA 0x270 #define USB3_P0_MOD 0x280 #define USB3_P0_CON 0x288 #define USB3_P0_STA 0x28c @@ -124,6 +127,9 @@ /* USB_INT_ENA_2 and USB_INT_STA_2 */ #define USB_INT_2_PIPE(n) BIT(n) +/* USB_OTG_STA, USB_OTG_INT_STA and USB_OTG_INT_ENA */ +#define USB_OTG_IDMON BIT(4) + /* P0_MOD */ #define P0_MOD_DIR BIT(6) @@ -362,10 +368,6 @@ static void usb3_init_axi_bridge(struct renesas_usb3 *usb3) static void usb3_init_epc_registers(struct renesas_usb3 *usb3) { - /* FIXME: How to change host / peripheral mode as well? */ - usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); - usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON); - usb3_write(usb3, ~0, USB3_USB_INT_STA_1); usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG); } @@ -538,11 +540,49 @@ static void usb3_check_vbus(struct renesas_usb3 *usb3) } } +static void usb3_set_mode(struct renesas_usb3 *usb3, bool host) +{ + if (host) + usb3_clear_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); + else + usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON); +} + +static void usb3_vbus_out(struct renesas_usb3 *usb3, bool enable) +{ + if (enable) + usb3_set_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON); + else + usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON); +} + +static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev) +{ + usb3_set_mode(usb3, host); + usb3_vbus_out(usb3, a_dev); +} + +static bool usb3_is_a_device(struct renesas_usb3 *usb3) +{ + return !(usb3_read(usb3, USB3_USB_OTG_STA) & USB_OTG_IDMON); +} + +static void usb3_check_id(struct renesas_usb3 *usb3) +{ + if (usb3_is_a_device(usb3)) + usb3_mode_config(usb3, true, true); + else + usb3_mode_config(usb3, false, false); +} + static void renesas_usb3_init_controller(struct renesas_usb3 *usb3) { usb3_init_axi_bridge(usb3); usb3_init_epc_registers(usb3); + usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_STA); + usb3_write(usb3, USB_OTG_IDMON, USB3_USB_OTG_INT_ENA); + usb3_check_id(usb3); usb3_check_vbus(usb3); } @@ -551,6 +591,7 @@ static void renesas_usb3_stop_controller(struct renesas_usb3 *usb3) usb3_disconnect(usb3); usb3_write(usb3, 0, USB3_P0_INT_ENA); usb3_write(usb3, 0, USB3_PN_INT_ENA); + usb3_write(usb3, 0, USB3_USB_OTG_INT_ENA); usb3_write(usb3, 0, USB3_USB_INT_ENA_1); usb3_write(usb3, 0, USB3_USB_INT_ENA_2); usb3_write(usb3, 0, USB3_AXI_INT_ENA); @@ -1474,10 +1515,22 @@ static void usb3_irq_epc_int_2(struct renesas_usb3 *usb3, u32 int_sta_2) } } +static void usb3_irq_idmon_change(struct renesas_usb3 *usb3) +{ + usb3_check_id(usb3); +} + +static void usb3_irq_otg_int(struct renesas_usb3 *usb3, u32 otg_int_sta) +{ + if (otg_int_sta & USB_OTG_IDMON) + usb3_irq_idmon_change(usb3); +} + static void usb3_irq_epc(struct renesas_usb3 *usb3) { u32 int_sta_1 = usb3_read(usb3, USB3_USB_INT_STA_1); u32 int_sta_2 = usb3_read(usb3, USB3_USB_INT_STA_2); + u32 otg_int_sta = usb3_read(usb3, USB3_USB_OTG_INT_STA); int_sta_1 &= usb3_read(usb3, USB3_USB_INT_ENA_1); if (int_sta_1) { @@ -1488,6 +1541,12 @@ static void usb3_irq_epc(struct renesas_usb3 *usb3) int_sta_2 &= usb3_read(usb3, USB3_USB_INT_ENA_2); if (int_sta_2) usb3_irq_epc_int_2(usb3, int_sta_2); + + otg_int_sta &= usb3_read(usb3, USB3_USB_OTG_INT_ENA); + if (otg_int_sta) { + usb3_write(usb3, otg_int_sta, USB3_USB_OTG_INT_STA); + usb3_irq_otg_int(usb3, otg_int_sta); + } } static irqreturn_t renesas_usb3_irq(int irq, void *_usb3)