From patchwork Sun Sep 29 06:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13814830 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 37C3ECF6498 for ; Sun, 29 Sep 2024 06:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0U8LbH+rf7sejnu9QxW84GSzNbD5+UrVyYsui/5NAnM=; b=0+ToKZE05lU9wb mjduKk40DozTVkBMIKG7d+KcgZPjQ9WNMk7BEukVX+0uqfYdqIVnTGAYoNFIcQlap0XLMdZ5SecJh V2a/zP5J7b+uhpKuRTioJvUexbEGQdAO4qYqLLOGY0C7iXpxeCz5/eb7KRy7UfC0t+OajKY2C7WCb TxyLeolQn9XB5yDd+ecX372Bq6YJLz92u3SpGnbQ1gH9L2J+QogGgwuK4SjbsOeYeEU9ArAqoWZKH B5y0ZYWpMTyNgBbNBFYnFTE8X1pjlOCeYCpcAABBdKlKbiZG+spstO5qmUKlNUurmF0ZqU9uMQehx We+s2UYYOC34K/y3XM5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sunDE-0000000EGNt-3xe8; Sun, 29 Sep 2024 06:15:20 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sun8d-0000000EFRM-0AlT; Sun, 29 Sep 2024 06:10:36 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2e09a36f54eso349764a91.1; Sat, 28 Sep 2024 23:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727590234; x=1728195034; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xKLiR5gYmZwZmfgs+vGwBtpwK5USPFATr2yD/8gCPKI=; b=HYowon+T3aNNWc8fNraSMbertV1pvTJR3NgzwPpmxvnUOPXmTt5CdX9yrEYwCe5p6Z tZCzvWNCSQN7QC7bSzSsVviTH2Y0CBeI4VG33RgHpfafPKBHeH4gPDJNE4ffxMLoWdrk 5QL81/o7CFAesWn9pWrWhtqS6hIk4FwGUz+hr2teEZ+ptJWdLnwFtCw+le63wbbgfXAG rGJdfPNZ4oeJMX1OoDEIyPNxoQtt9s4zXYK5d9ZghvawXvJibaNfCRpPw4gLQU9MWbC8 RIu4p2gvCc61Ira3r0RFlTfdGgC4lE0FrHeH/nCR1kowzeYdWOu1UP3CpS/zB3SOSBTX Xd9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727590234; x=1728195034; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xKLiR5gYmZwZmfgs+vGwBtpwK5USPFATr2yD/8gCPKI=; b=o3cT+NvjMyWlimt20GXsCTJnuN8vdlxPvMYH3xIDMI2yuDgV81SSKf1xkdTcR/5opj yBnQU/3zWPXyfPiw8UwEEugrafwMJAhycJDjTlEST6CriWSg0mDXQJXVvcNkE4z7gOGk H8oU8xz1QsDmNBxeS97zP+a11nlZeMrWUjr0EmD2BXK8W2WlrhbxjREejSF2IVNlVH+c 9MG5t8C8jISSy2mTQtXTWroqbP1SpmU9sVxRU8msNF8204ajK6tjAU+n6/iBMKkgNLDR iM6+DeE1+nzZAmItV1dacdYjt4c2V1vpXWVSIEoAdhKnrtXp6Ok+eWNLFNcX4/5Hs7V2 SXZw== X-Forwarded-Encrypted: i=1; AJvYcCUNHS2myveC96MQsNZbHDdRJgjnEv+hnxyLOuuANT37HxYZPuNrlKtbj8/75T6gJkpJAajWqC+xihp83AqmIjU=@lists.infradead.org, AJvYcCVicmlrkP7jZ9UVpgFef0uWHFty1b11rPqHIczW/eBSW/sECWXcvyV/gosR4a+eturY/GJrg1bbIeDZodU7zN0v@lists.infradead.org X-Gm-Message-State: AOJu0YyLTOBtP8iq761XFsMfC1kMWhNmKJRICjtdto3ORjhXAg7Ac2B5 51/N2CetRBtV2Og+WoUQSMYHJBy24YI31AqTpW0qhsEZCbdYPqDL X-Google-Smtp-Source: AGHT+IHuhs9Kcf2V+igHziL1L5Hw5uJbO/yqgFJbHygqQCcJ8RtC/6BHGX+4wtceCMUQFmbirgH0Uw== X-Received: by 2002:a05:6a21:78a1:b0:1cf:5471:bbe1 with SMTP id adf61e73a8af0-1d4fa7adecbmr6059094637.8.1727590233595; Sat, 28 Sep 2024 23:10:33 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2b974bsm4269584a12.34.2024.09.28.23.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 23:10:33 -0700 (PDT) From: Frank Wang To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, william.wu@rock-chips.com, tim.chen@rock-chips.com, frank.wang@rock-chips.com Subject: [PATCH v4 1/3] phy: rockchip: inno-usb2: convert clock management to bulk Date: Sun, 29 Sep 2024 14:10:23 +0800 Message-ID: <20240929061025.3704-1-frawang.cn@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240928_231035_139217_1B180791 X-CRM114-Status: GOOD ( 19.94 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Frank Wang Since some Rockchip SoCs (e.g RK3576) have more than one clock, this converts the clock management from single to bulk method to make the driver more flexible. Signed-off-by: Frank Wang --- Changelog: v4: - a new patch split from the [PATCH v3 2/2], suggestions from Heiko. v1-v3: - none drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 4f71373ae6e1..ad3e65dc6aa4 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -229,9 +229,10 @@ struct rockchip_usb2phy_port { * @dev: pointer to device. * @grf: General Register Files regmap. * @usbgrf: USB General Register Files regmap. - * @clk: clock struct of phy input clk. + * @clks: array of phy input clocks. * @clk480m: clock struct of phy output clk. * @clk480m_hw: clock struct of phy output clk management. + * @num_clks: number of phy input clocks. * @phy_reset: phy reset control. * @chg_state: states involved in USB charger detection. * @chg_type: USB charger types. @@ -246,9 +247,10 @@ struct rockchip_usb2phy { struct device *dev; struct regmap *grf; struct regmap *usbgrf; - struct clk *clk; + struct clk_bulk_data *clks; struct clk *clk480m; struct clk_hw clk480m_hw; + int num_clks; struct reset_control *phy_reset; enum usb_chg_state chg_state; enum power_supply_type chg_type; @@ -310,6 +312,13 @@ static int rockchip_usb2phy_reset(struct rockchip_usb2phy *rphy) return 0; } +static void rockchip_usb2phy_clk_bulk_disable(void *data) +{ + struct rockchip_usb2phy *rphy = data; + + clk_bulk_disable_unprepare(rphy->num_clks, rphy->clks); +} + static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw) { struct rockchip_usb2phy *rphy = @@ -376,7 +385,9 @@ rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy) { struct device_node *node = rphy->dev->of_node; struct clk_init_data init; + struct clk *refclk = NULL; const char *clk_name; + int i; int ret = 0; init.flags = 0; @@ -386,8 +397,15 @@ rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy) /* optional override of the clockname */ of_property_read_string(node, "clock-output-names", &init.name); - if (rphy->clk) { - clk_name = __clk_get_name(rphy->clk); + for (i = 0; i < rphy->num_clks; i++) { + if (!strncmp(rphy->clks[i].id, "phyclk", 6)) { + refclk = rphy->clks[i].clk; + break; + } + } + + if (!IS_ERR(refclk)) { + clk_name = __clk_get_name(refclk); init.parent_names = &clk_name; init.num_parents = 1; } else { @@ -1406,18 +1424,29 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) if (IS_ERR(rphy->phy_reset)) return PTR_ERR(rphy->phy_reset); - rphy->clk = devm_clk_get_optional_enabled(dev, "phyclk"); - if (IS_ERR(rphy->clk)) { - return dev_err_probe(&pdev->dev, PTR_ERR(rphy->clk), + ret = devm_clk_bulk_get_all(dev, &rphy->clks); + if (ret == -EPROBE_DEFER) { + return dev_err_probe(&pdev->dev, -EPROBE_DEFER, "failed to get phyclk\n"); } + /* Clocks are optional */ + rphy->num_clks = ret < 0 ? 0 : ret; + ret = rockchip_usb2phy_clk480m_register(rphy); if (ret) { dev_err(dev, "failed to register 480m output clock\n"); return ret; } + ret = clk_bulk_prepare_enable(rphy->num_clks, rphy->clks); + if (ret) + return ret; + + ret = devm_add_action_or_reset(dev, rockchip_usb2phy_clk_bulk_disable, rphy); + if (ret) + return ret; + if (rphy->phy_cfg->phy_tuning) { ret = rphy->phy_cfg->phy_tuning(rphy); if (ret) From patchwork Sun Sep 29 06:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13814831 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 C9928CF6495 for ; Sun, 29 Sep 2024 06:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=36SDnh6a/1kdc45tjo0T6GmOycC8yjeAHXHR2Q5CAIw=; b=CR62EdZMIq82eL +iPGTWsqPAC4BHR4OGAyjh/xh0TSrLgeOaeo/AzYv29MYL+CnLVUQXuxU221mzELP5iUUndYL5n3F vj4Np6ViwI3+W+6RZvwAh9DvlvBkg6G5cCudBkKTySk8NJTT07X24B8AOuvonaZU3XPMQZWDlqPKh G8nowkNT+zVE1S2K9AStnGEvGCbAak2QE+azwNwc5ipYnAdLEQeGhp4ttgnJUt4MvBfDsErcByQZ3 UpYEiiTEvF9EqDKiP4guzs3aX4nsme6gR6C+BSe+dHOqdZ5bXxr/9eJxYG+n9kflR+Yv9ST3USspd f/iT/G6a04wkr8Ul8MTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sunEO-0000000EGWT-2kD9; Sun, 29 Sep 2024 06:16:32 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sun8h-0000000EFT3-0TTP; Sun, 29 Sep 2024 06:10:40 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2e07d87adc2so713983a91.3; Sat, 28 Sep 2024 23:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727590238; x=1728195038; 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=uKZkhBzFBP4JhC5YWwmTbC/Q9z4TwAHwN6I2TQdXXDc=; b=Gcpl2ib+8nNoN2hY5y/FtHDF04qF98rSoQP3k1OFGg5mq07oVAykp93bQULfC9AUNG Iw2nneU6i63xmtjVaTbIQSGuYnhSYIWPNuMG6kbq2O1b53dothby/WK5NNpow1qeanfW mXUuPY0P0R6kFdk4cJt28UK01GCLEcjx9io4CllC/ghESCONvsOS9UCSDtyYiZEWx86Y MSVqeqIXxZor4s+77occt9nfVZm38rF7KgXz4MRKWurmrfRrVGbMSE6m0hsyU2xphJC1 bwWT7Wcru1wAMO1kLzBy209gmgXTLHoTsFJY7b6d4KkeQiLgCmgXjM04diT0wsepJf4F eHZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727590238; x=1728195038; 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=uKZkhBzFBP4JhC5YWwmTbC/Q9z4TwAHwN6I2TQdXXDc=; b=R3SY1OtgGfoHU9RWt1vb2UhuEkwoSwUMYvBpzDCAMp4yWwTPOg+QbXev2D7OHlS8H7 ZuuuYLK55WplN8/d5TPmMK+Egeoej5kj1fdyRTvAwsFDBU5HRJywOl/4TrQ9cI2XYKAM N3AHFG2qXJrnshseZCA8XLIABE4+MheLlqa10a3b2BG4aid3lfixZPURqVDbj4M6ytP3 GR2YYXbybIR0AdRfi/BLTWwBwuTvXBBO5cAKasorgOD+4jDgy26ovahGDSZ7vU3j3/A8 Fr6ZN88wjxYn8x90YLXpHnRqAmutrCahBag019Uo06f6wfVTBOGkncRhsrQJZ3ws0pMu yuJQ== X-Forwarded-Encrypted: i=1; AJvYcCUTv4exAHBAaDsNjfWCWmlFuM/xNrbn61g1Jk8i/Qbx5xvl8ToK2yjmmNTuRLGrtSs2AkuDRcZF3tU4vRijBdhR@lists.infradead.org, AJvYcCWEDyGCahr98uR8sNrUgKGDhJmWnfPLqRKwhO8+inv7Ql3BfJoyanWpevUNicXlhk8ZBymq7aM3FjFdudVf+WM=@lists.infradead.org X-Gm-Message-State: AOJu0YwfPc4nmSOhfdHH2PXAz28su77SaGfhGj+9pRy6ybZGng1oa5L6 +3rtEYx06GWNyqqcUyUGXB4QXWAY+xh0jst47KKCKepKrFNC0eRZ X-Google-Smtp-Source: AGHT+IE/hAsWcepkQrvYbUPM/E44kL/wr6eljuSNfdhzQXdTFpjJ6T8n0NU2RcJpW1S49Y+mbmcuAw== X-Received: by 2002:a05:6a21:6da1:b0:1cf:3130:9966 with SMTP id adf61e73a8af0-1d509b1c253mr2953358637.3.1727590238089; Sat, 28 Sep 2024 23:10:38 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2b974bsm4269584a12.34.2024.09.28.23.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 23:10:37 -0700 (PDT) From: Frank Wang To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, william.wu@rock-chips.com, tim.chen@rock-chips.com, frank.wang@rock-chips.com Subject: [PATCH v4 2/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3576 Date: Sun, 29 Sep 2024 14:10:24 +0800 Message-ID: <20240929061025.3704-2-frawang.cn@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929061025.3704-1-frawang.cn@gmail.com> References: <20240929061025.3704-1-frawang.cn@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240928_231039_179463_EAEFD91E X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Frank Wang Add compatible for the USB2 phy in the Rockchip RK3576 SoC. This change also refactor the clocks list as there are new clocks adding used for the USB MMU in RK3576 SoC. Signed-off-by: Frank Wang --- Changelog: v4: - refactor the clocks list used if:then: v3: - narrowed rk3576 clocks by compatible property. v2: - Categorize clock names by oneOf keyword. v1: - https://patchwork.kernel.org/project/linux-phy/patch/20240923025326.10467-1-frank.wang@rock-chips.com/ .../bindings/phy/rockchip,inno-usb2phy.yaml | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml index 5254413137c6..fc2c03d01a20 100644 --- a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml +++ b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml @@ -20,6 +20,7 @@ properties: - rockchip,rk3366-usb2phy - rockchip,rk3399-usb2phy - rockchip,rk3568-usb2phy + - rockchip,rk3576-usb2phy - rockchip,rk3588-usb2phy - rockchip,rv1108-usb2phy @@ -34,10 +35,12 @@ properties: const: 0 clocks: - maxItems: 1 + minItems: 1 + maxItems: 3 clock-names: - const: phyclk + minItems: 1 + maxItems: 3 assigned-clocks: description: @@ -172,6 +175,45 @@ allOf: - interrupts - interrupt-names + - if: + properties: + compatible: + contains: + enum: + - rockchip,px30-usb2phy + - rockchip,rk3128-usb2phy + - rockchip,rk3228-usb2phy + - rockchip,rk3308-usb2phy + - rockchip,rk3328-usb2phy + - rockchip,rk3366-usb2phy + - rockchip,rk3399-usb2phy + - rockchip,rk3568-usb2phy + - rockchip,rk3588-usb2phy + - rockchip,rv1108-usb2phy + then: + properties: + clocks: + maxItems: 1 + clock-names: + const: phyclk + + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3576-usb2phy + then: + properties: + clocks: + minItems: 3 + maxItems: 3 + clock-names: + items: + - const: phyclk + - const: aclk + - const: aclk_slv + additionalProperties: false examples: From patchwork Sun Sep 29 06:10:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13814832 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 7984ACF6495 for ; Sun, 29 Sep 2024 06:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oibDwvvfEInn1OND0kiDyigFS5zjH+blG1Lpot4ZsZg=; b=zGZU/yfwiUxEEy 3H5/1zyXX1iGkpPmCnBeiTQjrsMDC/Zsb1S/Rot8524VcN4uPzGkSH84yJVU7sMYtfnJLus1/1R+m UNDdGmy+eB1r6IsR3gS8ROKzxiWhW/SNVMU6ZYp3fn9fV0MPFglOykUinNDFdEBPIaU6yyi45dz2c KCvAa4XUM6a+DzYlrwmIwij7ko2gJ7LyT3+nUnz826UZKGfoA2jd6aGszH462AWCWfiXaexk981li CzFgR5wqjTWdkJhA8vzfiu470GPX74+2Fq0LXzy4ZWE2p0ADOakeD42MfwIweQNq8df+ekNJ2Wkry 78q8RBIb6weQA0Kd1+3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sunFX-0000000EGg2-2OyM; Sun, 29 Sep 2024 06:17:43 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sun8m-0000000EFVS-0WsE; Sun, 29 Sep 2024 06:10:45 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7191f1875d3so267032b3a.0; Sat, 28 Sep 2024 23:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727590243; x=1728195043; 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=9Akpn0thmbgIzVjfPV0oA4PJDLdf9K15fHM30omhDao=; b=F8VDmly6ZLJjxiItHgUmIST1U596AcHgwdr4IJ5BmREjl3Urz6NJJFiFTBVXrtC6bO GDEEQHiUiLgQVx6nm53b8A9BRyEwrGw92PwTF8pM4eK9rMb1vEDejvICgXVbqKsca3RK Gcx2VrycOeNmju7mytATtivqz9SNab34Fainq1s474LD/aHDiyJFQ+9VuguqncQnT4To SjVvFon1VGvRbvcOu9MH0haRwI0l4bQeYInlZO/d/XVpJipXPXQYQPbYNbhwA8MmADkQ 3LveHWewRFGQ8E5rfv7cIcbp+zZBoYzt2XYDQOK5oFf6P5S9Yw8SV00ochDCQNsq3V1o de7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727590243; x=1728195043; 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=9Akpn0thmbgIzVjfPV0oA4PJDLdf9K15fHM30omhDao=; b=h6wHN4SmOhwS2aFnQuD5wrGr9zZPqxa6RD5+Mt/kd/zOet+01oqpEQZHIK0AAfsBe0 EssSECN3sERi+sEx7+6+fqfNOeR3+3jJFtptVxFrcDMCYV3WJMz/p6QtQ1lZ24T92vRW R8aJmyH8I1qBOoSSmwtKru8nXKqnibQfE+1MzaRDaGoZ9FB7rEnyE/cktPk+MlsMsAKd rOxrgjQseX6bWFj/uqD/uxmb+mZkUQxd6tComT0oJ3k20hNsupe/PT9gOgdHZV19xbP6 Ai1iXtatuZJV/N8o6TV8lCCMZFPo85B50vvJgFkNtmGj9QfAQWIJLoapD2BGCXceFwHd m4kg== X-Forwarded-Encrypted: i=1; AJvYcCWkkwbWtlCvDRAK1We+wZ4YMZnXr123O9jeAoEh+3977BLQgv7zU/MekQ5GqdP4qg14VNIJx//ssFo/CO2DP1c=@lists.infradead.org, AJvYcCWnkHp19AgzQsYWNiUUjff68b///hHkdU+UGj2ujOtkdl3N2rXkb+qNMdisF5qbbYHyUFWvEY9xAvA5stKG774Z@lists.infradead.org X-Gm-Message-State: AOJu0Yy57kE1O3dpTPMdOiZvDtbkvOpPJzWl9FAW8u/J47NI9J8k6nzu 2YIIRGvz06sj15NU39oDjP8mN8FxvoDCAc36ZOufsUmFhDxRAZpwxX+dQAMF X-Google-Smtp-Source: AGHT+IF2iogTKpcc4OC3wX2AKFC19wwkglyqmU4gozQpOj4E0scTjZJgjLmWS2b6wIO27RM0B0DA3Q== X-Received: by 2002:a05:6a00:1990:b0:717:8b4e:98ad with SMTP id d2e1a72fcca58-71c6352f3demr2763841b3a.0.1727590243221; Sat, 28 Sep 2024 23:10:43 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2b974bsm4269584a12.34.2024.09.28.23.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Sep 2024 23:10:42 -0700 (PDT) From: Frank Wang To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, heiko@sntech.de Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, william.wu@rock-chips.com, tim.chen@rock-chips.com, frank.wang@rock-chips.com Subject: [PATCH v4 3/3] phy: rockchip: inno-usb2: Add usb2 phys support for rk3576 Date: Sun, 29 Sep 2024 14:10:25 +0800 Message-ID: <20240929061025.3704-3-frawang.cn@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929061025.3704-1-frawang.cn@gmail.com> References: <20240929061025.3704-1-frawang.cn@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240928_231044_227301_BAE3A7C9 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: William Wu The RK3576 SoC has two independent USB2.0 PHYs, and each PHY has one port. This adds device specific data for it. Signed-off-by: William Wu Signed-off-by: Frank Wang --- Changelog: v4: - split the bulk clock management as a new patch, and this just leave adding rk3576-specific data. v3: - amend the commit log adds clocks converting. - retrieve the clock by "clks.id" in *_clk480m_register() function. v2: - no changes. v1: - https://patchwork.kernel.org/project/linux-phy/patch/20240923025326.10467-2-frank.wang@rock-chips.com/ drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index ad3e65dc6aa4..629f71e7cd1b 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1524,6 +1524,30 @@ static int rk3128_usb2phy_tuning(struct rockchip_usb2phy *rphy) BIT(2) << BIT_WRITEABLE_SHIFT | 0); } +static int rk3576_usb2phy_tuning(struct rockchip_usb2phy *rphy) +{ + int ret; + u32 reg = rphy->phy_cfg->reg; + + /* Deassert SIDDQ to power on analog block */ + ret = regmap_write(rphy->grf, reg + 0x0010, GENMASK(29, 29) | 0x0000); + if (ret) + return ret; + + /* Do reset after exit IDDQ mode */ + ret = rockchip_usb2phy_reset(rphy); + if (ret) + return ret; + + /* HS DC Voltage Level Adjustment 4'b1001 : +5.89% */ + ret |= regmap_write(rphy->grf, reg + 0x000c, GENMASK(27, 24) | 0x0900); + + /* HS Transmitter Pre-Emphasis Current Control 2'b10 : 2x */ + ret |= regmap_write(rphy->grf, reg + 0x0010, GENMASK(20, 19) | 0x0010); + + return ret; +} + static int rk3588_usb2phy_tuning(struct rockchip_usb2phy *rphy) { int ret; @@ -1952,6 +1976,84 @@ static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] = { { /* sentinel */ } }; +static const struct rockchip_usb2phy_cfg rk3576_phy_cfgs[] = { + { + .reg = 0x0, + .num_ports = 1, + .phy_tuning = rk3576_usb2phy_tuning, + .clkout_ctl = { 0x0008, 0, 0, 1, 0 }, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0x0000, 8, 0, 0, 0x1d1 }, + .bvalid_det_en = { 0x00c0, 1, 1, 0, 1 }, + .bvalid_det_st = { 0x00c4, 1, 1, 0, 1 }, + .bvalid_det_clr = { 0x00c8, 1, 1, 0, 1 }, + .ls_det_en = { 0x00c0, 0, 0, 0, 1 }, + .ls_det_st = { 0x00c4, 0, 0, 0, 1 }, + .ls_det_clr = { 0x00c8, 0, 0, 0, 1 }, + .disfall_en = { 0x00c0, 6, 6, 0, 1 }, + .disfall_st = { 0x00c4, 6, 6, 0, 1 }, + .disfall_clr = { 0x00c8, 6, 6, 0, 1 }, + .disrise_en = { 0x00c0, 5, 5, 0, 1 }, + .disrise_st = { 0x00c4, 5, 5, 0, 1 }, + .disrise_clr = { 0x00c8, 5, 5, 0, 1 }, + .utmi_avalid = { 0x0080, 1, 1, 0, 1 }, + .utmi_bvalid = { 0x0080, 0, 0, 0, 1 }, + .utmi_ls = { 0x0080, 5, 4, 0, 1 }, + } + }, + .chg_det = { + .cp_det = { 0x0080, 8, 8, 0, 1 }, + .dcp_det = { 0x0080, 8, 8, 0, 1 }, + .dp_det = { 0x0080, 9, 9, 1, 0 }, + .idm_sink_en = { 0x0010, 5, 5, 1, 0 }, + .idp_sink_en = { 0x0010, 5, 5, 0, 1 }, + .idp_src_en = { 0x0010, 14, 14, 0, 1 }, + .rdm_pdwn_en = { 0x0010, 14, 14, 0, 1 }, + .vdm_src_en = { 0x0010, 7, 6, 0, 3 }, + .vdp_src_en = { 0x0010, 7, 6, 0, 3 }, + }, + }, + { + .reg = 0x2000, + .num_ports = 1, + .phy_tuning = rk3576_usb2phy_tuning, + .clkout_ctl = { 0x2008, 0, 0, 1, 0 }, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0x2000, 8, 0, 0, 0x1d1 }, + .bvalid_det_en = { 0x20c0, 1, 1, 0, 1 }, + .bvalid_det_st = { 0x20c4, 1, 1, 0, 1 }, + .bvalid_det_clr = { 0x20c8, 1, 1, 0, 1 }, + .ls_det_en = { 0x20c0, 0, 0, 0, 1 }, + .ls_det_st = { 0x20c4, 0, 0, 0, 1 }, + .ls_det_clr = { 0x20c8, 0, 0, 0, 1 }, + .disfall_en = { 0x20c0, 6, 6, 0, 1 }, + .disfall_st = { 0x20c4, 6, 6, 0, 1 }, + .disfall_clr = { 0x20c8, 6, 6, 0, 1 }, + .disrise_en = { 0x20c0, 5, 5, 0, 1 }, + .disrise_st = { 0x20c4, 5, 5, 0, 1 }, + .disrise_clr = { 0x20c8, 5, 5, 0, 1 }, + .utmi_avalid = { 0x2080, 1, 1, 0, 1 }, + .utmi_bvalid = { 0x2080, 0, 0, 0, 1 }, + .utmi_ls = { 0x2080, 5, 4, 0, 1 }, + } + }, + .chg_det = { + .cp_det = { 0x2080, 8, 8, 0, 1 }, + .dcp_det = { 0x2080, 8, 8, 0, 1 }, + .dp_det = { 0x2080, 9, 9, 1, 0 }, + .idm_sink_en = { 0x2010, 5, 5, 1, 0 }, + .idp_sink_en = { 0x2010, 5, 5, 0, 1 }, + .idp_src_en = { 0x2010, 14, 14, 0, 1 }, + .rdm_pdwn_en = { 0x2010, 14, 14, 0, 1 }, + .vdm_src_en = { 0x2010, 7, 6, 0, 3 }, + .vdp_src_en = { 0x2010, 7, 6, 0, 3 }, + }, + }, + { /* sentinel */ } +}; + static const struct rockchip_usb2phy_cfg rk3588_phy_cfgs[] = { { .reg = 0x0000, @@ -2123,6 +2225,7 @@ static const struct of_device_id rockchip_usb2phy_dt_match[] = { { .compatible = "rockchip,rk3366-usb2phy", .data = &rk3366_phy_cfgs }, { .compatible = "rockchip,rk3399-usb2phy", .data = &rk3399_phy_cfgs }, { .compatible = "rockchip,rk3568-usb2phy", .data = &rk3568_phy_cfgs }, + { .compatible = "rockchip,rk3576-usb2phy", .data = &rk3576_phy_cfgs }, { .compatible = "rockchip,rk3588-usb2phy", .data = &rk3588_phy_cfgs }, { .compatible = "rockchip,rv1108-usb2phy", .data = &rv1108_phy_cfgs }, {}