drm: omapdrm: hdmi: Store PHY features in PHY data structure
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 4 Aug 2017 22:43:51 +0000 (01:43 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 15 Aug 2017 12:18:25 +0000 (15:18 +0300)
PHY features are stored in a global variable, while they should be
properties of the PHY object. As existing OMAP platforms have a single
HDMI PHY this doesn't cause any issue, but doesn't follow the driver
model.

Move the PHY features to the HDMI PHY data structure to follow the
driver model and pave the road for multiple HDMI PHYs support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/dss/hdmi.h
drivers/gpu/drm/omapdrm/dss/hdmi_phy.c

index fb6cccd..851e5e6 100644 (file)
@@ -245,9 +245,16 @@ struct hdmi_pll_data {
        struct hdmi_wp_data *wp;
 };
 
+struct hdmi_phy_features {
+       bool bist_ctrl;
+       bool ldo_voltage;
+       unsigned long max_phy;
+};
+
 struct hdmi_phy_data {
        void __iomem *base;
 
+       const struct hdmi_phy_features *features;
        u8 lane_function[4];
        u8 lane_polarity[4];
 };
index fb5e4c7..bff1ea1 100644 (file)
 #include "dss.h"
 #include "hdmi.h"
 
-struct hdmi_phy_features {
-       bool bist_ctrl;
-       bool ldo_voltage;
-       unsigned long max_phy;
-};
-
-static const struct hdmi_phy_features *phy_feat;
-
 void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s)
 {
 #define DUMPPHY(r) seq_printf(s, "%-35s %08x\n", #r,\
@@ -36,7 +28,7 @@ void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s)
        DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL);
        DUMPPHY(HDMI_TXPHY_POWER_CTRL);
        DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL);
-       if (phy_feat->bist_ctrl)
+       if (phy->features->bist_ctrl)
                DUMPPHY(HDMI_TXPHY_BIST_CONTROL);
 }
 
@@ -146,7 +138,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk,
         * In OMAP5+, the HFBITCLK must be divided by 2 before issuing the
         * HDMI_PHYPWRCMD_LDOON command.
        */
-       if (phy_feat->bist_ctrl)
+       if (phy->features->bist_ctrl)
                REG_FLD_MOD(phy->base, HDMI_TXPHY_BIST_CONTROL, 1, 11, 11);
 
        /*
@@ -155,7 +147,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk,
         */
        if (hfbitclk != lfbitclk)
                freqout = 0;
-       else if (hfbitclk / 10 < phy_feat->max_phy)
+       else if (hfbitclk / 10 < phy->features->max_phy)
                freqout = 1;
        else
                freqout = 2;
@@ -170,7 +162,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk,
        hdmi_write_reg(phy->base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000);
 
        /* Setup max LDO voltage */
-       if (phy_feat->ldo_voltage)
+       if (phy->features->ldo_voltage)
                REG_FLD_MOD(phy->base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0);
 
        hdmi_phy_configure_lanes(phy);
@@ -190,7 +182,8 @@ static const struct hdmi_phy_features omap54xx_phy_feats = {
        .max_phy        =       186000000,
 };
 
-static int hdmi_phy_init_features(struct platform_device *pdev)
+static int hdmi_phy_init_features(struct platform_device *pdev,
+                                 struct hdmi_phy_data *phy)
 {
        struct hdmi_phy_features *dst;
        const struct hdmi_phy_features *src;
@@ -218,7 +211,7 @@ static int hdmi_phy_init_features(struct platform_device *pdev)
        }
 
        memcpy(dst, src, sizeof(*dst));
-       phy_feat = dst;
+       phy->features = dst;
 
        return 0;
 }
@@ -228,7 +221,7 @@ int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy)
        int r;
        struct resource *res;
 
-       r = hdmi_phy_init_features(pdev);
+       r = hdmi_phy_init_features(pdev, phy);
        if (r)
                return r;