* [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY
@ 2024-06-17 21:48 Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h Cristian Ciocaltea
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-17 21:48 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
The HDMI PHY PLL can be used as an alternative clock source to RK3588
SoC CRU. Since it provides more accurate clock rates, it can be used by
VOP2 to improve display modes handling, such as supporting non-integer
refresh rates.
The first two patches in the series provide a couple of fixes and
improvements to the existing HDPTX PHY driver, while the next two add
the necessary changes to support the clock provider functionality.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Cristian Ciocaltea (4):
phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h
phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level
dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells
phy: phy-rockchip-samsung-hdptx: Add clock provider support
.../bindings/phy/rockchip,rk3588-hdptx-phy.yaml | 3 +
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 208 +++++++++++++++++----
2 files changed, 174 insertions(+), 37 deletions(-)
---
base-commit: 6906a84c482f098d31486df8dc98cead21cce2d0
change-id: 20240617-rk3588-hdmiphy-clkprov-f05f165ac029
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h
2024-06-17 21:48 [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY Cristian Ciocaltea
@ 2024-06-17 21:48 ` Cristian Ciocaltea
2024-06-18 7:47 ` Heiko Stübner
2024-06-17 21:48 ` [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level Cristian Ciocaltea
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-17 21:48 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
Driver makes use of helpers from pm_runtime.h, but relies on the header
file being implicitly included.
Explicitly pull the header in to avoid potential build failures in some
configurations.
Fixes: 553be2830c5f ("phy: rockchip: Add Samsung HDMI/eDP Combo PHY driver")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 946c01210ac8..3bd9b62b23dc 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -15,6 +15,7 @@
#include <linux/of_platform.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/rational.h>
#include <linux/regmap.h>
#include <linux/reset.h>
--
2.45.2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level
2024-06-17 21:48 [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h Cristian Ciocaltea
@ 2024-06-17 21:48 ` Cristian Ciocaltea
2024-06-18 7:51 ` Heiko Stübner
2024-06-17 21:48 ` [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support Cristian Ciocaltea
3 siblings, 1 reply; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-17 21:48 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
When a new PHY is created via [devm_]phy_create(), the runtime PM for it
is not enabled unless the parent device (which creates the PHY) has its
own runtime PM already enabled.
Move the call to devm_pm_runtime_enable() before devm_phy_create() to
enable runtime PM at PHY core level.
With this change the ->power_on() and ->power_off() callbacks do not
require explicit runtime PM management anymore, since the PHY core
handles that via phy_pm_runtime_{get,put}_sync() when phy_power_on() and
phy_power_off() are invoked.
Hence drop the now unnecessary calls to pm_runtime_resume_and_get() and
pm_runtime_put() helpers.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 24 ++++++-----------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 3bd9b62b23dc..72de287282eb 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -860,7 +860,7 @@ static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
static int rk_hdptx_phy_power_on(struct phy *phy)
{
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
- int ret, bus_width = phy_get_bus_width(hdptx->phy);
+ int bus_width = phy_get_bus_width(hdptx->phy);
/*
* FIXME: Temporary workaround to pass pixel_clk_rate
* from the HDMI bridge driver until phy_configure_opts_hdmi
@@ -871,17 +871,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
dev_dbg(hdptx->dev, "%s bus_width=%x rate=%u\n",
__func__, bus_width, rate);
- ret = pm_runtime_resume_and_get(hdptx->dev);
- if (ret) {
- dev_err(hdptx->dev, "Failed to resume phy: %d\n", ret);
- return ret;
- }
-
- ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
- if (ret)
- pm_runtime_put(hdptx->dev);
-
- return ret;
+ return rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
}
static int rk_hdptx_phy_power_off(struct phy *phy)
@@ -894,8 +884,6 @@ static int rk_hdptx_phy_power_off(struct phy *phy)
if (ret == 0 && (val & HDPTX_O_PLL_LOCK_DONE))
rk_hdptx_phy_disable(hdptx);
- pm_runtime_put(hdptx->dev);
-
return ret;
}
@@ -977,6 +965,10 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(hdptx->grf),
"Could not get GRF syscon\n");
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+
hdptx->phy = devm_phy_create(dev, NULL, &rk_hdptx_phy_ops);
if (IS_ERR(hdptx->phy))
return dev_err_probe(dev, PTR_ERR(hdptx->phy),
@@ -986,10 +978,6 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev)
phy_set_drvdata(hdptx->phy, hdptx);
phy_set_bus_width(hdptx->phy, 8);
- ret = devm_pm_runtime_enable(dev);
- if (ret)
- return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
-
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),
--
2.45.2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells
2024-06-17 21:48 [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level Cristian Ciocaltea
@ 2024-06-17 21:48 ` Cristian Ciocaltea
2024-06-18 6:42 ` Krzysztof Kozlowski
2024-06-17 21:48 ` [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support Cristian Ciocaltea
3 siblings, 1 reply; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-17 21:48 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
The HDMI PHY can be used as a clock provider on RK3588 SoC, hence add
the necessary '#clock-cells' property.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Documentation/devicetree/bindings/phy/rockchip,rk3588-hdptx-phy.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/phy/rockchip,rk3588-hdptx-phy.yaml b/Documentation/devicetree/bindings/phy/rockchip,rk3588-hdptx-phy.yaml
index 54e822c715f3..84fe59dbcf48 100644
--- a/Documentation/devicetree/bindings/phy/rockchip,rk3588-hdptx-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/rockchip,rk3588-hdptx-phy.yaml
@@ -27,6 +27,9 @@ properties:
- const: ref
- const: apb
+ "#clock-cells":
+ const: 0
+
"#phy-cells":
const: 0
--
2.45.2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support
2024-06-17 21:48 [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY Cristian Ciocaltea
` (2 preceding siblings ...)
2024-06-17 21:48 ` [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells Cristian Ciocaltea
@ 2024-06-17 21:48 ` Cristian Ciocaltea
2024-06-18 7:55 ` Heiko Stübner
3 siblings, 1 reply; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-17 21:48 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
The HDMI PHY PLL can be used as an alternative dclk source to RK3588 SoC
CRU. It provides more accurate clock rates required by VOP2 to improve
existing support for display modes handling, which is known to be
problematic when dealing with non-integer refresh rates, among others.
It is worth noting this only works for HDMI 2.0 or below, e.g. cannot be
used to support HDMI 2.1 4K@120Hz mode.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 189 +++++++++++++++++++---
1 file changed, 167 insertions(+), 22 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 72de287282eb..ad3fd4084377 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -8,6 +8,7 @@
*/
#include <linux/bitfield.h>
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
@@ -191,6 +192,8 @@
#define LN3_TX_SER_RATE_SEL_HBR2 BIT(3)
#define LN3_TX_SER_RATE_SEL_HBR3 BIT(2)
+#define HDMI20_MAX_RATE 600000000
+
struct lcpll_config {
u32 bit_rate;
u8 lcvco_mode_en;
@@ -273,6 +276,12 @@ struct rk_hdptx_phy {
struct clk_bulk_data *clks;
int nr_clks;
struct reset_control_bulk_data rsts[RST_MAX];
+
+ /* clk provider */
+ struct clk_hw hw;
+ unsigned long rate;
+
+ atomic_t usage_count;
};
static const struct ropll_config ropll_tmds_cfg[] = {
@@ -760,6 +769,8 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
struct ropll_config rc = {0};
int i;
+ hdptx->rate = rate * 100;
+
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
if (rate == ropll_tmds_cfg[i].bit_rate) {
cfg = &ropll_tmds_cfg[i];
@@ -823,19 +834,6 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
unsigned int rate)
{
- u32 val;
- int ret;
-
- ret = regmap_read(hdptx->grf, GRF_HDPTX_STATUS, &val);
- if (ret)
- return ret;
-
- if (!(val & HDPTX_O_PLL_LOCK_DONE)) {
- ret = rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
- if (ret)
- return ret;
- }
-
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_common_sb_init_seq);
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
@@ -857,10 +855,66 @@ static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
return rk_hdptx_post_enable_lane(hdptx);
}
+static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
+ unsigned int rate)
+{
+ u32 status;
+ int ret;
+
+ if (atomic_inc_return(&hdptx->usage_count) > 1)
+ return 0;
+
+ ret = regmap_read(hdptx->grf, GRF_HDPTX_STATUS, &status);
+ if (ret)
+ goto dec_usage;
+
+ if (status & HDPTX_O_PLL_LOCK_DONE)
+ dev_warn(hdptx->dev, "PLL locked by unknown consumer!\n");
+
+ if (rate) {
+ ret = rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
+ if (ret)
+ goto dec_usage;
+ }
+
+ return 0;
+
+dec_usage:
+ atomic_dec(&hdptx->usage_count);
+ return ret;
+}
+
+static int rk_hdptx_phy_consumer_put(struct rk_hdptx_phy *hdptx)
+{
+ u32 status;
+ int ret;
+
+ ret = atomic_dec_return(&hdptx->usage_count);
+ if (ret > 0)
+ return 0;
+
+ if (ret < 0) {
+ dev_warn(hdptx->dev, "Usage count underflow!\n");
+ ret = -EINVAL;
+ } else {
+ ret = regmap_read(hdptx->grf, GRF_HDPTX_STATUS, &status);
+ if (!ret) {
+ if (status & HDPTX_O_PLL_LOCK_DONE)
+ rk_hdptx_phy_disable(hdptx);
+ return 0;
+ }
+ }
+
+ atomic_inc(&hdptx->usage_count);
+ return ret;
+}
+
static int rk_hdptx_phy_power_on(struct phy *phy)
{
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
int bus_width = phy_get_bus_width(hdptx->phy);
+ int ret;
+
/*
* FIXME: Temporary workaround to pass pixel_clk_rate
* from the HDMI bridge driver until phy_configure_opts_hdmi
@@ -871,20 +925,18 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
dev_dbg(hdptx->dev, "%s bus_width=%x rate=%u\n",
__func__, bus_width, rate);
- return rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
+ ret = rk_hdptx_phy_consumer_get(hdptx, rate);
+ if (!ret)
+ ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
+
+ return ret;
}
static int rk_hdptx_phy_power_off(struct phy *phy)
{
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
- u32 val;
- int ret;
-
- ret = regmap_read(hdptx->grf, GRF_HDPTX_STATUS, &val);
- if (ret == 0 && (val & HDPTX_O_PLL_LOCK_DONE))
- rk_hdptx_phy_disable(hdptx);
- return ret;
+ return rk_hdptx_phy_consumer_put(hdptx);
}
static const struct phy_ops rk_hdptx_phy_ops = {
@@ -893,6 +945,99 @@ static const struct phy_ops rk_hdptx_phy_ops = {
.owner = THIS_MODULE,
};
+static struct rk_hdptx_phy *to_rk_hdptx_phy(struct clk_hw *hw)
+{
+ return container_of(hw, struct rk_hdptx_phy, hw);
+}
+
+static int rk_hdptx_phy_clk_prepare(struct clk_hw *hw)
+{
+ struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
+
+ return rk_hdptx_phy_consumer_get(hdptx, hdptx->rate / 100);
+}
+
+static void rk_hdptx_phy_clk_unprepare(struct clk_hw *hw)
+{
+ struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
+
+ rk_hdptx_phy_consumer_put(hdptx);
+}
+
+static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
+
+ return hdptx->rate;
+}
+
+static long rk_hdptx_phy_clk_round_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *parent_rate)
+{
+ u32 bit_rate = rate / 100;
+ int i;
+
+ if (rate > HDMI20_MAX_RATE)
+ return rate;
+
+ for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
+ if (bit_rate == ropll_tmds_cfg[i].bit_rate)
+ break;
+
+ if (i == ARRAY_SIZE(ropll_tmds_cfg) &&
+ !rk_hdptx_phy_clk_pll_calc(bit_rate, NULL))
+ return -EINVAL;
+
+ return rate;
+}
+
+static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
+
+ return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate / 100);
+}
+
+static const struct clk_ops hdptx_phy_clk_ops = {
+ .prepare = rk_hdptx_phy_clk_prepare,
+ .unprepare = rk_hdptx_phy_clk_unprepare,
+ .recalc_rate = rk_hdptx_phy_clk_recalc_rate,
+ .round_rate = rk_hdptx_phy_clk_round_rate,
+ .set_rate = rk_hdptx_phy_clk_set_rate,
+};
+
+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;
+
+ 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";
+ pname = __clk_get_name(refclk);
+
+ hdptx->hw.init = CLK_HW_INIT(name, pname, &hdptx_phy_clk_ops,
+ CLK_GET_RATE_NOCACHE);
+
+ ret = devm_clk_hw_register(dev, &hdptx->hw);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to register clock\n");
+
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &hdptx->hw);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "Failed to register clk provider\n");
+ return 0;
+}
+
static int rk_hdptx_phy_runtime_suspend(struct device *dev)
{
struct rk_hdptx_phy *hdptx = dev_get_drvdata(dev);
@@ -987,7 +1132,7 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev)
reset_control_deassert(hdptx->rsts[RST_CMN].rstc);
reset_control_deassert(hdptx->rsts[RST_INIT].rstc);
- return 0;
+ return rk_hdptx_phy_clk_register(hdptx);
}
static const struct dev_pm_ops rk_hdptx_phy_pm_ops = {
--
2.45.2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells
2024-06-17 21:48 ` [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells Cristian Ciocaltea
@ 2024-06-18 6:42 ` Krzysztof Kozlowski
0 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-18 6:42 UTC (permalink / raw)
To: Cristian Ciocaltea, Vinod Koul, Kishon Vijay Abraham I,
Heiko Stuebner, Algea Cao, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
On 17/06/2024 23:48, Cristian Ciocaltea wrote:
> The HDMI PHY can be used as a clock provider on RK3588 SoC, hence add
> the necessary '#clock-cells' property.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h
2024-06-17 21:48 ` [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h Cristian Ciocaltea
@ 2024-06-18 7:47 ` Heiko Stübner
0 siblings, 0 replies; 10+ messages in thread
From: Heiko Stübner @ 2024-06-18 7:47 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Algea Cao, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Cristian Ciocaltea
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
Am Montag, 17. Juni 2024, 23:48:09 CEST schrieb Cristian Ciocaltea:
> Driver makes use of helpers from pm_runtime.h, but relies on the header
> file being implicitly included.
>
> Explicitly pull the header in to avoid potential build failures in some
> configurations.
>
> Fixes: 553be2830c5f ("phy: rockchip: Add Samsung HDMI/eDP Combo PHY driver")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level
2024-06-17 21:48 ` [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level Cristian Ciocaltea
@ 2024-06-18 7:51 ` Heiko Stübner
0 siblings, 0 replies; 10+ messages in thread
From: Heiko Stübner @ 2024-06-18 7:51 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Algea Cao, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Cristian Ciocaltea
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
Am Montag, 17. Juni 2024, 23:48:10 CEST schrieb Cristian Ciocaltea:
> When a new PHY is created via [devm_]phy_create(), the runtime PM for it
> is not enabled unless the parent device (which creates the PHY) has its
> own runtime PM already enabled.
>
> Move the call to devm_pm_runtime_enable() before devm_phy_create() to
> enable runtime PM at PHY core level.
>
> With this change the ->power_on() and ->power_off() callbacks do not
> require explicit runtime PM management anymore, since the PHY core
> handles that via phy_pm_runtime_{get,put}_sync() when phy_power_on() and
> phy_power_off() are invoked.
>
> Hence drop the now unnecessary calls to pm_runtime_resume_and_get() and
> pm_runtime_put() helpers.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
checked against phy_create()
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support
2024-06-17 21:48 ` [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support Cristian Ciocaltea
@ 2024-06-18 7:55 ` Heiko Stübner
2024-06-18 11:25 ` Cristian Ciocaltea
0 siblings, 1 reply; 10+ messages in thread
From: Heiko Stübner @ 2024-06-18 7:55 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Algea Cao, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Cristian Ciocaltea
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
Am Montag, 17. Juni 2024, 23:48:12 CEST schrieb Cristian Ciocaltea:
> The HDMI PHY PLL can be used as an alternative dclk source to RK3588 SoC
> CRU. It provides more accurate clock rates required by VOP2 to improve
> existing support for display modes handling, which is known to be
> problematic when dealing with non-integer refresh rates, among others.
>
> It is worth noting this only works for HDMI 2.0 or below, e.g. cannot be
> used to support HDMI 2.1 4K@120Hz mode.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 189 +++++++++++++++++++---
> 1 file changed, 167 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> index 72de287282eb..ad3fd4084377 100644
> --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
> static int rk_hdptx_phy_power_on(struct phy *phy)
> {
> struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
> int bus_width = phy_get_bus_width(hdptx->phy);
> + int ret;
> +
> /*
> * FIXME: Temporary workaround to pass pixel_clk_rate
> * from the HDMI bridge driver until phy_configure_opts_hdmi
> @@ -871,20 +925,18 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
> dev_dbg(hdptx->dev, "%s bus_width=%x rate=%u\n",
> __func__, bus_width, rate);
>
> - return rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
> + ret = rk_hdptx_phy_consumer_get(hdptx, rate);
> + if (!ret)
> + ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
I think this will need a put if _mode_config fails?
> +
> + return ret;
> }
Heiko
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support
2024-06-18 7:55 ` Heiko Stübner
@ 2024-06-18 11:25 ` Cristian Ciocaltea
0 siblings, 0 replies; 10+ messages in thread
From: Cristian Ciocaltea @ 2024-06-18 11:25 UTC (permalink / raw)
To: Heiko Stübner, Vinod Koul, Kishon Vijay Abraham I, Algea Cao,
Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: kernel, linux-phy, linux-arm-kernel, linux-rockchip, linux-kernel,
devicetree
On 6/18/24 10:55 AM, Heiko Stübner wrote:
> Am Montag, 17. Juni 2024, 23:48:12 CEST schrieb Cristian Ciocaltea:
>> The HDMI PHY PLL can be used as an alternative dclk source to RK3588 SoC
>> CRU. It provides more accurate clock rates required by VOP2 to improve
>> existing support for display modes handling, which is known to be
>> problematic when dealing with non-integer refresh rates, among others.
>>
>> It is worth noting this only works for HDMI 2.0 or below, e.g. cannot be
>> used to support HDMI 2.1 4K@120Hz mode.
>>
>> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
>> ---
>> drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 189 +++++++++++++++++++---
>> 1 file changed, 167 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
>> index 72de287282eb..ad3fd4084377 100644
>> --- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
>> +++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
>
>> static int rk_hdptx_phy_power_on(struct phy *phy)
>> {
>> struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
>> int bus_width = phy_get_bus_width(hdptx->phy);
>> + int ret;
>> +
>> /*
>> * FIXME: Temporary workaround to pass pixel_clk_rate
>> * from the HDMI bridge driver until phy_configure_opts_hdmi
>> @@ -871,20 +925,18 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
>> dev_dbg(hdptx->dev, "%s bus_width=%x rate=%u\n",
>> __func__, bus_width, rate);
>>
>> - return rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
>> + ret = rk_hdptx_phy_consumer_get(hdptx, rate);
>> + if (!ret)
>> + ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
>
> I think this will need a put if _mode_config fails?
Indeed, a forced put variant would be required to ignore any
regmap_read() errors and keep usage_count decremented. This should be
also used in rk_hdptx_phy_clk_unprepare(), since ->unprepare() callback
cannot fail.
Will get this fixed in v2.
Thanks for reviewing!
Cristian
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-06-18 11:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 21:48 [PATCH 0/4] Add clock provider support to Rockchip RK3588 HDMI TX PHY Cristian Ciocaltea
2024-06-17 21:48 ` [PATCH 1/4] phy: phy-rockchip-samsung-hdptx: Explicitly include pm_runtime.h Cristian Ciocaltea
2024-06-18 7:47 ` Heiko Stübner
2024-06-17 21:48 ` [PATCH 2/4] phy: phy-rockchip-samsung-hdptx: Enable runtime PM at PHY core level Cristian Ciocaltea
2024-06-18 7:51 ` Heiko Stübner
2024-06-17 21:48 ` [PATCH 3/4] dt-bindings: phy: rockchip,rk3588-hdptx-phy: Add #clock-cells Cristian Ciocaltea
2024-06-18 6:42 ` Krzysztof Kozlowski
2024-06-17 21:48 ` [PATCH 4/4] phy: phy-rockchip-samsung-hdptx: Add clock provider support Cristian Ciocaltea
2024-06-18 7:55 ` Heiko Stübner
2024-06-18 11:25 ` Cristian Ciocaltea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).