In order to support correct initialization of the timer base in the HDMI
QP IP block, extend the platform data to provide the necessary reference
clock rate.
While at it, ensure plat_data is zero-initialized in
dw_hdmi_qp_rockchip_bind().
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 13 ++++++++++++-
include/drm/bridge/dw_hdmi_qp.h | 1 +
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
index 126e556025961e8645f3567b4d7a1c73cc2f2e7f..8c1185490009c5f1bc658998a868f8b18dc479a3 100644
--- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c
@@ -431,8 +431,8 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
void *data)
{
struct platform_device *pdev = to_platform_device(dev);
+ struct dw_hdmi_qp_plat_data plat_data = {};
const struct rockchip_hdmi_qp_cfg *cfg;
- struct dw_hdmi_qp_plat_data plat_data;
struct drm_device *drm = data;
struct drm_connector *connector;
struct drm_encoder *encoder;
@@ -515,6 +515,17 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master,
return ret;
}
+ for (i = 0; i < ret; i++) {
+ if (!strcmp(clks[i].id, "ref")) {
+ plat_data.ref_clk_rate = clk_get_rate(clks[i].clk);
+ break;
+ }
+ }
+ if (!plat_data.ref_clk_rate) {
+ dev_err(hdmi->dev, "Missing ref clock\n");
+ return -EINVAL;
+ }
+
hdmi->enable_gpio = devm_gpiod_get_optional(hdmi->dev, "enable",
GPIOD_OUT_HIGH);
if (IS_ERR(hdmi->enable_gpio)) {
diff --git a/include/drm/bridge/dw_hdmi_qp.h b/include/drm/bridge/dw_hdmi_qp.h
index b4a9b739734ec7b67013b683fe6017551aa19172..76ecf31301997718604a05f70ce9eab8695e26b5 100644
--- a/include/drm/bridge/dw_hdmi_qp.h
+++ b/include/drm/bridge/dw_hdmi_qp.h
@@ -24,6 +24,7 @@ struct dw_hdmi_qp_plat_data {
void *phy_data;
int main_irq;
int cec_irq;
+ unsigned long ref_clk_rate;
};
struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
--
2.50.0
On Fri, Jul 04, 2025 at 05:23:24PM +0300, Cristian Ciocaltea wrote: > In order to support correct initialization of the timer base in the HDMI > QP IP block, extend the platform data to provide the necessary reference > clock rate. > > While at it, ensure plat_data is zero-initialized in > dw_hdmi_qp_rockchip_bind(). > > Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> > --- > drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 13 ++++++++++++- > include/drm/bridge/dw_hdmi_qp.h | 1 + > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c > index 126e556025961e8645f3567b4d7a1c73cc2f2e7f..8c1185490009c5f1bc658998a868f8b18dc479a3 100644 > --- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c > +++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c > @@ -431,8 +431,8 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master, > void *data) > { > struct platform_device *pdev = to_platform_device(dev); > + struct dw_hdmi_qp_plat_data plat_data = {}; > const struct rockchip_hdmi_qp_cfg *cfg; > - struct dw_hdmi_qp_plat_data plat_data; > struct drm_device *drm = data; > struct drm_connector *connector; > struct drm_encoder *encoder; > @@ -515,6 +515,17 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master, > return ret; > } > > + for (i = 0; i < ret; i++) { > + if (!strcmp(clks[i].id, "ref")) { > + plat_data.ref_clk_rate = clk_get_rate(clks[i].clk); > + break; > + } > + } > + if (!plat_data.ref_clk_rate) { > + dev_err(hdmi->dev, "Missing ref clock\n"); > + return -EINVAL; > + } > + You'd be better off not using clk_bulk, or calling an additional clk_get for the ref clock only. Maxime
Hi Maxime, On 7/4/25 6:07 PM, Maxime Ripard wrote: > On Fri, Jul 04, 2025 at 05:23:24PM +0300, Cristian Ciocaltea wrote: >> In order to support correct initialization of the timer base in the HDMI >> QP IP block, extend the platform data to provide the necessary reference >> clock rate. >> >> While at it, ensure plat_data is zero-initialized in >> dw_hdmi_qp_rockchip_bind(). >> >> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> >> --- >> drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c | 13 ++++++++++++- >> include/drm/bridge/dw_hdmi_qp.h | 1 + >> 2 files changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c >> index 126e556025961e8645f3567b4d7a1c73cc2f2e7f..8c1185490009c5f1bc658998a868f8b18dc479a3 100644 >> --- a/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c >> +++ b/drivers/gpu/drm/rockchip/dw_hdmi_qp-rockchip.c >> @@ -431,8 +431,8 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master, >> void *data) >> { >> struct platform_device *pdev = to_platform_device(dev); >> + struct dw_hdmi_qp_plat_data plat_data = {}; >> const struct rockchip_hdmi_qp_cfg *cfg; >> - struct dw_hdmi_qp_plat_data plat_data; >> struct drm_device *drm = data; >> struct drm_connector *connector; >> struct drm_encoder *encoder; >> @@ -515,6 +515,17 @@ static int dw_hdmi_qp_rockchip_bind(struct device *dev, struct device *master, >> return ret; >> } >> >> + for (i = 0; i < ret; i++) { >> + if (!strcmp(clks[i].id, "ref")) { >> + plat_data.ref_clk_rate = clk_get_rate(clks[i].clk); >> + break; >> + } >> + } >> + if (!plat_data.ref_clk_rate) { >> + dev_err(hdmi->dev, "Missing ref clock\n"); >> + return -EINVAL; >> + } >> + > > You'd be better off not using clk_bulk, or calling an additional clk_get > for the ref clock only. I'd keep clk_bulk as there are 5 more clocks in the list. But replacing the loop with just an extra clk_get would be a simpler approach, indeed, so thanks for the hint! Regards, Cristian
© 2016 - 2025 Red Hat, Inc.