From patchwork Sun Feb 23 12:22:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987005 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 456B6C021B2 for ; Sun, 23 Feb 2025 12:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Imu1A98L2KP46AIXwK/kKuPHdfCAq0a74bOMQZLOfVI=; b=OmIG/wnYtiFQqRJFlDd3Rvr3qP U+Dw5kFdPbVxKn1NF/Oii4HhuKMuCTsiYHGTC43pxD9wX8TIxRJ2j6k4oItPNDbgDxhEDZ9I3pNmS v2TJFDJ9C6MZlMxiFUTAa5nxWxiM03kOf9PqOPFqlbGpLMKbj3R3Aur0scA2egyMOi1aKlrjHy07N vCU/OaC1KUU0J/OeqzzGpol9jPQyT9lm6dUtu6hg/mmfZj9oyma9WFjKajWZcAM8tcWL9lEpwcLYE Ng7wJBwD7NwxiTvvZQp1eWlLB9AwhTIN3yofzoK37kYR0B8l9rbMxg9pZ4uZpWrbAmjXensetQla9 8fNLBubA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmB39-0000000B5Sn-0ZVr; Sun, 23 Feb 2025 12:25:35 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0E-0000000B4qD-46vx; Sun, 23 Feb 2025 12:22:36 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-38f29a1a93bso2827405f8f.1; Sun, 23 Feb 2025 04:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313353; x=1740918153; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Imu1A98L2KP46AIXwK/kKuPHdfCAq0a74bOMQZLOfVI=; b=FxWtkZcbJD28kWeHfA07WJfgk8FXZZ49IEH0TrTP/g7mhIbY4iGPs4z11xSYROo2yO 9q6v7mxVx+l/fJYt0ZYmH4ANS23W2rG/yjeEveW/8/z6YgNyKm70QCe03a4RtXgrpwKG 40HabaCFSq+u0/54+eZQniDo7UJobh7d9A+NeNmrMjHL+2QQrE67UJVjpnF5Og0ReD+2 V/yFoD1uhOd09pcUlLTCDLCoIEAAQL2AE7N6KmllP3ctFvi5c9tTeY6G+8aVFSxFDXEC zmxB16LchgLCCoyez1+v9ibwX4B9kzE3YkiX3fMgHeRrWRO3rGhDGsqzFqr4QJIVTP1w sKZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313353; x=1740918153; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Imu1A98L2KP46AIXwK/kKuPHdfCAq0a74bOMQZLOfVI=; b=FBCgGLwo94TaODK8hsHESuYyu2+FjqNcrE+0CAiYXN162tL+jmsA66IzES/AIpBX+X ENKRZH3q3HURLBAqkItEw5Ea9OjJD6gRCZ5b31JyTmRsIiM9AwOhzZhv09FsAzQovJqu AELdKZfV+PqLefPwpd/WEtRCKB/IxWVHNQVVw1JTRH3G8XBHTKf5hNUT9nlqnccCyuSy 0kIOXstzwz6BYOSPRrzoZ9aoRnsGL96LSd29oy0z3YWoeuvO0e/LoS+rWQBIyUViA/0C niDCdp9rlDEFQXck3fgO0A5hVddolQluclVAxPImjAkNJbxW/0K/zpOh7Zjp50El1SKh rolw== X-Forwarded-Encrypted: i=1; AJvYcCVC9hjfY7qfEb329XRA/qn/20cADw4wS4e43YsB2wyGlZb8RUl408eGu4gzt4+qDQZj9GHnUyWr/pSb45//zKFk@lists.infradead.org, AJvYcCX57LX+odsy3pITkkEgUpCT+wzYNdTu2UwcOkRU/ZrjweIgAI87xnC5ViWvvHRUfu2WfG8v+RTvblxs@lists.infradead.org X-Gm-Message-State: AOJu0YxA9MXHfRecVn1LHWKgFsEWZ/KO+baLN9rvMQ/Gz0S79RRR1QLf knSOuBpyzGkpSP+qjBLMIKhZDNoKJ9R1myKFbQLlDgbwSrHusYGS X-Gm-Gg: ASbGncv2LxUcEYsxvFXg1SPUeW8KXMD9E3Wt+BLq5jhvFy6NC2CNc386xfWMaofG/Nr kp3srGwuETXLJpIkt7Fjj3wEs4zLAijGjfc9570AqlfA1UImsM/ivsyi+pC81tWYhjxFP+gbWHb eN1Nvt7Nv8NQKfUrttyxbHCz8Yy1IgSxTFkIJ06ttwml81PguOlIezyfupMUM91tqnsTRZiqtNq LMNP6AfW6L7sX6HIbxrQJF1B44LsthxnuXyNJpKqZ0Ee2K6Hrvpi9XVbTc4Nix4VXGQEkUSrEkK +xYaNvp6C4h598vJOYGwaqpFVtQ6fJrBxQflxtEmwVAd3wXRhBBNFIhk4zocIxvoTwxtqKcmHnF EFw== X-Google-Smtp-Source: AGHT+IHaUz0XhpP9SWkDpIHgSlmiijMV4PEbmK8V+w/DLEX2GzBOqorv8lkEfT706XJetrp/boI5lQ== X-Received: by 2002:a5d:5888:0:b0:38f:2efb:b829 with SMTP id ffacd0b85a97d-38f6f0d1d04mr7837154f8f.50.1740313351723; Sun, 23 Feb 2025 04:22:31 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:31 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/8] dt-bindings: phy: rename qcom,snps-eusb2-phy binding to snps,eusb2-phy Date: Sun, 23 Feb 2025 14:22:20 +0200 Message-ID: <20250223122227.725233-2-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042235_016613_8A2C2AF6 X-CRM114-Status: UNSURE ( 7.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As Samsung has been using the same Synopsys eUSB2 IP in Exynos2200, albeit with a different register layout, rename qcom,snps-eusb2-phy to snps,eusb2-phy and drop mentions of it being only for Qualcomm SoCs in the binding description. Signed-off-by: Ivaylo Ivanov --- .../phy/{qcom,snps-eusb2-phy.yaml => snps,eusb2-phy.yaml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename Documentation/devicetree/bindings/phy/{qcom,snps-eusb2-phy.yaml => snps,eusb2-phy.yaml} (90%) diff --git a/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-phy.yaml b/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml similarity index 90% rename from Documentation/devicetree/bindings/phy/qcom,snps-eusb2-phy.yaml rename to Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml index 142b3c883..22c77968f 100644 --- a/Documentation/devicetree/bindings/phy/qcom,snps-eusb2-phy.yaml +++ b/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml @@ -1,16 +1,16 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/phy/qcom,snps-eusb2-phy.yaml# +$id: http://devicetree.org/schemas/phy/snps,eusb2-phy.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Qualcomm SNPS eUSB2 phy controller +title: SNPS eUSB2 phy controller maintainers: - Abel Vesa description: - eUSB2 controller supports LS/FS/HS usb connectivity on Qualcomm chipsets. + eUSB2 controller supports LS/FS/HS usb connectivity. properties: compatible: From patchwork Sun Feb 23 12:22:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987018 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 DA91AC021B2 for ; Sun, 23 Feb 2025 12:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vMvQlF05mCiAYcMEroKJ0h4q5UvU+zcKze89brABNJQ=; b=iaX1mi2XyZaCx4br13m4H/sg8E ZYHvNDnnWYvJaEyv8hPNV2ta9jKZ/N4q9lJq+0dnrA5+p1DPwxDzRCqSuAvOzDDZzPjJdrXtQdl3B sAFuyZiEV9E+9q79odp8IdFkNk4CS7G9mVhwUnA57MzucAMCcz+iVl2vO8/LlrqN9h+SWATpnm2We jqSbIaFUr2j3HhoOvMYOn2iGgYYgHsW3tpElnIDwCK3yPzsl9+ReGfycAtXcyYZAjeMjnSZjHoV+9 Eui1saTjf+s5VwzFgkpnPfQAzCf7njB37ArpfoA+uAs3QEUA3w0We1MV6BOuxLMJSTqr0oHFU8A4u orT8BWeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmB4b-0000000B5gp-0Z0S; Sun, 23 Feb 2025 12:27:05 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0G-0000000B4qh-1iKB; Sun, 23 Feb 2025 12:22:37 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-38a25d4b9d4so2000792f8f.0; Sun, 23 Feb 2025 04:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313355; x=1740918155; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vMvQlF05mCiAYcMEroKJ0h4q5UvU+zcKze89brABNJQ=; b=hW6KfXvW42eQCalr9AxnUCcESwb9qQdzZfr6DMtI150/Bj3IOb2ieAA9ZWesoLLTfZ uhE0t3gKXo+qFlfLKfxUrO9gidj1Mjmlb7zmIcec2gLqHX+qdR4eri7C1vS1OwumeDwj idyD6JYlCgPKm07SL3bA/k8xVbZqFJcGDAwHm+LpjPEbnvmlZuDCj9WpeOUcNuXpyvIY mOqTfIaEoR1XcQLrhYEzDVhXnE3E2vfRUERlRdMST9rVCeC8b106MQvv1hSBIl0jGXb1 lMsYGMh/1e4MRMiQ+IIOnh2E2ff6QUJTEQ6ecoMwpFyXN7FS3YsxZw0xxIn31NZdIoxs xmkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313355; x=1740918155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vMvQlF05mCiAYcMEroKJ0h4q5UvU+zcKze89brABNJQ=; b=kafT7nC72gkwcdTOoAVY+tEtWUJXX0exzeGA/S/4Vi7vRpFW6sUY9QT5ZEHoPaPX8k wSCmUXhRwTuHyCPTTwYVbu/4UDfIeq63n10np12Wp2JjePnoBVUn/IvRbzkcbiIGR9BI +ip2P/UUwCV0ulzgXSvoF1FgKsK1qjJuqiXNoqm9f11HqQ3CYRqBjkMcDgZvkHZTbqkw 3829//64Rqy0mIfRNZJXo4OiiGxV+/B+gCTeAn8DnRg3GBGROqselQmGm4cDKHQsfmBO mDe+r6WGYHFxtzrIZEhM6uGypc4cpmg6STfc/8Rt/mAaGGxVt/lA1r9911HwCHdXcmA/ nTzg== X-Forwarded-Encrypted: i=1; AJvYcCVeDo9XL3JF/qhaHfM6wwOk0HKjiwVdFADiztM8/e6bdxwS56SG+6e8DGIs1cUNOHe7G9xF294sRUlFn3WTufHA@lists.infradead.org, AJvYcCWyYvL7N1DLhMv8UJzvacoA1r1EYosI9NzvYizZxVfOIPwcnH5pSFYbF7dEoERYd09vuI8gRM3p39V/@lists.infradead.org X-Gm-Message-State: AOJu0YzkWJcJbZxWTW1Aeaz/Hnnk1DckDIg/tmQVlJDEAdWRmNbhibJQ ndMOSp4QhC48nh1mv/HP1LjIyUw+d6wAy++BTd/EWbfpLWvsYxx9qJNKTA== X-Gm-Gg: ASbGncsYSl79N3VG1PeR8cp0GSlVF4MQ/RbJd3ALc4yzdmRytlzwd2+m7xAnsRAfh5F DLVNGeuBOB1V+KcQTGVA/o+fH08IGLhi6jHt2XfajAW853orcb/+gLQtAFp+MV4I6U8wOQUvYJ+ r/DOTLsAlxk9dV3iehUo4VRNtmh4iy99fraE7qFZMLWPo/ykcB6uG7hfrgbz/V3a07QkgShSpnG /PwGny1lf043JwuvrtTPuBEDPMKqJU2KY62XSFJL4k+U8UCL7hamfp3FEGgaO2pWSyooAgI+fWi nrTs+56jPi5YpYxW+ipOMtaP2gmXEwism0uu76v+4PeHFNmYgZu5Ovh8+DUYGRyUmDsRsjVf7Im hUg== X-Google-Smtp-Source: AGHT+IG+0MAODFk+p1TBCBtE4y4nFsqlItck+UeuAIWOTYDShqxnT5f5tx5xGljZ6owFfPbJmR567A== X-Received: by 2002:a5d:648a:0:b0:38f:43c8:f751 with SMTP id ffacd0b85a97d-38f6f0959c5mr10354553f8f.35.1740313353094; Sun, 23 Feb 2025 04:22:33 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:32 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] dt-bindings: phy: snps-eusb2: add exynos2200 support Date: Sun, 23 Feb 2025 14:22:21 +0200 Message-ID: <20250223122227.725233-3-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042236_450511_1FAF9A75 X-CRM114-Status: UNSURE ( 7.86 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Exynos 2200 makes use of the Synposys eUSB2 IP, so document it in the binding. Unlike the currently documented Qualcomm SoCs, it doesn't provide reset lines for reset control and uses more clocks. Signed-off-by: Ivaylo Ivanov --- .../bindings/phy/snps,eusb2-phy.yaml | 64 +++++++++++++++++-- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml b/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml index 22c77968f..f4164db71 100644 --- a/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml +++ b/Documentation/devicetree/bindings/phy/snps,eusb2-phy.yaml @@ -23,6 +23,7 @@ properties: - qcom,x1e80100-snps-eusb2-phy - const: qcom,sm8550-snps-eusb2-phy - const: qcom,sm8550-snps-eusb2-phy + - const: samsung,exynos2200-snps-eusb2-phy reg: maxItems: 1 @@ -31,12 +32,12 @@ properties: const: 0 clocks: - items: - - description: ref + minItems: 1 + maxItems: 3 clock-names: - items: - - const: ref + minItems: 1 + maxItems: 3 resets: maxItems: 1 @@ -58,11 +59,60 @@ required: - compatible - reg - "#phy-cells" - - clocks - - clock-names - vdd-supply - vdda12-supply - - resets + +allOf: + - if: + properties: + compatible: + contains: + enum: + - qcom,sm8550-snps-eusb2-phy + + then: + properties: + reg: + maxItems: 1 + + clocks: + items: + - description: ref + + clock-names: + items: + - const: ref + + required: + - clocks + - clock-names + - resets + + - if: + properties: + compatible: + contains: + enum: + - samsung,exynos2200-snps-eusb2-phy + + then: + properties: + + clocks: + items: + - description: Reference clock + - description: Bus (APB) clock + - description: Control clock + + clock-names: + items: + - const: ref + - const: bus + - const: ctrl + + required: + - clocks + - clock-names additionalProperties: false From patchwork Sun Feb 23 12:22:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987019 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 72950C021B2 for ; Sun, 23 Feb 2025 12:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2TbGBzUDvgVe7DZmZtqsqC9SxMmEhDsYTwwUDb5o6oI=; b=Vn5daBeN3r3DoN+b8LqKDGjWGb QQ45UicGakhm1c/Pm+y36N06EFlywQkDJfGOB1q3gOwy54Y+56ucR2p9DThceXonmAn9UtG5HnbOp rgnXAEuJ700ownyMuT6+kODRsXlwerYMXzdFvzEB0FEIT1yTrxVJ7joSE3M/b9iUOpQlMMfDQlbp0 sQJ5dG7Cbk/PKbatItjPeEVySbEggrvo4Xgw0SNghpovzFfilBAdv4Ia5oGA1IHHNoUlZwUjjhh3t jcvkxqoyCSVFLIfhF6/v5szAuyl6tPKys0QF5/qRJs2Jwxq9PCOpd6PTksJBpEmHiur58nixM7rJK NoP36wsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmB62-0000000B5sE-0yrL; Sun, 23 Feb 2025 12:28:34 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0G-0000000B4qg-1hYX; Sun, 23 Feb 2025 12:22:37 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-38a8b17d7a7so1901169f8f.2; Sun, 23 Feb 2025 04:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313355; x=1740918155; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2TbGBzUDvgVe7DZmZtqsqC9SxMmEhDsYTwwUDb5o6oI=; b=Kw33UKd6+71um4AmgkoL3O4PFB+bGr9dHcE7AfelFmvgZzZxHfBlLwXn66bU1YtxNT q4rNoo1wKxq6vI8AgIzg869Q8rS3B0FTNDL6nWwfxX9DhRrNqR/JOqkHhCSxOSNvv/aw hnzyhFRaWIOFqD4LnA9y/cVuyZHhErlr3dVon2js5PytCLBlq3ffOm7VbhU92PdfLH3i 6udGCcaOIxIOzy6VcISeMASQjJKv+zT/XYMr7oA99yqrsOjm9ayuC/m5KQaX66nNHtoF 6bfwy55oyezMu2Vsozlm8rLHy7zwoaedPXtBEpZlmiPGqjI+gSt0Tn/f1ijVTjib1xF2 xung== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313355; x=1740918155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2TbGBzUDvgVe7DZmZtqsqC9SxMmEhDsYTwwUDb5o6oI=; b=evdAG0Kba18/FD2a+MQX+0ekkAXnIviKc+yMn7Sboqf4bXPqBIDGO8EEfc+Jr1OsRo ODle4sVc57/wkUwJp2ybHDiFfIzRcoY1E4a0n23F21U1Ce0GoT4UHHgJlhqBfa7zAYdZ zBqHU1GrwKwoW4V1kJoY/vAXIeW6u0PPF59BsQMzyVbIyGcHesGZbqYK9KCsTr2EcKkw NyjLmRMadTHUODq2uHRY25NmdakYy9poUCU2wdCRQtISVHGpVxu2s8hZAhdNrrHD/aiz xseLJQ24yqT8LxHVzzPk/9Q3ei63JwnLUgM/t81V/yQw2pUon64LpzALnDCggltJnncT 2L0Q== X-Forwarded-Encrypted: i=1; AJvYcCVL9dJhHdYA2+IrBMM1PIFd0y21LeCm1tYjVCZrM71Qf3jhZPAQtaIyS+leF4MtxNbcaGk1vMc/wfFKLtilGest@lists.infradead.org, AJvYcCVgI/llYbApWcLZp12qjPWxXJzMkYoVvHucwrtUMbXt8rwqIcox6TFxL5hOyInsfZd64d89l2XMTYxw@lists.infradead.org X-Gm-Message-State: AOJu0YwHq4G7TG1Q/eGjynnla423CV6FlSpDB6PMelRP4LEyFwPxb7zh 0VElHOBO81KKiTxYvs+cW+m0TSVNaU+xKUiIHVO6UEJB4yEcX1Bt X-Gm-Gg: ASbGncs8r/W5byOFqtrCSey3FdEgWXutCHDK/IXipEf9b25KvgaekxMoKcHz1Lthzj1 wCse/XiysPU3/9xde6TboO/Vo5N37Fx+IuyI0u3opDoJel+Kd0aFyDTRu3ELuC0pmfqXXtFtAr0 +9u51rY4evTO1GUWTpppvv9JwcuG2ukVPf1QLRnAgI7BCrQ0dB8MAVM7Ksux0pOvV+2RB3tN3LL aBdh7VhIQyu6tOyKBgW3Z+4x+UY9aBU4H7ToopCBkwQkpzBS08vLRs8oV6dGbu/Ct1pWvw4vM0J WkT65vtG32bBQdVbZHTQC8hCkIUIsE8WVJTHkAM5emU5ke3QSViGzU3uiJFpBSlbhWlEV2gXz5y kJA== X-Google-Smtp-Source: AGHT+IFMMFEPDMQAE9igHIO1s4NQHd7QMje6bLzkA+Bu0OEI2dPAuclKIJlYvuVA53CK1jDPbgzvtA== X-Received: by 2002:a5d:584b:0:b0:38f:3b41:c952 with SMTP id ffacd0b85a97d-38f6e754b82mr7082161f8f.4.1740313354607; Sun, 23 Feb 2025 04:22:34 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:34 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/8] dt-bindings: phy: add samsung,exynos2200-usbcon-phy schema file Date: Sun, 23 Feb 2025 14:22:22 +0200 Message-ID: <20250223122227.725233-4-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042236_444911_6AA21475 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Exynos2200 SoC has a USB controller PHY, which acts as an intermediary between a USB controller (typically DWC3) and other PHYs (UTMI, PIPE3). Add a dt-binding schema for it. Signed-off-by: Ivaylo Ivanov --- .../phy/samsung,exynos2200-usbcon-phy.yaml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/samsung,exynos2200-usbcon-phy.yaml diff --git a/Documentation/devicetree/bindings/phy/samsung,exynos2200-usbcon-phy.yaml b/Documentation/devicetree/bindings/phy/samsung,exynos2200-usbcon-phy.yaml new file mode 100644 index 000000000..7d879ec8b --- /dev/null +++ b/Documentation/devicetree/bindings/phy/samsung,exynos2200-usbcon-phy.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/samsung,exynos2200-usbcon-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Exynos2200 USB controller PHY + +maintainers: + - Ivaylo Ivanov + +description: + Exynos2200 USB controller PHY is an intermediary between a USB controller + (typically DWC3) and other PHYs (UTMI, PIPE3). + +properties: + compatible: + enum: + - samsung,exynos2200-usbcon-phy + + reg: + maxItems: 1 + + clocks: + items: + - description: bus clock + + clock-names: + items: + - const: bus + + "#phy-cells": + const: 0 + + phys: + maxItems: 1 + description: + Phandle to eUSB2 PHY + + samsung,pmu-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + maxItems: 1 + items: + minItems: 1 + items: + - description: phandle for PMU system controller interface, used to + control PMU registers bits for USBCON PHY + - description: offset of the pmu control register + description: + Should be phandle/offset pair. The phandle to System Register syscon node + and the offset for USBCON PHY. + +required: + - compatible + - reg + - clocks + - clock-names + - "#phy-cells" + - phys + - samsung,pmu-syscon + +additionalProperties: false + +examples: + - | + #include + + usb_con_phy: phy@10aa0000 { + compatible = "samsung,exynos2200-usbcon-phy"; + reg = <0x10aa0000 0x10000>; + clocks = <&cmu_hsi0 CLK_MOUT_HSI0_NOC>; + clock-names = "bus"; + #phy-cells = <0>; + phys = <&usb_hs_phy>; + samsung,pmu-syscon = <&pmu_system_controller 0x72c>; + }; From patchwork Sun Feb 23 12:22:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987020 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 ED87EC021B2 for ; Sun, 23 Feb 2025 12:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w5AqloAAA42MXmA8w7bAhHKGWmPLv+VF0Ofk4tbyqKU=; b=NbtQNAvlFS6dnmb2Oymu0Jpbvg c067VReaLlxlvh7pfIDE03LReJY1lpcAQiVV9FQbKAZLMzgTiFQg7Fudf9Czm1sUH6rID/lbcCLxs oVLVJCkdx4RXE0o2YSXXVsJAXreEQQnMmsAClii3iJOnCbBqKCXRVRUKEE2HNhVq5yeWbgQ9bgY5J ftaU9Rsxbz4jpar7YQS2iSIhzIeeLTKH3ZYSSRNateO5VJGlyix7alhyVlq1WdH1RBnX9kcLrE/fF 1VS54EgiN0xpqMNNvAahurGdgu7X6tOO8h4Ejk9SF80k2Ff+6b/nTkWfIrZZvmctTT4lyC5OtF4A0 8lMr4qmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmB7U-0000000B61U-0dhc; Sun, 23 Feb 2025 12:30:04 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0H-0000000B4rV-3zYC; Sun, 23 Feb 2025 12:22:39 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4399d14334aso31121545e9.0; Sun, 23 Feb 2025 04:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313356; x=1740918156; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w5AqloAAA42MXmA8w7bAhHKGWmPLv+VF0Ofk4tbyqKU=; b=Af7crL4SZpF5g5jAEhx7cOdTF374hNxDE1SHCExpDNVxMeX3NzOR9XBT5aHyjmmz2o JAKjbnxaHD5P3V7FsA5yfNgY+PJZBK+a35n4mJqsBkkOKl8/yJSsCVBQjCt257AF9Myj ZvjePSDzv5p0ovjx+8561C7wJ8CY3KSKEn+9Z3FzrGibPG3hkifPBNTluLEejFv27IB6 1eKZmWCNIEmuNqMpr8VgN8HuzPyM8ceJBLAxsP4Z//5gQbdMv2PXbQAcnsVDPSDoHM07 8QXEny9I2b2gb/V754GtCEdgT2KX+R1cRxpEFn3dsx31+CJPjVoyXups0SFh6Vp84BsK Nqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313356; x=1740918156; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w5AqloAAA42MXmA8w7bAhHKGWmPLv+VF0Ofk4tbyqKU=; b=cdix4LUOIZUZ8hDMOmFYDg6/IWiho8U69k0E12nJMkQ+FVdMLC9mWT4c6zym+KaUqL szrJ8IKpR7agegtUYGV/Aq4A34VK5ijmhLZ9soVGAgrq25r1AoxjKVI3jUsVJrgbWueb KLCqWri8bJ/kp6Td44QPpbOChOeiaxDVmi+nK1lhXHrMWxz+dRTb8JUuKqC75GCx5WFo esowR7KdtPQTY7QRZQsDNmHF86sIfobrr62viRwkCTkCzSmFPiAR4IF1ewPgjYUfpAfy M16DbgmStmVxnF260HD8gZXb97q5IltQuCJyAv7tIUbkQnTqfqGv/Uo6FNvyx02UcMFR qdQg== X-Forwarded-Encrypted: i=1; AJvYcCUucIyVBcLOZRbhcrNs9DsR1QOahpm17vfWjw88YR1B6S7OMPJfqD0Ceoy46rHK9wpidOmYVOKbcuBSQZ21L5Dn@lists.infradead.org, AJvYcCVPCJPAD2HDqlU5rEUu/degxrOk+T3q31B85AbMNGCot/HVovtKoPZK0fyC8dsBwFwqpMLbY0nUFNt1@lists.infradead.org X-Gm-Message-State: AOJu0YxSV4sQ2skcC0bo9s7dMmgLexgeJ8HHB/0i208gwVPuJKI0MnMt DaKxjS3KH/vvPaVKOA63ahUvJEsgoR8u31h7T66rV3vh3DQzgxp9 X-Gm-Gg: ASbGncvnJDKQSgTHFlUAbV2Ahdh+ldZqsaY+M5GTzx9RrIv4VD13vlM6T/1JQdpITGJ vq6bwuwClgjtCzzNstf9WCcYGOitVZzLOLsGMekrVoohysjPlmR5gm4BptAx4f9kasf3YOl/lXR 2IRaYUHpK4pq4nUkegMfMf9BTdr5IJ6muf7gDLYTDhyT/Z6ONV8k4S9O+YkcnMgF90UomxgKCPU FMRfRWDhCHXmxyLgb56kcSb5QvSausp+AUjwvlg2xoLUed0CKx/9zvCXMGzzvn8e0I4M9zU5Hxu JemSLv/9HUPtJJr9PIttF1bYcNh6dzDeX/ULFFZFPiyybqQjnwYw6GB2TW9aS4sfPh8BhuTQHQo uEA== X-Google-Smtp-Source: AGHT+IHqP76iHfiYngmm0o31mQ9yL26b7/JkdUj5J77MLt+JVK4hCOloOw0no10cd3jakQMTipP2eA== X-Received: by 2002:a05:6000:184f:b0:38d:dffc:c144 with SMTP id ffacd0b85a97d-38f6f0c8e74mr7319751f8f.55.1740313356080; Sun, 23 Feb 2025 04:22:36 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:35 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] phy: move phy-qcom-snps-eusb2 out of its vendor sub-directory Date: Sun, 23 Feb 2025 14:22:23 +0200 Message-ID: <20250223122227.725233-5-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042237_999611_A6A227D0 X-CRM114-Status: GOOD ( 19.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As Samsung is using the same Synopsys eUSB2 IP in Exynos2200, albeit with a different register layout, it only makes sense to implement support for that in the existing eUSB2 driver. To make room for new non-qcom SoCs, do the following: 1. Move phy-qcom-snps-eusb2.c to phy-snps-eusb2.c 2. Rename all qcom_snps_eusb2 functions and structs to snps_eusb2_phy 3. Add a prefix to the qcom-specific register offset definitions 4. Make a generic phy_ops init that sets up power before the SoC-specific eUSB2 IP init 5. Introduce a driver data structure with init function and clocks Signed-off-by: Ivaylo Ivanov Suggested-by: Krzysztof Kozlowski --- drivers/phy/Kconfig | 8 + drivers/phy/Makefile | 1 + drivers/phy/phy-snps-eusb2.c | 505 +++++++++++++++++++++ drivers/phy/qualcomm/Kconfig | 9 - drivers/phy/qualcomm/Makefile | 1 - drivers/phy/qualcomm/phy-qcom-snps-eusb2.c | 442 ------------------ 6 files changed, 514 insertions(+), 452 deletions(-) create mode 100644 drivers/phy/phy-snps-eusb2.c delete mode 100644 drivers/phy/qualcomm/phy-qcom-snps-eusb2.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 8d58efe99..11c166204 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -43,6 +43,14 @@ config PHY_PISTACHIO_USB help Enable this to support the USB2.0 PHY on the IMG Pistachio SoC. +config PHY_SNPS_EUSB2 + tristate "SNPS eUSB2 PHY Driver" + depends on OF && (ARCH_QCOM || COMPILE_TEST) + select GENERIC_PHY + help + Enable support for the USB high-speed SNPS eUSB2 phy on select + SoCs. The PHY is usually paired with a Synopsys DWC3 USB controller. + config PHY_XGENE tristate "APM X-Gene 15Gbps PHY support" depends on HAS_IOMEM && OF && (ARCH_XGENE || COMPILE_TEST) diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index e281442ac..c670a8dac 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_PHY_CAN_TRANSCEIVER) += phy-can-transceiver.o obj-$(CONFIG_PHY_LPC18XX_USB_OTG) += phy-lpc18xx-usb-otg.o obj-$(CONFIG_PHY_XGENE) += phy-xgene.o obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o +obj-$(CONFIG_PHY_SNPS_EUSB2) += phy-snps-eusb2.o obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o obj-$(CONFIG_PHY_NXP_PTN3222) += phy-nxp-ptn3222.o diff --git a/drivers/phy/phy-snps-eusb2.c b/drivers/phy/phy-snps-eusb2.c new file mode 100644 index 000000000..4e5914a76 --- /dev/null +++ b/drivers/phy/phy-snps-eusb2.c @@ -0,0 +1,505 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2023, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define QCOM_USB_PHY_UTMI_CTRL0 (0x3c) +#define SLEEPM BIT(0) +#define OPMODE_MASK GENMASK(4, 3) +#define OPMODE_NONDRIVING BIT(3) + +#define QCOM_USB_PHY_UTMI_CTRL5 (0x50) +#define POR BIT(1) + +#define QCOM_USB_PHY_HS_PHY_CTRL_COMMON0 (0x54) +#define PHY_ENABLE BIT(0) +#define SIDDQ_SEL BIT(1) +#define SIDDQ BIT(2) +#define RETENABLEN BIT(3) +#define FSEL_MASK GENMASK(6, 4) +#define FSEL_19_2_MHZ_VAL (0x0) +#define FSEL_38_4_MHZ_VAL (0x4) + +#define QCOM_USB_PHY_CFG_CTRL_1 (0x58) +#define PHY_CFG_PLL_CPBIAS_CNTRL_MASK GENMASK(7, 1) + +#define QCOM_USB_PHY_CFG_CTRL_2 (0x5c) +#define PHY_CFG_PLL_FB_DIV_7_0_MASK GENMASK(7, 0) +#define DIV_7_0_19_2_MHZ_VAL (0x90) +#define DIV_7_0_38_4_MHZ_VAL (0xc8) + +#define QCOM_USB_PHY_CFG_CTRL_3 (0x60) +#define PHY_CFG_PLL_FB_DIV_11_8_MASK GENMASK(3, 0) +#define DIV_11_8_19_2_MHZ_VAL (0x1) +#define DIV_11_8_38_4_MHZ_VAL (0x0) + +#define PHY_CFG_PLL_REF_DIV GENMASK(7, 4) +#define PLL_REF_DIV_VAL (0x0) + +#define QCOM_USB_PHY_HS_PHY_CTRL2 (0x64) +#define VBUSVLDEXT0 BIT(0) +#define USB2_SUSPEND_N BIT(2) +#define USB2_SUSPEND_N_SEL BIT(3) +#define VBUS_DET_EXT_SEL BIT(4) + +#define QCOM_USB_PHY_CFG_CTRL_4 (0x68) +#define PHY_CFG_PLL_GMP_CNTRL_MASK GENMASK(1, 0) +#define PHY_CFG_PLL_INT_CNTRL_MASK GENMASK(7, 2) + +#define QCOM_USB_PHY_CFG_CTRL_5 (0x6c) +#define PHY_CFG_PLL_PROP_CNTRL_MASK GENMASK(4, 0) +#define PHY_CFG_PLL_VREF_TUNE_MASK GENMASK(7, 6) + +#define QCOM_USB_PHY_CFG_CTRL_6 (0x70) +#define PHY_CFG_PLL_VCO_CNTRL_MASK GENMASK(2, 0) + +#define QCOM_USB_PHY_CFG_CTRL_7 (0x74) + +#define QCOM_USB_PHY_CFG_CTRL_8 (0x78) +#define PHY_CFG_TX_FSLS_VREF_TUNE_MASK GENMASK(1, 0) +#define PHY_CFG_TX_FSLS_VREG_BYPASS BIT(2) +#define PHY_CFG_TX_HS_VREF_TUNE_MASK GENMASK(5, 3) +#define PHY_CFG_TX_HS_XV_TUNE_MASK GENMASK(7, 6) + +#define QCOM_USB_PHY_CFG_CTRL_9 (0x7c) +#define PHY_CFG_TX_PREEMP_TUNE_MASK GENMASK(2, 0) +#define PHY_CFG_TX_RES_TUNE_MASK GENMASK(4, 3) +#define PHY_CFG_TX_RISE_TUNE_MASK GENMASK(6, 5) +#define PHY_CFG_RCAL_BYPASS BIT(7) + +#define QCOM_USB_PHY_CFG_CTRL_10 (0x80) + +#define QCOM_USB_PHY_CFG0 (0x94) +#define DATAPATH_CTRL_OVERRIDE_EN BIT(0) +#define CMN_CTRL_OVERRIDE_EN BIT(1) + +#define QCOM_UTMI_PHY_CMN_CTRL0 (0x98) +#define TESTBURNIN BIT(6) + +#define QCOM_USB_PHY_FSEL_SEL (0xb8) +#define FSEL_SEL BIT(0) + +#define QCOM_USB_PHY_APB_ACCESS_CMD (0x130) +#define RW_ACCESS BIT(0) +#define APB_START_CMD BIT(1) +#define APB_LOGIC_RESET BIT(2) + +#define QCOM_USB_PHY_APB_ACCESS_STATUS (0x134) +#define ACCESS_DONE BIT(0) +#define TIMED_OUT BIT(1) +#define ACCESS_ERROR BIT(2) +#define ACCESS_IN_PROGRESS BIT(3) + +#define QCOM_USB_PHY_APB_ADDRESS (0x138) +#define APB_REG_ADDR_MASK GENMASK(7, 0) + +#define QCOM_USB_PHY_APB_WRDATA_LSB (0x13c) +#define APB_REG_WRDATA_7_0_MASK GENMASK(3, 0) + +#define QCOM_USB_PHY_APB_WRDATA_MSB (0x140) +#define APB_REG_WRDATA_15_8_MASK GENMASK(7, 4) + +#define QCOM_USB_PHY_APB_RDDATA_LSB (0x144) +#define APB_REG_RDDATA_7_0_MASK GENMASK(3, 0) + +#define QCOM_USB_PHY_APB_RDDATA_MSB (0x148) +#define APB_REG_RDDATA_15_8_MASK GENMASK(7, 4) + +static const char * const eusb2_hsphy_vreg_names[] = { + "vdd", "vdda12", +}; + +#define EUSB2_NUM_VREGS ARRAY_SIZE(eusb2_hsphy_vreg_names) + +struct snps_eusb2_phy_drvdata { + int (*phy_init)(struct phy *p); + const char * const *clk_names; + int num_clks; +}; + +struct snps_eusb2_hsphy { + struct phy *phy; + void __iomem *base; + + struct clk *ref_clk; + struct clk_bulk_data *clks; + + struct reset_control *phy_reset; + + struct regulator_bulk_data vregs[EUSB2_NUM_VREGS]; + + enum phy_mode mode; + + struct phy *repeater; + + const struct snps_eusb2_phy_drvdata *data; +}; + +static int snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode) +{ + struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); + + phy->mode = mode; + + return phy_set_mode_ext(phy->repeater, mode, submode); +} + +static void snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset, + u32 mask, u32 val) +{ + u32 reg; + + reg = readl_relaxed(base + offset); + reg &= ~mask; + reg |= val & mask; + writel_relaxed(reg, base + offset); + + /* Ensure above write is completed */ + readl_relaxed(base + offset); +} + +static void qcom_eusb2_default_parameters(struct snps_eusb2_hsphy *phy) +{ + /* default parameters: tx pre-emphasis */ + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_PREEMP_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_PREEMP_TUNE_MASK, 0)); + + /* tx rise/fall time */ + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_RISE_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_RISE_TUNE_MASK, 0x2)); + + /* source impedance adjustment */ + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_9, + PHY_CFG_TX_RES_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_RES_TUNE_MASK, 0x1)); + + /* dc voltage level adjustement */ + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_8, + PHY_CFG_TX_HS_VREF_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_HS_VREF_TUNE_MASK, 0x3)); + + /* transmitter HS crossover adjustement */ + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_8, + PHY_CFG_TX_HS_XV_TUNE_MASK, + FIELD_PREP(PHY_CFG_TX_HS_XV_TUNE_MASK, 0x0)); +} + +static int qcom_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) +{ + unsigned long ref_clk_freq = clk_get_rate(phy->ref_clk); + + switch (ref_clk_freq) { + case 19200000: + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL_COMMON0, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_19_2_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_2, + PHY_CFG_PLL_FB_DIV_7_0_MASK, + DIV_7_0_19_2_MHZ_VAL); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_FB_DIV_11_8_MASK, + DIV_11_8_19_2_MHZ_VAL); + break; + + case 38400000: + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL_COMMON0, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_38_4_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_2, + PHY_CFG_PLL_FB_DIV_7_0_MASK, + DIV_7_0_38_4_MHZ_VAL); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_FB_DIV_11_8_MASK, + DIV_11_8_38_4_MHZ_VAL); + break; + + default: + dev_err(&phy->phy->dev, "unsupported ref_clk_freq:%lu\n", ref_clk_freq); + return -EINVAL; + } + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_3, + PHY_CFG_PLL_REF_DIV, PLL_REF_DIV_VAL); + + return 0; +} + +static int qcom_snps_eusb2_hsphy_init(struct phy *p) +{ + struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); + int ret; + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG0, + CMN_CTRL_OVERRIDE_EN, CMN_CTRL_OVERRIDE_EN); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_UTMI_CTRL5, POR, POR); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL_COMMON0, + PHY_ENABLE | RETENABLEN, PHY_ENABLE | RETENABLEN); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_APB_ACCESS_CMD, + APB_LOGIC_RESET, APB_LOGIC_RESET); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_UTMI_PHY_CMN_CTRL0, TESTBURNIN, 0); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_FSEL_SEL, + FSEL_SEL, FSEL_SEL); + + /* update ref_clk related registers */ + ret = qcom_eusb2_ref_clk_init(phy); + if (ret) + return ret; + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_1, + PHY_CFG_PLL_CPBIAS_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_CPBIAS_CNTRL_MASK, 0x1)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_4, + PHY_CFG_PLL_INT_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_INT_CNTRL_MASK, 0x8)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_4, + PHY_CFG_PLL_GMP_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_GMP_CNTRL_MASK, 0x1)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_5, + PHY_CFG_PLL_PROP_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_PROP_CNTRL_MASK, 0x10)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_6, + PHY_CFG_PLL_VCO_CNTRL_MASK, + FIELD_PREP(PHY_CFG_PLL_VCO_CNTRL_MASK, 0x0)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_CFG_CTRL_5, + PHY_CFG_PLL_VREF_TUNE_MASK, + FIELD_PREP(PHY_CFG_PLL_VREF_TUNE_MASK, 0x1)); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL2, + VBUS_DET_EXT_SEL, VBUS_DET_EXT_SEL); + + /* set default parameters */ + qcom_eusb2_default_parameters(phy); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL2, + USB2_SUSPEND_N_SEL | USB2_SUSPEND_N, + USB2_SUSPEND_N_SEL | USB2_SUSPEND_N); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_UTMI_CTRL0, SLEEPM, SLEEPM); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL_COMMON0, + SIDDQ_SEL, SIDDQ_SEL); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL_COMMON0, + SIDDQ, 0); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_UTMI_CTRL5, POR, 0); + + snps_eusb2_hsphy_write_mask(phy->base, QCOM_USB_PHY_HS_PHY_CTRL2, + USB2_SUSPEND_N_SEL, 0); + + return 0; +} + +static const char * const qcom_eusb2_hsphy_clock_names[] = { + "ref", +}; + +static const struct snps_eusb2_phy_drvdata sm8550_snps_eusb2_phy = { + .phy_init = qcom_snps_eusb2_hsphy_init, + .clk_names = qcom_eusb2_hsphy_clock_names, + .num_clks = ARRAY_SIZE(qcom_eusb2_hsphy_clock_names), +}; + +static int snps_eusb2_hsphy_init(struct phy *p) +{ + struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(phy->vregs), phy->vregs); + if (ret) + return ret; + + ret = phy_init(phy->repeater); + if (ret) { + dev_err(&p->dev, "repeater init failed. %d\n", ret); + goto disable_vreg; + } + + ret = clk_prepare_enable(phy->ref_clk); + if (ret) { + dev_err(&p->dev, "failed to enable ref clock, %d\n", ret); + goto disable_vreg; + } + + ret = reset_control_assert(phy->phy_reset); + if (ret) { + dev_err(&p->dev, "failed to assert phy_reset, %d\n", ret); + goto disable_ref_clk; + } + + usleep_range(100, 150); + + ret = reset_control_deassert(phy->phy_reset); + if (ret) { + dev_err(&p->dev, "failed to de-assert phy_reset, %d\n", ret); + goto disable_ref_clk; + } + + ret = phy->data->phy_init(p); + if (ret) + goto disable_ref_clk; + + return 0; + +disable_ref_clk: + clk_disable_unprepare(phy->ref_clk); + +disable_vreg: + regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); + + return ret; +} + +static int snps_eusb2_hsphy_exit(struct phy *p) +{ + struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); + + clk_disable_unprepare(phy->ref_clk); + + regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); + + phy_exit(phy->repeater); + + return 0; +} + +static const struct phy_ops snps_eusb2_hsphy_ops = { + .init = snps_eusb2_hsphy_init, + .exit = snps_eusb2_hsphy_exit, + .set_mode = snps_eusb2_hsphy_set_mode, + .owner = THIS_MODULE, +}; + +static int snps_eusb2_hsphy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct snps_eusb2_hsphy *phy; + struct phy_provider *phy_provider; + struct phy *generic_phy; + const struct snps_eusb2_phy_drvdata *drv_data; + int ret, i; + int num; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + drv_data = of_device_get_match_data(dev); + if (!drv_data) + return -EINVAL; + phy->data = drv_data; + + phy->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(phy->base)) + return PTR_ERR(phy->base); + + phy->phy_reset = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(phy->phy_reset)) + return PTR_ERR(phy->phy_reset); + + phy->clks = devm_kcalloc(dev, + phy->data->num_clks, + sizeof(*phy->clks), + GFP_KERNEL); + if (!phy->clks) + return -ENOMEM; + + for (int i = 0; i < phy->data->num_clks; ++i) + phy->clks[i].id = phy->data->clk_names[i]; + + ret = devm_clk_bulk_get(dev, phy->data->num_clks, + phy->clks); + if (ret) + return dev_err_probe(dev, ret, + "failed to get phy clock(s)\n"); + + phy->ref_clk = NULL; + for (int i = 0; i < phy->data->num_clks; ++i) { + if (!strcmp(phy->clks[i].id, "ref")) { + phy->ref_clk = phy->clks[i].clk; + break; + } + } + + if (IS_ERR_OR_NULL(phy->ref_clk)) + return dev_err_probe(dev, PTR_ERR(phy->ref_clk), + "failed to get ref clk\n"); + + num = ARRAY_SIZE(phy->vregs); + for (i = 0; i < num; i++) + phy->vregs[i].supply = eusb2_hsphy_vreg_names[i]; + + ret = devm_regulator_bulk_get(dev, num, phy->vregs); + if (ret) + return dev_err_probe(dev, ret, + "failed to get regulator supplies\n"); + + phy->repeater = devm_of_phy_get_by_index(dev, np, 0); + if (IS_ERR(phy->repeater)) + return dev_err_probe(dev, PTR_ERR(phy->repeater), + "failed to get repeater\n"); + + generic_phy = devm_phy_create(dev, NULL, &snps_eusb2_hsphy_ops); + if (IS_ERR(generic_phy)) { + dev_err(dev, "failed to create phy %d\n", ret); + return PTR_ERR(generic_phy); + } + + dev_set_drvdata(dev, phy); + phy_set_drvdata(generic_phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return PTR_ERR(phy_provider); + + dev_info(dev, "Registered Snps-eUSB2 phy\n"); + + return 0; +} + +static const struct of_device_id snps_eusb2_hsphy_of_match_table[] = { + { + .compatible = "qcom,sm8550-snps-eusb2-phy", + .data = &sm8550_snps_eusb2_phy, + }, { }, +}; +MODULE_DEVICE_TABLE(of, snps_eusb2_hsphy_of_match_table); + +static struct platform_driver snps_eusb2_hsphy_driver = { + .probe = snps_eusb2_hsphy_probe, + .driver = { + .name = "snps-eusb2-hsphy", + .of_match_table = snps_eusb2_hsphy_of_match_table, + }, +}; + +module_platform_driver(snps_eusb2_hsphy_driver); +MODULE_DESCRIPTION("SNPS eUSB2 HS PHY driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/phy/qualcomm/Kconfig b/drivers/phy/qualcomm/Kconfig index 846f8c995..914547068 100644 --- a/drivers/phy/qualcomm/Kconfig +++ b/drivers/phy/qualcomm/Kconfig @@ -125,15 +125,6 @@ config PHY_QCOM_QUSB2 PHY which is usually paired with either the ChipIdea or Synopsys DWC3 USB IPs on MSM SOCs. -config PHY_QCOM_SNPS_EUSB2 - tristate "Qualcomm SNPS eUSB2 PHY Driver" - depends on OF && (ARCH_QCOM || COMPILE_TEST) - select GENERIC_PHY - help - Enable support for the USB high-speed SNPS eUSB2 phy on Qualcomm - chipsets. The PHY is paired with a Synopsys DWC3 USB controller - on Qualcomm SOCs. - config PHY_QCOM_EUSB2_REPEATER tristate "Qualcomm SNPS eUSB2 Repeater Driver" depends on OF && (ARCH_QCOM || COMPILE_TEST) diff --git a/drivers/phy/qualcomm/Makefile b/drivers/phy/qualcomm/Makefile index eb60e950a..2121e92df 100644 --- a/drivers/phy/qualcomm/Makefile +++ b/drivers/phy/qualcomm/Makefile @@ -15,7 +15,6 @@ obj-$(CONFIG_PHY_QCOM_QMP_USB) += phy-qcom-qmp-usb.o obj-$(CONFIG_PHY_QCOM_QMP_USB_LEGACY) += phy-qcom-qmp-usb-legacy.o obj-$(CONFIG_PHY_QCOM_QUSB2) += phy-qcom-qusb2.o -obj-$(CONFIG_PHY_QCOM_SNPS_EUSB2) += phy-qcom-snps-eusb2.o obj-$(CONFIG_PHY_QCOM_EUSB2_REPEATER) += phy-qcom-eusb2-repeater.o obj-$(CONFIG_PHY_QCOM_USB_HS) += phy-qcom-usb-hs.o obj-$(CONFIG_PHY_QCOM_USB_HSIC) += phy-qcom-usb-hsic.o diff --git a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c b/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c deleted file mode 100644 index 1484691a4..000000000 --- a/drivers/phy/qualcomm/phy-qcom-snps-eusb2.c +++ /dev/null @@ -1,442 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2023, Linaro Limited - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USB_PHY_UTMI_CTRL0 (0x3c) -#define SLEEPM BIT(0) -#define OPMODE_MASK GENMASK(4, 3) -#define OPMODE_NONDRIVING BIT(3) - -#define USB_PHY_UTMI_CTRL5 (0x50) -#define POR BIT(1) - -#define USB_PHY_HS_PHY_CTRL_COMMON0 (0x54) -#define PHY_ENABLE BIT(0) -#define SIDDQ_SEL BIT(1) -#define SIDDQ BIT(2) -#define RETENABLEN BIT(3) -#define FSEL_MASK GENMASK(6, 4) -#define FSEL_19_2_MHZ_VAL (0x0) -#define FSEL_38_4_MHZ_VAL (0x4) - -#define USB_PHY_CFG_CTRL_1 (0x58) -#define PHY_CFG_PLL_CPBIAS_CNTRL_MASK GENMASK(7, 1) - -#define USB_PHY_CFG_CTRL_2 (0x5c) -#define PHY_CFG_PLL_FB_DIV_7_0_MASK GENMASK(7, 0) -#define DIV_7_0_19_2_MHZ_VAL (0x90) -#define DIV_7_0_38_4_MHZ_VAL (0xc8) - -#define USB_PHY_CFG_CTRL_3 (0x60) -#define PHY_CFG_PLL_FB_DIV_11_8_MASK GENMASK(3, 0) -#define DIV_11_8_19_2_MHZ_VAL (0x1) -#define DIV_11_8_38_4_MHZ_VAL (0x0) - -#define PHY_CFG_PLL_REF_DIV GENMASK(7, 4) -#define PLL_REF_DIV_VAL (0x0) - -#define USB_PHY_HS_PHY_CTRL2 (0x64) -#define VBUSVLDEXT0 BIT(0) -#define USB2_SUSPEND_N BIT(2) -#define USB2_SUSPEND_N_SEL BIT(3) -#define VBUS_DET_EXT_SEL BIT(4) - -#define USB_PHY_CFG_CTRL_4 (0x68) -#define PHY_CFG_PLL_GMP_CNTRL_MASK GENMASK(1, 0) -#define PHY_CFG_PLL_INT_CNTRL_MASK GENMASK(7, 2) - -#define USB_PHY_CFG_CTRL_5 (0x6c) -#define PHY_CFG_PLL_PROP_CNTRL_MASK GENMASK(4, 0) -#define PHY_CFG_PLL_VREF_TUNE_MASK GENMASK(7, 6) - -#define USB_PHY_CFG_CTRL_6 (0x70) -#define PHY_CFG_PLL_VCO_CNTRL_MASK GENMASK(2, 0) - -#define USB_PHY_CFG_CTRL_7 (0x74) - -#define USB_PHY_CFG_CTRL_8 (0x78) -#define PHY_CFG_TX_FSLS_VREF_TUNE_MASK GENMASK(1, 0) -#define PHY_CFG_TX_FSLS_VREG_BYPASS BIT(2) -#define PHY_CFG_TX_HS_VREF_TUNE_MASK GENMASK(5, 3) -#define PHY_CFG_TX_HS_XV_TUNE_MASK GENMASK(7, 6) - -#define USB_PHY_CFG_CTRL_9 (0x7c) -#define PHY_CFG_TX_PREEMP_TUNE_MASK GENMASK(2, 0) -#define PHY_CFG_TX_RES_TUNE_MASK GENMASK(4, 3) -#define PHY_CFG_TX_RISE_TUNE_MASK GENMASK(6, 5) -#define PHY_CFG_RCAL_BYPASS BIT(7) - -#define USB_PHY_CFG_CTRL_10 (0x80) - -#define USB_PHY_CFG0 (0x94) -#define DATAPATH_CTRL_OVERRIDE_EN BIT(0) -#define CMN_CTRL_OVERRIDE_EN BIT(1) - -#define UTMI_PHY_CMN_CTRL0 (0x98) -#define TESTBURNIN BIT(6) - -#define USB_PHY_FSEL_SEL (0xb8) -#define FSEL_SEL BIT(0) - -#define USB_PHY_APB_ACCESS_CMD (0x130) -#define RW_ACCESS BIT(0) -#define APB_START_CMD BIT(1) -#define APB_LOGIC_RESET BIT(2) - -#define USB_PHY_APB_ACCESS_STATUS (0x134) -#define ACCESS_DONE BIT(0) -#define TIMED_OUT BIT(1) -#define ACCESS_ERROR BIT(2) -#define ACCESS_IN_PROGRESS BIT(3) - -#define USB_PHY_APB_ADDRESS (0x138) -#define APB_REG_ADDR_MASK GENMASK(7, 0) - -#define USB_PHY_APB_WRDATA_LSB (0x13c) -#define APB_REG_WRDATA_7_0_MASK GENMASK(3, 0) - -#define USB_PHY_APB_WRDATA_MSB (0x140) -#define APB_REG_WRDATA_15_8_MASK GENMASK(7, 4) - -#define USB_PHY_APB_RDDATA_LSB (0x144) -#define APB_REG_RDDATA_7_0_MASK GENMASK(3, 0) - -#define USB_PHY_APB_RDDATA_MSB (0x148) -#define APB_REG_RDDATA_15_8_MASK GENMASK(7, 4) - -static const char * const eusb2_hsphy_vreg_names[] = { - "vdd", "vdda12", -}; - -#define EUSB2_NUM_VREGS ARRAY_SIZE(eusb2_hsphy_vreg_names) - -struct qcom_snps_eusb2_hsphy { - struct phy *phy; - void __iomem *base; - - struct clk *ref_clk; - struct reset_control *phy_reset; - - struct regulator_bulk_data vregs[EUSB2_NUM_VREGS]; - - enum phy_mode mode; - - struct phy *repeater; -}; - -static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode) -{ - struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); - - phy->mode = mode; - - return phy_set_mode_ext(phy->repeater, mode, submode); -} - -static void qcom_snps_eusb2_hsphy_write_mask(void __iomem *base, u32 offset, - u32 mask, u32 val) -{ - u32 reg; - - reg = readl_relaxed(base + offset); - reg &= ~mask; - reg |= val & mask; - writel_relaxed(reg, base + offset); - - /* Ensure above write is completed */ - readl_relaxed(base + offset); -} - -static void qcom_eusb2_default_parameters(struct qcom_snps_eusb2_hsphy *phy) -{ - /* default parameters: tx pre-emphasis */ - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, - PHY_CFG_TX_PREEMP_TUNE_MASK, - FIELD_PREP(PHY_CFG_TX_PREEMP_TUNE_MASK, 0)); - - /* tx rise/fall time */ - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, - PHY_CFG_TX_RISE_TUNE_MASK, - FIELD_PREP(PHY_CFG_TX_RISE_TUNE_MASK, 0x2)); - - /* source impedance adjustment */ - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, - PHY_CFG_TX_RES_TUNE_MASK, - FIELD_PREP(PHY_CFG_TX_RES_TUNE_MASK, 0x1)); - - /* dc voltage level adjustement */ - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_8, - PHY_CFG_TX_HS_VREF_TUNE_MASK, - FIELD_PREP(PHY_CFG_TX_HS_VREF_TUNE_MASK, 0x3)); - - /* transmitter HS crossover adjustement */ - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_8, - PHY_CFG_TX_HS_XV_TUNE_MASK, - FIELD_PREP(PHY_CFG_TX_HS_XV_TUNE_MASK, 0x0)); -} - -static int qcom_eusb2_ref_clk_init(struct qcom_snps_eusb2_hsphy *phy) -{ - unsigned long ref_clk_freq = clk_get_rate(phy->ref_clk); - - switch (ref_clk_freq) { - case 19200000: - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, - FSEL_MASK, - FIELD_PREP(FSEL_MASK, FSEL_19_2_MHZ_VAL)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_2, - PHY_CFG_PLL_FB_DIV_7_0_MASK, - DIV_7_0_19_2_MHZ_VAL); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, - PHY_CFG_PLL_FB_DIV_11_8_MASK, - DIV_11_8_19_2_MHZ_VAL); - break; - - case 38400000: - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, - FSEL_MASK, - FIELD_PREP(FSEL_MASK, FSEL_38_4_MHZ_VAL)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_2, - PHY_CFG_PLL_FB_DIV_7_0_MASK, - DIV_7_0_38_4_MHZ_VAL); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, - PHY_CFG_PLL_FB_DIV_11_8_MASK, - DIV_11_8_38_4_MHZ_VAL); - break; - - default: - dev_err(&phy->phy->dev, "unsupported ref_clk_freq:%lu\n", ref_clk_freq); - return -EINVAL; - } - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, - PHY_CFG_PLL_REF_DIV, PLL_REF_DIV_VAL); - - return 0; -} - -static int qcom_snps_eusb2_hsphy_init(struct phy *p) -{ - struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); - int ret; - - ret = regulator_bulk_enable(ARRAY_SIZE(phy->vregs), phy->vregs); - if (ret) - return ret; - - ret = phy_init(phy->repeater); - if (ret) { - dev_err(&p->dev, "repeater init failed. %d\n", ret); - goto disable_vreg; - } - - ret = clk_prepare_enable(phy->ref_clk); - if (ret) { - dev_err(&p->dev, "failed to enable ref clock, %d\n", ret); - goto disable_vreg; - } - - ret = reset_control_assert(phy->phy_reset); - if (ret) { - dev_err(&p->dev, "failed to assert phy_reset, %d\n", ret); - goto disable_ref_clk; - } - - usleep_range(100, 150); - - ret = reset_control_deassert(phy->phy_reset); - if (ret) { - dev_err(&p->dev, "failed to de-assert phy_reset, %d\n", ret); - goto disable_ref_clk; - } - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG0, - CMN_CTRL_OVERRIDE_EN, CMN_CTRL_OVERRIDE_EN); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL5, POR, POR); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, - PHY_ENABLE | RETENABLEN, PHY_ENABLE | RETENABLEN); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_APB_ACCESS_CMD, - APB_LOGIC_RESET, APB_LOGIC_RESET); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, UTMI_PHY_CMN_CTRL0, TESTBURNIN, 0); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_FSEL_SEL, - FSEL_SEL, FSEL_SEL); - - /* update ref_clk related registers */ - ret = qcom_eusb2_ref_clk_init(phy); - if (ret) - goto disable_ref_clk; - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_1, - PHY_CFG_PLL_CPBIAS_CNTRL_MASK, - FIELD_PREP(PHY_CFG_PLL_CPBIAS_CNTRL_MASK, 0x1)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_4, - PHY_CFG_PLL_INT_CNTRL_MASK, - FIELD_PREP(PHY_CFG_PLL_INT_CNTRL_MASK, 0x8)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_4, - PHY_CFG_PLL_GMP_CNTRL_MASK, - FIELD_PREP(PHY_CFG_PLL_GMP_CNTRL_MASK, 0x1)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_5, - PHY_CFG_PLL_PROP_CNTRL_MASK, - FIELD_PREP(PHY_CFG_PLL_PROP_CNTRL_MASK, 0x10)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_6, - PHY_CFG_PLL_VCO_CNTRL_MASK, - FIELD_PREP(PHY_CFG_PLL_VCO_CNTRL_MASK, 0x0)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_5, - PHY_CFG_PLL_VREF_TUNE_MASK, - FIELD_PREP(PHY_CFG_PLL_VREF_TUNE_MASK, 0x1)); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, - VBUS_DET_EXT_SEL, VBUS_DET_EXT_SEL); - - /* set default parameters */ - qcom_eusb2_default_parameters(phy); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, - USB2_SUSPEND_N_SEL | USB2_SUSPEND_N, - USB2_SUSPEND_N_SEL | USB2_SUSPEND_N); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL0, SLEEPM, SLEEPM); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, - SIDDQ_SEL, SIDDQ_SEL); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, - SIDDQ, 0); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL5, POR, 0); - - qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, - USB2_SUSPEND_N_SEL, 0); - - return 0; - -disable_ref_clk: - clk_disable_unprepare(phy->ref_clk); - -disable_vreg: - regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); - - return ret; -} - -static int qcom_snps_eusb2_hsphy_exit(struct phy *p) -{ - struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); - - clk_disable_unprepare(phy->ref_clk); - - regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); - - phy_exit(phy->repeater); - - return 0; -} - -static const struct phy_ops qcom_snps_eusb2_hsphy_ops = { - .init = qcom_snps_eusb2_hsphy_init, - .exit = qcom_snps_eusb2_hsphy_exit, - .set_mode = qcom_snps_eusb2_hsphy_set_mode, - .owner = THIS_MODULE, -}; - -static int qcom_snps_eusb2_hsphy_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; - struct qcom_snps_eusb2_hsphy *phy; - struct phy_provider *phy_provider; - struct phy *generic_phy; - int ret, i; - int num; - - phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); - if (!phy) - return -ENOMEM; - - phy->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(phy->base)) - return PTR_ERR(phy->base); - - phy->phy_reset = devm_reset_control_get_exclusive(dev, NULL); - if (IS_ERR(phy->phy_reset)) - return PTR_ERR(phy->phy_reset); - - phy->ref_clk = devm_clk_get(dev, "ref"); - if (IS_ERR(phy->ref_clk)) - return dev_err_probe(dev, PTR_ERR(phy->ref_clk), - "failed to get ref clk\n"); - - num = ARRAY_SIZE(phy->vregs); - for (i = 0; i < num; i++) - phy->vregs[i].supply = eusb2_hsphy_vreg_names[i]; - - ret = devm_regulator_bulk_get(dev, num, phy->vregs); - if (ret) - return dev_err_probe(dev, ret, - "failed to get regulator supplies\n"); - - phy->repeater = devm_of_phy_get_by_index(dev, np, 0); - if (IS_ERR(phy->repeater)) - return dev_err_probe(dev, PTR_ERR(phy->repeater), - "failed to get repeater\n"); - - generic_phy = devm_phy_create(dev, NULL, &qcom_snps_eusb2_hsphy_ops); - if (IS_ERR(generic_phy)) { - dev_err(dev, "failed to create phy %d\n", ret); - return PTR_ERR(generic_phy); - } - - dev_set_drvdata(dev, phy); - phy_set_drvdata(generic_phy, phy); - - phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); - if (IS_ERR(phy_provider)) - return PTR_ERR(phy_provider); - - dev_info(dev, "Registered Qcom-eUSB2 phy\n"); - - return 0; -} - -static const struct of_device_id qcom_snps_eusb2_hsphy_of_match_table[] = { - { .compatible = "qcom,sm8550-snps-eusb2-phy", }, - { }, -}; -MODULE_DEVICE_TABLE(of, qcom_snps_eusb2_hsphy_of_match_table); - -static struct platform_driver qcom_snps_eusb2_hsphy_driver = { - .probe = qcom_snps_eusb2_hsphy_probe, - .driver = { - .name = "qcom-snps-eusb2-hsphy", - .of_match_table = qcom_snps_eusb2_hsphy_of_match_table, - }, -}; - -module_platform_driver(qcom_snps_eusb2_hsphy_driver); -MODULE_DESCRIPTION("Qualcomm SNPS eUSB2 HS PHY driver"); -MODULE_LICENSE("GPL"); From patchwork Sun Feb 23 12:22:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987024 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 C7C2FC021B3 for ; Sun, 23 Feb 2025 12:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z0wQhVsHeKChXXBl+h2UsEWEersbr5rCyfY+lWbHqbE=; b=CM1JkKjB2DwonmpL+jirZ9irGQ xiQSNawW5mwo7J+uItm145HgvR5dkgcNS8P2Zw0nkcp71WmQl7uTY5KDGUDQj5Bqn0IBenv0BNtxh TKwGB1gKChX0XVMaect9k7s4BA7X00KAJbEmuEHuRFJD1q/M5Zzr9ZJWjVtd7fiWPx7Y23sUa2k47 AbuHa3UFltqU+/MR4huthjF7bMdXakqQwtfMkv9EJ+BVGYAS9Uyj4iIZ927xD1z8kwY9+/pKMj/+6 5Dk/Sv60CjN/omqV16N70GmmsA8TRdgSdAJWHVS6XTsYX/HNNXtzOHNd3IUTDwPToeHMzdZ1IbbuW X2uW9rwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmB8w-0000000B6J2-1Efd; Sun, 23 Feb 2025 12:31:34 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0J-0000000B4s7-0jxB; Sun, 23 Feb 2025 12:22:40 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-439350f1a0bso20681855e9.0; Sun, 23 Feb 2025 04:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313357; x=1740918157; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z0wQhVsHeKChXXBl+h2UsEWEersbr5rCyfY+lWbHqbE=; b=hno8D7DrTc2KXniycq/eXrMFpHAfFfbozCKS4JUADogtjJ3wUazx9uSu/+vUA8w9kF PvQFrmwt7LA2O/HRQ9llLQ9EB9xTOunn3hXYxWC7vONOT7gaPkMDk3VJS9rgaKS86kaf 1mioZJ+ZkZ2hn2fTLJNQshbBMLbollhicLPC5ElGOa0XgNQu/67s/VHD/cRMI/IHgNmH mMjzyLTzk0q4KRFVpANXeAUOvy7KlFQiwA9sGvaod1oa8l7LjgL9B7E24V9C/QM7dW31 SumaGtjjSKy2yu5ef/YQluC+9YiTfKx5VRV9bqqMVaWz0b/GcZaUAfN0kKlsGXzf//Fs kxog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313357; x=1740918157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z0wQhVsHeKChXXBl+h2UsEWEersbr5rCyfY+lWbHqbE=; b=hjpmEag5y2/eFHmpKV4CuOXLxF4hbAAYKx6rEzlEI2ngQOsGkNMO1U9BBUKqzpl9sD +GJBk9F+GNxHFQmGyO3M6dQ5poHY5RvLQyQXWSK3VU+0GvQsDmb9eLuuU+vEtdHpURNa 8jFiUDAtmR+74i5tg8LWfPHFCy7C2qc4trIbCo36E5KBigbdDQLcuE+LXD7P0kwkvg7/ iulnYQElVfqDRrzJCPccPKJRKjeWBLn13teM83OReX91NImHVDn0ejuHs/RBRZam8+Lx LBD2Izhtl5wR1QEJ3CFazu3CR2Erq/XlrOm5khU7T5qR2dJKcDsevdoZYSkJLVjmwYZA 9Dmw== X-Forwarded-Encrypted: i=1; AJvYcCUqWs8lJWZGiaK3zz5u+NudyULrV3Z91/EwWFPsAB2VgdJX2U0KAV8iLh/hvWwItHxL0DiP5st84seo@lists.infradead.org, AJvYcCVPCfXFajIekDA8Xgp/RjhTv00qk9TeU37TwuQy76Zv1F9+36pVTCsRzKUJbnQ3smcODSAhdeuGwV0jxKE0Ct7K@lists.infradead.org X-Gm-Message-State: AOJu0YwdJrtpGsk14lN0MhoIBX01WJd0UgGcFyFHJ0l1+iLe/qE/KEj8 LnQg91liGizNCbbD3RQ/rYXemTzrVZamgZZFB5NqSpi1WjDWnYIH X-Gm-Gg: ASbGncvHfO636kUML1TIJaW+ze2f0gbVtf1WqVj3zw0NE+UjwOSygRgxMIv0zFDMs9e dyKPyy7chFZOz0vKQ/BYN4p8WQ+SiZCLSQaolZ/HpKnEEu75265PlRW8P2aSABIS+9fpswpSrDn +hZGiHXsNYWyGL4+BDgHkQ2YBI/cKgDcbnOA/fagyxbStqGdN05VG74DTSEitD0EhdQEEY3OCCJ HyU68N7R7g8zsoBL1Na85NvfAZ2YCPTXxfFiQ7NLa35w10ehQPtxXiErLTT6j2Pf4Wt4G2zVCMF U//OvCe8RR736r1ezRlbMsf5ma906ZJYBeCVUNA1s/XPgKMzFLjw0/rAbpGFaz3OKU8Kx9QAQwG HGA== X-Google-Smtp-Source: AGHT+IELhxBegLSVK0u+lmVP1P13Q3bXTlowJFOfv8B2pMlO46HBtKWfy8VmtqQKECimk9UdAMZdXw== X-Received: by 2002:a05:600c:4511:b0:439:5f04:4f8d with SMTP id 5b1f17b1804b1-439ae320687mr67074255e9.12.1740313357412; Sun, 23 Feb 2025 04:22:37 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:36 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] phy: phy-snps-eusb2: make repeater optional Date: Sun, 23 Feb 2025 14:22:24 +0200 Message-ID: <20250223122227.725233-6-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042239_532293_AE9A8515 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some platforms initialize their eUSB2 to USB repeater in the previous stage bootloader and leave it in a working state for linux. Make the repeater optional in order to allow for reusing that state until proper repeater drivers are introduced. Signed-off-by: Ivaylo Ivanov --- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-snps-eusb2.c b/drivers/phy/phy-snps-eusb2.c index 4e5914a76..dcc69c00a 100644 --- a/drivers/phy/phy-snps-eusb2.c +++ b/drivers/phy/phy-snps-eusb2.c @@ -461,7 +461,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "failed to get regulator supplies\n"); - phy->repeater = devm_of_phy_get_by_index(dev, np, 0); + phy->repeater = devm_of_phy_optional_get(dev, np, 0); if (IS_ERR(phy->repeater)) return dev_err_probe(dev, PTR_ERR(phy->repeater), "failed to get repeater\n"); From patchwork Sun Feb 23 12:22:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987025 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 E6D48C021B2 for ; Sun, 23 Feb 2025 12:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=C92cg9pDirScfRELIv/SYftxNY7no1Ol/6QVuJ3MiRc=; b=M6zVzMTA95GAmakH5jUcR9ngfC pJ5Buzt/TD9aWaNLNbc5+TDO0WaIjefT/49bAvzIJYZzIeXghkLpdQ8g2GeHAxVXRfdGiObfYsCNj kJHJk5pEfXYh9KqZ0nsoxzDtuYVflRPH9OmTAuTj3aFkMKYwl9FPPykaMhO6fqB7k67nNVDeC+IbI /+tDejciCo/BAYYAVTFhorEi1qjvF1GGy5+5wDdKnHPou8o0Q8s/mYYeh59T3KLx4akgDunVYOMNr eQ0nNPYw8OKPGSa0HUAZpBc4C/o1G0Aiv1IaOTwMM4CkFyUYF3jxNx9s5Z6R9nlrsPUT2llpNQsAe cnH21HAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmBAN-0000000B6X3-1CCp; Sun, 23 Feb 2025 12:33:03 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0K-0000000B4sH-23IX; Sun, 23 Feb 2025 12:22:41 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-38f325ddbc2so2634615f8f.1; Sun, 23 Feb 2025 04:22:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313359; x=1740918159; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C92cg9pDirScfRELIv/SYftxNY7no1Ol/6QVuJ3MiRc=; b=UcQpk3RhuPZmaoErkj28frBL9UQH3VeWMp0aTLGuXldO/X7WL0dbhwXTfskIMRJXwg SOsQH4sepRjmmCnI369GIkcYtYD1WefGdtVacvts7bO3GlkqoAfBKWdSQsM+YRiPx9TG Wqq4Renm5VRcMU4lpkGf/g4iSbc1RyD1+y0uMZ7Tg2r0TdtE8tQf8e+2afiAUsxG7VLo 4H3FSnjryKXBWatiDmLcz81tyc8Fa/5SHcRI0TycoEr8Z3SziPSxrPIGaNngkuWWaMSP 6sYBXLQujEGGoexhA2gDcH28bSRrvbW23iCJNNgJYcYDVU0yMUy4Cqlu+XWk5W4CxmXi 3zNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313359; x=1740918159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C92cg9pDirScfRELIv/SYftxNY7no1Ol/6QVuJ3MiRc=; b=MAbQ6Y3w32oaCqtiIyrz0tvl21gQfCopRqf5dT7TG/2FWmN9sVQTLNEwPASdFYI06k s44GcpGsrBfdmIt8JPHBxDWtWS/nQSVImpT0kSS+wIkljc5LIpgG+dLei3EdCy1rZegt OA2b+vwA8NBDvwK2sNZg9FRAqV9pp4hcqN6W6S72TIMRF08I+WhVq5+8x90BTkrII0vA 2RtlPcbG5bg3AtNjvZ/DWm1cD5yfnT4TTffG7oDcrHyRdj5NcUKAXCkgn7TyTW6Bi9td QV7OU+4mgWRWu5+EAzAbZF0Usm7mz0c7cJL8QbXqSxGo+vTun7Rf2mwOJAOBnIjXis84 dwnQ== X-Forwarded-Encrypted: i=1; AJvYcCUMkQiJffTCCX3+iihg32cs0Piu2WFMVJ5Qh9+LDIy2KqU17D500HeL0woparD39vEfRMngN6I6UzhxrjOTT3GE@lists.infradead.org, AJvYcCV9DpJiW887XQKmtwcyOFQfgFhbFUbr8n/VQzFHu1reeIe9quelYfKhF80yWYMeTbE3EDNzDPpHM5XA@lists.infradead.org X-Gm-Message-State: AOJu0YzgG9i04x760vWiuuFv87IiXQDQUCXAMYVXCfmflCFbq8Q7l5Sn TB/YoADr9fDbsF4GxL6POjUaDiq0rWjlL0dgHn4IUSWCsJy3W63pE7K8hg== X-Gm-Gg: ASbGnct7AT2NVrl2nFT1V228/KfQEMUl3KSHmClDQnZjwfJ9NFQy5XcCyLCEwcPwKlI 3lDW2+1B2Pgx23YlI2yR/4slWUKBhomWxuAsxqxswH1tfGNh0Ls8Mm0kjz4hTtzpQmtKmb0jrJA fmm7FHUUh05iRPAg7BD6YaNOH7k7g2MqF899MxuRn9+hTCDEFQsrXmANe28tubA6dhmsHURRhSe DokBQPJ+Y8QEjqBCrQCt3bvSc6Uy0/1xBB5jqXdMzoe5t2jGXoHz6538F865Drc4SbqydIdx1yS SJ5VcQ5eJymCe8SQnZev2nrQyoQiak5VMmSovvdpna1tNLH9e9qKB8eVHWMwadkW++EglR+Xkg5 f9w== X-Google-Smtp-Source: AGHT+IHD/1fKxNbRJHEqjlek+14p9mn6PKTF//azfEyhIr2/+Ub8gP0MUCWd/hcqjMmdh1I7H/WIww== X-Received: by 2002:a5d:5850:0:b0:38f:2030:7da9 with SMTP id ffacd0b85a97d-38f707b0b87mr8586440f8f.28.1740313358741; Sun, 23 Feb 2025 04:22:38 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:38 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] phy: phy-snps-eusb2: make reset control optional Date: Sun, 23 Feb 2025 14:22:25 +0200 Message-ID: <20250223122227.725233-7-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042240_524735_A3DA02FE X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some SoCs don't provide explicit reset lines, so make them optional. Signed-off-by: Ivaylo Ivanov --- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-snps-eusb2.c b/drivers/phy/phy-snps-eusb2.c index dcc69c00a..7a242fe32 100644 --- a/drivers/phy/phy-snps-eusb2.c +++ b/drivers/phy/phy-snps-eusb2.c @@ -420,7 +420,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) if (IS_ERR(phy->base)) return PTR_ERR(phy->base); - phy->phy_reset = devm_reset_control_get_exclusive(dev, NULL); + phy->phy_reset = devm_reset_control_get_optional_exclusive(dev, NULL); if (IS_ERR(phy->phy_reset)) return PTR_ERR(phy->phy_reset); From patchwork Sun Feb 23 12:22:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987026 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 676C4C021B2 for ; Sun, 23 Feb 2025 12:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uX6OdJxwETGtTGGkJLPqG+9wSA4petjmxxTURrNfA8Q=; b=xgkdjfzxQH5ZBzojArphD90rmL Yt71VgDfJFeVPvDYZB3gf2YtVJvz3TnY3UNXLQ+fjxpSlLY3IWRcGW7mrTE3FVsZBAnffSmvsegxg 3FO4+nZWNCl5r3K2R6II9LxETzFu2pL9xN+oA1NABxpXfT75CYaTNbNI461SXII/5/lHULaOp9vtr 0Y7OaUXkSVQaoZZP0kshYNYTDgkthzU87WdjBBA8uHI26+halXqCEQNWgeYB9B1OsAfID7Vwsl7Ao WV+FnUtlYKduW9J0rx07wplOHZu2FAaDhC1JR3vhHJ6T6bPHkKWVHyxAqdpD7NXcRwDtJP6zfum4z DvZ2GSZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmBBp-0000000B6h9-0hij; Sun, 23 Feb 2025 12:34:33 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0L-0000000B4t7-3MQw; Sun, 23 Feb 2025 12:22:42 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-38f24fc466aso2679970f8f.2; Sun, 23 Feb 2025 04:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313360; x=1740918160; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uX6OdJxwETGtTGGkJLPqG+9wSA4petjmxxTURrNfA8Q=; b=jXfvPZcpLdPcj6q/oMJNDrWlh2pE4a/Z5wjNPLn9Jxzhq37jo37wMe960lv3Rbwv1c 8VBFeIJPJpFBEzGXd6YXnQ0LX1FPSceTimIYglDAIIsi64mng8iBzQRk9pzi/qoG0/pi AUH6VxUOO0GokngsrAFSmO0+qP9qfMktQ7j6JxbHFdm5sd2zqKXNQ3F6SSP0HZVhtLmj vBqgZ9Hv2bIzvtiz4JxklPxQbkqOaSnJYoMgga8CrBbbM/la+n7zzLGM/lGQjAJBTGEQ bs1llRiLMDvh8nft51ZfR6eTOUoS6AbXMoWQNXKZOagsF7eop6e+klsPXGz5HVZ0HUTK g9zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313360; x=1740918160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uX6OdJxwETGtTGGkJLPqG+9wSA4petjmxxTURrNfA8Q=; b=GSts1yYBtJUHewYWp2SWenrekDog775Cu/R/f0EMuiZBCQLkOq7YwM02YSOmb2oXjh P4P8ZFFa4m+VTOa5K2Ch3qjywFlVHwrE+6YxyiIzNjKogpprBq7ylSBvNvVV4h+1dSDk 70oVDMnbmrEaJIhZvPWQbwamHAcsOZa+Qex53uPiusAuDMjWnx3W8e5Xk8HCSxkA8XwZ EDl61CKBhCwoD8632hm1IF+H1xzw70LmxP3xvmfXefYXE5FsS3bOB3iCa1qFYcSY0Abq XfSZqB+gXXRaJsiaWx8fki2oZ3a89C7IMzyBNRTdmb6+A41YKe/FWiCYcWtnhk2KZX8q Ni1w== X-Forwarded-Encrypted: i=1; AJvYcCWhZOiS9FMq4yVar7tEdlaPjITA/RyNKLY2GnoktYQiWRVTLIvFhqfkP9XFOm+SZkydiFt3xla9JxIh@lists.infradead.org, AJvYcCXeruFn6SPPjfegZYXWKjqE8DFYr+Ijb1UHNDqo04idUuhmRBYl669tuW7xS0ZD6iaNuQDUkeTu5eh8NkbZWEaJ@lists.infradead.org X-Gm-Message-State: AOJu0YwSIr0CWpTKEY0hZwwtRNDYjtFwM2/g3qVyGnu/dehbUE3OV2he rSM/FuFJm7S81JfHa1eMj8LdIGwboxLL6LkO8FZ6IfSm2HcR3rW2rhtYDw== X-Gm-Gg: ASbGncuowCU/TNG20MjmwjI4/h3kJrwPVrUoeqXYRKa0JL2946fctgOZ9ma8YTgQMCV TlD4r6/L/l8F81YL2S4UvxV6KscuKQymL6gGWjNkusE9+b7WZLT0WTNMoQZUlVIdM1oQN5SkmbO z+67WlomBbZ6vHqfkV/Y5LozPYoQTAYOvc0v1vxhXZOjh05DmXdEgjS/WwVguRzeWYX8fPN+Gmg XYpz89I8o6rdLGtzBlwNtg1SrR0H/+M8f/WDWq2riU43GL2Hv9KcyaJxcBe8uxM5lb4l/x9jwyI PzanTIHZPd4xt+s8cl1aENxRZZqqMceJFb3nQz4igMbVSsacQZufdaeNf8X/JhZinoH7qS//Mij cPQ== X-Google-Smtp-Source: AGHT+IGM38Zp+pP6TM93b+qjLZgJemULvP7cowReOHzSCfeBj9XGBP7OMOSTNANHlWJlZmr6UB7gYw== X-Received: by 2002:a05:6000:2a8:b0:38d:d69e:1326 with SMTP id ffacd0b85a97d-38f70783ad2mr7683466f8f.9.1740313360081; Sun, 23 Feb 2025 04:22:40 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:39 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] phy: phy-snps-eusb2: add support for exynos2200 Date: Sun, 23 Feb 2025 14:22:26 +0200 Message-ID: <20250223122227.725233-8-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042241_838125_54BA0CC2 X-CRM114-Status: GOOD ( 15.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Exynos2200 SoC reuses the Synopsis eUSB2 PHY IP, alongside an external repeater, for USB 2.0. Add support for it to the existing driver. Signed-off-by: Ivaylo Ivanov --- drivers/phy/Kconfig | 2 +- drivers/phy/phy-snps-eusb2.c | 172 +++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 11c166204..58c911e1b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -45,7 +45,7 @@ config PHY_PISTACHIO_USB config PHY_SNPS_EUSB2 tristate "SNPS eUSB2 PHY Driver" - depends on OF && (ARCH_QCOM || COMPILE_TEST) + depends on OF && (ARCH_EXYNOS || ARCH_QCOM || COMPILE_TEST) select GENERIC_PHY help Enable support for the USB high-speed SNPS eUSB2 phy on select diff --git a/drivers/phy/phy-snps-eusb2.c b/drivers/phy/phy-snps-eusb2.c index 7a242fe32..67a19d671 100644 --- a/drivers/phy/phy-snps-eusb2.c +++ b/drivers/phy/phy-snps-eusb2.c @@ -13,6 +13,39 @@ #include #include +#define EXYNOS_USB_PHY_HS_PHY_CTRL_RST (0x0) +#define USB_PHY_RST_MASK GENMASK(1, 0) +#define UTMI_PORT_RST_MASK GENMASK(5, 4) + +#define EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON (0x4) +#define RPTR_MODE BIT(10) +#define FSEL_20_MHZ_VAL (0x1) +#define FSEL_24_MHZ_VAL (0x2) +#define FSEL_26_MHZ_VAL (0x3) +#define FSEL_48_MHZ_VAL (0x2) + +#define EXYNOS_USB_PHY_CFG_PLLCFG0 (0x8) +#define PHY_CFG_PLL_FB_DIV_19_8_MASK GENMASK(19, 8) +#define DIV_19_8_19_2_MHZ_VAL (0x170) +#define DIV_19_8_20_MHZ_VAL (0x160) +#define DIV_19_8_24_MHZ_VAL (0x120) +#define DIV_19_8_26_MHZ_VAL (0x107) +#define DIV_19_8_48_MHZ_VAL (0x120) + +#define EXYNOS_USB_PHY_CFG_PLLCFG1 (0xc) +#define EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK GENMASK(11, 8) +#define EXYNOS_DIV_11_8_19_2_MHZ_VAL (0x0) +#define EXYNOS_DIV_11_8_20_MHZ_VAL (0x0) +#define EXYNOS_DIV_11_8_24_MHZ_VAL (0x0) +#define EXYNOS_DIV_11_8_26_MHZ_VAL (0x0) +#define EXYNOS_DIV_11_8_48_MHZ_VAL (0x1) + +#define EXYNOS_PHY_CFG_TX (0x14) +#define EXYNOS_PHY_CFG_TX_FSLS_VREF_TUNE_MASK GENMASK(2, 1) + +#define EXYNOS_USB_PHY_UTMI_TESTSE (0x20) +#define TEST_IDDQ BIT(6) + #define QCOM_USB_PHY_UTMI_CTRL0 (0x3c) #define SLEEPM BIT(0) #define OPMODE_MASK GENMASK(4, 3) @@ -196,6 +229,93 @@ static void qcom_eusb2_default_parameters(struct snps_eusb2_hsphy *phy) FIELD_PREP(PHY_CFG_TX_HS_XV_TUNE_MASK, 0x0)); } +static int exynos_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) +{ + unsigned long ref_clk_freq = clk_get_rate(phy->ref_clk); + + switch (ref_clk_freq) { + case 19200000: + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_19_2_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG0, + PHY_CFG_PLL_FB_DIV_19_8_MASK, + FIELD_PREP(PHY_CFG_PLL_FB_DIV_19_8_MASK, + DIV_19_8_19_2_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG1, + EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK, + EXYNOS_DIV_11_8_19_2_MHZ_VAL); + break; + + case 20000000: + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_20_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG0, + PHY_CFG_PLL_FB_DIV_19_8_MASK, + FIELD_PREP(PHY_CFG_PLL_FB_DIV_19_8_MASK, + DIV_19_8_20_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG1, + EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK, + EXYNOS_DIV_11_8_20_MHZ_VAL); + break; + + case 24000000: + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_24_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG0, + PHY_CFG_PLL_FB_DIV_19_8_MASK, + FIELD_PREP(PHY_CFG_PLL_FB_DIV_19_8_MASK, + DIV_19_8_24_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG1, + EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK, + EXYNOS_DIV_11_8_24_MHZ_VAL); + break; + + case 26000000: + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_26_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG0, + PHY_CFG_PLL_FB_DIV_19_8_MASK, + FIELD_PREP(PHY_CFG_PLL_FB_DIV_19_8_MASK, + DIV_19_8_26_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG1, + EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK, + EXYNOS_DIV_11_8_26_MHZ_VAL); + break; + + case 48000000: + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + FSEL_MASK, + FIELD_PREP(FSEL_MASK, FSEL_48_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG0, + PHY_CFG_PLL_FB_DIV_19_8_MASK, + FIELD_PREP(PHY_CFG_PLL_FB_DIV_19_8_MASK, + DIV_19_8_48_MHZ_VAL)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_CFG_PLLCFG1, + EXYNOS_PHY_CFG_PLL_FB_DIV_11_8_MASK, + EXYNOS_DIV_11_8_48_MHZ_VAL); + break; + default: + dev_err(&phy->phy->dev, "unsupported ref_clk_freq:%lu\n", ref_clk_freq); + return -EINVAL; + } + + return 0; +} + static int qcom_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) { unsigned long ref_clk_freq = clk_get_rate(phy->ref_clk); @@ -240,6 +360,55 @@ static int qcom_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) return 0; } +static int exynos_snps_eusb2_hsphy_init(struct phy *p) +{ + struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); + int ret; + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_RST, + USB_PHY_RST_MASK | UTMI_PORT_RST_MASK, + USB_PHY_RST_MASK | UTMI_PORT_RST_MASK); + fsleep(50); /* required after holding phy in reset */ + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + RPTR_MODE, RPTR_MODE); + + /* update ref_clk related registers */ + ret = exynos_eusb2_ref_clk_init(phy); + if (ret) + return ret; + + /* default parameter: tx fsls-vref */ + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_PHY_CFG_TX, + EXYNOS_PHY_CFG_TX_FSLS_VREF_TUNE_MASK, + FIELD_PREP(EXYNOS_PHY_CFG_TX_FSLS_VREF_TUNE_MASK, 0x0)); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_UTMI_TESTSE, + TEST_IDDQ, 0); + fsleep(10); /* required after releasing test_iddq */ + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_RST, + USB_PHY_RST_MASK, 0); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_COMMON, + PHY_ENABLE, PHY_ENABLE); + + snps_eusb2_hsphy_write_mask(phy->base, EXYNOS_USB_PHY_HS_PHY_CTRL_RST, + UTMI_PORT_RST_MASK, 0); + + return 0; +} + +static const char * const exynos_eusb2_hsphy_clock_names[] = { + "ref", "bus", "ctrl", +}; + +static const struct snps_eusb2_phy_drvdata exynos2200_snps_eusb2_phy = { + .phy_init = exynos_snps_eusb2_hsphy_init, + .clk_names = exynos_eusb2_hsphy_clock_names, + .num_clks = ARRAY_SIZE(exynos_eusb2_hsphy_clock_names), +}; + static int qcom_snps_eusb2_hsphy_init(struct phy *p) { struct snps_eusb2_hsphy *phy = phy_get_drvdata(p); @@ -488,6 +657,9 @@ static const struct of_device_id snps_eusb2_hsphy_of_match_table[] = { { .compatible = "qcom,sm8550-snps-eusb2-phy", .data = &sm8550_snps_eusb2_phy, + }, { + .compatible = "samsung,exynos2200-snps-eusb2-phy", + .data = &exynos2200_snps_eusb2_phy, }, { }, }; MODULE_DEVICE_TABLE(of, snps_eusb2_hsphy_of_match_table); From patchwork Sun Feb 23 12:22:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Ivanov X-Patchwork-Id: 13987033 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 92ACBC021B2 for ; Sun, 23 Feb 2025 12:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Mk17Af825MoY5+ViL1QPuoghulUe2DIpjNeLf3FSRxs=; b=Nih6Qe4KppoHiRZC4KDHEBVb5m VbQJa+njeclFmX9aw3eTXfPxP+gJ1P+Sw69UkTs3mykHTzDFf+mDgKeQacv9ZkOo/5vdg1OUCK182 S6xeyuWcVYkh6oss7cAxhxm/80uEMWlMZbGn1yeuTYCdmRu79myuGM3qcENlUCPlSqfHYNDMax55o qGXTI6Lx+CiDuJnF6ocO7GHYw/dQ91Y7GJniAyJgts63tcW0CJGJY2cJbTaX7O2pmkQ+3QbITytIh AFB01l38IyA/xhdcPA+6pJBxrS6wOrPxb0jI9jqAB7j0UIb/IgHVXBauBMPoyJiSTwwTO7vBQrvp2 2UlBQF4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmBDG-0000000B6sm-1H4n; Sun, 23 Feb 2025 12:36:02 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmB0N-0000000B4ta-0Uq1; Sun, 23 Feb 2025 12:22:44 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-38f70170005so1882947f8f.3; Sun, 23 Feb 2025 04:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740313361; x=1740918161; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mk17Af825MoY5+ViL1QPuoghulUe2DIpjNeLf3FSRxs=; b=YDAQae+ZodXOMI8wSSIfVQcB88NuxSHZtL6QUBNxugMtBgMK3ikY2TfmnDjyi4mEM6 XsgNgfr4mqXQY9WK5/uaWLa2sUB8CUpweYBxaVfC1sqnJzhvY4lyHe6nNxPHL234IF1X ZtKtJaPW7Om2xYQhkKNXaeGiVnRVxTaxtiBWXADvorXB08pNXJuhnUBfqJWoD0T0+wxi HYYtCHDsCm8X2Qm3hVKHmGXBHuvlcG0+rTy6QEjB5EozNcHvz+t1m7gVwS6rO0J5aZir YSHoUnORbVRYE8HyLifi3G5R2DYpN64KSjR3OKSxaWyt+FVLO2m2zW3Of5avhIkJO9de EEyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740313361; x=1740918161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mk17Af825MoY5+ViL1QPuoghulUe2DIpjNeLf3FSRxs=; b=M0OA0wy2uYCE+Wj4bvHcHx4EKiUA3LhDjLPkGktN/FqsFo/nuQIlDsaRKx1A919+re 5hc6VOo2zN+7N5Vjt2uxRz6q/4POFkTiltbgfH2qWl6OnxnbEcNO/5qFfbOTEIlpfTpQ yLLBGv0Uf7F/CZlfCZzoG1C9uV6zqLkGMX2wbBOcV6bicyYqPriUWX5tDCEBH30pfRAy ZV4Ek7NkDhw7G06301/wSShvd8GfpNKuQz6jDyfn+FuOQr2GSTx/muZfVYQPygYB8x/H JYBJjGsxr0Yor7M++TToUINSpXvNwREdwecjzb/xAFK+zP00vqWW7Yl7apmCoXG61PJE anNA== X-Forwarded-Encrypted: i=1; AJvYcCUkZlJfYZw6vExOjO0UNwAcfPWUL/oPw70u+nbSe73keSgIxgTCvGPY2hQaSYOeLfpu3yGmheT+rFcCtbNziUml@lists.infradead.org, AJvYcCUqUHe16TTsQfZ1K8sOGJcsx9FPXCitByW9fSenWTConmPlZshhHxKruuqHIO/yBUdY/cjm88TZz0Ye@lists.infradead.org X-Gm-Message-State: AOJu0Yw9Wzssdj+QiWrq37OmzYkoBGUR8F5gzrbWdBy7yw+shOCWukpu +8R5gYhWmGzrYtwtbvH42GFdQGQ9AIW2R4Pn9EFMJ5hUqCvDZTRb X-Gm-Gg: ASbGnctWKXZj6QprU19LcziIOVAiGxPkRx3BRpGlea/ofPDDywKNsrV3bjLGPSTVu0M s8xHEsd8HLr6h25FTWjMBuZyAPJ4XsfWzMYqNs3QDBNtoWzFqo0lVXL+5blcqCKDrMl1ocGVskc 3HB/XIa2xQMmA+H5BF06QICFsUiyiPqrLn0EUsH+jneb7Npqv24hTf58pZKRjRueKsy2H0c7YqJ 5tpchN/JxyKo2cxYEiGeJYJLWVGtNU3lR/WnB6mDJRyJbKcEX0R3KDsafEoqzbdqikX/X/Pc3cL IC1HPZNl7f0T4lhuoykcW5RlvnhEhmEwE/D35vdLky58JUUIYDNt6d+ovkd6k2sjEVirhLhGyjH QnA== X-Google-Smtp-Source: AGHT+IGWxAXkSNHk+1KebllT+xCEuhjnywiq2a9VK2BhfWGgHCBvEOWfCz0XyKO8Rf1jRfUwEJMmcw== X-Received: by 2002:a05:6000:1ac7:b0:38d:d299:709f with SMTP id ffacd0b85a97d-38f6f0d1d13mr8003029f8f.48.1740313361328; Sun, 23 Feb 2025 04:22:41 -0800 (PST) Received: from ivaylo-T580.. (91-139-201-119.stz.ddns.bulsat.com. [91.139.201.119]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38f259f8602sm29611608f8f.94.2025.02.23.04.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2025 04:22:40 -0800 (PST) From: Ivaylo Ivanov To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alim Akhtar , Philipp Zabel , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] phy: samsung: add Exynos2200 usb phy controller Date: Sun, 23 Feb 2025 14:22:27 +0200 Message-ID: <20250223122227.725233-9-ivo.ivanov.ivanov1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> References: <20250223122227.725233-1-ivo.ivanov.ivanov1@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250223_042243_162644_EEE7663A X-CRM114-Status: GOOD ( 24.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Exynos2200 SoC comes with a TI external repeater and 3 USB PHYs: - snps eUSB2 for UTMI - snps USBDP combophy for PIPE3 and DP - samsung USBCON phy The USBCON phy is an intermediary between the USB controller (DWC3) and the underlying PHYs. Add a new driver for it, modelled to take a phandle to the high-speed PHY for now. Signed-off-by: Ivaylo Ivanov --- drivers/phy/samsung/Kconfig | 12 + drivers/phy/samsung/Makefile | 1 + drivers/phy/samsung/phy-exynos2200-usbcon.c | 250 ++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 drivers/phy/samsung/phy-exynos2200-usbcon.c diff --git a/drivers/phy/samsung/Kconfig b/drivers/phy/samsung/Kconfig index e2330b089..0f809a382 100644 --- a/drivers/phy/samsung/Kconfig +++ b/drivers/phy/samsung/Kconfig @@ -77,6 +77,18 @@ config PHY_S5PV210_USB2 particular SoC is compiled in the driver. In case of S5PV210 two phys are available - device and host. +config PHY_EXYNOS2200_USBCON + tristate "Exynos2200 USBCON PHY driver" + depends on (ARCH_EXYNOS && OF) || COMPILE_TEST + depends on HAS_IOMEM + select GENERIC_PHY + select MFD_SYSCON + default y + help + Enable USBCON PHY support for Exynos2200 SoC. + This driver provides PHY interface for the USBCON phy, which acts as + an intermediary between the USB controller and underlying PHYs. + config PHY_EXYNOS5_USBDRD tristate "Exynos5 SoC series USB DRD PHY driver" depends on (ARCH_EXYNOS && OF) || COMPILE_TEST diff --git a/drivers/phy/samsung/Makefile b/drivers/phy/samsung/Makefile index fea1f96d0..e2686a3f5 100644 --- a/drivers/phy/samsung/Makefile +++ b/drivers/phy/samsung/Makefile @@ -14,5 +14,6 @@ phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o phy-exynos-usb2-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o +obj-$(CONFIG_PHY_EXYNOS2200_USBCON) += phy-exynos2200-usbcon.o obj-$(CONFIG_PHY_EXYNOS5_USBDRD) += phy-exynos5-usbdrd.o obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o diff --git a/drivers/phy/samsung/phy-exynos2200-usbcon.c b/drivers/phy/samsung/phy-exynos2200-usbcon.c new file mode 100644 index 000000000..aad59349e --- /dev/null +++ b/drivers/phy/samsung/phy-exynos2200-usbcon.c @@ -0,0 +1,250 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2025, Ivaylo Ivanov + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EXYNOS2200_USBCON_LINKCTRL 0x4 +#define LINKCTRL_FORCE_QACT BIT(8) + +#define EXYNOS2200_USBCON_UTMI_CTRL 0x10 +#define UTMI_CTRL_FORCESLEEP BIT(13) +#define UTMI_CTRL_FORCESUSPEND BIT(12) +#define UTMI_CTRL_FORCE_VBUSVALID BIT(1) +#define UTMI_CTRL_FORCE_BVALID BIT(0) + +#define EXYNOS2200_USBCON_LINK_CLKRST 0xc +#define LINK_CLKRST_SW_RST BIT(0) + +struct exynos2200_usbcon_phy_drvdata { + const char * const *clk_names; + int num_clks; +}; + +struct exynos2200_usbcon_phy { + struct phy *phy; + void __iomem *base; + struct regmap *reg_pmu; + struct clk_bulk_data *clks; + const struct exynos2200_usbcon_phy_drvdata *drv_data; + u32 pmu_offset; + struct phy *hs_phy; +}; + +static void exynos2200_usbcon_phy_isol(struct exynos2200_usbcon_phy *inst, + bool isolate) +{ + unsigned int val; + + if (!inst->reg_pmu) + return; + + val = isolate ? 0 : EXYNOS4_PHY_ENABLE; + + regmap_update_bits(inst->reg_pmu, inst->pmu_offset, + EXYNOS4_PHY_ENABLE, val); +} + +static void exynos2200_usbcon_phy_write_mask(void __iomem *base, u32 offset, + u32 mask, u32 val) +{ + u32 reg; + + reg = readl(base + offset); + reg &= ~mask; + reg |= val & mask; + writel(reg, base + offset); + + /* Ensure above write is completed */ + readl(base + offset); +} + +static int exynos2200_usbcon_phy_init(struct phy *p) +{ + int ret; + struct exynos2200_usbcon_phy *phy = phy_get_drvdata(p); + + /* Power-on PHY ... */ + ret = clk_bulk_prepare_enable(phy->drv_data->num_clks, phy->clks); + if (ret) + return ret; + + /* + * ... and ungate power via PMU. Without this here, we can't access + * registers + */ + exynos2200_usbcon_phy_isol(phy, false); + + /* + * Disable HWACG (hardware auto clock gating control). This will force + * QACTIVE signal in Q-Channel interface to HIGH level, to make sure + * the PHY clock is not gated by the hardware. + */ + exynos2200_usbcon_phy_write_mask(phy->base, EXYNOS2200_USBCON_LINKCTRL, + LINKCTRL_FORCE_QACT, + LINKCTRL_FORCE_QACT); + + /* Reset Link */ + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_LINK_CLKRST, + LINK_CLKRST_SW_RST, + LINK_CLKRST_SW_RST); + + fsleep(10); /* required after POR high */ + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_LINK_CLKRST, + LINK_CLKRST_SW_RST, 0); + + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_UTMI_CTRL, + UTMI_CTRL_FORCESLEEP | + UTMI_CTRL_FORCESUSPEND, + 0); + + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_UTMI_CTRL, + UTMI_CTRL_FORCE_BVALID | + UTMI_CTRL_FORCE_VBUSVALID, + UTMI_CTRL_FORCE_BVALID | + UTMI_CTRL_FORCE_VBUSVALID); + + return phy_init(phy->hs_phy); +} + +static int exynos2200_usbcon_phy_exit(struct phy *p) +{ + struct exynos2200_usbcon_phy *phy = phy_get_drvdata(p); + int ret; + + ret = phy_exit(phy->hs_phy); + if (ret) + return ret; + + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_UTMI_CTRL, + UTMI_CTRL_FORCESLEEP | + UTMI_CTRL_FORCESUSPEND, + UTMI_CTRL_FORCESLEEP | + UTMI_CTRL_FORCESUSPEND); + + exynos2200_usbcon_phy_write_mask(phy->base, + EXYNOS2200_USBCON_LINK_CLKRST, + LINK_CLKRST_SW_RST, + LINK_CLKRST_SW_RST); + + /* Gate power via PMU */ + exynos2200_usbcon_phy_isol(phy, true); + + clk_bulk_disable_unprepare(phy->drv_data->num_clks, phy->clks); + + return 0; +} + +static const struct phy_ops exynos2200_usbcon_phy_ops = { + .init = exynos2200_usbcon_phy_init, + .exit = exynos2200_usbcon_phy_exit, + .owner = THIS_MODULE, +}; + +static int exynos2200_usbcon_phy_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct exynos2200_usbcon_phy *phy; + const struct exynos2200_usbcon_phy_drvdata *drv_data; + struct phy_provider *phy_provider; + struct phy *generic_phy; + int ret; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return -ENOMEM; + + drv_data = of_device_get_match_data(dev); + if (!drv_data) + return -EINVAL; + phy->drv_data = drv_data; + + phy->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(phy->base)) + return PTR_ERR(phy->base); + + phy->clks = devm_kcalloc(dev, drv_data->num_clks, + sizeof(*phy->clks), GFP_KERNEL); + if (!phy->clks) + return -ENOMEM; + + for (int i = 0; i < drv_data->num_clks; ++i) + phy->clks[i].id = drv_data->clk_names[i]; + + ret = devm_clk_bulk_get(dev, phy->drv_data->num_clks, + phy->clks); + if (ret) + return dev_err_probe(dev, ret, + "failed to get phy clock(s)\n"); + + phy->reg_pmu = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "samsung,pmu-syscon", + 1, &phy->pmu_offset); + if (IS_ERR(phy->reg_pmu)) { + dev_err(dev, "Failed to lookup PMU regmap\n"); + return PTR_ERR(phy->reg_pmu); + } + + phy->hs_phy = devm_of_phy_get_by_index(dev, dev->of_node, 0); + if (IS_ERR(phy->hs_phy)) + return dev_err_probe(dev, PTR_ERR(phy->hs_phy), + "failed to get hs_phy\n"); + + generic_phy = devm_phy_create(dev, NULL, &exynos2200_usbcon_phy_ops); + if (IS_ERR(generic_phy)) + return dev_err_probe(dev, PTR_ERR(generic_phy), + "failed to create phy %d\n", ret); + + dev_set_drvdata(dev, phy); + phy_set_drvdata(generic_phy, phy); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + if (IS_ERR(phy_provider)) + return dev_err_probe(dev, PTR_ERR(phy_provider), + "failed to register phy provider\n"); + + return 0; +} + +static const char * const exynos2200_clk_names[] = { + "bus", +}; + +static const struct exynos2200_usbcon_phy_drvdata exynos2200_usbcon_phy = { + .clk_names = exynos2200_clk_names, + .num_clks = ARRAY_SIZE(exynos2200_clk_names), +}; + +static const struct of_device_id exynos2200_usbcon_phy_of_match_table[] = { + { + .compatible = "samsung,exynos2200-usbcon-phy", + .data = &exynos2200_usbcon_phy, + }, { }, +}; +MODULE_DEVICE_TABLE(of, exynos2200_usbcon_phy_of_match_table); + +static struct platform_driver exynos2200_usbcon_phy_driver = { + .probe = exynos2200_usbcon_phy_probe, + .driver = { + .name = "exynos2200-usbcon-phy", + .of_match_table = exynos2200_usbcon_phy_of_match_table, + }, +}; + +module_platform_driver(exynos2200_usbcon_phy_driver); +MODULE_DESCRIPTION("Exynos2200 USBCON PHY driver"); +MODULE_LICENSE("GPL");