Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

OMAPDSS: HDMI: PHY changes for OMAP5

OMAP5 HDMI PHY has some differences compared to OMAP4 HDMI PHY. This
patch creates a features struct which help the driver configure the PHY
based on what SoC it is.

Some of the features aren't currenlty used, but will come in use later.

Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

authored by

Archit Taneja and committed by
Tomi Valkeinen
19289fdc 8955b727

+94 -2
+1
drivers/video/fbdev/omap2/dss/hdmi.h
··· 80 80 #define HDMI_TXPHY_DIGITAL_CTRL 0x4 81 81 #define HDMI_TXPHY_POWER_CTRL 0x8 82 82 #define HDMI_TXPHY_PAD_CFG_CTRL 0xC 83 + #define HDMI_TXPHY_BIST_CONTROL 0x1C 83 84 84 85 enum hdmi_pll_pwr { 85 86 HDMI_PLLPWRCMD_ALLOFF = 0,
+93 -2
drivers/video/fbdev/omap2/dss/hdmi_phy.c
··· 12 12 #include <linux/err.h> 13 13 #include <linux/io.h> 14 14 #include <linux/platform_device.h> 15 + #include <linux/slab.h> 15 16 #include <video/omapdss.h> 16 17 17 18 #include "dss.h" 18 19 #include "hdmi.h" 20 + 21 + struct hdmi_phy_features { 22 + bool bist_ctrl; 23 + bool calc_freqout; 24 + bool ldo_voltage; 25 + unsigned long dcofreq_min; 26 + unsigned long max_phy; 27 + }; 28 + 29 + static const struct hdmi_phy_features *phy_feat; 19 30 20 31 void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s) 21 32 { ··· 37 26 DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL); 38 27 DUMPPHY(HDMI_TXPHY_POWER_CTRL); 39 28 DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL); 29 + if (phy_feat->bist_ctrl) 30 + DUMPPHY(HDMI_TXPHY_BIST_CONTROL); 40 31 } 41 32 42 33 int hdmi_phy_parse_lanes(struct hdmi_phy_data *phy, const u32 *lanes) ··· 134 121 135 122 int hdmi_phy_configure(struct hdmi_phy_data *phy, struct hdmi_config *cfg) 136 123 { 124 + u8 freqout; 125 + 137 126 /* 138 127 * Read address 0 in order to get the SCP reset done completed 139 128 * Dummy access performed to make sure reset is done ··· 143 128 hdmi_read_reg(phy->base, HDMI_TXPHY_TX_CTRL); 144 129 145 130 /* 131 + * In OMAP5+, the HFBITCLK must be divided by 2 before issuing the 132 + * HDMI_PHYPWRCMD_LDOON command. 133 + */ 134 + if (phy_feat->bist_ctrl) 135 + REG_FLD_MOD(phy->base, HDMI_TXPHY_BIST_CONTROL, 1, 11, 11); 136 + 137 + if (phy_feat->calc_freqout) { 138 + /* DCOCLK/10 is pixel clock, compare pclk with DCOCLK_MIN/10 */ 139 + u32 dco_min = phy_feat->dcofreq_min / 10; 140 + u32 pclk = cfg->timings.pixelclock; 141 + 142 + if (pclk < dco_min) 143 + freqout = 0; 144 + else if ((pclk >= dco_min) && (pclk < phy_feat->max_phy)) 145 + freqout = 1; 146 + else 147 + freqout = 2; 148 + } else { 149 + freqout = 1; 150 + } 151 + 152 + /* 146 153 * Write to phy address 0 to configure the clock 147 154 * use HFBITCLK write HDMI_TXPHY_TX_CONTROL_FREQOUT field 148 155 */ 149 - REG_FLD_MOD(phy->base, HDMI_TXPHY_TX_CTRL, 0x1, 31, 30); 156 + REG_FLD_MOD(phy->base, HDMI_TXPHY_TX_CTRL, freqout, 31, 30); 150 157 151 158 /* Write to phy address 1 to start HDMI line (TXVALID and TMDSCLKEN) */ 152 159 hdmi_write_reg(phy->base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000); 153 160 154 161 /* Setup max LDO voltage */ 155 - REG_FLD_MOD(phy->base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0); 162 + if (phy_feat->ldo_voltage) 163 + REG_FLD_MOD(phy->base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0); 156 164 157 165 hdmi_phy_configure_lanes(phy); 158 166 ··· 185 147 #define PHY_OFFSET 0x300 186 148 #define PHY_SIZE 0x100 187 149 150 + static const struct hdmi_phy_features omap44xx_phy_feats = { 151 + .bist_ctrl = false, 152 + .calc_freqout = false, 153 + .ldo_voltage = true, 154 + .dcofreq_min = 500000000, 155 + .max_phy = 185675000, 156 + }; 157 + 158 + static const struct hdmi_phy_features omap54xx_phy_feats = { 159 + .bist_ctrl = true, 160 + .calc_freqout = true, 161 + .ldo_voltage = false, 162 + .dcofreq_min = 750000000, 163 + .max_phy = 186000000, 164 + }; 165 + 166 + static int hdmi_phy_init_features(struct platform_device *pdev) 167 + { 168 + struct hdmi_phy_features *dst; 169 + const struct hdmi_phy_features *src; 170 + 171 + dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); 172 + if (!dst) { 173 + dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); 174 + return -ENOMEM; 175 + } 176 + 177 + switch (omapdss_get_version()) { 178 + case OMAPDSS_VER_OMAP4430_ES1: 179 + case OMAPDSS_VER_OMAP4430_ES2: 180 + case OMAPDSS_VER_OMAP4: 181 + src = &omap44xx_phy_feats; 182 + break; 183 + 184 + case OMAPDSS_VER_OMAP5: 185 + src = &omap54xx_phy_feats; 186 + break; 187 + 188 + default: 189 + return -ENODEV; 190 + } 191 + 192 + memcpy(dst, src, sizeof(*dst)); 193 + phy_feat = dst; 194 + 195 + return 0; 196 + } 197 + 188 198 int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) 189 199 { 200 + int r; 190 201 struct resource *res; 191 202 struct resource temp_res; 203 + 204 + r = hdmi_phy_init_features(pdev); 205 + if (r) 206 + return r; 192 207 193 208 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); 194 209 if (!res) {