* [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management
@ 2025-03-18 12:35 Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 01/14] phy: Add HDMI configuration options Cristian Ciocaltea
` (14 more replies)
0 siblings, 15 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
This series relies on the new HDMI PHY configuration options [1] (patch
included here for convenience) to provide high color depth management
for rockchip-samsung-hdptx, and to introduce a proper solution to setup
the TMDS character rate on this PHY.
[1] https://lore.kernel.org/lkml/d1cff6c03ec3732d2244022029245ab2d954d997.1734340233.git.Sandor.yu@nxp.com/
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
Changes in v6:
- Collected R-b tags from Dmitry
- Updated commit description for "phy: rockchip: samsung-hdptx: Fix
clock ratio setup"
- Added new patch "phy: rockchip: samsung-hdptx: Do no set
rk_hdptx_phy->rate in case of errors"
- Replaced some "unsigned long" and "u32" types with "unsigned long
long" in "phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion
overhead" to match the tmds_char_rate type (Dmitry)
- Added new patch "phy: rockchip: samsung-hdptx: Rename ambiguous
rk_hdptx_phy->rate", originally part of "phy: rockchip: samsung-hdptx:
Optimize internal rate handling" (Dmitry)
- Rebased series onto next-20250317
- Link to v5: https://lore.kernel.org/r/20250308-phy-sam-hdptx-bpc-v5-0-35087287f9d1@collabora.com
Changes in v5:
- Moved the patch eliminating the unnecessary and rather confusing
Hz<->hHz unit conversion before all the others adding new content
- Moved the patch adding high color depth management to the last
position, so that it follows the internal rate handling optimization
- Amended description for a few patches to improve clarity
- Performed some trivial refactoring in some cases while dealing with
rebase conflicts
- Link to v4: https://lore.kernel.org/r/20250304-phy-sam-hdptx-bpc-v4-0-8657847c13f7@collabora.com
Changes in v4:
- Added patches to drop unnecessary phy_cfg & cfgs driver data
- Embedded struct phy_configure_opts_hdmi in driver data (Dmitry)
- Added new patch to provide config params validation support
- Provided a patch to restrict altering TMDS char rate via CCF (Dmitry)
- Made a bunch of small tweaks here and there
- Link to v3: https://lore.kernel.org/r/20250223-phy-sam-hdptx-bpc-v3-0-66a5c8e68327@collabora.com
Changes in v3:
- Rebased series onto next-20250221 and fixed several conflicts due to
the recently introduced eDP support
- Link to v2: https://lore.kernel.org/r/20241212-phy-sam-hdptx-bpc-v2-0-57e672c7c7c4@collabora.com
Changes in v2:
- Added new patches providing a bug fix and several driver cleanups and
improvements
- Link to v1: https://lore.kernel.org/r/20241207-phy-sam-hdptx-bpc-v1-0-03c2e4d6d797@collabora.com
---
Cristian Ciocaltea (13):
phy: hdmi: Add color depth configuration
phy: rockchip: samsung-hdptx: Fix clock ratio setup
phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors
phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config
phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data
phy: rockchip: samsung-hdptx: Drop superfluous cfgs driver data
phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead
phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi
phy: rockchip: samsung-hdptx: Provide config params validation support
phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF
phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate
phy: rockchip: samsung-hdptx: Optimize internal rate handling
phy: rockchip: samsung-hdptx: Add high color depth management
Sandor Yu (1):
phy: Add HDMI configuration options
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 292 +++++++++++++---------
include/linux/phy/phy-hdmi.h | 21 ++
include/linux/phy/phy.h | 7 +-
3 files changed, 202 insertions(+), 118 deletions(-)
---
base-commit: e94bd4ec45ac156616da285a0bf03056cd7430fc
change-id: 20241206-phy-sam-hdptx-bpc-3b05c6276fd7
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v6 01/14] phy: Add HDMI configuration options
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 02/14] phy: hdmi: Add color depth configuration Cristian Ciocaltea
` (13 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
From: Sandor Yu <Sandor.yu@nxp.com>
Allow HDMI PHYs to be configured through the generic
functions through a custom structure added to the generic union.
The parameters added here are based on HDMI PHY
implementation practices. The current set of parameters
should cover the potential users.
Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/d1cff6c03ec3732d2244022029245ab2d954d997.1734340233.git.Sandor.yu@nxp.com
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
include/linux/phy/phy-hdmi.h | 19 +++++++++++++++++++
include/linux/phy/phy.h | 7 ++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/include/linux/phy/phy-hdmi.h b/include/linux/phy/phy-hdmi.h
new file mode 100644
index 0000000000000000000000000000000000000000..6a696922bc7f29af63d88646701b2c0fcee5c885
--- /dev/null
+++ b/include/linux/phy/phy-hdmi.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2022,2024 NXP
+ */
+
+#ifndef __PHY_HDMI_H_
+#define __PHY_HDMI_H_
+
+/**
+ * struct phy_configure_opts_hdmi - HDMI configuration set
+ * @tmds_char_rate: HDMI TMDS Character Rate in Hertz.
+ *
+ * This structure is used to represent the configuration state of a HDMI phy.
+ */
+struct phy_configure_opts_hdmi {
+ unsigned long long tmds_char_rate;
+};
+
+#endif /* __PHY_HDMI_H_ */
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index e63e6e70e860421539179c8178cbe742410cc546..437769e061b7030105c9ea4e9b0da9d32b6fa158 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -17,6 +17,7 @@
#include <linux/regulator/consumer.h>
#include <linux/phy/phy-dp.h>
+#include <linux/phy/phy-hdmi.h>
#include <linux/phy/phy-lvds.h>
#include <linux/phy/phy-mipi-dphy.h>
@@ -42,7 +43,8 @@ enum phy_mode {
PHY_MODE_MIPI_DPHY,
PHY_MODE_SATA,
PHY_MODE_LVDS,
- PHY_MODE_DP
+ PHY_MODE_DP,
+ PHY_MODE_HDMI,
};
enum phy_media {
@@ -60,11 +62,14 @@ enum phy_media {
* the DisplayPort protocol.
* @lvds: Configuration set applicable for phys supporting
* the LVDS phy mode.
+ * @hdmi: Configuration set applicable for phys supporting
+ * the HDMI phy mode.
*/
union phy_configure_opts {
struct phy_configure_opts_mipi_dphy mipi_dphy;
struct phy_configure_opts_dp dp;
struct phy_configure_opts_lvds lvds;
+ struct phy_configure_opts_hdmi hdmi;
};
/**
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 02/14] phy: hdmi: Add color depth configuration
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 01/14] phy: Add HDMI configuration options Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 03/14] phy: rockchip: samsung-hdptx: Fix clock ratio setup Cristian Ciocaltea
` (12 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Extend the HDMI configuration options to allow managing bits per color
channel. This is required by some PHY drivers such as
rockchip-samsung-hdptx.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
include/linux/phy/phy-hdmi.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/phy/phy-hdmi.h b/include/linux/phy/phy-hdmi.h
index 6a696922bc7f29af63d88646701b2c0fcee5c885..f0ec963c6e84f1b7728acafc824dff191c6b873d 100644
--- a/include/linux/phy/phy-hdmi.h
+++ b/include/linux/phy/phy-hdmi.h
@@ -9,11 +9,13 @@
/**
* struct phy_configure_opts_hdmi - HDMI configuration set
* @tmds_char_rate: HDMI TMDS Character Rate in Hertz.
+ * @bpc: Bits per color channel.
*
* This structure is used to represent the configuration state of a HDMI phy.
*/
struct phy_configure_opts_hdmi {
unsigned long long tmds_char_rate;
+ unsigned int bpc;
};
#endif /* __PHY_HDMI_H_ */
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 03/14] phy: rockchip: samsung-hdptx: Fix clock ratio setup
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 01/14] phy: Add HDMI configuration options Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 02/14] phy: hdmi: Add color depth configuration Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 04/14] phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors Cristian Ciocaltea
` (11 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
The switch from 1/10 to 1/40 clock ratio must happen when exceeding the
340 MHz rate limit of HDMI 1.4, i.e. when entering the HDMI 2.0 domain,
and not before.
Therefore, use the correct comparison operator '>' instead of '>=' when
checking the max rate. While at it, introduce a define for this rate
limit constant.
Fixes: 553be2830c5f ("phy: rockchip: Add Samsung HDMI/eDP Combo PHY driver")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index fe7c057483563686b8076cf2ce562440cfa6fe55..34a7ef20936422b540b699f1acba44ca465501b7 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -320,6 +320,7 @@
#define LN3_TX_SER_RATE_SEL_HBR2_MASK BIT(3)
#define LN3_TX_SER_RATE_SEL_HBR3_MASK BIT(2)
+#define HDMI14_MAX_RATE 340000000
#define HDMI20_MAX_RATE 600000000
enum dp_link_rate {
@@ -1072,7 +1073,7 @@ static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
- if (rate >= 3400000) {
+ if (rate > HDMI14_MAX_RATE / 100) {
/* For 1/40 bitrate clk */
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_tmds_lntop_highbr_seq);
} else {
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 04/14] phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (2 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 03/14] phy: rockchip: samsung-hdptx: Fix clock ratio setup Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 05/14] phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config Cristian Ciocaltea
` (10 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Ensure rk_hdptx_ropll_tmds_cmn_config() updates hdptx->rate only after
all the other operations have been successful.
Fixes: c4b09c562086 ("phy: phy-rockchip-samsung-hdptx: Add clock provider support")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 34a7ef20936422b540b699f1acba44ca465501b7..d0989dc5a0173af4de4521e690c3f7b6cc343402 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -1006,9 +1006,7 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
{
const struct ropll_config *cfg = NULL;
struct ropll_config rc = {0};
- int i;
-
- hdptx->rate = rate * 100;
+ int ret, i;
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
if (rate == ropll_tmds_cfg[i].bit_rate) {
@@ -1063,7 +1061,11 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
regmap_update_bits(hdptx->regmap, CMN_REG(0086), PLL_PCG_CLK_EN_MASK,
FIELD_PREP(PLL_PCG_CLK_EN_MASK, 0x1));
- return rk_hdptx_post_enable_pll(hdptx);
+ ret = rk_hdptx_post_enable_pll(hdptx);
+ if (!ret)
+ hdptx->rate = rate * 100;
+
+ return ret;
}
static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 05/14] phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (3 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 04/14] phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 06/14] phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data Cristian Ciocaltea
` (9 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
This is just a leftover from downstream support for HDMI 2.1.
Remove the unused struct for now.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 31 -----------------------
1 file changed, 31 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index d0989dc5a0173af4de4521e690c3f7b6cc343402..70621687b5eb3581a81af20b23d0be53263003bb 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -329,37 +329,6 @@ enum dp_link_rate {
DP_BW_HBR2,
};
-struct lcpll_config {
- u32 bit_rate;
- u8 lcvco_mode_en;
- u8 pi_en;
- u8 clk_en_100m;
- u8 pms_mdiv;
- u8 pms_mdiv_afc;
- u8 pms_pdiv;
- u8 pms_refdiv;
- u8 pms_sdiv;
- u8 pi_cdiv_rstn;
- u8 pi_cdiv_sel;
- u8 sdm_en;
- u8 sdm_rstn;
- u8 sdc_frac_en;
- u8 sdc_rstn;
- u8 sdm_deno;
- u8 sdm_num_sign;
- u8 sdm_num;
- u8 sdc_n;
- u8 sdc_n2;
- u8 sdc_num;
- u8 sdc_deno;
- u8 sdc_ndiv_rstn;
- u8 ssc_en;
- u8 ssc_fm_dev;
- u8 ssc_fm_freq;
- u8 ssc_clk_div_sel;
- u8 cd_tx_ser_rate_sel;
-};
-
struct ropll_config {
u32 bit_rate;
u8 pms_mdiv;
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 06/14] phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (4 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 05/14] phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 07/14] phy: rockchip: samsung-hdptx: Drop superfluous cfgs " Cristian Ciocaltea
` (8 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
There is no usage of phy_cfg in the upstream driver data, nor in the
downstream one, hence remove it.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 70621687b5eb3581a81af20b23d0be53263003bb..c9f79c4e698cef405dd2b6a8c1071e296464c36e 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -397,7 +397,6 @@ struct rk_hdptx_phy {
int phy_id;
struct phy *phy;
- struct phy_config *phy_cfg;
struct clk_bulk_data *clks;
int nr_clks;
struct reset_control_bulk_data rsts[RST_MAX];
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 07/14] phy: rockchip: samsung-hdptx: Drop superfluous cfgs driver data
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (5 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 06/14] phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead Cristian Ciocaltea
` (7 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
The ->cfgs member has been introduced via commit f08d1c085638 ("phy:
phy-rockchip-samsung-hdptx: Don't use dt aliases to determine phy-id"),
but it is only used during probe() in order to setup ->phy_id.
Use a probe() local variable to store device match data and remove the
now unnecessary member from struct rk_hdptx_phy.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index c9f79c4e698cef405dd2b6a8c1071e296464c36e..2c0ae2442842fe84a86eba6815125be9d31cc41e 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -392,10 +392,7 @@ struct rk_hdptx_phy {
struct regmap *regmap;
struct regmap *grf;
- /* PHY const config */
- const struct rk_hdptx_phy_cfg *cfgs;
int phy_id;
-
struct phy *phy;
struct clk_bulk_data *clks;
int nr_clks;
@@ -1894,6 +1891,7 @@ static int rk_hdptx_phy_runtime_resume(struct device *dev)
static int rk_hdptx_phy_probe(struct platform_device *pdev)
{
+ const struct rk_hdptx_phy_cfg *cfgs;
struct phy_provider *phy_provider;
struct device *dev = &pdev->dev;
struct rk_hdptx_phy *hdptx;
@@ -1912,14 +1910,14 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(regs),
"Failed to ioremap resource\n");
- hdptx->cfgs = device_get_match_data(dev);
- if (!hdptx->cfgs)
+ cfgs = device_get_match_data(dev);
+ if (!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]) {
+ for (id = 0; id < cfgs->num_phys; id++) {
+ if (res->start == cfgs->phy_ids[id]) {
hdptx->phy_id = id;
break;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (6 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 07/14] phy: rockchip: samsung-hdptx: Drop superfluous cfgs " Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-21 16:24 ` Dmitry Baryshkov
2025-03-18 12:35 ` [PATCH v6 09/14] phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi Cristian Ciocaltea
` (6 subsequent siblings)
14 siblings, 1 reply; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
The ropll_tmds_cfg table used to identify the configuration params for
the supported rates expects the search key, i.e. bit_rate member of
struct ropll_config, to be provided in hHz rather than Hz (1 hHz = 100
Hz). This requires multiple conversions between these units being
performed at runtime.
Improve implementation clarity and efficiency by consistently using the
Hz unit throughout driver's internal data structures and functions.
Also rename the rather misleading struct member.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 79 +++++++++++------------
1 file changed, 39 insertions(+), 40 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 2c0ae2442842fe84a86eba6815125be9d31cc41e..e4f6b1d6d999ae01eb7a9a35ea1748b8a2da339c 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -330,7 +330,7 @@ enum dp_link_rate {
};
struct ropll_config {
- u32 bit_rate;
+ unsigned long long rate;
u8 pms_mdiv;
u8 pms_mdiv_afc;
u8 pms_pdiv;
@@ -410,45 +410,45 @@ struct rk_hdptx_phy {
};
static const struct ropll_config ropll_tmds_cfg[] = {
- { 5940000, 124, 124, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 594000000ULL, 124, 124, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 3712500, 155, 155, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 371250000ULL, 155, 155, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 2970000, 124, 124, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 297000000ULL, 124, 124, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1620000, 135, 135, 1, 1, 3, 1, 1, 0, 1, 1, 1, 1, 4, 0, 3, 5, 5, 0x10,
+ { 162000000ULL, 135, 135, 1, 1, 3, 1, 1, 0, 1, 1, 1, 1, 4, 0, 3, 5, 5, 0x10,
1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1856250, 155, 155, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 185625000ULL, 155, 155, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1540000, 193, 193, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 193, 1, 32, 2, 1,
+ { 154000000ULL, 193, 193, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 193, 1, 32, 2, 1,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1485000, 0x7b, 0x7b, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 4, 0, 3, 5, 5,
+ { 148500000ULL, 0x7b, 0x7b, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 4, 0, 3, 5, 5,
0x10, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1462500, 122, 122, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 244, 1, 16, 2, 1, 1,
+ { 146250000ULL, 122, 122, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 244, 1, 16, 2, 1, 1,
1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1190000, 149, 149, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 149, 1, 16, 2, 1, 1,
+ { 119000000ULL, 149, 149, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 149, 1, 16, 2, 1, 1,
1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1065000, 89, 89, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 89, 1, 16, 1, 0, 1,
+ { 106500000ULL, 89, 89, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 89, 1, 16, 1, 0, 1,
1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 1080000, 135, 135, 1, 1, 5, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
+ { 108000000ULL, 135, 135, 1, 1, 5, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
0x14, 0x18, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 855000, 214, 214, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 214, 1, 16, 2, 1,
+ { 85500000ULL, 214, 214, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 214, 1, 16, 2, 1,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 835000, 105, 105, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 42, 1, 16, 1, 0,
+ { 83500000ULL, 105, 105, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 42, 1, 16, 1, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 928125, 155, 155, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 92812500ULL, 155, 155, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 742500, 124, 124, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
+ { 74250000ULL, 124, 124, 1, 1, 7, 1, 1, 1, 1, 1, 1, 1, 62, 1, 16, 5, 0,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 650000, 162, 162, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 54, 0, 16, 4, 1,
+ { 65000000ULL, 162, 162, 1, 1, 11, 1, 1, 1, 1, 1, 1, 1, 54, 0, 16, 4, 1,
1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 337500, 0x70, 0x70, 1, 1, 0xf, 1, 1, 1, 1, 1, 1, 1, 0x2, 0, 0x01, 5,
+ { 33750000ULL, 0x70, 0x70, 1, 1, 0xf, 1, 1, 1, 1, 1, 1, 1, 0x2, 0, 0x01, 5,
1, 1, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 400000, 100, 100, 1, 1, 11, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
+ { 40000000ULL, 100, 100, 1, 1, 11, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
0x14, 0x18, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 270000, 0x5a, 0x5a, 1, 1, 0xf, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
+ { 27000000ULL, 0x5a, 0x5a, 1, 1, 0xf, 1, 1, 0, 1, 0, 1, 1, 0x9, 0, 0x05, 0,
0x14, 0x18, 1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
- { 251750, 84, 84, 1, 1, 0xf, 1, 1, 1, 1, 1, 1, 1, 168, 1, 16, 4, 1, 1,
+ { 25175000ULL, 84, 84, 1, 1, 0xf, 1, 1, 1, 1, 1, 1, 1, 168, 1, 16, 4, 1, 1,
1, 0, 0x20, 0x0c, 1, 0x0e, 0, 0, },
};
@@ -894,10 +894,10 @@ static void rk_hdptx_phy_disable(struct rk_hdptx_phy *hdptx)
regmap_write(hdptx->grf, GRF_HDPTX_CON0, val);
}
-static bool rk_hdptx_phy_clk_pll_calc(unsigned int data_rate,
+static bool rk_hdptx_phy_clk_pll_calc(unsigned long long rate,
struct ropll_config *cfg)
{
- const unsigned int fout = data_rate / 2, fref = 24000;
+ const unsigned int fout = div_u64(rate, 200), fref = 24000;
unsigned long k = 0, lc, k_sub, lc_sub;
unsigned int fvco, sdc;
u32 mdiv, sdiv, n = 8;
@@ -967,14 +967,14 @@ static bool rk_hdptx_phy_clk_pll_calc(unsigned int data_rate,
}
static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
- unsigned int rate)
+ unsigned long long rate)
{
const struct ropll_config *cfg = NULL;
struct ropll_config rc = {0};
int ret, i;
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
- if (rate == ropll_tmds_cfg[i].bit_rate) {
+ if (rate == ropll_tmds_cfg[i].rate) {
cfg = &ropll_tmds_cfg[i];
break;
}
@@ -988,8 +988,8 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
}
}
- dev_dbg(hdptx->dev, "mdiv=%u, sdiv=%u, sdm_en=%u, k_sign=%u, k=%u, lc=%u\n",
- cfg->pms_mdiv, cfg->pms_sdiv + 1, cfg->sdm_en,
+ dev_dbg(hdptx->dev, "%s rate=%llu mdiv=%u sdiv=%u sdm_en=%u k_sign=%u k=%u lc=%u\n",
+ __func__, rate, cfg->pms_mdiv, cfg->pms_sdiv + 1, cfg->sdm_en,
cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
rk_hdptx_pre_power_up(hdptx);
@@ -1028,19 +1028,19 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
ret = rk_hdptx_post_enable_pll(hdptx);
if (!ret)
- hdptx->rate = rate * 100;
+ hdptx->rate = rate;
return ret;
}
static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
- unsigned int rate)
+ unsigned long long rate)
{
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_common_sb_init_seq);
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
- if (rate > HDMI14_MAX_RATE / 100) {
+ if (rate > HDMI14_MAX_RATE) {
/* For 1/40 bitrate clk */
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_tmds_lntop_highbr_seq);
} else {
@@ -1093,7 +1093,7 @@ static void rk_hdptx_dp_reset(struct rk_hdptx_phy *hdptx)
}
static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
- unsigned int rate)
+ unsigned long long rate)
{
enum phy_mode mode = phy_get_mode(hdptx->phy);
u32 status;
@@ -1411,8 +1411,8 @@ static int rk_hdptx_dp_aux_init(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 bus_width = phy_get_bus_width(hdptx->phy);
enum phy_mode mode = phy_get_mode(phy);
+ unsigned long long rate;
int ret, lane;
/*
@@ -1420,10 +1420,10 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
* from the HDMI bridge driver until phy_configure_opts_hdmi
* becomes available in the PHY API.
*/
- unsigned int rate = bus_width & 0xfffffff;
+ rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
+ rate *= 100;
- dev_dbg(hdptx->dev, "%s bus_width=%x rate=%u\n",
- __func__, bus_width, rate);
+ dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, rate);
ret = rk_hdptx_phy_consumer_get(hdptx, rate);
if (ret)
@@ -1785,7 +1785,7 @@ 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);
+ return rk_hdptx_phy_consumer_get(hdptx, hdptx->rate);
}
static void rk_hdptx_phy_clk_unprepare(struct clk_hw *hw)
@@ -1806,18 +1806,17 @@ static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw,
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)
+ if (rate == ropll_tmds_cfg[i].rate)
break;
if (i == ARRAY_SIZE(ropll_tmds_cfg) &&
- !rk_hdptx_phy_clk_pll_calc(bit_rate, NULL))
+ !rk_hdptx_phy_clk_pll_calc(rate, NULL))
return -EINVAL;
return rate;
@@ -1828,7 +1827,7 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
- return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate / 100);
+ return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
}
static const struct clk_ops hdptx_phy_clk_ops = {
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 09/14] phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (7 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 10/14] phy: rockchip: samsung-hdptx: Provide config params validation support Cristian Ciocaltea
` (5 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
The current workaround to setup the TMDS character rate relies on the
unconventional usage of phy_set_bus_width().
Make use of the recently introduced HDMI PHY configuration API to
properly handle the setup. The workaround will be dropped as soon as
the switch has been completed on both ends.
Rename rk_hdptx_phy_verify_config() to rk_hdptx_phy_verify_dp_config()
and introduce the rk_hdptx_phy_verify_hdmi_config() helper to check the
HDMI parameters during phy_configure().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 64 +++++++++++++++++------
1 file changed, 47 insertions(+), 17 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index e4f6b1d6d999ae01eb7a9a35ea1748b8a2da339c..62de40515338730a56a83972ad57a7e71c3ca5cb 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -394,6 +394,7 @@ struct rk_hdptx_phy {
int phy_id;
struct phy *phy;
+ struct phy_configure_opts_hdmi hdmi_cfg;
struct clk_bulk_data *clks;
int nr_clks;
struct reset_control_bulk_data rsts[RST_MAX];
@@ -1412,20 +1413,24 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
{
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
enum phy_mode mode = phy_get_mode(phy);
- unsigned long long rate;
int ret, lane;
- /*
- * FIXME: Temporary workaround to pass pixel_clk_rate
- * from the HDMI bridge driver until phy_configure_opts_hdmi
- * becomes available in the PHY API.
- */
- rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
- rate *= 100;
+ if (mode != PHY_MODE_DP) {
+ if (!hdptx->hdmi_cfg.tmds_char_rate) {
+ /*
+ * FIXME: Temporary workaround to setup TMDS char rate
+ * from the RK DW HDMI QP bridge driver.
+ * Will be removed as soon the switch to the HDMI PHY
+ * configuration API has been completed on both ends.
+ */
+ hdptx->hdmi_cfg.tmds_char_rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
+ hdptx->hdmi_cfg.tmds_char_rate *= 100;
+ }
- dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, rate);
+ dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, hdptx->hdmi_cfg.tmds_char_rate);
+ }
- ret = rk_hdptx_phy_consumer_get(hdptx, rate);
+ ret = rk_hdptx_phy_consumer_get(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
if (ret)
return ret;
@@ -1456,7 +1461,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
regmap_write(hdptx->grf, GRF_HDPTX_CON0,
HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0));
- ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
+ ret = rk_hdptx_ropll_tmds_mode_config(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
if (ret)
rk_hdptx_phy_consumer_put(hdptx, true);
}
@@ -1471,8 +1476,27 @@ static int rk_hdptx_phy_power_off(struct phy *phy)
return rk_hdptx_phy_consumer_put(hdptx, false);
}
-static int rk_hdptx_phy_verify_config(struct rk_hdptx_phy *hdptx,
- struct phy_configure_opts_dp *dp)
+static int rk_hdptx_phy_verify_hdmi_config(struct rk_hdptx_phy *hdptx,
+ struct phy_configure_opts_hdmi *hdmi)
+{
+ int i;
+
+ if (!hdmi->tmds_char_rate || hdmi->tmds_char_rate > HDMI20_MAX_RATE)
+ return -EINVAL;
+
+ for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
+ if (hdmi->tmds_char_rate == ropll_tmds_cfg[i].rate)
+ break;
+
+ if (i == ARRAY_SIZE(ropll_tmds_cfg) &&
+ !rk_hdptx_phy_clk_pll_calc(hdmi->tmds_char_rate, NULL))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int rk_hdptx_phy_verify_dp_config(struct rk_hdptx_phy *hdptx,
+ struct phy_configure_opts_dp *dp)
{
int i;
@@ -1732,12 +1756,18 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
enum phy_mode mode = phy_get_mode(phy);
int ret;
- if (mode != PHY_MODE_DP)
- return 0;
+ if (mode != PHY_MODE_DP) {
+ ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
+ if (ret)
+ dev_err(hdptx->dev, "invalid hdmi params for phy configure\n");
+ else
+ hdptx->hdmi_cfg = opts->hdmi;
+ return ret;
+ }
- ret = rk_hdptx_phy_verify_config(hdptx, &opts->dp);
+ ret = rk_hdptx_phy_verify_dp_config(hdptx, &opts->dp);
if (ret) {
- dev_err(hdptx->dev, "invalid params for phy configure\n");
+ dev_err(hdptx->dev, "invalid dp params for phy configure\n");
return ret;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 10/14] phy: rockchip: samsung-hdptx: Provide config params validation support
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (8 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 09/14] phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 11/14] phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF Cristian Ciocaltea
` (4 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Implement the phy_ops.validate() callback to allow checking the PHY
configuration parameters without actually applying them.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 62de40515338730a56a83972ad57a7e71c3ca5cb..80dd896861bcac6ef9dbde410327b893f8039627 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -1799,10 +1799,22 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
return 0;
}
+static int rk_hdptx_phy_validate(struct phy *phy, enum phy_mode mode,
+ int submode, union phy_configure_opts *opts)
+{
+ struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
+
+ if (mode != PHY_MODE_DP)
+ return rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
+
+ return rk_hdptx_phy_verify_dp_config(hdptx, &opts->dp);
+}
+
static const struct phy_ops rk_hdptx_phy_ops = {
.power_on = rk_hdptx_phy_power_on,
.power_off = rk_hdptx_phy_power_off,
.configure = rk_hdptx_phy_configure,
+ .validate = rk_hdptx_phy_validate,
.owner = THIS_MODULE,
};
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 11/14] phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (9 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 10/14] phy: rockchip: samsung-hdptx: Provide config params validation support Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 12/14] phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate Cristian Ciocaltea
` (3 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Although, in theory, the clock provider functionality could be enabled
as a standalone driver feature, in practice it is unlikely that it would
be ever needed separately from the common PHY related features, i.e.
making use of the PHY PLL as an alternative and more accurate clock
source for display modes handling. Which means the PLL will be always
programmed according to the TMDS char rate set via the HDMI PHY
configuration API.
Currently it's possible to freely adjust the rate via the clock API as
well, that is through clk_set_rate(). Making the clock read-only is not
feasible since we need to ensure any rate update done via the PHY
configuration API has been actually programmed into the hardware before
CCF accesses it. This would be normally done during phy_ops.power_on()
or clk_ops.prepare() callbacks, but it might happen that the former gets
fired too late and the latter only once, hence we need to keep handle it
via clk_ops.set_rate() as a fallback approach.
Prevent changing the TMDS character rate via CCF by letting
rk_hdptx_phy_clk_round_rate() always return the value set via
phy_configure(). To avoid breaking existing users, i.e. RK DW HDMI QP
bridge driver, until the switch to the HDMI PHY config based approach is
completed, introduce a temporary exception to the rule, toggled via the
new ->restrict_rate_change flag, which indicates whether phy_configure()
has been called or not.
Additionally, revert any unlikely rate change that might have occurred
between the calls to ->round_rate() and ->set_rate().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 52 +++++++++++++++++------
1 file changed, 40 insertions(+), 12 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 80dd896861bcac6ef9dbde410327b893f8039627..2feb46f6d4e5bd2f43140e465cc25d2b0c363df4 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -402,6 +402,7 @@ struct rk_hdptx_phy {
/* clk provider */
struct clk_hw hw;
unsigned long rate;
+ bool restrict_rate_change;
atomic_t usage_count;
@@ -1758,10 +1759,12 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
if (mode != PHY_MODE_DP) {
ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
- if (ret)
+ if (ret) {
dev_err(hdptx->dev, "invalid hdmi params for phy configure\n");
- else
+ } else {
hdptx->hdmi_cfg = opts->hdmi;
+ hdptx->restrict_rate_change = true;
+ }
return ret;
}
@@ -1848,20 +1851,31 @@ static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw,
static long rk_hdptx_phy_clk_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *parent_rate)
{
- int i;
+ struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
- if (rate > HDMI20_MAX_RATE)
- return rate;
+ /*
+ * FIXME: Temporarily allow altering TMDS char rate via CCF.
+ * To be dropped as soon as the RK DW HDMI QP bridge driver
+ * switches to make use of phy_configure().
+ */
+ if (!hdptx->restrict_rate_change && rate != hdptx->hdmi_cfg.tmds_char_rate) {
+ struct phy_configure_opts_hdmi hdmi = {
+ .tmds_char_rate = rate,
+ };
+ int ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &hdmi);
- for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
- if (rate == ropll_tmds_cfg[i].rate)
- break;
+ if (ret)
+ return ret;
- if (i == ARRAY_SIZE(ropll_tmds_cfg) &&
- !rk_hdptx_phy_clk_pll_calc(rate, NULL))
- return -EINVAL;
+ hdptx->hdmi_cfg = hdmi;
+ }
- return rate;
+ /*
+ * The TMDS char rate shall be adjusted via phy_configure() only,
+ * hence ensure rk_hdptx_phy_clk_set_rate() won't be invoked with
+ * a different rate argument.
+ */
+ return hdptx->hdmi_cfg.tmds_char_rate;
}
static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -1869,6 +1883,20 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
+ /* Revert any unlikely TMDS char rate change since round_rate() */
+ if (hdptx->hdmi_cfg.tmds_char_rate != rate) {
+ dev_warn(hdptx->dev, "Reverting unexpected rate change from %lu to %llu\n",
+ rate, hdptx->hdmi_cfg.tmds_char_rate);
+ hdptx->hdmi_cfg.tmds_char_rate = rate;
+ }
+
+ /*
+ * The TMDS char rate would be normally programmed in HW during
+ * phy_ops.power_on() or clk_ops.prepare() callbacks, but it might
+ * happen that the former gets fired too late, i.e. after this call,
+ * while the latter being executed only once, i.e. when clock remains
+ * in the prepared state during rate changes.
+ */
return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
}
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 12/14] phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (10 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 11/14] phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling Cristian Ciocaltea
` (2 subsequent siblings)
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
The main purpose of the ->rate member of struct rk_hdptx_phy is to
implement rk_hdptx_phy_clk_recalc_rate() by providing the actual rate
programmed in hardware. Hence the current naming is too generic and
rather ambiguous.
Improve clarity by renaming ->rate to ->hw_rate.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index 2feb46f6d4e5bd2f43140e465cc25d2b0c363df4..a19a89233d808e2b38f6e7e58a1dc38ddd7cadd3 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -401,7 +401,7 @@ struct rk_hdptx_phy {
/* clk provider */
struct clk_hw hw;
- unsigned long rate;
+ unsigned long hw_rate;
bool restrict_rate_change;
atomic_t usage_count;
@@ -1030,7 +1030,7 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
ret = rk_hdptx_post_enable_pll(hdptx);
if (!ret)
- hdptx->rate = rate;
+ hdptx->hw_rate = rate;
return ret;
}
@@ -1830,7 +1830,7 @@ 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);
+ return rk_hdptx_phy_consumer_get(hdptx, hdptx->hw_rate);
}
static void rk_hdptx_phy_clk_unprepare(struct clk_hw *hw)
@@ -1845,7 +1845,7 @@ static unsigned long rk_hdptx_phy_clk_recalc_rate(struct clk_hw *hw,
{
struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
- return hdptx->rate;
+ return hdptx->hw_rate;
}
static long rk_hdptx_phy_clk_round_rate(struct clk_hw *hw, unsigned long rate,
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (11 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 12/14] phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-03-21 16:31 ` Dmitry Baryshkov
2025-03-18 12:35 ` [PATCH v6 14/14] phy: rockchip: samsung-hdptx: Add high color depth management Cristian Ciocaltea
2025-04-11 12:11 ` [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support " Vinod Koul
14 siblings, 1 reply; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Drop the rate parameter from a bunch of internal helpers and, instead,
make better use of the newly introduced ->hdmi_cfg.tmds_char_rate driver
data.
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 47 +++++++++++------------
1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index a19a89233d808e2b38f6e7e58a1dc38ddd7cadd3..d09e1f7b25ec131d3c40fb52564cad27dce3b2d4 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -968,31 +968,34 @@ static bool rk_hdptx_phy_clk_pll_calc(unsigned long long rate,
return true;
}
-static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
- unsigned long long rate)
+static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx)
{
const struct ropll_config *cfg = NULL;
struct ropll_config rc = {0};
int ret, i;
+ if (!hdptx->hdmi_cfg.tmds_char_rate)
+ return 0;
+
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
- if (rate == ropll_tmds_cfg[i].rate) {
+ if (hdptx->hdmi_cfg.tmds_char_rate == ropll_tmds_cfg[i].rate) {
cfg = &ropll_tmds_cfg[i];
break;
}
if (!cfg) {
- if (rk_hdptx_phy_clk_pll_calc(rate, &rc)) {
- cfg = &rc;
- } else {
- dev_err(hdptx->dev, "%s cannot find pll cfg\n", __func__);
+ if (!rk_hdptx_phy_clk_pll_calc(hdptx->hdmi_cfg.tmds_char_rate, &rc)) {
+ dev_err(hdptx->dev, "%s cannot find pll cfg for rate=%llu\n",
+ __func__, hdptx->hdmi_cfg.tmds_char_rate);
return -EINVAL;
}
+
+ cfg = &rc;
}
dev_dbg(hdptx->dev, "%s rate=%llu mdiv=%u sdiv=%u sdm_en=%u k_sign=%u k=%u lc=%u\n",
- __func__, rate, cfg->pms_mdiv, cfg->pms_sdiv + 1, cfg->sdm_en,
- cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
+ __func__, hdptx->hdmi_cfg.tmds_char_rate, cfg->pms_mdiv, cfg->pms_sdiv + 1,
+ cfg->sdm_en, cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
rk_hdptx_pre_power_up(hdptx);
@@ -1030,19 +1033,18 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
ret = rk_hdptx_post_enable_pll(hdptx);
if (!ret)
- hdptx->hw_rate = rate;
+ hdptx->hw_rate = hdptx->hdmi_cfg.tmds_char_rate;
return ret;
}
-static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
- unsigned long long rate)
+static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx)
{
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_common_sb_init_seq);
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
- if (rate > HDMI14_MAX_RATE) {
+ if (hdptx->hdmi_cfg.tmds_char_rate > HDMI14_MAX_RATE) {
/* For 1/40 bitrate clk */
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_tmds_lntop_highbr_seq);
} else {
@@ -1094,8 +1096,7 @@ static void rk_hdptx_dp_reset(struct rk_hdptx_phy *hdptx)
HDPTX_I_BGR_EN << 16 | FIELD_PREP(HDPTX_I_BGR_EN, 0x0));
}
-static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
- unsigned long long rate)
+static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx)
{
enum phy_mode mode = phy_get_mode(hdptx->phy);
u32 status;
@@ -1114,11 +1115,9 @@ static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
if (mode == PHY_MODE_DP) {
rk_hdptx_dp_reset(hdptx);
} else {
- if (rate) {
- ret = rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
- if (ret)
- goto dec_usage;
- }
+ ret = rk_hdptx_ropll_tmds_cmn_config(hdptx);
+ if (ret)
+ goto dec_usage;
}
return 0;
@@ -1431,7 +1430,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, hdptx->hdmi_cfg.tmds_char_rate);
}
- ret = rk_hdptx_phy_consumer_get(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
+ ret = rk_hdptx_phy_consumer_get(hdptx);
if (ret)
return ret;
@@ -1462,7 +1461,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
regmap_write(hdptx->grf, GRF_HDPTX_CON0,
HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0));
- ret = rk_hdptx_ropll_tmds_mode_config(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
+ ret = rk_hdptx_ropll_tmds_mode_config(hdptx);
if (ret)
rk_hdptx_phy_consumer_put(hdptx, true);
}
@@ -1830,7 +1829,7 @@ 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->hw_rate);
+ return rk_hdptx_phy_consumer_get(hdptx);
}
static void rk_hdptx_phy_clk_unprepare(struct clk_hw *hw)
@@ -1897,7 +1896,7 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
* while the latter being executed only once, i.e. when clock remains
* in the prepared state during rate changes.
*/
- return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
+ return rk_hdptx_ropll_tmds_cmn_config(hdptx);
}
static const struct clk_ops hdptx_phy_clk_ops = {
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v6 14/14] phy: rockchip: samsung-hdptx: Add high color depth management
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (12 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling Cristian Ciocaltea
@ 2025-03-18 12:35 ` Cristian Ciocaltea
2025-04-11 12:11 ` [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support " Vinod Koul
14 siblings, 0 replies; 18+ messages in thread
From: Cristian Ciocaltea @ 2025-03-18 12:35 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I, Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
Add support for 8-bit, 10-bit, 12-bit and 16-bit color depth setup.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
index d09e1f7b25ec131d3c40fb52564cad27dce3b2d4..fc289ed8d915d84916870329101655cd956898e3 100644
--- a/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
+++ b/drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c
@@ -1028,6 +1028,9 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx)
regmap_update_bits(hdptx->regmap, CMN_REG(0086), PLL_PCG_POSTDIV_SEL_MASK,
FIELD_PREP(PLL_PCG_POSTDIV_SEL_MASK, cfg->pms_sdiv));
+ regmap_update_bits(hdptx->regmap, CMN_REG(0086), PLL_PCG_CLK_SEL_MASK,
+ FIELD_PREP(PLL_PCG_CLK_SEL_MASK, (hdptx->hdmi_cfg.bpc - 8) >> 1));
+
regmap_update_bits(hdptx->regmap, CMN_REG(0086), PLL_PCG_CLK_EN_MASK,
FIELD_PREP(PLL_PCG_CLK_EN_MASK, 0x1));
@@ -1427,7 +1430,8 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
hdptx->hdmi_cfg.tmds_char_rate *= 100;
}
- dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, hdptx->hdmi_cfg.tmds_char_rate);
+ dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
+ hdptx->hdmi_cfg.tmds_char_rate, hdptx->hdmi_cfg.bpc);
}
ret = rk_hdptx_phy_consumer_get(hdptx);
@@ -1492,6 +1496,19 @@ static int rk_hdptx_phy_verify_hdmi_config(struct rk_hdptx_phy *hdptx,
!rk_hdptx_phy_clk_pll_calc(hdmi->tmds_char_rate, NULL))
return -EINVAL;
+ if (!hdmi->bpc)
+ hdmi->bpc = 8;
+
+ switch (hdmi->bpc) {
+ case 8:
+ case 10:
+ case 12:
+ case 16:
+ break;
+ default:
+ return -EINVAL;
+ };
+
return 0;
}
@@ -1764,6 +1781,9 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
hdptx->hdmi_cfg = opts->hdmi;
hdptx->restrict_rate_change = true;
}
+
+ dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
+ hdptx->hdmi_cfg.tmds_char_rate, hdptx->hdmi_cfg.bpc);
return ret;
}
@@ -1972,6 +1992,7 @@ static int rk_hdptx_phy_probe(struct platform_device *pdev)
return -ENOMEM;
hdptx->dev = dev;
+ hdptx->hdmi_cfg.bpc = 8;
regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(regs))
--
2.48.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead
2025-03-18 12:35 ` [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead Cristian Ciocaltea
@ 2025-03-21 16:24 ` Dmitry Baryshkov
0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2025-03-21 16:24 UTC (permalink / raw)
To: Cristian Ciocaltea, Vinod Koul, Kishon Vijay Abraham I,
Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Maxime Ripard, kernel, linux-kernel,
linux-phy, linux-arm-kernel, linux-rockchip, Dmitry Baryshkov
On 18/03/2025 14:35, Cristian Ciocaltea wrote:
> The ropll_tmds_cfg table used to identify the configuration params for
> the supported rates expects the search key, i.e. bit_rate member of
> struct ropll_config, to be provided in hHz rather than Hz (1 hHz = 100
> Hz). This requires multiple conversions between these units being
> performed at runtime.
>
> Improve implementation clarity and efficiency by consistently using the
> Hz unit throughout driver's internal data structures and functions.
> Also rename the rather misleading struct member.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 79 +++++++++++------------
> 1 file changed, 39 insertions(+), 40 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling
2025-03-18 12:35 ` [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling Cristian Ciocaltea
@ 2025-03-21 16:31 ` Dmitry Baryshkov
0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Baryshkov @ 2025-03-21 16:31 UTC (permalink / raw)
To: Cristian Ciocaltea, Vinod Koul, Kishon Vijay Abraham I,
Heiko Stuebner
Cc: Algea Cao, Sandor Yu, Maxime Ripard, kernel, linux-kernel,
linux-phy, linux-arm-kernel, linux-rockchip, Dmitry Baryshkov
On 18/03/2025 14:35, Cristian Ciocaltea wrote:
> Drop the rate parameter from a bunch of internal helpers and, instead,
> make better use of the newly introduced ->hdmi_cfg.tmds_char_rate driver
> data.
>
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
> drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c | 47 +++++++++++------------
> 1 file changed, 23 insertions(+), 24 deletions(-)
Acked-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
` (13 preceding siblings ...)
2025-03-18 12:35 ` [PATCH v6 14/14] phy: rockchip: samsung-hdptx: Add high color depth management Cristian Ciocaltea
@ 2025-04-11 12:11 ` Vinod Koul
14 siblings, 0 replies; 18+ messages in thread
From: Vinod Koul @ 2025-04-11 12:11 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Heiko Stuebner, Cristian Ciocaltea
Cc: Algea Cao, Sandor Yu, Dmitry Baryshkov, Maxime Ripard, kernel,
linux-kernel, linux-phy, linux-arm-kernel, linux-rockchip,
Dmitry Baryshkov
On Tue, 18 Mar 2025 14:35:34 +0200, Cristian Ciocaltea wrote:
> This series relies on the new HDMI PHY configuration options [1] (patch
> included here for convenience) to provide high color depth management
> for rockchip-samsung-hdptx, and to introduce a proper solution to setup
> the TMDS character rate on this PHY.
>
> [1] https://lore.kernel.org/lkml/d1cff6c03ec3732d2244022029245ab2d954d997.1734340233.git.Sandor.yu@nxp.com/
>
> [...]
Applied, thanks!
[01/14] phy: Add HDMI configuration options
commit: 10ed34d6eaaf86e301a8f2dd190d26dfbc9799bd
[02/14] phy: hdmi: Add color depth configuration
commit: 3bb9286f4ece6acbc1fbaa9f192a82645d30efbf
[03/14] phy: rockchip: samsung-hdptx: Fix clock ratio setup
commit: 0422253ac1919fea8292381c85f11a9decff1bb1
[04/14] phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors
commit: 1f4d382769e3b38dfc498c806811dae856e40f31
[05/14] phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config
commit: 6218c3fd6702a5bc4ab323fed25714cde127684c
[06/14] phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data
commit: bcd61d182618c6a77d0841fcdc3333e125725360
[07/14] phy: rockchip: samsung-hdptx: Drop superfluous cfgs driver data
commit: bacf2fe750dab6bc7ed50556aaadd3ab107fc643
[08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead
commit: 0edf9d2bb9b4ba7566dfdc7605883e04575129d9
[09/14] phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi
commit: c871a311edf0ebb1b934946a84a6c532cac0c035
[10/14] phy: rockchip: samsung-hdptx: Provide config params validation support
commit: 2392050a2cb94ff3397949e109e4b9f0285ee085
[11/14] phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF
commit: 6efbd0f46dd8ae1d2b91b41d98c2800c60ab1f5e
[12/14] phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate
commit: 37f335dbfd028c008d0a7940ca5a270d1e2f6b81
[13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling
commit: 45b14bdcf4acfd483d9890396197c35c23821124
[14/14] phy: rockchip: samsung-hdptx: Add high color depth management
commit: 9d0ec51d7c227c3ae837e22832eaed219e25f126
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2025-04-11 12:25 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 12:35 [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support high color depth management Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 01/14] phy: Add HDMI configuration options Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 02/14] phy: hdmi: Add color depth configuration Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 03/14] phy: rockchip: samsung-hdptx: Fix clock ratio setup Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 04/14] phy: rockchip: samsung-hdptx: Do no set rk_hdptx_phy->rate in case of errors Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 05/14] phy: rockchip: samsung-hdptx: Drop unused struct lcpll_config Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 06/14] phy: rockchip: samsung-hdptx: Drop unused phy_cfg driver data Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 07/14] phy: rockchip: samsung-hdptx: Drop superfluous cfgs " Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 08/14] phy: rockchip: samsung-hdptx: Avoid Hz<->hHz unit conversion overhead Cristian Ciocaltea
2025-03-21 16:24 ` Dmitry Baryshkov
2025-03-18 12:35 ` [PATCH v6 09/14] phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 10/14] phy: rockchip: samsung-hdptx: Provide config params validation support Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 11/14] phy: rockchip: samsung-hdptx: Restrict altering TMDS char rate via CCF Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 12/14] phy: rockchip: samsung-hdptx: Rename ambiguous rk_hdptx_phy->rate Cristian Ciocaltea
2025-03-18 12:35 ` [PATCH v6 13/14] phy: rockchip: samsung-hdptx: Optimize internal rate handling Cristian Ciocaltea
2025-03-21 16:31 ` Dmitry Baryshkov
2025-03-18 12:35 ` [PATCH v6 14/14] phy: rockchip: samsung-hdptx: Add high color depth management Cristian Ciocaltea
2025-04-11 12:11 ` [PATCH v6 00/14] phy: rockchip: samsung-hdptx: Support " Vinod Koul
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).