From patchwork Mon Apr 29 00:31:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13646167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E37EC4345F for ; Mon, 29 Apr 2024 00:31:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ASUsDh0klW5jnsGfUfGN4aGeVl6MvONM9YSr4MaDFGQ=; b=X8KNSVRuS3kNq5 JXX7QAvHgBgq8yKOboiZagoNGuvkN5F1DPtgzEa11nVCEfdLsA95HhoeSQ4pd9AghJrWole4MQEtu v+XWI8tHrGnWXhU6Ht6Kpm2gGbjfFbCSeVLOLVB6YNK++ehhCVohtY01v0vtP4cFNPnAOVTWcAzIk iQ9L6MKADMtKVDia+6YuGLaR6nedWFojeiCKB1/w0N3pG6558StHeaZdGRhbFdPhxDOu+0RJFC/lH KPYAaX+FiGUEhkfzqYKzadAASY+DpL2NGfdRk2hXtLaovcsXRxtBMMFu/waT/4NueDwWTVgUtY51j pvVPXUschzvxNL3b+Spg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1EvI-0000000149O-3MRM; Mon, 29 Apr 2024 00:31:12 +0000 Received: from mail-dm3nam02olkn20801.outbound.protection.outlook.com ([2a01:111:f403:2c05::801] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1EvF-0000000148n-3KGi for linux-phy@lists.infradead.org; Mon, 29 Apr 2024 00:31:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OwuOTyty7fAlb3oHUY/dUc1ShSrbITy1BkMWptGZW/cyMefgrPz2sUHjC5VRqyn4AO9WRvhA7NSlFHx3f2BCVqMnqFWjHicg017X+YFG+w9MhHA7Oih5kWWAvyd/l9IyBaU5xcW4HkzppwSoQmrKBLDNvliqTYQb7VCiY6ptAJmJGoNgRrTHZu3qjcKYbL5K4m1ZemO6HUKyuOv30hTwCcRYrsXcasa5diKtXbOBZwLYdWqEzZG+m49zokfJ8KwFtR76dp214wbcos+7p+BtRZQxsvugzo8d5gRXBsAlIjCmXswxbGRslQGvA8TeSzOtHhBCJbuQ0vnvZg9LihG5Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ki0dPVLZxhyClX7JvgRmjpK+pMAR+r4av7UlE62CZ+k=; b=FnFQdok0t/+wC/X7+kl9HYR+dh+ClACcDW9L/obLpd6dPrjlZLMb8TF628amJTJXyOWiPWE1P7ii7BKjBNoDOXp3vwKd90KNh/HK+29Fe3lcxZ1euAKDFkiKDWELy5L32JKXtD43T8HrGn+2pHf/YFGgN5Rx5OhbyVMhXxJ5K13+clfZMJPOlAhBdoXhoPul5MivpEFwif0blm0L4T8ttCWgBbHhC4M4a2NZe7NFSozuHsWcj6Z+u6YlF1FEZDAKFnG08jm4Zzjp7SSN6xqzIfLZ1+Lpmpl0qPSP5u2AnQZsjpWTcDQNkcYYUOuUAeaKAknQ9EF5HAIZwaGYU9m0EA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ki0dPVLZxhyClX7JvgRmjpK+pMAR+r4av7UlE62CZ+k=; b=B8Yxy/cHunfFw0IP0cFfzrUvL7WEmuGwJdl4hPAoA31GrOIDuB3dqzJ8+TUUs2MTAYTU3CX8+DJUBtvxjpeuaJkeAHwVlSBq+y2/J59/jYTZOhZhPtxrSKqXFGGCD+rhRt2Z0UXbL64QVb24WNC2vAEZDIursA/2x35nT63U2GEcVXAghsm4/F3yWuBD8HDWFSUeMKPVpFyU61zBDvJJ5+lfVy9Kw3F3F2RF9HnkiV+hDtFHhNSIfiNa7QO8f9w3Ed+WSk3/oxJls8s7Q631IgalihMrISo6l9vesdwNH8GVj6OnRmeb+KoDr543fFyfuo+NvROnm6ELxibVbJzzUA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by SA1PR20MB6009.namprd20.prod.outlook.com (2603:10b6:806:339::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 00:31:02 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819%2]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 00:31:02 +0000 From: Inochi Amaoto To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: Jisheng Zhang , Liu Gui , Jingbao Qiu , dlan@gentoo.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] dt-bindings: phy: Add Sophgo CV1800 USB phy Date: Mon, 29 Apr 2024 08:31:11 +0800 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: X-TMN: [1ZlEETfDaNL6KNIE3nGTyObqvfdPfuw7MFVv478EWFM=] X-ClientProxiedBy: TYCP286CA0018.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:263::9) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240429003113.108667-1-inochiama@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|SA1PR20MB6009:EE_ X-MS-Office365-Filtering-Correlation-Id: 4570f98d-4455-4f09-a78e-08dc67e3a638 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|440099019|3412199016|1602099003|1710799017; X-Microsoft-Antispam-Message-Info: 3dyePR3VoIHN3OQSzOGzDwoVk1YthDStRxw+gV8iCVINVwpBpgriYsLLBV5m9YxUgntH7UVP/9jVMUhrdTvCu8os8xvk0ANbrDQ6IWcxgtYK+TkJp8XgDt/BA1JoR74hVRFiWQsJFEItsHZEfhDtGFvsvfYW4pMdLZ+DvDLDYyexMCl5mABr2lr3M32lcSMxl+J7FTQIknoywixURj1utUZvu8pOZ2OEWYW7B7MXzTRgPVdKApHtUXVCqErfRe0JAFCKXCcvMiC2mrDWp6r3Q743P05xBYqJar38sr93RGIuQmGWDU02fLH5Jne6ySE1mvqUfQwMRhKI0a8MJrIp08SJS4X2N2K4c+8/HC2PlMoqfat2MkRY/53R232J+e1wXw342xodjwbf2XlkBHLVqUrI5WaN9Yz5TribloyFknMVr/f1j78GNJ27zMRDkwIs0GVPSqFJd+rUngKlx64KHtx3QeEYsPfVko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7roDFChpDxZXx9jA2gM7AvY92bk0LwOxDwbuUJbOSWUpVgVZnjnA7jASYDBlfF8dnKuuitsi1+nUF6yZeswb2zRZJMhyB2792kRnbnW00uLh2NpH+4ipiam+99SXenXQkSEMJvw/oypWn7e5DtSRernAhFFkAWWdhBlBo15xRiPr/ODJu8uMNEM0YY7Ki/ocgMXGCzUALxi/L5Vtpiv5cCIWOH+AAqbzX7cC9UaWRSfaTF+S4aJOrg5l3QlwuSgV3yYvnSXFVal14urYNLv6n/4zHx4EoWwnFY3iinjo48RjHsv1RzK2jR1faBUmo09ow2usYXjDCn7YCLasAUhID6Yb4zkIYE6ofvRxTnqJjN3vK6k5f48lUXqFVBzsGsdXvLZEf7tJ89WB6Sjk0kQWmUXs6nDCGNh03HSgUGFdy364rjidyu+m3PR+CQxuXprUnHwCBiiNekew9eDEwQ X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4570f98d-4455-4f09-a78e-08dc67e3a638 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 00:31:02.5216 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR20MB6009 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240428_173109_910690_6E5F29E3 X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The USB phy of Sophgo CV18XX series SoC needs to sense a pin called "VBUS_DET" to get the right operation mode. If this pin is not connected, it only supports setting the mode manually. Add USB phy bindings for Sophgo CV18XX/SG200X series SoC. Signed-off-by: Inochi Amaoto --- .../bindings/phy/sophgo,cv1800-usb-phy.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/sophgo,cv1800-usb-phy.yaml -- 2.44.0 diff --git a/Documentation/devicetree/bindings/phy/sophgo,cv1800-usb-phy.yaml b/Documentation/devicetree/bindings/phy/sophgo,cv1800-usb-phy.yaml new file mode 100644 index 000000000000..7e3382c18d44 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/sophgo,cv1800-usb-phy.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/sophgo,cv1800-usb-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo CV18XX/SG200X USB 2.0 PHY + +maintainers: + - Inochi Amaoto + +properties: + compatible: + const: sophgo,cv1800-usb-phy + + reg: + maxItems: 1 + + "#phy-cells": + const: 0 + + clocks: + items: + - description: PHY clock + - description: PHY app clock + - description: PHY stb clock + - description: PHY lpm clock + + clock-names: + items: + - const: phy + - const: app + - const: stb + - const: lpm + + vbus_det-gpios: + description: GPIO to the USB OTG VBUS detect pin. This should not be + defined if vbus_det pin and switch pin are connected, which may + break the VBUS detection. + maxItems: 1 + + sophgo,switch-gpios: + description: GPIO array for the phy to control connected switch. For + host mode, the driver will set these GPIOs to low one by one. For + device mode, the driver will set these GPIOs to high in reverse + order. + maxItems: 2 + +required: + - compatible + - "#phy-cells" + - clocks + - clock-names + +additionalProperties: false + +examples: + - | + phy@48 { + compatible = "sophgo,cv1800-usb-phy"; + reg = <0x48 0x4>; + #phy-cells = <0>; + clocks = <&clk 92>, <&clk 93>, + <&clk 94>, <&clk 95>; + clock-names = "phy", "app", "stb", "lpm"; + }; + +... From patchwork Mon Apr 29 00:31:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13646168 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A85D2C4345F for ; Mon, 29 Apr 2024 00:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kj5bTGiEcjRl7u04HAkUz0PWz+4ctLAtP/LdO4/OsLw=; b=wl1TbnqTDXiDkG ZzN1Ysk75Y8+C4VUIbnvQzaJjC7+Oae/pH2mqh4ZGPsE0OmGImOrCNEyPBBqGsLyOyNN6dxwD0Wuq 2cLtIdSdxbSfpyzUAkWZcDqOm4Ne9+xdYCTzhnmE3heRbDOfVBUA6qxZ2QjGkJxebIiIdD2v8i3MO KTMpi1A94FvMZ5/x95zOM2EK/tSiU7lOd0FJnt1UkbFX1AOlqUlWhuD1FeAPdlb/JAZN+aos96hz0 37U8vNATPftWu4UhdOGJJrfAI8uc8mPU5ur8PY92B8KbEBtg36GirHnsWmtRqeXWmloAZx8xSoi1P llx9/6Fr9bjYciJNCcig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1EvM-000000014AE-1VWD; Mon, 29 Apr 2024 00:31:16 +0000 Received: from mail-bn8nam12olkn20801.outbound.protection.outlook.com ([2a01:111:f403:2c18::801] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1EvJ-0000000149H-3laM for linux-phy@lists.infradead.org; Mon, 29 Apr 2024 00:31:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YN9TP52hMW5qrWi7MkjWvWH83ufd6PwDp1qWKfb/O1x8ftEVndNuOZJAQDPiCOsOA8bDKZJCP85tc23LJvlWeFeR+A8MuQgUC6ME58D5eDlz4lEe7Gjw2LxKup1fzVGEnJg6QFAluIxiKq1jEzOiFW9Q7QlQDY98r1BHPOzyJn2UAe0/1aDNqvqiP2c4ZIGE7DW9dgpIES5NV9RNAxZ18qS8RF4Zfp0EfKpwvhaoEKwfsJozPzM2hG6TNsPJULgGZktPxJw/qACLloWfWpwgNxYfTDoFCuNz3GEqnvqzMhmj/t7r8A5Bn5ZLzDM8PHFEjbEG4DgXMgVOrXzy17HmdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IPWNq2Rhrz/9Gd+qGmqORVrVawLKy7jj1FMAz9diJfk=; b=noCrBS7iO3NJK1G4oCSd/jOJ6mGdEQEXNy+sI02pl2a40mow2Rg3QjJVI/bJQjuSpEn+R4mCMr+0dZgyEbGJ7VbsS4WWarmG5bQ3oTvRuXHhCD+VHkojmJv+ILHCKD9hPj+fqhR3Lr74U5tCInfafX6nfzaT7jIcwxnVibD1w1b79mT+qSpFA8qPRKZUxHxL+6zmP6TkXFm27taPxAWSuW5eCuoYDOVC22W2Rz6bGX4GJsyPba2XXfuRwgY010W47+k3vyXrXx9mS2vSLlxe0QisLu4jNjHzLiTRo3/16YZ61ut7t5lN+Jcajl6GS6TmTanhw3g9uRChSi+8fRCKSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPWNq2Rhrz/9Gd+qGmqORVrVawLKy7jj1FMAz9diJfk=; b=s+uBZfJkfny6zF9vr6312PoumxyY0aoVBauKlWQdKVNnocDpZHlVREwMsrS5QXk5h6eWiVHT6H96t3cy9mq2nxjvpeB663fP5mCP4jN6vZqurqK0Vcbverl29LNq6gL1haFGGhgU8f9dguwf5t98CGIW1A2QOSyFHk0Nplwn0P8ENa0xmgMD8joMeeJVoHwPtZLOXb5uh55nG5jc6SYFmNsSIll1E/EuysUHm+k2BGggDTDu+0nAdB3rtp1VMpp7GsMuFWJxKgkvpux8nkEg8sX83gAK5aZkHnCHOHPo/75AhHqsoA7VBC6CxIwLR8gqOpq+P25gC3qx0TvzcliDfg== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by DS0PR20MB6850.namprd20.prod.outlook.com (2603:10b6:8:1aa::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 00:31:07 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::182f:841b:6e76:b819%2]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 00:31:07 +0000 From: Inochi Amaoto To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto Cc: Jisheng Zhang , Liu Gui , Jingbao Qiu , dlan@gentoo.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] phy: sophgo: Add USB 2.0 PHY driver for Sophgo CV18XX/SG200X Date: Mon, 29 Apr 2024 08:31:12 +0800 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: X-TMN: [QZb2mJKrn7Cfq4v5V2+TAfbsFMc2unHVw3i2Se5fLG8=] X-ClientProxiedBy: TYCPR01CA0182.jpnprd01.prod.outlook.com (2603:1096:400:2b0::6) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240429003113.108667-2-inochiama@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|DS0PR20MB6850:EE_ X-MS-Office365-Filtering-Correlation-Id: 96d15848-6386-4a66-7d2d-08dc67e3a8f3 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: YpGSDBwb7+jMlOCLz6T/A37qQfi7V8aGiel4Qs+l6LpPx2OwHG4HPRJEpGJhv6cJnlNK/E5KWPpjWZi4/sHdaeuCFscKXB8W9DGK4rTeuWvwu0HWwzZNeWx12Iz6uR+SPh+6B6zpzv8QsfBYk8oMxckfDtM6zHNkk1IB8GU2zSxphOB95ujajDvBvtH+Vu4KNctwYpgG8S/ooMc/WmHvXOsJ07Z5W5Qdb5dVpmFW8PifwFKEvmEtCAXJDzHWkIN8k8sm3SHWqkHSKkW5FUfuDSDcd9KhIvyYoSlRn0BBhgJhY428aCO9JQoCJKpn6rsyC1l5tvhvKWDCp/jdeVHYAga230I8LXsh8w4ss0s8rYsNc/uq5eu76MKtglumh6uXl5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dTrFTAtEm/BxSDHor1er0hiszYMcjSXH/Fi8MR4nD8mXr1zAbWTK/YGZ9UbN6qwesjT5jkY9mb0g/DP1xFojdimH7jbc8nmowfFRH3yI8/KGOhIS74BJdLb8IPqhvaGYqfhIKUiSHn+/R5UePm8Ws/cWw40laFddxg9Rbnzs5QlOj8jPnq12RxmFa9H1W5EH6dL0B2QzWE4+Xd6ymb/dtJuDUdCkvDpqySeDhYWyyIQdB525JCb/acJI0+v1uBxAb7+/I3hNfr6zF+yFx8qxzQF9Xjo4I5eBZFSNrk2RGnFzF/X8KUSffchDo4JqHRQltTZpLKd6gyRHzZd3Qcol1Ytgp5da3LxIxsxyo/WoGI5MgR5UZLiTtJKKV3Q3MJ0aqfewM5pMFr0bYtHRScmNM0wtmdrtW+VLwi0I2Hv9zdbJFTqXxCat1GZBqk2Ufuhr4pHIySoWlHy+7lDiHk08wbY6UmHCNrmWOdBNH99qRonH7QOSniWldmiMz/69F/25qrPK10e6hOum3YTapHAXFwH X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96d15848-6386-4a66-7d2d-08dc67e3a8f3 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 00:31:07.1904 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR20MB6850 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240428_173114_053751_C8E8AA36 X-CRM114-Status: GOOD ( 23.77 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Add USB 2.0 PHY driver for Sophgo CV18XX/SG200X. Signed-off-by: Inochi Amaoto --- drivers/phy/Kconfig | 1 + drivers/phy/Makefile | 1 + drivers/phy/sophgo/Kconfig | 19 ++ drivers/phy/sophgo/Makefile | 2 + drivers/phy/sophgo/phy-cv1800-usb.c | 378 ++++++++++++++++++++++++++++ 5 files changed, 401 insertions(+) create mode 100644 drivers/phy/sophgo/Kconfig create mode 100644 drivers/phy/sophgo/Makefile create mode 100644 drivers/phy/sophgo/phy-cv1800-usb.c -- 2.44.0 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 787354b849c7..596b37ab3191 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -92,6 +92,7 @@ source "drivers/phy/renesas/Kconfig" source "drivers/phy/rockchip/Kconfig" source "drivers/phy/samsung/Kconfig" source "drivers/phy/socionext/Kconfig" +source "drivers/phy/sophgo/Kconfig" source "drivers/phy/st/Kconfig" source "drivers/phy/starfive/Kconfig" source "drivers/phy/sunplus/Kconfig" diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 868a220ed0f6..7ff32f0ae08a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -31,6 +31,7 @@ obj-y += allwinner/ \ rockchip/ \ samsung/ \ socionext/ \ + sophgo/ \ st/ \ starfive/ \ sunplus/ \ diff --git a/drivers/phy/sophgo/Kconfig b/drivers/phy/sophgo/Kconfig new file mode 100644 index 000000000000..b1c558de6616 --- /dev/null +++ b/drivers/phy/sophgo/Kconfig @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Phy drivers for Sophgo platforms +# + +if ARCH_SOPHGO || COMPILE_TEST + +config PHY_SOPHGO_CV1800_USB + tristate "Sophgo CV18XX/SG200X USB 2.0 PHY support" + depends on MFD_SYSCON + depends on USB_SUPPORT + select GENERIC_PHY + help + Enable this to support the USB 2.0 PHY used with + the DWC2 USB controller in Sophgo CV18XX/SG200X + series SoC. + If unsure, say N. + +endif # ARCH_SOPHGO || COMPILE_TEST diff --git a/drivers/phy/sophgo/Makefile b/drivers/phy/sophgo/Makefile new file mode 100644 index 000000000000..659537054cd4 --- /dev/null +++ b/drivers/phy/sophgo/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PHY_SOPHGO_CV1800_USB) += phy-cv1800-usb.o diff --git a/drivers/phy/sophgo/phy-cv1800-usb.c b/drivers/phy/sophgo/phy-cv1800-usb.c new file mode 100644 index 000000000000..bf1b86f7aa1a --- /dev/null +++ b/drivers/phy/sophgo/phy-cv1800-usb.c @@ -0,0 +1,378 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Inochi Amaoto + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PHY_IDPAD_C_OW BIT(6) +#define PHY_IDPAD_C_SW BIT(7) + +#define PHY_BASE_CLK_RATE 300000000 +#define PHY_APP_CLK_RATE 125000000 +#define PHY_LPM_CLK_RATE 12000000 +#define PHY_STB_CLK_RATE 333334 + +#define PHY_VBUS_DET_DEBOUNCE_TIME usecs_to_jiffies(100) + +struct cv1800_usb_phy { + struct phy *phy; + struct regmap *syscon; + spinlock_t lock; + struct clk *usb_phy_clk; + struct clk *usb_app_clk; + struct clk *usb_lpm_clk; + struct clk *usb_stb_clk; + struct gpio_descs *switch_gpios; + struct gpio_desc *vbus_det_gpio; + int vbus_det_irq; + struct delayed_work vbus_work; + bool enable_otg; +}; + +static int cv1800_usb_phy_set_idpad(struct cv1800_usb_phy *phy, + bool is_host) +{ + unsigned long flags; + unsigned int regval = 0; + int ret; + + if (is_host) + regval = PHY_IDPAD_C_OW; + else + regval = PHY_IDPAD_C_OW | PHY_IDPAD_C_SW; + + spin_lock_irqsave(&phy->lock, flags); + ret = regmap_update_bits(phy->syscon, CV1800_USB_PHY_CTRL_REG, + PHY_IDPAD_C_OW | PHY_IDPAD_C_SW, + regval); + spin_unlock_irqrestore(&phy->lock, flags); + + return ret; +} + +static void cv1800_usb_phy_set_gpio(struct cv1800_usb_phy *phy, + bool is_host) +{ + unsigned int i, ndescs; + struct gpio_desc **gpios; + + if (!phy->switch_gpios) + return; + + ndescs = phy->switch_gpios->ndescs; + gpios = phy->switch_gpios->desc; + + if (is_host) { + for (i = 0; i < ndescs; i++) + gpiod_set_value_cansleep(gpios[i], 0); + } else { + for (i = 0; i < ndescs; i++) + gpiod_set_value_cansleep(gpios[ndescs - 1 - i], 1); + } +} + +static int cv1800_usb_phy_set_mode_internal(struct cv1800_usb_phy *phy, + bool is_host) +{ + int ret = cv1800_usb_phy_set_idpad(phy, is_host); + + if (ret < 0) + return ret; + + cv1800_usb_phy_set_gpio(phy, is_host); + + return 0; +} + +static ssize_t dr_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct cv1800_usb_phy *phy = dev_get_drvdata(dev); + bool is_host; + + if (sysfs_streq(buf, "host")) { + phy->enable_otg = false; + is_host = true; + } else if (sysfs_streq(buf, "peripheral")) { + phy->enable_otg = false; + is_host = false; + } else if (sysfs_streq(buf, "otg") && phy->vbus_det_irq > 0) { + phy->enable_otg = true; + } else { + return -EINVAL; + } + + if (phy->enable_otg) + queue_delayed_work(system_wq, &phy->vbus_work, + PHY_VBUS_DET_DEBOUNCE_TIME); + else + cv1800_usb_phy_set_mode_internal(phy, is_host); + + return len; +} + +static ssize_t dr_mode_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct cv1800_usb_phy *phy = dev_get_drvdata(dev); + unsigned long flags; + unsigned int regval; + bool is_host = true; + int ret; + + spin_lock_irqsave(&phy->lock, flags); + ret = regmap_read(phy->syscon, CV1800_USB_PHY_CTRL_REG, ®val); + spin_unlock_irqrestore(&phy->lock, flags); + + if (ret) + return ret; + + if (regval & PHY_IDPAD_C_SW) + is_host = false; + + return sprintf(buf, "%s%s\n", + phy->enable_otg ? "otg: " : "", + is_host ? "host" : "peripheral"); +} + +static DEVICE_ATTR_RW(dr_mode); + +static struct attribute *cv1800_usb_phy_attrs[] = { + &dev_attr_dr_mode.attr, + NULL +}; + +static const struct attribute_group cv1800_usb_phy_group = { + .attrs = cv1800_usb_phy_attrs, +}; + +static int cv1800_usb_phy_set_clock(struct cv1800_usb_phy *phy) +{ + int ret; + + ret = clk_set_rate(phy->usb_phy_clk, PHY_BASE_CLK_RATE); + if (ret) + return ret; + + ret = clk_set_rate(phy->usb_app_clk, PHY_APP_CLK_RATE); + if (ret) + return ret; + + ret = clk_set_rate(phy->usb_lpm_clk, PHY_LPM_CLK_RATE); + if (ret) + return ret; + + ret = clk_set_rate(phy->usb_stb_clk, PHY_STB_CLK_RATE); + if (ret) + return ret; + + return 0; +} + +static int cv1800_usb_phy_set_mode(struct phy *_phy, + enum phy_mode mode, int submode) +{ + struct cv1800_usb_phy *phy = phy_get_drvdata(_phy); + bool is_host; + + switch (mode) { + case PHY_MODE_USB_DEVICE: + is_host = false; + phy->enable_otg = false; + break; + case PHY_MODE_USB_HOST: + is_host = true; + phy->enable_otg = false; + break; + case PHY_MODE_USB_OTG: + /* phy only supports soft OTG when VBUS_DET pin is connected. */ + if (phy->vbus_det_irq > 0) { + phy->enable_otg = true; + queue_delayed_work(system_wq, &phy->vbus_work, + PHY_VBUS_DET_DEBOUNCE_TIME); + } + return 0; + default: + return -EINVAL; + } + + return cv1800_usb_phy_set_mode_internal(phy, is_host); +} + +static const struct phy_ops cv1800_usb_phy_ops = { + .set_mode = cv1800_usb_phy_set_mode, + .owner = THIS_MODULE, +}; + +static void cv1800_usb_phy_vbus_switch(struct work_struct *work) +{ + struct cv1800_usb_phy *phy = + container_of(work, struct cv1800_usb_phy, vbus_work.work); + int state = gpiod_get_value_cansleep(phy->vbus_det_gpio); + + cv1800_usb_phy_set_mode_internal(phy, state == 0); +} + +static irqreturn_t cv1800_usb_phy_vbus_det_irq(int irq, void *dev_id) +{ + struct cv1800_usb_phy *phy = dev_id; + + if (phy->enable_otg) + queue_delayed_work(system_wq, &phy->vbus_work, + PHY_VBUS_DET_DEBOUNCE_TIME); + return IRQ_HANDLED; +} + +static void cv1800_usb_phy_init_mode(struct device *dev, + struct cv1800_usb_phy *phy) +{ + phy->enable_otg = false; + + if (phy->vbus_det_irq > 0) + phy->enable_otg = true; + + if (phy->enable_otg) + queue_delayed_work(system_wq, &phy->vbus_work, 0); + else + cv1800_usb_phy_set_mode_internal(phy, true); +} + +static int cv1800_usb_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device *parent = dev->parent; + struct cv1800_usb_phy *phy; + struct phy_provider *phy_provider; + int ret; + + if (!parent) + return -ENODEV; + + phy = devm_kmalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + phy->syscon = syscon_node_to_regmap(parent->of_node); + if (IS_ERR_OR_NULL(phy->syscon)) + return -ENODEV; + + spin_lock_init(&phy->lock); + + phy->usb_phy_clk = devm_clk_get_enabled(dev, "phy"); + if (IS_ERR(phy->usb_phy_clk)) + return dev_err_probe(dev, PTR_ERR(phy->usb_phy_clk), + "Failed to get phy clock\n"); + + phy->usb_app_clk = devm_clk_get_enabled(dev, "app"); + if (IS_ERR(phy->usb_app_clk)) + return dev_err_probe(dev, PTR_ERR(phy->usb_app_clk), + "Failed to get app clock\n"); + + phy->usb_lpm_clk = devm_clk_get_enabled(dev, "lpm"); + if (IS_ERR(phy->usb_lpm_clk)) + return dev_err_probe(dev, PTR_ERR(phy->usb_lpm_clk), + "Failed to get lpm clock\n"); + + phy->usb_stb_clk = devm_clk_get_enabled(dev, "stb"); + if (IS_ERR(phy->usb_stb_clk)) + return dev_err_probe(dev, PTR_ERR(phy->usb_stb_clk), + "Failed to get stb clock\n"); + + phy->phy = devm_phy_create(dev, NULL, &cv1800_usb_phy_ops); + if (IS_ERR(phy->phy)) + return dev_err_probe(dev, PTR_ERR(phy->phy), + "Failed to create phy\n"); + + ret = cv1800_usb_phy_set_clock(phy); + if (ret) + return ret; + + phy->switch_gpios = devm_gpiod_get_array_optional(dev, "sophgo,switch", + GPIOD_OUT_LOW); + if (IS_ERR(phy->switch_gpios)) + return dev_err_probe(dev, PTR_ERR(phy->switch_gpios), + "Failed to get switch pin\n"); + + phy->vbus_det_gpio = devm_gpiod_get_optional(dev, "vbus_det", GPIOD_IN); + if (IS_ERR(phy->vbus_det_gpio)) + return dev_err_probe(dev, PTR_ERR(phy->vbus_det_gpio), + "Failed to process vbus pin\n"); + + phy->vbus_det_irq = gpiod_to_irq(phy->vbus_det_gpio); + if (phy->vbus_det_irq > 0) { + ret = devm_request_irq(dev, phy->vbus_det_irq, + cv1800_usb_phy_vbus_det_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, + "usb-vbus-det", phy); + if (ret) + return dev_err_probe(dev, ret, + "Failed to request vbus irq\n"); + } + + INIT_DELAYED_WORK(&phy->vbus_work, cv1800_usb_phy_vbus_switch); + + ret = sysfs_create_group(&dev->kobj, &cv1800_usb_phy_group); + if (ret) + dev_warn(dev, "failed to create sysfs attributes\n"); + + phy_set_drvdata(phy->phy, phy); + platform_set_drvdata(pdev, phy); + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + + /* + * phy needs to change mode twice after initialization, + * otherwise the controller can not found devices attached + * to the phy. + */ + cv1800_usb_phy_set_idpad(phy, false); + cv1800_usb_phy_set_idpad(phy, true); + cv1800_usb_phy_init_mode(dev, phy); + + return PTR_ERR_OR_ZERO(phy_provider); +} + +static void cv1800_usb_phy_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct cv1800_usb_phy *phy = platform_get_drvdata(pdev); + + if (phy->vbus_det_irq > 0) + devm_free_irq(dev, phy->vbus_det_irq, phy); + + cancel_delayed_work_sync(&phy->vbus_work); +} + +static const struct of_device_id cv1800_usb_phy_ids[] = { + { .compatible = "sophgo,cv1800-usb-phy" }, + { }, +}; +MODULE_DEVICE_TABLE(of, cv1800_usb_phy_ids); + +static struct platform_driver cv1800_usb_phy_driver = { + .probe = cv1800_usb_phy_probe, + .remove_new = cv1800_usb_phy_remove, + .driver = { + .name = "cv1800-usb-phy", + .of_match_table = cv1800_usb_phy_ids, + }, +}; +module_platform_driver(cv1800_usb_phy_driver); +MODULE_DESCRIPTION("CV1800/SG2000 SoC USB 2.0 PHY driver"); +MODULE_LICENSE("GPL");