From patchwork Thu Jan 7 09:18:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7975141 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A04E89F1CC for ; Thu, 7 Jan 2016 09:18:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EBC92014A for ; Thu, 7 Jan 2016 09:18:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 829EA20149 for ; Thu, 7 Jan 2016 09:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910AbcAGJSc (ORCPT ); Thu, 7 Jan 2016 04:18:32 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:30091 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752446AbcAGJSY (ORCPT ); Thu, 7 Jan 2016 04:18:24 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 07 Jan 2016 18:18:22 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id C017161501; Thu, 7 Jan 2016 18:18:22 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id B77942806E; Thu, 7 Jan 2016 18:18:22 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id AF4902806D; Thu, 7 Jan 2016 18:18:22 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id UAB19275; Thu, 7 Jan 2016 18:18:22 +0900 X-IronPort-AV: E=Sophos;i="5.20,532,1444662000"; d="scan'";a="201811457" Received: from mail-pu1apc01lp0016.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.16]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Jan 2016 18:18:21 +0900 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by SG2PR06MB0919.apcprd06.prod.outlook.com (10.162.204.152) with Microsoft SMTP Server (TLS) id 15.1.361.13; Thu, 7 Jan 2016 09:18:19 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH] usb: renesas_usbhs: add R-Car Gen3 power control Date: Thu, 7 Jan 2016 18:18:13 +0900 Message-ID: <1452158293-6332-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0012.apcprd02.prod.outlook.com (25.163.104.150) To SG2PR06MB0919.apcprd06.prod.outlook.com (25.162.204.152) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0919; 2:o4pTd8SLQkB/dkhV+nrkVOevANOkGmuUVcw0cZ5UUwf4m214d9kr43oLfe3+ndn/RsbFGihz7F4IjPr0d2r8r3VlGcolCo5oR0FHkBy7CVhbONwfeZrGW7zUTuOD5oT4uaXN+2pCwvscsbUdobhx1w==; 3:8zVQxWMfqgowSQ5fjAnyp2KxHLmHvZNR+Fd4hs0qA5c6NXC3xmqK7p+2BN/3YwOVhY4QcKAx7RUYsu196b1J7XkYmJtNQ2Zt5A7fjA5BRHuz857WChJqPoj7xAjamgAz; 25:4jqjCx6tUydSYOQnPNMqMUL4Ap2FEnjigM6npr3Vz36ZWw26Mrx/9/IEgKpLgeRUq0Ms/zFu/LPcv7B/EJQLl9GzYiBF3Ak/wkNvYk1wvs4p4TlWgvu6ndHIHMtnBjoxJH8R5gthVIgpZf/IJhy0LyQhzHw8XPMEDqqvo/j2M3AX4N7JT+jrgOLU9MkIJDMes1vSMKkKE74ST9DRM88fylvg+W12wrhJDcJfsUwYBK09SkhGZ5OAQmnZbZH0U6QW X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0919; X-MS-Office365-Filtering-Correlation-Id: 98cd4c32-cd06-4f9c-a1be-08d317437c0e X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0919; 20:4sXapV2wb2MUc1/lk3QdZ5tliue+6F2O4UvruJFO+LQ8v5lOVchgZdfGXW8/U0fXHVuDaYUyMgjV3MuvyDL2H5N84mTRo+DrOGB+NzqoUcGIPc13jNEzz41ic+YizGQMn9iTESkiAsludfNfAANZGetJytWZVyvhzZV6V4hkUSscEWjPkrNsnEOq+J2spjVhfQTmOv/2hgpavp1t8Dp74bqtjxEUslFicS2liYZ/iv6E4BMTK3+0j1ZklOJuqvk1abwqT1V71DuM3nWyzxKI60LiU8ioT5MFek6kyz6GI6STeEH4Ezca+LSUjd+7sgL5vQ8ZL+py1lRu/UQUr3dogXzK1XL0CEltyJuseiRVl9GXYWwGrEIYFm6lF0mFQUqzdJSgiBF5U9QIm86voxBFT7ebKoEp3yP1pmFs4vbniVdYK3ZEf9nRah3ew3SshO1mpQ0S0NUivohd6Z4c46BTWN7SjAl414hUlQzyUT9SeiBjOFhiocRQD7OUwUBdWE3Y; 4:q81086rV7XvHe043lpHL1KpEkdb7zcRIao6hKs5GOTKfgb8wfKtXRhIx4/B1U/sIdi4iWUeh9RQ9c9Ua5qvrIOeIXX1Fjfli9nkkcn02o1GBjDKPqs8sxPpcJpMUgKNLgTj0Jg1AZZqIaD5y0zU4RxCb/qZBEXU8gS0q0/R7u3RMER7N5TzelIv1ie1PHH58gpegID4xh7SD+luGkKFrVyBQBK+alPu/CV5W+6qDDQRy08Opzg9YkeR+SES+WXTVuM8kVbAgURCYE5bKai7wwEq7+5ZHc5tsrgHj/BQoQFzIKD59J+LdLRngWHbCczsQNBFQajqO7XrZnI0k9zsjizTVrqSX6DTr1FcRy9S4ZcE7ktH3ch4/o+8uhIEdAOYet3cHsXb9LyEvekuaKUEw09QrKRu8zkhmbhTLn3 ebhfykagc9D0KXuoLUhcbq9HAX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:SG2PR06MB0919; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0919; X-Forefront-PRVS: 0814A2C7A3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(199003)(189002)(42382002)(5001960100002)(101416001)(105586002)(50986999)(5001770100001)(50466002)(81156007)(97736004)(33646002)(189998001)(6116002)(107886002)(4326007)(4001430100002)(586003)(1096002)(3846002)(36756003)(87976001)(77096005)(229853001)(575784001)(5008740100001)(48376002)(92566002)(19580405001)(78352003)(19580395003)(5004730100002)(66066001)(50226001)(47776003)(42186005)(106356001)(76506005)(122386002)(40100003)(2906002)(5003940100001)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0919; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0919; 23:XvyLtozbI4pJN7X6h2W1KHJWRxnPGOLPWN95Ji40u?= =?us-ascii?Q?BHLK+H3Bg3jNQI5z/fRGundBAOLHNNcdc/oRNa7dchXyegWrDsOF2mgMtpwB?= =?us-ascii?Q?NEeYof9soHDy8i/pXwhZI+f/QXM9t8IU80G+PujsJVLBMI8rJywn5P/sNJPQ?= =?us-ascii?Q?lX928zonxZpgB3lCww1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-ascii?Q?HL9+rCadzXoiMo5//mjC8bB24VRMFHSzctYww/g6xelOirZZnR0cf9GRbdL5?= =?us-ascii?Q?0oKR43+CrEH3fGU3kyTYMu7ROxtAoaNiZf+V/KzpFuWFuEAyND0GeO5DYnPq?= =?us-ascii?Q?aogh8YX9EboRKA=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0919; 5:AvsT5sqmpKnrFqPQYxfd3hJHHC9fsG+0darR51dKAcF0x9pzcgAImFmX0eYB5Ln7XMvxT1AqaSanfAYxzP8QYlqBSIbIvyQ9h6s7jFe7pUu9rnOGJ2yMIT8oEW129CKle/dfr1yF/0C3kGPeYiBw/Q==; 24:xyLrfWPU/5uUtSV990/bjAb3Y+5Qr+8qDu9i7e+IkJbyISg198hBRj8GgyMnLBxJqnQVfBJhJu6B8UDQK/aGpupmiihY40toJeIGqdJXWJ4=; 20:QhfKdq1mitokMuBSxhuquQDr0nraaALsgUrjSmDTkI4JekLyry8mILu+UlGtNzFMuIgI03qMQMU9ADp+KrZ9PmawWcqgtmOyddmf/h7gGj2TaEzG6xfgyvOyLoLJ1JO5Dk94aVqV6UtyAJiv64sDSjWoKPQIeh4DnEDVXfBSWWs= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2016 09:18:19.7203 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0919 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-3.9 required=5.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, 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 Since the usb2 phy driver for gen3 (phy-rcar-gen3-usb2) cannot access LPSTS and UGCTRL2 registers in the HSUSB module, this driver have to initialize the registers. So, this patch adds such handling code into rcar3.c. Signed-off-by: Yoshihiro Shimoda --- This patch is based on the latest Felipe's usb.git / testing/next branch. (commit id = 5072cfc40a80cea3749fd3413b3896630d8c787e) drivers/usb/renesas_usbhs/Makefile | 2 +- drivers/usb/renesas_usbhs/common.c | 14 +++++++--- drivers/usb/renesas_usbhs/rcar3.c | 54 ++++++++++++++++++++++++++++++++++++++ drivers/usb/renesas_usbhs/rcar3.h | 3 +++ include/linux/usb/renesas_usbhs.h | 1 + 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 drivers/usb/renesas_usbhs/rcar3.c create mode 100644 drivers/usb/renesas_usbhs/rcar3.h diff --git a/drivers/usb/renesas_usbhs/Makefile b/drivers/usb/renesas_usbhs/Makefile index 9e47f47..d787d05 100644 --- a/drivers/usb/renesas_usbhs/Makefile +++ b/drivers/usb/renesas_usbhs/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs.o -renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o +renesas_usbhs-y := common.o mod.o pipe.o fifo.o rcar2.o rcar3.o ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),) renesas_usbhs-y += mod_host.o diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 5af9ca5..baeb7d2 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -25,6 +25,7 @@ #include #include "common.h" #include "rcar2.h" +#include "rcar3.h" /* * image of renesas_usbhs @@ -477,18 +478,16 @@ static const struct of_device_id usbhs_of_match[] = { .data = (void *)USBHS_TYPE_RCAR_GEN2, }, { - /* Gen3 is compatible with Gen2 */ .compatible = "renesas,usbhs-r8a7795", - .data = (void *)USBHS_TYPE_RCAR_GEN2, + .data = (void *)USBHS_TYPE_RCAR_GEN3, }, { .compatible = "renesas,rcar-gen2-usbhs", .data = (void *)USBHS_TYPE_RCAR_GEN2, }, { - /* Gen3 is compatible with Gen2 */ .compatible = "renesas,rcar-gen3-usbhs", - .data = (void *)USBHS_TYPE_RCAR_GEN2, + .data = (void *)USBHS_TYPE_RCAR_GEN3, }, { }, }; @@ -578,6 +577,13 @@ static int usbhs_probe(struct platform_device *pdev) priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); } break; + case USBHS_TYPE_RCAR_GEN3: + priv->pfunc = usbhs_rcar3_ops; + if (!priv->dparam.pipe_configs) { + priv->dparam.pipe_configs = usbhsc_new_pipe; + priv->dparam.pipe_size = ARRAY_SIZE(usbhsc_new_pipe); + } + break; default: if (!info->platform_callback.get_id) { dev_err(&pdev->dev, "no platform callbacks"); diff --git a/drivers/usb/renesas_usbhs/rcar3.c b/drivers/usb/renesas_usbhs/rcar3.c new file mode 100644 index 0000000..38b01f2 --- /dev/null +++ b/drivers/usb/renesas_usbhs/rcar3.c @@ -0,0 +1,54 @@ +/* + * Renesas USB driver R-Car Gen. 3 initialization and power control + * + * Copyright (C) 2016 Renesas Electronics Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include "common.h" +#include "rcar3.h" + +#define LPSTS 0x102 +#define UGCTRL2 0x184 /* 32-bit register */ + +/* Low Power Status register (LPSTS) */ +#define LPSTS_SUSPM 0x4000 + +/* USB General control register 2 (UGCTRL2), bit[31:6] should be 0 */ +#define UGCTRL2_RESERVED_3 0x00000001 /* bit[3:0] should be B'0001 */ +#define UGCTRL2_USB0SEL_OTG 0x00000030 + +void usbhs_write32(struct usbhs_priv *priv, u32 reg, u32 data) +{ + iowrite32(data, priv->base + reg); +} + +static int usbhs_rcar3_power_ctrl(struct platform_device *pdev, + void __iomem *base, int enable) +{ + struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + + usbhs_write32(priv, UGCTRL2, UGCTRL2_RESERVED_3 | UGCTRL2_USB0SEL_OTG); + + if (enable) + usbhs_bset(priv, LPSTS, LPSTS_SUSPM, LPSTS_SUSPM); + else + usbhs_bset(priv, LPSTS, LPSTS_SUSPM, 0); + + return 0; +} + +static int usbhs_rcar3_get_id(struct platform_device *pdev) +{ + return USBHS_GADGET; +} + +const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = { + .power_ctrl = usbhs_rcar3_power_ctrl, + .get_id = usbhs_rcar3_get_id, +}; diff --git a/drivers/usb/renesas_usbhs/rcar3.h b/drivers/usb/renesas_usbhs/rcar3.h new file mode 100644 index 0000000..5f850b2 --- /dev/null +++ b/drivers/usb/renesas_usbhs/rcar3.h @@ -0,0 +1,3 @@ +#include "common.h" + +extern const struct renesas_usbhs_platform_callback usbhs_rcar3_ops; diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 4db191f..00a47d0 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h @@ -184,6 +184,7 @@ struct renesas_usbhs_driver_param { }; #define USBHS_TYPE_RCAR_GEN2 1 +#define USBHS_TYPE_RCAR_GEN3 2 /* * option: