From patchwork Fri Dec 6 10:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13896976 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 225D4E7717B for ; Fri, 6 Dec 2024 10:49:11 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FoLUAVv4jozml8lmMwENZc0zyFI2Q4HEyBHzGUHeaHk=; b=L0zbmW+6Dazswv YZuwVUNqVh99GAOo24myinZduIsugJ9P2dCmzEUBkQwhMDhc2H4jFM7OF1L7aJc06OSx0IEcDnEel +2lFbpSBv+ZeB0eYFw9bbWXNoM+pE0Gsdz1HtPty65gRIXg1zzXXWbWHXxHtDhPvDrTYHT4ie6YRd Gz/pXhuPhdJwlMtgBe3cDs8fr+5lOKbLXY2vJfOtRDN6mOJDU6FcS/yVm90mW8ITyyII5mFEYP50d rVw+m4Ze8Gay7Sm8PoN4cfjwX90AvhxSfVauqYzAbOMYEW1V4dIq6YmEtn+2VmUHRFD9Ys5+GvX3K iK9heGbU9xygJ4vZVQ7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJVtU-00000001MCI-31ju; Fri, 06 Dec 2024 10:49:08 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJVfL-00000001JTb-2n3d; Fri, 06 Dec 2024 10:34:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SO3Xh29xRkdmQmLn6fa6N/djXaj2dmx9KQNMok66AoA=; b=vhB6ht+507ZVQSUB/53u6YxVEU kkBQESnINzaHc1MK6vkAs0aYmwVtf6XKW8ezYAx8gR6xYpsigr9GLQEwjKX6aRBOyabg4wRVEnmbX ziVvluAie5euLgQmRYlvSAbtuFx/Iq8dVaQG+nS1Hd6wUzPQakaV3Xi5gEZLrIs21SHuWZ1KmTChV DzzwqQ2Hr+wU8UhIRB7Y4ZVrxEZe5ADNKv6po5N85a4R5MfwBbeBeK6DlMtN1Mn46LGSyyUF1xF8b 1fSWBlXHad+EZ0mdZujv/FFcCX3KMwsuMK/5dNF0eyXje0nTX6HRzFtoIZ/iP0zCtwb3MvX6Ffwib R3oVHnwA==; Received: from i53875bc4.versanet.de ([83.135.91.196] helo=localhost.localdomain) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJVfI-0007XU-0C; Fri, 06 Dec 2024 11:34:28 +0100 From: Heiko Stuebner To: vkoul@kernel.org, kishon@kernel.org Subject: [PATCH 1/2] phy: phy-rockchip-samsung-hdptx: annotate regmap register-callback Date: Fri, 6 Dec 2024 11:34:00 +0100 Message-ID: <20241206103401.1780416-2-heiko@sntech.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206103401.1780416-1-heiko@sntech.de> References: <20241206103401.1780416-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241206_023431_744408_042D3912 X-CRM114-Status: GOOD ( 10.81 ) 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: , Cc: heiko@sntech.de, linux-rockchip@lists.infradead.org, quentin.schulz@cherry.de, linux-kernel@vger.kernel.org, Heiko Stuebner , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Heiko Stuebner The variant of the driver in the vendor-tree contained those handy comments in the regmap register callback. Having the different ranges describe what they are looks helpful. Signed-off-by: Heiko Stuebner Reviewed-by: Cristian Ciocaltea --- drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c index 4ced1479e2dc..c5c64c209e96 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -766,13 +766,13 @@ static struct tx_drv_ctrl tx_drv_ctrl_hbr2[4][4] = { static bool rk_hdptx_phy_is_rw_reg(struct device *dev, unsigned int reg) { switch (reg) { - case 0x0000 ... 0x029c: - case 0x0400 ... 0x04a4: - case 0x0800 ... 0x08a4: - case 0x0c00 ... 0x0cb4: - case 0x1000 ... 0x10b4: - case 0x1400 ... 0x14b4: - case 0x1800 ... 0x18b4: + case 0x0000 ... 0x029c: /* CMN Register */ + case 0x0400 ... 0x04a4: /* Sideband Register */ + case 0x0800 ... 0x08a4: /* Lane Top Register */ + case 0x0c00 ... 0x0cb4: /* Lane 0 Register */ + case 0x1000 ... 0x10b4: /* Lane 1 Register */ + case 0x1400 ... 0x14b4: /* Lane 2 Register */ + case 0x1800 ... 0x18b4: /* Lane 3 Register */ return true; } From patchwork Fri Dec 6 10:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 13896977 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 03859E77173 for ; Fri, 6 Dec 2024 10:50:22 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PbWR759NjwHuMQ4vR1bWpXrji10YuqepMgQzWdgfSDc=; b=AvVnYAl1uD6tz/ YHpSNSX01y2Km6cv/nNJEWpg7oHKTYpUCmYOQdVH0pCoBf24MM9qmw61Cdo6QkgqXgaMUQrw/k1qV EHDILA7FBz1YS14l2CWteNPKP85upBAGJwtr02wSm5UZzL278Ok18pljqE6NzJWg6OihINai5WRvR eEYHt7iFcjpeVVWh2U+LWYcEh3q04rt8dgugLpVRkbuAn4kVKBFkLP2yU8NnhFFkFQUUOodF17Y/a uiZDh98Hkf2XhlzCo6J23eg5z1eE8X4dAwz8fRwMcmOmXI9TC7dojrxh/QSlmLNeC+/LyOvdewWqb IXSwUXxwsf8naGdo+JBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJVub-00000001MUL-0hPN; Fri, 06 Dec 2024 10:50:17 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJVfL-00000001JTs-3NZ4; Fri, 06 Dec 2024 10:34:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1UN1KsYoShLP+jnqNIAIPC6ZRY2mrO3AN1No45ThK+A=; b=mzzy5mD5NWF6ZSh19e3QQ5MydT S5w2G+L96caWc7NlxMc1pxfCni2jc1+nhvTDAOp0652BZqOQOn7zpvMrBMZNef69oIJ8S2EjbrAkz pSB5htNJrn9KGuTcM/t9QQyr/2NbBPKZF0MBsTvKVTmfeohLMeGyP2UpgSW9IIyGX4gefdeKl0mjz 5jWZQ1+1tuZwfuZ23ntF+1ZJkS4G9UMXzL8HxOyFXux6580OnWhyI03SRtOPJNdkQT6LznCuP0YxA JREvhPDW2uI5gKotYB4zCR2T1paeX8zLjB/un6zWB9f7sh0rXMxuHQtBI+J+ZGF+0WIchelknuohz Vd9/2/ow==; Received: from i53875bc4.versanet.de ([83.135.91.196] helo=localhost.localdomain) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tJVfI-0007XU-FB; Fri, 06 Dec 2024 11:34:28 +0100 From: Heiko Stuebner To: vkoul@kernel.org, kishon@kernel.org Subject: [PATCH 2/2] phy: phy-rockchip-samsung-hdptx: Don't use dt aliases to determine phy-id Date: Fri, 6 Dec 2024 11:34:01 +0100 Message-ID: <20241206103401.1780416-3-heiko@sntech.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206103401.1780416-1-heiko@sntech.de> References: <20241206103401.1780416-1-heiko@sntech.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241206_023431_868087_7ACF6AA4 X-CRM114-Status: GOOD ( 21.03 ) 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: , Cc: heiko@sntech.de, linux-rockchip@lists.infradead.org, quentin.schulz@cherry.de, linux-kernel@vger.kernel.org, Heiko Stuebner , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Heiko Stuebner The phy needs to know its identity in the system (phy0 or phy1 on rk3588) for some actions and the driver currently contains code abusing of_alias for that. Devicetree aliases are always optional and should not be used for core device functionality, so instead keep a list of phys on a soc in the of_device_data and find the phy-id by comparing against the mapped register-base. Fixes: c4b09c562086 ("phy: phy-rockchip-samsung-hdptx: Add clock provider support") Signed-off-by: Heiko Stuebner Reviewed-by: Cristian Ciocaltea --- .../phy/rockchip/phy-rockchip-samsung-hdptx.c | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c index c5c64c209e96..b137f8c4d157 100644 --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c @@ -385,11 +385,22 @@ enum rk_hdptx_reset { RST_MAX }; +#define MAX_HDPTX_PHY_NUM 2 + +struct rk_hdptx_phy_cfg { + unsigned int num_phys; + unsigned int phy_ids[MAX_HDPTX_PHY_NUM]; +}; + struct rk_hdptx_phy { struct device *dev; struct regmap *regmap; struct regmap *grf; + /* PHY const config */ + const struct rk_hdptx_phy_cfg *cfgs; + int phy_id; + struct phy *phy; struct phy_config *phy_cfg; struct clk_bulk_data *clks; @@ -1857,15 +1868,14 @@ static int rk_hdptx_phy_clk_register(struct rk_hdptx_phy *hdptx) struct device *dev = hdptx->dev; const char *name, *pname; struct clk *refclk; - int ret, id; + int ret; refclk = devm_clk_get(dev, "ref"); if (IS_ERR(refclk)) return dev_err_probe(dev, PTR_ERR(refclk), "Failed to get ref clock\n"); - id = of_alias_get_id(dev->of_node, "hdptxphy"); - name = id > 0 ? "clk_hdmiphy_pixel1" : "clk_hdmiphy_pixel0"; + name = hdptx->phy_id > 0 ? "clk_hdmiphy_pixel1" : "clk_hdmiphy_pixel0"; pname = __clk_get_name(refclk); hdptx->hw.init = CLK_HW_INIT(name, pname, &hdptx_phy_clk_ops, @@ -1908,8 +1918,9 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev) struct phy_provider *phy_provider; struct device *dev = &pdev->dev; struct rk_hdptx_phy *hdptx; + struct resource *res; void __iomem *regs; - int ret; + int ret, id; hdptx = devm_kzalloc(dev, sizeof(*hdptx), GFP_KERNEL); if (!hdptx) @@ -1917,11 +1928,27 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev) hdptx->dev = dev; - regs = devm_platform_ioremap_resource(pdev, 0); + regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(regs)) return dev_err_probe(dev, PTR_ERR(regs), "Failed to ioremap resource\n"); + hdptx->cfgs = device_get_match_data(dev); + if (!hdptx->cfgs) + return dev_err_probe(dev, -EINVAL, "missing match data\n"); + + /* find the phy-id from the io address */ + hdptx->phy_id = -ENODEV; + for (id = 0; id < hdptx->cfgs->num_phys; id++) { + if (res->start == hdptx->cfgs->phy_ids[id]) { + hdptx->phy_id = id; + break; + } + } + + if (hdptx->phy_id < 0) + return dev_err_probe(dev, -ENODEV, "no matching device found\n"); + ret = devm_clk_bulk_get_all(dev, &hdptx->clks); if (ret < 0) return dev_err_probe(dev, ret, "Failed to get clocks\n"); @@ -1981,8 +2008,19 @@ static const struct dev_pm_ops rk_hdptx_phy_pm_ops = { rk_hdptx_phy_runtime_resume, NULL) }; +static const struct rk_hdptx_phy_cfg rk3588_hdptx_phy_cfgs = { + .num_phys = 2, + .phy_ids = { + 0xfed60000, + 0xfed70000, + }, +}; + static const struct of_device_id rk_hdptx_phy_of_match[] = { - { .compatible = "rockchip,rk3588-hdptx-phy", }, + { + .compatible = "rockchip,rk3588-hdptx-phy", + .data = &rk3588_hdptx_phy_cfgs + }, {} }; MODULE_DEVICE_TABLE(of, rk_hdptx_phy_of_match);