From patchwork Mon Oct 5 12:06:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 7327001 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 AE80A9F2F7 for ; Mon, 5 Oct 2015 12:07:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFF8820680 for ; Mon, 5 Oct 2015 12:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B3BD20675 for ; Mon, 5 Oct 2015 12:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbbJEMG7 (ORCPT ); Mon, 5 Oct 2015 08:06:59 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:12969 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751054AbbJEMG6 (ORCPT ); Mon, 5 Oct 2015 08:06:58 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 05 Oct 2015 21:06:57 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 45BC54D92D; Mon, 5 Oct 2015 21:06:57 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 4711C8002E; Mon, 5 Oct 2015 21:06:57 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 423E68002D; Mon, 5 Oct 2015 21:06:57 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id XAM29165; Mon, 5 Oct 2015 21:06:57 +0900 X-IronPort-AV: E=Sophos;i="5.17,638,1437404400"; d="scan'208";a="195770781" Received: from mail-hk2apc01lp0214.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.214]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 05 Oct 2015 21:06:56 +0900 Received: from SG2PR06MB0919.apcprd06.prod.outlook.com (10.162.204.152) by SG2PR06MB1087.apcprd06.prod.outlook.com (10.169.58.21) with Microsoft SMTP Server (TLS) id 15.1.286.20; Mon, 5 Oct 2015 12:06:55 +0000 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.280.20; Mon, 5 Oct 2015 12:06:53 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda Subject: [PATCH 3/4] usb: host: xhci-rcar: Change code for new SoCs Date: Mon, 5 Oct 2015 21:06:29 +0900 Message-ID: <1444046790-5804-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1444046790-5804-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1444046790-5804-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0018.apcprd02.prod.outlook.com (25.164.90.156) To SG2PR06MB0919.apcprd06.prod.outlook.com (25.162.204.152) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0919; 2:RD1DK1509AA4B1d1dXhwAuNPBR7I3n2j1tD76eiRaG9TRr24wNbIMeFfLqYhUGL27VKWCV05WohoYDiW+H4M+1/vwEh3lyZgnirzpFZUwuvS3T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8Zk0yt3Ron2lBeuLDWJsExKaNOM; 4:ZwCfIAG1nrt+95ihwqvLbMKfAJndvSSwuK+kZ6W/n0Aeie5S7b47ppQ+9Fdx7ejiERdqJz1xmdJDa87kmjZYj7YzNfzGoKmfavRAlycgdVzGDqL+KhZcUKgLkgJnm7eDgkxhTmWpRgNn6obFPIyJi89ojKFQyEVJlYccZ6uKohbl3gitC1iGLrQVDnJu2nIndFkowgrQm+irYecl+2cIqC+aE8E84snVY5x2HItOjpB3vWQOISi+hsUt6GD7tizBBKBqKbgPC+ZQg4IYWgK2X1DnV+RpRISrcT7hZecdi0/0yo74cNANsgCuYiSl1PxPfTTjYw3dHroxROd2EFp+nNyRoHAjN2VbYM0DJ4p3BOA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001); SRVR:SG2PR06MB0919; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0919; X-Forefront-PRVS: 07200C0526 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6029001)(6069001)(6009001)(199003)(189002)(40100003)(81156007)(105586002)(87976001)(78352002)(2950100001)(5001860100001)(50226001)(42186005)(107886002)(19580405001)(189998001)(122386002)(5007970100001)(97736004)(5004730100002)(5001770100001)(76506005)(48376002)(77156002)(50986999)(42382002)(46102003)(36756003)(92566002)(101416001)(5001960100002)(106356001)(50466002)(19580395003)(5003940100001)(4001540100001)(68736005)(33646002)(5001830100001)(47776003)(76176999)(64706001)(77096005)(5008740100001)(66066001)(62966003)(229853001)(4001430100001); 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:UfxHosUNEbgoT89qkfDtU+kF3uwbP1CtyHcvjCOW2?= =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+8kK36/2Sut4Cs+FtIAvkt6qcWEE3d/5?= =?us-ascii?Q?8sIcUL1kw/05hXDyJLW5C9wcBnt/aXVnsYX7DF0GLI72McIhK8B2Oqwciniv?= =?us-ascii?Q?LlZgJ/Rtcr3X0Y7VhFrmjPePiMG2rRExQfHeHMC6dJ1xogil6IfqyEVh/4Xc?= =?us-ascii?Q?/2Wy8qu5vCZQdhe18THCgt7tpVDIhkx2AZPc+wCBWyaj0R1P888maV1ZPuJD?= =?us-ascii?Q?ogfqM0sBYc71/MIJVarj3765nR9jmJy73MKTKgETMOFhhiGZXSgUCFNYWzR4?= =?us-ascii?Q?0c0qyMIJXgFu3JcsP6gkoXUyhBoZItF2w7aU0LMhdl7HSz91zbc0lgj1CnwJ?= =?us-ascii?Q?nBGSwJdysgh2wwsKrdQw4suXtHPl0zigDu1FnjXMHZjzcyfjbZHk9A9Axhp0?= =?us-ascii?Q?0pP+Eb+Z5r3eTDD/p3v17he6peb2YdvQP8cKQLBR3Yp?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0919; 5:Pulek+Sa5+hwz+pt9pXBAfltXlA9/SHkqv71xjFlmETv8vFrhnIVb9SfxkyaNChPKdLTd/6gIrKzn+JgWEdvCxuWq65lRKbxGWWkKkd/RTpkF+dF1bPgKlW1t6MYef9rhWukgFsJ0YFU6xHXpi2WLA==; 24:EANydwyTYMryRqhWWd03S07rAVb1qjcjp/p93mwl4Pr6XSlCoQRLE2dV6PTJlpxgOXSNqFlx0AgmVmQmx3kJzSorgkYLKWEKl5hJy10v0io=; 20:iqOlWZIA2NcJw2/+bDax9YVs5KCH3ZHvKpcyfHQuCui5OW6zRaYml4GhkijU8EA1IDZ2taM/6STHZoB9vpYmUZaPywKAPMVOmOJFeq4yP/xqTJHKZAaJN+s0n0gLGJkTsMNBhtaDSmmFjfwmqf9ZYaivtwpLmn1CJXIsbjWDBCU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2015 12:06:53.4856 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0919 X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1087; 2:SuIIC4NK4ynSW/mITMTCTYXmU79HEK3GT4qSEW/9AjgWWAMxAQAZ4rixFNAi+iG989jt7iuMLdU9uIBJp2lAmbCWEun3J5HdeEsNWTbDj2KoCVwSmeuLJ/JJaEsaPcpgHjoSdg1sTg3O/SkpV1IYTmoMDmZmCD/n90RuXJOMJhQ=; 23:pLVVK1Q/wTFLbtIyAPIGOYN6PpOeptl739DnYsmgdERqaXljbj2Wyvh/WBEuCxV6CyFAiRIspN0bUKiig22BE+w6emHFR9oqAjyK+tS8vilUxXL5ROCahq/7NMGUmGJTufcj6rZUjacym2xSlfsqyNMjX+ANNaJnRa/zN00aNjNjiH+6inO8H4geE4i0Zfun 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=-4.2 required=5.0 tests=AXB_X_OUTLOOKPROT_ENVSDR, BAYES_00, RCVD_IN_DNSWL_HI, T_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 changes code to ease the addition of next generation SoCs. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/host/xhci-rcar.c | 51 +++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index b4b110e..acfa03a 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -17,8 +17,8 @@ #include "xhci.h" #include "xhci-rcar.h" -#define FIRMWARE_NAME "r8a779x_usb3_v1.dlmem" -MODULE_FIRMWARE(FIRMWARE_NAME); +#define FIRMWARE_NAME_V1 "r8a779x_usb3_v1.dlmem" +MODULE_FIRMWARE(FIRMWARE_NAME_V1); /*** Register Offset ***/ #define RCAR_USB3_INT_ENA 0x224 /* Interrupt Enable */ @@ -57,7 +57,7 @@ MODULE_FIRMWARE(FIRMWARE_NAME); #define RCAR_USB3_RX_POL_VAL BIT(21) #define RCAR_USB3_TX_POL_VAL BIT(4) -bool xhci_rcar_is_compatible(struct usb_hcd *hcd) +static bool xhci_rcar_is_compatible_with_gen2(struct usb_hcd *hcd) { struct device_node *of_node = hcd->self.controller->of_node; @@ -69,6 +69,27 @@ bool xhci_rcar_is_compatible(struct usb_hcd *hcd) return false; } +bool xhci_rcar_is_compatible(struct usb_hcd *hcd) +{ + if (xhci_rcar_is_compatible_with_gen2(hcd)) + return true; + + return false; +} + +static void xhci_rcar_start_gen2(struct usb_hcd *hcd) +{ + /* LCLK Select */ + writel(RCAR_USB3_LCLK_ENA_VAL, hcd->regs + RCAR_USB3_LCLK); + /* USB3.0 Configuration */ + writel(RCAR_USB3_CONF1_VAL, hcd->regs + RCAR_USB3_CONF1); + writel(RCAR_USB3_CONF2_VAL, hcd->regs + RCAR_USB3_CONF2); + writel(RCAR_USB3_CONF3_VAL, hcd->regs + RCAR_USB3_CONF3); + /* USB3.0 Polarity */ + writel(RCAR_USB3_RX_POL_VAL, hcd->regs + RCAR_USB3_RX_POL); + writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL); +} + void xhci_rcar_start(struct usb_hcd *hcd) { u32 temp; @@ -78,19 +99,13 @@ void xhci_rcar_start(struct usb_hcd *hcd) temp = readl(hcd->regs + RCAR_USB3_INT_ENA); temp |= RCAR_USB3_INT_ENA_VAL; writel(temp, hcd->regs + RCAR_USB3_INT_ENA); - /* LCLK Select */ - writel(RCAR_USB3_LCLK_ENA_VAL, hcd->regs + RCAR_USB3_LCLK); - /* USB3.0 Configuration */ - writel(RCAR_USB3_CONF1_VAL, hcd->regs + RCAR_USB3_CONF1); - writel(RCAR_USB3_CONF2_VAL, hcd->regs + RCAR_USB3_CONF2); - writel(RCAR_USB3_CONF3_VAL, hcd->regs + RCAR_USB3_CONF3); - /* USB3.0 Polarity */ - writel(RCAR_USB3_RX_POL_VAL, hcd->regs + RCAR_USB3_RX_POL); - writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL); + if (xhci_rcar_is_compatible_with_gen2(hcd)) + xhci_rcar_start_gen2(hcd); } } -static int xhci_rcar_download_firmware(struct device *dev, void __iomem *regs) +static int xhci_rcar_download_firmware(struct device *dev, void __iomem *regs, + const char *firmware_name) { const struct firmware *fw; int retval, index, j, time; @@ -98,7 +113,7 @@ static int xhci_rcar_download_firmware(struct device *dev, void __iomem *regs) u32 data, val, temp; /* request R-Car USB3.0 firmware */ - retval = request_firmware(&fw, FIRMWARE_NAME, dev); + retval = request_firmware(&fw, firmware_name, dev); if (retval) return retval; @@ -153,9 +168,15 @@ static int xhci_rcar_download_firmware(struct device *dev, void __iomem *regs) /* This function needs to initialize a "phy" of usb before */ int xhci_rcar_init_quirk(struct usb_hcd *hcd) { + const char *firmware_name = NULL; + /* If hcd->regs is NULL, we don't just call the following function */ if (!hcd->regs) return 0; - return xhci_rcar_download_firmware(hcd->self.controller, hcd->regs); + if (xhci_rcar_is_compatible_with_gen2(hcd)) + firmware_name = FIRMWARE_NAME_V1; + + return xhci_rcar_download_firmware(hcd->self.controller, hcd->regs, + firmware_name); }