[PATCH v2 16/28] drm: omapdrm: hdmi: Store PLL hardware data in HDMI transmitter drivers

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon May 8 11:32:51 UTC 2017


The HDMI PLL hardware data are dependent on the HDMI transmitter model.
The PLL driver contains hardware data for all supported transmitters,
and selects the appropriate hardware data based on the OMAP SoC version.

It makes more sense to store the PLL hardware data in the HDMI
transmitter drivers and pass them to the HDMI PLL initialization
function, as the HDMI transmitter drivers are transmitter-specific and
don't need to check the OMAP SoC version.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/dss/hdmi.h     |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c    | 27 +++++++++++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c    | 28 ++++++++++++-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 77 +++-------------------------------
 4 files changed, 60 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index 2b4312f8e97d..7ae26c7c5189 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -316,7 +316,7 @@ phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp_data *wp);
 /* HDMI PLL funcs */
 void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s);
 int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
-	struct hdmi_wp_data *wp);
+		  const struct dss_pll_hw *pll_hw, struct hdmi_wp_data *wp);
 void hdmi_pll_uninit(struct hdmi_pll_data *hpll);
 
 /* HDMI PHY funcs */
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 1feb6deab108..b34f82bb61d5 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -689,6 +689,31 @@ static const struct hdmi_phy_features hdmi4_phy_feats = {
 	.max_phy	=	185675000,
 };
 
+static const struct dss_pll_hw hdmi4_pll_hw = {
+	.type = DSS_PLL_TYPE_B,
+
+	.n_max = 255,
+	.m_min = 20,
+	.m_max = 4095,
+	.mX_max = 127,
+	.fint_min = 500000,
+	.fint_max = 2500000,
+
+	.clkdco_min = 500000000,
+	.clkdco_low = 1000000000,
+	.clkdco_max = 2000000000,
+
+	.n_msb = 8,
+	.n_lsb = 1,
+	.m_msb = 20,
+	.m_lsb = 9,
+
+	.mX_msb[0] = 24,
+	.mX_lsb[0] = 18,
+
+	.has_selfreqdco = true,
+};
+
 static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -709,7 +734,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		return r;
 
-	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi4_pll_hw, &hdmi.wp);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 529653180bfc..54df41f24085 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -721,6 +721,32 @@ static const struct hdmi_phy_features hdmi5_phy_feats = {
 	.max_phy	=	186000000,
 };
 
+static const struct dss_pll_hw hdmi5_pll_hw = {
+	.type = DSS_PLL_TYPE_B,
+
+	.n_max = 255,
+	.m_min = 20,
+	.m_max = 2045,
+	.mX_max = 127,
+	.fint_min = 620000,
+	.fint_max = 2500000,
+
+	.clkdco_min = 750000000,
+	.clkdco_low = 1500000000,
+	.clkdco_max = 2500000000UL,
+
+	.n_msb = 8,
+	.n_lsb = 1,
+	.m_msb = 20,
+	.m_lsb = 9,
+
+	.mX_msb[0] = 24,
+	.mX_lsb[0] = 18,
+
+	.has_selfreqdco = true,
+	.has_refsel = true,
+};
+
 static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -741,7 +767,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data)
 	if (r)
 		return r;
 
-	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp);
+	r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi5_pll_hw, &hdmi.wp);
 	if (r)
 		return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 46239358655a..870c5e633075 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -77,58 +77,9 @@ static const struct dss_pll_ops dsi_pll_ops = {
 	.set_config = dss_pll_write_config_type_b,
 };
 
-static const struct dss_pll_hw dss_omap4_hdmi_pll_hw = {
-	.type = DSS_PLL_TYPE_B,
-
-	.n_max = 255,
-	.m_min = 20,
-	.m_max = 4095,
-	.mX_max = 127,
-	.fint_min = 500000,
-	.fint_max = 2500000,
-
-	.clkdco_min = 500000000,
-	.clkdco_low = 1000000000,
-	.clkdco_max = 2000000000,
-
-	.n_msb = 8,
-	.n_lsb = 1,
-	.m_msb = 20,
-	.m_lsb = 9,
-
-	.mX_msb[0] = 24,
-	.mX_lsb[0] = 18,
-
-	.has_selfreqdco = true,
-};
-
-static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = {
-	.type = DSS_PLL_TYPE_B,
-
-	.n_max = 255,
-	.m_min = 20,
-	.m_max = 2045,
-	.mX_max = 127,
-	.fint_min = 620000,
-	.fint_max = 2500000,
-
-	.clkdco_min = 750000000,
-	.clkdco_low = 1500000000,
-	.clkdco_max = 2500000000UL,
-
-	.n_msb = 8,
-	.n_lsb = 1,
-	.m_msb = 20,
-	.m_lsb = 9,
-
-	.mX_msb[0] = 24,
-	.mX_lsb[0] = 18,
-
-	.has_selfreqdco = true,
-	.has_refsel = true,
-};
-
-static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data *hpll)
+static int dsi_init_pll_data(struct platform_device *pdev,
+			     struct hdmi_pll_data *hpll,
+			     const struct dss_pll_hw *pll_hw)
 {
 	struct dss_pll *pll = &hpll->pll;
 	struct clk *clk;
@@ -144,23 +95,7 @@ static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data
 	pll->id = DSS_PLL_HDMI;
 	pll->base = hpll->base;
 	pll->clkin = clk;
-
-	switch (omapdss_get_version()) {
-	case OMAPDSS_VER_OMAP4430_ES1:
-	case OMAPDSS_VER_OMAP4430_ES2:
-	case OMAPDSS_VER_OMAP4:
-		pll->hw = &dss_omap4_hdmi_pll_hw;
-		break;
-
-	case OMAPDSS_VER_OMAP5:
-	case OMAPDSS_VER_DRA7xx:
-		pll->hw = &dss_omap5_hdmi_pll_hw;
-		break;
-
-	default:
-		return -ENODEV;
-	}
-
+	pll->hw = pll_hw;
 	pll->ops = &dsi_pll_ops;
 
 	r = dss_pll_register(pll);
@@ -171,7 +106,7 @@ static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data
 }
 
 int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
-	struct hdmi_wp_data *wp)
+		  const struct dss_pll_hw *pll_hw, struct hdmi_wp_data *wp)
 {
 	int r;
 	struct resource *res;
@@ -184,7 +119,7 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll,
 	if (IS_ERR(pll->base))
 		return PTR_ERR(pll->base);
 
-	r = dsi_init_pll_data(pdev, pll);
+	r = dsi_init_pll_data(pdev, pll, pll_hw);
 	if (r) {
 		DSSERR("failed to init HDMI PLL\n");
 		return r;
-- 
Regards,

Laurent Pinchart



More information about the dri-devel mailing list