From patchwork Wed May 24 12:17:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9745929 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 CED396032B for ; Wed, 24 May 2017 12:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFA1128968 for ; Wed, 24 May 2017 12:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4B0528975; Wed, 24 May 2017 12:23:03 +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=unavailable 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 B63F428974 for ; Wed, 24 May 2017 12:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762350AbdEXMUq (ORCPT ); Wed, 24 May 2017 08:20:46 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:57567 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759630AbdEXMUB (ORCPT ); Wed, 24 May 2017 08:20:01 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 24 May 2017 21:19:59 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id A8CDC72766; Wed, 24 May 2017 21:19:59 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.38,386,1491231600"; d="scan'208";a="244996779" Received: from mail-hk2apc01lp0214.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.214]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 24 May 2017 21:19:58 +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=3oeafk0nglcZV6woi9GH0B1X4uM3tfL6EoQVjWM400I=; b=lCUWjzWTKt9lT8ZPvA4csvTTzciRXs1lfv7Yp/9RXCMOA5B4y/dHnB0xfdT4v89ESGnCodwyK0hAXgmipQpG005TJ7SZEz5aoQYXBzYRd0VOZDFNsZB75afANSI+TfZxhLzT78AaZzxU9jOOY38RX3O97VRJYmUJT/dvZBNdACw= Authentication-Results: ti.com; dkim=none (message not signed) header.d=none; ti.com; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.144) by SG2PR06MB0983.apcprd06.prod.outlook.com (2a01:111:e400:5213::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Wed, 24 May 2017 12:19:55 +0000 From: Yoshihiro Shimoda To: , , CC: , , , Yoshihiro Shimoda Subject: [PATCH v2] phy: rcar-gen3-usb3: add support for R-Car Gen3 USB 3.0 PHY Date: Wed, 24 May 2017 21:17:24 +0900 Message-ID: <1495628244-28406-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR02CA0003.apcprd02.prod.outlook.com (2a01:111:e400:a429::13) To SG2PR06MB0983.apcprd06.prod.outlook.com (2a01:111:e400:5213::25) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PR06MB0983: X-MS-Office365-Filtering-Correlation-Id: 48b59157-f641-4002-3708-08d4a29f3082 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SG2PR06MB0983; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 3:db0uj2MijOjrPu67hrutwRYlSrgL08VGybyUVBA35Z8Z6Uo7BhiMaIbVPVFTAfRkVRlcsP9WaJwjJy0kOxXEx+3j3bqzSH/sZwjRfAQNFzJ76FD/ZbTisTiSg19WNegilMJx34h+SqtLF8ndVUKON36JERFv292+vuutjsHOwiMnFsRjGT3BdvDUo68SvulKmO579CkZVEUAKvtsaypXqirXFyXbcyx/y1ggnDWwbf5rKLI3tqc1DDq/Qk8QyAbx1/zDwjII9VbDhRG+jfFur3Eb7naYFlEtPHtDGDzuzDvZ93ctykm/4UESTmmswiEC5RzywqKiXSJf+JsAASU75jMwkrrt04uLs5DiOenxQCo=; 25:MRidLjs9eMtfyXxJ8Spty4udMIVdgjFUDgQf5pBATc1lISiAK3huoe6I5OjpcPdM9JOlFJeuuAQoXZmDRuhS+C7PZ43iIALZl9xFpkXiWkd0btCw+X3lCNihdASsz0NldOuEHoHUq2Mi6Od0xJA0ZNx1M4oIE+JKAtiUwOuKtMIyupiVzTBYD8wXhSm4pYeVs8wY1LOPN7P1zWF7opL9EgzwCAkX1VL3IOIHdyeGcmYsG43uSU9xgssk2D3smkKsFQ5WpC4PELV28lakQgaNCBf7momUPcwRvauqDydd1Q7ao1RSE1ZFrKZH41ULZ70uwLc9TPJsoUn/5L+Cu/rOI+S018+Q33Lpbu4uxwsMDT/ONXJqntb2ivzdNK6ahoCtU6KEEjWibB7He2O9F/FV544YGhleH+zWsHYSyuzXdVZeuo+iQiUDORuVhXL+B3W7zMhDcQ5OotSEkzVsjdYt7R1oP+/bOoDB0VkZ+HbXoHo= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 31:j5XONR4fb/mAfr+QdEan5vYuKNk/bQJtX0b+uwNbRLjEt098I+pOWrLgGCEgv8+OGl0MqqCBPZqaCxzB2DcWwRfPM90VmSZSA4ozxmMQWAZEEoQDfveg4EAmXSOCNsKEn4GugDFE7rPDk79Z5gI80vT5F8ZsEKJqnUm0BfmNLZVt3uixFXgLWs01mTe49yNY44Lz8mbpDmS+lksaRuISld/nXWRUoWGZ5bcWwFlqUq29238tV+DlDRbFj/Hu3bBy4r9vb5F2oM+C2S1F4WFBqw==; 20:nx/k4taYSDhj26magY4mxYHuDp7lw2LeDoeNeptI/ig6fPUbTVKlrnJDJCTeqZcmQR0xSuuGIrE0qJBwc9ae5O3rTkjtT+pDzJbnz+QbW6hqSmfAN9J7pfe2CETg2pDeMWLIAitDMKTLzUI8WwHCbqJ2EwgargtGvZySQoMbN4u/FTRH0mllap909uyczjsjh/gPFCJyS0Y7dOesfsDAfl56dRs9KqYGvOqnYC7jrhxMlL0Owdtf4BVy5GIlmxkJKm4fRXeaFkcTFILsUOzHcwy3Q5S7SuE3aBXRuGUhfktpuWfAXiGr3f2hhcjTxercLMGgTfF2H0MnEWaSLffIxI7WW0zR+RSwNdtl7kryPczeoP2ZjgcIvUMckX/M8A8MSNnw5ZKIleEgpLPyn/cgGZQhaTvA8dwFzVUOinoJy7srbQ01T92RJdfr/lMhbxhs5gk2/5cvvlCB23l42kVwAAczn2DqIx/KcJ1ccIJ9/HchbwqFhPmvz+W1pi7uPmaQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700054)(100105000095)(100000701054)(100105300095)(100000702054)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(100000703054)(100105400095)(93006095)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061750153)(20161123562025)(20161123558100)(6072148)(100000704054)(100105200095)(100000705054)(100105500095); SRVR:SG2PR06MB0983; BCL:0; PCL:0; RULEID:(100000800054)(100110000095)(100000801054)(100110300095)(100000802054)(100110100095)(100000803054)(100110400095)(100000804054)(100110200095)(100000805047)(100110500095); SRVR:SG2PR06MB0983; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0983; 4:dRTCqnQlG81m0XJqy1+mbh4M+f4q3WUNB08XHtIZ9W?= =?us-ascii?Q?wyGPF+z93pS0669nFpDV9Qbsb2kGvIGJd4x4l6tLVA7QEEv6EvhIRwVTevgV?= =?us-ascii?Q?WexA7xPmGCy1eH6KkKKi0wlEejWX4ZIM3YiH1NHGYTNU8TqLyV5RRjMsk2wz?= =?us-ascii?Q?+dd/mp1qUyMHwnPsfQj6/eoaeadr4uM0HTXTHd1DhEV7MLKh+Cw2dKArHIhZ?= =?us-ascii?Q?aMSE66wLMQ+f8ckr6+tlYpBAkA78+dlHdWxM7k+QY4cxp5ieDFVLhy4kljXQ?= =?us-ascii?Q?8P+4+fu2vLh3UZxT88VWHBby/oR0yt2m4AC9FLdVeZRz9sfFCRt+35SM7lia?= =?us-ascii?Q?fScowwJKd5ZfVGY2ucGTDyLtDRA/7JAWDtKlWBq3ABWOzPm7NTXAAmzSNe6C?= =?us-ascii?Q?Hwe6Bf9IjjerU4g1qgrwSpmwtCR0Kq82kXNsDl66raX4HZnvlqKtzVjAQAqW?= =?us-ascii?Q?1PZPdl7Vip77YakXlARsiKcearvk51JYkWFxMaRi0lcCT3gDkhl1Xq34cBNW?= =?us-ascii?Q?lCaqMdQmTynX09vDljR03wUpuUqLI0x+q//5gy+qfGO3aAZ5Uc8aUxpE2//X?= =?us-ascii?Q?PS08Kl0yYYTSnY828ZMbt1krLX3FopojNL3y7z9pbzzlk82ljmwnlpX9mjmy?= =?us-ascii?Q?y87SIhUaOiigUbqUJgTHiW9t5gKnqsAAavWNwuwIt0vdjdJYSaDhMYkgARWn?= =?us-ascii?Q?wBk3rmITzTwQ+woSpryOgwicWMwzSV6GABPEKErmApJsJs2vJVy014zzFcqy?= =?us-ascii?Q?ct4+bukOdF2AnUOfCqFsglBgvVFj3F3c4AlIOIu0Goqe6mWdAhScZ3XSSEda?= =?us-ascii?Q?6i1QoIV6jJxi1tokjYqQa3PiuUqCsA5USHPLaATkFMGtXTO8CNnrzWwyIIsG?= =?us-ascii?Q?KE5+fIvQcSZ7RdR9SkflMd7BroDBSjwvQzF4PQp9RgOvMmg39R6CddWi+p9M?= =?us-ascii?Q?YYR/8bCXFOHK7KZkRhqs3yzMpNnNE4FLyzSkNpOcfMKDTMbXfIMH3unsM8Gc?= =?us-ascii?Q?wq3HAKjSX+RAGjLl5NHP/0J2SPeQIpyW5gu7PhyJ917C28bsIvbed/OqJ9tq?= =?us-ascii?Q?uy463zmgFDB9EHgxlRuBmlZFXHOV8PPpNp9e4ctstKg7Lwpx5xahF5B09p3x?= =?us-ascii?Q?kxLEG127B1n3l6o90mpWK1yGihnd5dfsN9oxE1WQ7Yyg3M72gJ4SyHwywbd9?= =?us-ascii?Q?ZUKHjqGMUVcpI=3D?= X-Forefront-PRVS: 031763BCAF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39850400002)(39860400002)(39450400003)(39410400002)(39400400002)(39840400002)(2906002)(50986999)(81166006)(6666003)(42186005)(42882006)(4326008)(8676002)(25786009)(48376002)(189998001)(50466002)(5660300001)(498600001)(966005)(78352004)(230783001)(305945005)(33646002)(47776003)(66066001)(5003940100001)(7736002)(53936002)(3846002)(107886003)(54906002)(50226002)(36756003)(6512007)(6306002)(38730400002)(6506006)(6486002)(6116002)(2004002)(309714004); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0983; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0983; 23:BDAJrXsP4iz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KmCmdDC5?= =?us-ascii?Q?AsAv1KA2Ly0usa54NYf8J971l2+5PCOmU+sxPvcXmAmK3adxQo8d/5Vu2x99?= =?us-ascii?Q?XGxezijlfPWYEa9omekK2aCrKr3u474jPW64W8/VEiBujprqn61NQDU3sFs0?= =?us-ascii?Q?hmrUSurNp8omVUWaP3N89RNMjbexHxUCGdZbcZyAk13untlP5tBbHT1GiE4D?= =?us-ascii?Q?AiMz/QIk6mbb2+1bLqPD6iCKLgwj7T4UTonyofJDJVYnI1QfCtEzIKu7RFsd?= =?us-ascii?Q?xj5qsj7e1hiVWzhYogtPrgARayScWMR?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 6:yZytcLQHWeZ1VmFBg5bUUhQUjATigl1uSwv72ukjOZNSIwjkyK6FUq9bH8JMqyPcwO64p7sNC2UXi7k/7299XO3fInn9tpIXwGXPx1oQRfmGIPD56HpbjPJ3TsbYQ0HLflL1bx0bxFmgs7q0fKp5DTP6q3sStg4lUVzF1FULEyqaIS9VclP2V05z9XEwRCyMfUJGa35qfEgqM89K6kN384rNu5noAkUz0Fg4yMljM5u3FggWMsL8qx0HQ+98bgS67q9hi0NOCt4OoncworR8WcNZ4sR4AuGlGoTwCtyNK95YMRq67b4PIvmIwquR33zbIUQyMjtlit2047IccK7ZXBuroLQrRW+6S2tED6VXEbjDfzt9bsKaPU+U/BqEMjcnrR7XbWOwu47yVndWdu1Ay4n91YjnTbiJ39udTIzvlHpbRYLv5OnuPNQGbjKXV3EzA0YYQPacsjD8iJlLyhessC+0r9P+yy0h1tQiARdEofokD/RJFagw6rNamEvelVyysKG3SSlUnvEtUUNNv3p3CHthZYtCd/NT+W3lDD2ppgI= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0983; 5:d1O73dEQz5ay6QYFRJYLQbkqfR9LHXpqhwElm7NJs8kxQ//80bKkWGb2DuV2gfX09SaDTpP/wB8wBWC6GeffUxCU3EIHTLD04EewZDyIYG/cg1i5ZH0YBXzAqQaI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ogtTmG31wD7V2wFcKgk0H5jFgxWM1Dj+Q= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2017 12:19:55.4034 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0983 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 The USB 3.0 PHY modules of R-Car Gen3 SoCs have: - Spread spectrum clock (ssc). - Using USB 2.0 EXTAL clock instead of USB 3.0 clock. - Enabling VBUS detection for usb3.0 peripheral. So, this driver supports these features. Signed-off-by: Yoshihiro Shimoda --- This patch is based on the latest linux-phy.git / next branch and "[PATCH v5 3/3] phy: Group vendor specific phy drivers" patch. I discussed with Geert-san about this driver on the ML: https://patchwork.kernel.org/patch/9731759/ Changes from v1: - Changes from dev_info to dev_vdbg in rcar_gen3_phy_usb3_init(). .../devicetree/bindings/phy/rcar-gen3-phy-usb3.txt | 47 +++++ MAINTAINERS | 4 +- drivers/phy/renesas/Kconfig | 7 + drivers/phy/renesas/Makefile | 1 + drivers/phy/renesas/phy-rcar-gen3-usb3.c | 207 +++++++++++++++++++++ 5 files changed, 264 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb3.txt create mode 100644 drivers/phy/renesas/phy-rcar-gen3-usb3.c diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb3.txt b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb3.txt new file mode 100644 index 0000000..e58ba6b --- /dev/null +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb3.txt @@ -0,0 +1,47 @@ +* Renesas R-Car generation 3 USB 3.0 PHY + +This file provides information on what the device node for the R-Car generation +3 USB 3.0 PHY contains. +If you want to enable spread spectrum clock (ssc), you should use USB_EXTAL +instead of USB3_CLK. However, if you don't want to these features, you don't +need this driver. + +Required properties: +- compatible: "renesas,r8a7795-usb3-phy" if the device is a part of an R8A7795 + SoC. + "renesas,r8a7796-usb3-phy" if the device is a part of an R8A7796 + SoC. + "renesas,rcar-gen3-usb3-phy" for a generic R-Car Gen3 compatible + device. + + When compatible with the generic version, nodes must list the + SoC-specific version corresponding to the platform first + followed by the generic version. + +- reg: offset and length of the USB 3.0 PHY register block. +- clocks: A list of phandles and clock-specifier pairs. +- clock-names: Name of the clocks. + - The funcional clock must be "usb3-if". + - The usb3's external clock must be "usb3s_clk". If you want to use the ssc, + the clock-frequency must be 0. + - The usb2's external clock must be "usb_extal". If you want to use the ssc, + the clock-frequenvy must not be 0. +- #phy-cells: see phy-bindings.txt in the same directory, must be <0>. + +Optional properties: +- renesas,ssc-range: Enable/disable spread spectrum clock (ssc) by using + the following values as u32: + - 0 (or the property doesn't exist): disable the ssc + - 4980: enable the ssc as -4980 ppm + - 4492: enable the ssc as -4492 ppm + - 4003: enable the ssc as -4003 ppm + +Example (R-Car H3): + + usb-phy@e65ee000 { + compatible = "renesas,r8a7795-usb3-phy", + "renesas,rcar-gen3-usb3-phy"; + reg = <0 0xe65ee000 0 0x90>; + clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>, <&usb_extal>; + clock-names = "usb3-if", "usb3s_clk", "usb_extal"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index a47d3da..d711d53 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10829,11 +10829,11 @@ L: linux-iio@vger.kernel.org S: Supported F: drivers/iio/adc/rcar_gyro_adc.c -RENESAS USB2 PHY DRIVER +RENESAS USB PHY DRIVER M: Yoshihiro Shimoda L: linux-renesas-soc@vger.kernel.org S: Maintained -F: drivers/phy/renesas/phy-rcar-gen3-usb2.c +F: drivers/phy/renesas/phy-rcar-gen3-usb*.c RESET CONTROLLER FRAMEWORK M: Philipp Zabel diff --git a/drivers/phy/renesas/Kconfig b/drivers/phy/renesas/Kconfig index 432e271..4377064 100644 --- a/drivers/phy/renesas/Kconfig +++ b/drivers/phy/renesas/Kconfig @@ -15,3 +15,10 @@ config PHY_RCAR_GEN3_USB2 select GENERIC_PHY help Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs. + +config PHY_RCAR_GEN3_USB3 + tristate "Renesas R-Car generation 3 USB 3.0 PHY driver" + depends on ARCH_RENESAS + select GENERIC_PHY + help + Support for USB 3.0 PHY found on Renesas R-Car generation 3 SoCs. diff --git a/drivers/phy/renesas/Makefile b/drivers/phy/renesas/Makefile index 695241a..8b60259 100644 --- a/drivers/phy/renesas/Makefile +++ b/drivers/phy/renesas/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o obj-$(CONFIG_PHY_RCAR_GEN3_USB2) += phy-rcar-gen3-usb2.o +obj-$(CONFIG_PHY_RCAR_GEN3_USB3) += phy-rcar-gen3-usb3.o diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb3.c b/drivers/phy/renesas/phy-rcar-gen3-usb3.c new file mode 100644 index 0000000..dcc40ad --- /dev/null +++ b/drivers/phy/renesas/phy-rcar-gen3-usb3.c @@ -0,0 +1,207 @@ +/* + * Renesas R-Car Gen3 for USB3.0 PHY driver + * + * Copyright (C) 2017 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 +#include +#include +#include +#include +#include + +#define USB30_CLKSET0 0x034 +#define USB30_CLKSET1 0x036 +#define USB30_SSC_SET 0x038 +#define USB30_VBUS_EN 0x064 + +#define CLKSET0_RESERVED 0x05c0 +#define CLKSET0_USB_EXTAL (CLKSET0_RESERVED | 0x0002) + +#define CLKSET1_PLL_MULTI_SHIFT 6 +#define CLKSET1_PLL_MULTI_USB_EXTAL (0x64 << CLKSET1_PLL_MULTI_SHIFT) +#define CLKSET1_REF_CLKDIV_USB_EXTAL BIT(3) +#define CLKSET1_RESERVED_1 BIT(1) +#define CLKSET1_REF_CLK_SEL_USB_EXTAL 0 +#define CLKSET1_USB_EXTAL (CLKSET1_PLL_MULTI_USB_EXTAL | \ + CLKSET1_REF_CLKDIV_USB_EXTAL | \ + CLKSET1_RESERVED_1 | \ + CLKSET1_REF_CLK_SEL_USB_EXTAL) + +#define SSC_SET_SSC_EN BIT(12) +#define SSC_SET_RANGE_SHIFT 9 +#define SSC_SET_RANGE_4980 (0x0 << SSC_SET_RANGE_SHIFT) +#define SSC_SET_RANGE_4492 (0x1 << SSC_SET_RANGE_SHIFT) +#define SSC_SET_RANGE_4003 (0x2 << SSC_SET_RANGE_SHIFT) + +#define VBUS_EN_VBUS_EN BIT(1) + +struct rcar_gen3_usb3 { + void __iomem *base; + struct phy *phy; + u32 ssc_range; + bool usb3s_clk; + bool usb_extal; +}; + +static void rcar_gen3_phy_usb3_enable_ssc(struct rcar_gen3_usb3 *r) +{ + u16 val = SSC_SET_SSC_EN; + + switch (r->ssc_range) { + case 4980: + val |= SSC_SET_RANGE_4980; + break; + case 4492: + val |= SSC_SET_RANGE_4492; + break; + case 4003: + val |= SSC_SET_RANGE_4003; + break; + default: + dev_err(&r->phy->dev, "%s: unsupported range (%x)\n", __func__, + r->ssc_range); + return; + } + + writew(val, r->base + USB30_SSC_SET); +} + +static void rcar_gen3_phy_usb3_select_usb_extal(struct rcar_gen3_usb3 *r) +{ + writew(CLKSET0_USB_EXTAL, r->base + USB30_CLKSET0); + writew(CLKSET1_USB_EXTAL, r->base + USB30_CLKSET1); +} + +static int rcar_gen3_phy_usb3_init(struct phy *p) +{ + struct rcar_gen3_usb3 *r = phy_get_drvdata(p); + + dev_vdbg(&r->phy->dev, "%s: enter (%d, %d, %d)\n", __func__, + r->usb3s_clk, r->usb_extal, r->ssc_range); + + if (!r->usb3s_clk && r->usb_extal) { + rcar_gen3_phy_usb3_select_usb_extal(r); + /* SSC can be enabled when usb_extal is used */ + if (r->ssc_range) + rcar_gen3_phy_usb3_enable_ssc(r); + } + + /* Enables VBUS detection anyway */ + writew(VBUS_EN_VBUS_EN, r->base + USB30_VBUS_EN); + + return 0; +} + +static const struct phy_ops rcar_gen3_phy_usb3_ops = { + .init = rcar_gen3_phy_usb3_init, + .owner = THIS_MODULE, +}; + +static const struct of_device_id rcar_gen3_phy_usb3_match_table[] = { + { .compatible = "renesas,r8a7795-usb3-phy" }, + { .compatible = "renesas,r8a7796-usb3-phy" }, + { .compatible = "renesas,rcar-gen3-usb3-phy" }, + { } +}; +MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb3_match_table); + +static int rcar_gen3_phy_usb3_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rcar_gen3_usb3 *r; + struct phy_provider *provider; + struct resource *res; + int ret = 0; + struct clk *clk; + + if (!dev->of_node) { + dev_err(dev, "This driver needs device tree\n"); + return -EINVAL; + } + + r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL); + if (!r) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + r->base = devm_ioremap_resource(dev, res); + if (IS_ERR(r->base)) + return PTR_ERR(r->base); + + clk = devm_clk_get(dev, "usb3s_clk"); + if (!IS_ERR(clk) && !clk_prepare_enable(clk)) { + r->usb3s_clk = !!clk_get_rate(clk); + clk_disable_unprepare(clk); + } + clk = devm_clk_get(dev, "usb_extal"); + if (!IS_ERR(clk) && !clk_prepare_enable(clk)) { + r->usb_extal = !!clk_get_rate(clk); + clk_disable_unprepare(clk); + } + + if (!r->usb3s_clk && !r->usb_extal) { + dev_err(dev, "This driver needs usb3s_clk and/or usb_extal\n"); + ret = -EINVAL; + goto error; + } + + /* + * devm_phy_create() will call pm_runtime_enable(&phy->dev); + * And then, phy-core will manage runtime pm for this device. + */ + pm_runtime_enable(dev); + + r->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb3_ops); + if (IS_ERR(r->phy)) { + dev_err(dev, "Failed to create USB3 PHY\n"); + ret = PTR_ERR(r->phy); + goto error; + } + + of_property_read_u32(dev->of_node, "renesas,ssc-range", &r->ssc_range); + + platform_set_drvdata(pdev, r); + phy_set_drvdata(r->phy, r); + + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(provider)) { + dev_err(dev, "Failed to register PHY provider\n"); + ret = PTR_ERR(provider); + goto error; + } + + return 0; + +error: + pm_runtime_disable(dev); + + return ret; +} + +static int rcar_gen3_phy_usb3_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + + return 0; +}; + +static struct platform_driver rcar_gen3_phy_usb3_driver = { + .driver = { + .name = "phy_rcar_gen3_usb3", + .of_match_table = rcar_gen3_phy_usb3_match_table, + }, + .probe = rcar_gen3_phy_usb3_probe, + .remove = rcar_gen3_phy_usb3_remove, +}; +module_platform_driver(rcar_gen3_phy_usb3_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Renesas R-Car Gen3 USB 3.0 PHY"); +MODULE_AUTHOR("Yoshihiro Shimoda ");