From patchwork Fri Oct 11 06:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13832141 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 66FE0D2447B for ; Fri, 11 Oct 2024 06:56:17 +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=bap6NcLh0pXaVf015NHqf3HEtrL+l/m7NKTGhXQVdDM=; b=t+zSfR/pgD6Aup rt6UEla/rR5/Q2mZ/P4bhE/C+jWZrdlAkNiAqXK+xHzC/LZCsNslc7Hkq+rgoVOdH3WB3t/Jxi8VN aJfCiL9pznisDY33ElSmhDlHV/WYxKZ9mi7zcrEaZo3lmXo3FShZnEJ73uWPrQT8Wq6UQ8X/JzUPY qXIqH3ODYrGWMrUbVxmdYhlC5ynjErj6fbOsL3KfAq0/SWpRM3elyf6ZeFVqgK5oaJE5+jXqXqvyV vw/sjvh0QjbhbqUrZ0nUBryv1kCos0iTw/vQUsFCYYdIF3rF0WfljpKRCGqVtDlnDLvLoTH/E8Am0 Gh0dbK/klZWdXO2rTtbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz9ZR-0000000FSqo-0PyJ; Fri, 11 Oct 2024 06:56:17 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz9V7-0000000FS06-49AZ; Fri, 11 Oct 2024 06:51:51 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-71e269db566so99600b3a.3; Thu, 10 Oct 2024 23:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728629508; x=1729234308; 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=vUd+ptjyv9QJ5lB7HGC0V0YSPXyHnn+kNuvjqh6RNSw=; b=l+YNEGMk+K+Sd6+RNZjkBAElP+7O52DJ9zCxRTn3Dev0kRiR+Q4ov+V8O7OK+TY8ED To4UfvNgjBz+61QZIZEWIcHCditOXVmXoKg5WSArzGkL7hwJqxVt6M3vw5LUCjTaOQ+y Zxkw8VDJOI01//uJojGRY/oQejgM+Rh/utNHfh/Byos1Jr6nD7YTH0FpkCDXhKcG87Gr +61j9OdkBsXfybFWZCBHAno1GVVNSrXvwRN88A6XxYQYf7YrWtZmiubNuCY6UzVEG83f AO7jcig1cqegLEafCAMSWBppx6wAjdxNnCoZ/rkKaf7jPowPlR+KwnFLjOFbCwA4GaKn NRnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728629508; x=1729234308; 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=vUd+ptjyv9QJ5lB7HGC0V0YSPXyHnn+kNuvjqh6RNSw=; b=VXQOs/GnEnXourtfQ5vQ6q3JpBS5JurimQV3RZy2t9Z02MYXKXStUYAwLzLscPTi+u aEKTXfEHjhEkkmslTPQfGtcmqUDLHZLG+KbMnha28CK/vVoeZDPNQFq2D0BAYKjr3oAq TUFby3ea3HnX7jp0N7mV1C/N1y1/F0IBJHSChxD75yxj0XLO1CU74NLcq6LKcRONEJfh gVY+/Ni8VXqDQrQT4LpJcnNG/6hclPMrLABs+liKBel3j72QsTKIfOmym/LbUi4WMsVm bAdgx0GNRn7jSP5Y0asOP8rs707YOrrcMGEGkbuMWhxN/U6BABvN8JdXvLEYZT2OIY44 s3WA== X-Forwarded-Encrypted: i=1; AJvYcCViImvJ05a3TChRC3ab68skflV2usXPyGJJ1E0jU/Uuu9druwh8FbJyrcVRHvbUJP8UIQsxrowhG9WHQKSYE4g=@lists.infradead.org, AJvYcCXEM5CoTG9QwNrn6AV/nrx4yyELxikg34v9iF8Ic0wNTiZ6BfNgSc48DLR/ptGIKgYFZ99xjZ1asjD9pRB8J4gY@lists.infradead.org X-Gm-Message-State: AOJu0Ywe1hePt/ZmuwbHJfKQVzdcYR7JKAjrptAqYutDoGRZg/7mDVYn OAWTR2WraRsZRxvcGM7IwuTLLKWO28davCuXs3ExVmdWwho+4bLI X-Google-Smtp-Source: AGHT+IHjExOTWS+ut51FciTmYkVQWJwbGbZ+dp9P/ObMFftp08A8WqGSO9KFwxV+tjO4x0yePjh8LQ== X-Received: by 2002:a05:6a00:8594:b0:718:e49f:4185 with SMTP id d2e1a72fcca58-71e38126090mr1026885b3a.7.1728629508440; Thu, 10 Oct 2024 23:51:48 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2ab109e4sm2036099b3a.206.2024.10.10.23.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 23:51:48 -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 Subject: [PATCH v5 1/3] phy: rockchip: inno-usb2: convert clock management to bulk Date: Fri, 11 Oct 2024 14:51:38 +0800 Message-Id: <20241011065140.19999-1-frawang.cn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_235150_109238_6B977D4E X-CRM114-Status: GOOD ( 19.67 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Heiko Stuebner --- Changelog: V5: - use dev_err_probe() in clock enable error path in probe. 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 | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 6e5214862b8a3..f71266c27091e 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 { @@ -1399,15 +1417,26 @@ 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), - "failed to get phyclk\n"); + ret = devm_clk_bulk_get_all(dev, &rphy->clks); + if (ret == -EPROBE_DEFER) + return dev_err_probe(&pdev->dev, -EPROBE_DEFER, + "failed to get phy clock\n"); + + /* Clocks are optional */ + rphy->num_clks = ret < 0 ? 0 : ret; ret = rockchip_usb2phy_clk480m_register(rphy); if (ret) return dev_err_probe(dev, ret, "failed to register 480m output clock\n"); + ret = clk_bulk_prepare_enable(rphy->num_clks, rphy->clks); + if (ret) + return dev_err_probe(dev, ret, "failed to enable phy clock\n"); + + 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 Fri Oct 11 06:51:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13832142 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 AB54BD2447F for ; Fri, 11 Oct 2024 06:57:44 +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=+1+EkgmbcPWac9Y+Qin7P0LJu/05Ypojekk9rgcWIFE=; b=yJUaJhQXCFntB9 zI9cAfD8usuKbLVsxMBtTJyGI5MJS3cipdMOyW9quCb+2IS4yvyT4xQTeCRBcry7Ju5blpE7PNgbZ nHnp5rJjCIl9WCPWS89FnGZLwUYHvCBE+oFEjo78wkLrSzc4SHYGom2zFSyntaqSYfqOaKgwuZAKN 70yEMoJg4TciTjz/hg8zTIFd7CAI+1EH5uMJDwRWIEeHHZCHY+8epI6aQQ6ceA/ti5S0klrhVO9ef buj6scSmZ9i+51W/7WcSYXPLjxly24qQFnnOwkW+88v2oY1w3FusAB5p2nCmtH0DuewlUtiAF+6MH M/uZz/TJiGziSzhPwSeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz9aq-0000000FTAO-1kSp; Fri, 11 Oct 2024 06:57:44 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz9VB-0000000FS1x-40Jf; Fri, 11 Oct 2024 06:51:55 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-71df49bbc2fso159994b3a.1; Thu, 10 Oct 2024 23:51:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728629513; x=1729234313; 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=EdDw79rH2ZZXFzCqs3bPN+dRZOAgzWUPfJIf5p7fl3c=; b=hmSO4dAOMyWGDXFIQA3ST5Y+6Z9SsU6ON/3ovpolpbVEFjRM/2ajmkzYlEB3x2pxBT eJE/joKmbkZGwLzkwYKWndaZVWkeWXJ6jK1XSzOztaVzUmicSPMgabjVR7P6m3LHm+1P jOsFufsIaZG4eN4L/L4EsMZRdevfvHYnrScM6l6gMqROq+h7HUOpiH6N+O+UkkChDRe5 nqPtC3X3hVrEVhvvH+V63Z+jNklfeE/bWIoZJenlA1vQaIufeyfJqQWmwIPvcZ8TAT3q n/vL1kLXQNoK6xzMXtee3ig4KrHpkw5aLFUqLjjzBdxMp0LAyADykuKi3uRtPEY11FU1 Nq1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728629513; x=1729234313; 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=EdDw79rH2ZZXFzCqs3bPN+dRZOAgzWUPfJIf5p7fl3c=; b=gI4UQePCFlNEr3pGfTCtAWUv5MglbpG3eiU3tbS97AcqYOgcZlVXLM+wM3buWzacne ORIyqXhn90KUE8WoP5/ZagSOym2Zn0fkj+bRHzTWeLZLJLjxjou3miRB7xfBHW2d/6P5 JKN9nsxAQX8izZIwa0ebdbfNdxcOIn/kvHY8Jl2jBecc9XkZNsj9QSmx09ApAOQWIIyB IkPnVtSZ+XlpttmaIhUn30+642RWcefR3tJfBsd2xySd9yueOTN1dSD0EKdpBmDkA63N Kp7lof4Oy5VilH7/JKU6Sv9Ieo6jtRhcxdnzstT0ip2ymUz8DCrqTb84NEmFxJ1f+6S2 4rgg== X-Forwarded-Encrypted: i=1; AJvYcCUMqiAZchG5JqhDiYYlUYI2v4mSTBGRkOU9fCfJRTE39uKEuvWm2yXTwvs2jIpencuE4QI5ZRY2bViKf0uQXQtW@lists.infradead.org, AJvYcCXtW/ITolf23qh7ZH3Ze2aw7mp+82sZu6371TB972nyUqUD9m96bFzusBlCvT0QNXO8cNBOoEcfoiUXcswXhVo=@lists.infradead.org X-Gm-Message-State: AOJu0YwnxlP+el6LT7bP+lNOjcNBdF960GN2gmAg/01V9lasY5huoofB NWM9APs13aSzaA1u6y2EqWz9ZovyjzXeKpuRkdPsFKZjwq4CJc8E X-Google-Smtp-Source: AGHT+IEvzv0o+ss8gCY1Mp117fH1qmaJdW78qEOqQWOSBsVTBUkvz8aULfP30Jh+8lxMYgt+jtRYDg== X-Received: by 2002:a05:6a00:92a8:b0:71e:3b51:e84d with SMTP id d2e1a72fcca58-71e3b51ea63mr796027b3a.4.1728629512713; Thu, 10 Oct 2024 23:51:52 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2ab109e4sm2036099b3a.206.2024.10.10.23.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 23:51:52 -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 Subject: [PATCH v5 2/3] dt-bindings: phy: rockchip,inno-usb2phy: add rk3576 Date: Fri, 11 Oct 2024 14:51:39 +0800 Message-Id: <20241011065140.19999-2-frawang.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241011065140.19999-1-frawang.cn@gmail.com> References: <20241011065140.19999-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-20241010_235154_030034_3A2C969E X-CRM114-Status: GOOD ( 11.38 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Krzysztof Kozlowski Reviewed-by: Heiko Stuebner --- Changelog: v5: - move the clock-names item list to top-level property. - only defined minItems/maxItems in each if: then block. 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 | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml b/Documentation/devicetree/bindings/phy/rockchip,inno-usb2phy.yaml index 5254413137c64..6a7ef556414ce 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,15 @@ properties: const: 0 clocks: - maxItems: 1 + minItems: 1 + maxItems: 3 clock-names: - const: phyclk + minItems: 1 + items: + - const: phyclk + - const: aclk + - const: aclk_slv assigned-clocks: description: @@ -172,6 +178,41 @@ 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: + maxItems: 1 + + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3576-usb2phy + then: + properties: + clocks: + minItems: 3 + clock-names: + minItems: 3 + additionalProperties: false examples: From patchwork Fri Oct 11 06:51:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wang X-Patchwork-Id: 13832143 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 F083BD2447B for ; Fri, 11 Oct 2024 06:59:05 +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=fbqiWVGdXlaSo/hD8Nui2Hd0/unbliyuHQiMHwFBI2M=; b=Z3TZ0bnBmTmym+ PejlrWkNhc9beyR+dgZ56yie/6riNAprCOzKvrXwhDHNg1TJquJ8ezfEBj0q8+2MTyHEUTL9Cnmq5 r00ZJH30e76Y2V06Xu0C8jPHpvdcVw8/7KU4Jv6ibK4oV8MxQ0V4YRd/HgIiCBDomtTFNO9PO225D ZlfxmL1k2nG2IJnGI1YRjjzd4kheI3ky3tjFER6CCe+hEFFw5qaUjcsK+3r9bJKvxIpuEahRG8iup oEqyCwWQWDfj7j5+8rE1CdCtNgAFs8eHd7bEYobq+DVOnC61VdaV69tB37c/zX/+ppmdjrCx6+m1q hppdfhP8vjV06XRUhFTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz9c9-0000000FTHR-2SwC; Fri, 11 Oct 2024 06:59:05 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sz9VG-0000000FS3e-0KI2; Fri, 11 Oct 2024 06:51:59 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-71e01eff868so138961b3a.1; Thu, 10 Oct 2024 23:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728629517; x=1729234317; 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=RoXrcFLiduR8K9NPSxdvgXuql0UA1hd/Qh6Orl6Z1QI=; b=Z6irtxnbT1tFyAdZVVVP6DFl/GQ2ZFba/II//loH8zzz69Y/J9YGCDWytoMddkgRii eiA5b/NB1AfgA+DFbOFSBqfwRaJonR1YPHAUouqTAtjGzj2MF2bB1p/H+Ueshpk7Y1kW gk/VjeuyE2Pad0BCrvC6e0MDPt2y3PXu9Sctub+vCZXoRODNcF3wCa5y4mlB8G8ReQWl 80HlUOXdcjcV0s9pwaY6WEG/LiDR1b3/1Q+I788rk8b+9n4RA4XPtpUBYWDTWj0NuSz+ +zV/0bAgpysH+L/o5qqxjnbg2/y/WQ/u3oGpAtXgpYwqQF/+d5KQux6uSYh6J9OjZtNL Ya9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728629517; x=1729234317; 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=RoXrcFLiduR8K9NPSxdvgXuql0UA1hd/Qh6Orl6Z1QI=; b=tQAB2DpQpX5KOGLqm1mnumkiQ/IPr1/6A3PekVUVyQfKM1E0LfP3jLx7ssJelBS0pH m6jhcYXjhiHTCw3IpTtLeNJnlSz2sLRkvYbGuhXyHWP6LFRwfDEhCqRiQK2XjHh5Gxq3 uoiKVup818yVtfyVnjXovhGJhlKA/Je8NelDMHhR227fRa6rhT6FW9B6Mb6yd9rpc8xc oZA1JA7vvqaMVxatAodcibk3aznYfS2o1WPUezrViUTgSXpy0MGkn5zhwJ7C/TggD4cZ GletCWcKU7Z4oRkRv7nvK3eUoEowEW5b/bIC5EAlnB1PkeXtIp87gaSh17y4JiZhwXbs V0GA== X-Forwarded-Encrypted: i=1; AJvYcCWWweOhNCcI3HlYW7RBEPsnFcFLDgBMQBE1aMLLhGFYyWT6ZaqcLlPpRrPewE8fJme7EfL3Tj3Tm2sAGVZDe8A=@lists.infradead.org, AJvYcCX/IM5+g1qNTBAVXr1jQtn2Sz8nhQ3rZThABcB5zDiICEvTEzxkYqQZF1UAaZQdjMy5o9Y301rPfnU+8QhYmTl4@lists.infradead.org X-Gm-Message-State: AOJu0YxCH90wiy0h4UryKg5K0fvy73fLljREJcwO49GEjkrS76AXurcx WHTsbn30CGt2U2zec1nbJ+6mEQYFHajElUJArS1eENtilQyKEwJ0 X-Google-Smtp-Source: AGHT+IE0a4raEMb1CKHZOr3RN/vfXnIURFS+NIbfrAYdekgJC1BrJeUqK/aGlnsCilzTxJ63p8IKRQ== X-Received: by 2002:a05:6a00:9453:b0:71d:f2d9:bd5d with SMTP id d2e1a72fcca58-71e380c5a41mr1100111b3a.7.1728629516958; Thu, 10 Oct 2024 23:51:56 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2ab109e4sm2036099b3a.206.2024.10.10.23.51.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 23:51:56 -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 Subject: [PATCH v5 3/3] phy: rockchip: inno-usb2: Add usb2 phys support for rk3576 Date: Fri, 11 Oct 2024 14:51:40 +0800 Message-Id: <20241011065140.19999-3-frawang.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241011065140.19999-1-frawang.cn@gmail.com> References: <20241011065140.19999-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-20241010_235158_147463_6DE7F81E X-CRM114-Status: GOOD ( 15.20 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Heiko Stuebner --- Changelog: v5: - no changes. 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 f71266c27091e..96f3d868a526f 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1510,6 +1510,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; @@ -1938,6 +1962,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, @@ -2109,6 +2211,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 }, {}