Skip to content

Commit bcc6570

Browse files
Deepak Mjnikula
authored andcommitted
drm/i915/glk: Program txesc clock divider for GLK
v2: Addressed Jani's Review comments(renamed bit field macros) Txesc clock divider is calculated and programmed for geminilake platform. Signed-off-by: Deepak M <m.deepak@intel.com> Signed-off-by: Madhav Chauhan <madhav.chauhan@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1487335415-14766-7-git-send-email-madhav.chauhan@intel.com
1 parent 09a568e commit bcc6570

2 files changed

Lines changed: 64 additions & 2 deletions

File tree

‎drivers/gpu/drm/i915/i915_reg.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8251,6 +8251,11 @@ enum {
82518251
#define _MIPI_PORT(port, a, c) _PORT3(port, a, 0, c) /* ports A and C only */
82528252
#define _MMIO_MIPI(port, a, c) _MMIO(_MIPI_PORT(port, a, c))
82538253

8254+
#define MIPIO_TXESC_CLK_DIV1 _MMIO(0x160004)
8255+
#define GLK_TX_ESC_CLK_DIV1_MASK 0x3FF
8256+
#define MIPIO_TXESC_CLK_DIV2 _MMIO(0x160008)
8257+
#define GLK_TX_ESC_CLK_DIV2_MASK 0x3FF
8258+
82548259
/* BXT MIPI clock controls */
82558260
#define BXT_MAX_VAR_OUTPUT_KHZ 39500
82568261

‎drivers/gpu/drm/i915/intel_dsi_pll.c‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,53 @@ static void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
372372
ESCAPE_CLOCK_DIVIDER_SHIFT);
373373
}
374374

375+
static void glk_dsi_program_esc_clock(struct drm_device *dev,
376+
const struct intel_crtc_state *config)
377+
{
378+
struct drm_i915_private *dev_priv = to_i915(dev);
379+
u32 dsi_rate = 0;
380+
u32 pll_ratio = 0;
381+
u32 ddr_clk = 0;
382+
u32 div1_value = 0;
383+
u32 div2_value = 0;
384+
u32 txesc1_div = 0;
385+
u32 txesc2_div = 0;
386+
387+
pll_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK;
388+
389+
dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
390+
391+
ddr_clk = dsi_rate / 2;
392+
393+
/* Variable divider value */
394+
div1_value = DIV_ROUND_CLOSEST(ddr_clk, 20000);
395+
396+
/* Calculate TXESC1 divider */
397+
if (div1_value <= 10)
398+
txesc1_div = div1_value;
399+
else if ((div1_value > 10) && (div1_value <= 20))
400+
txesc1_div = DIV_ROUND_UP(div1_value, 2);
401+
else if ((div1_value > 20) && (div1_value <= 30))
402+
txesc1_div = DIV_ROUND_UP(div1_value, 4);
403+
else if ((div1_value > 30) && (div1_value <= 40))
404+
txesc1_div = DIV_ROUND_UP(div1_value, 6);
405+
else if ((div1_value > 40) && (div1_value <= 50))
406+
txesc1_div = DIV_ROUND_UP(div1_value, 8);
407+
else
408+
txesc1_div = 10;
409+
410+
/* Calculate TXESC2 divider */
411+
div2_value = DIV_ROUND_UP(div1_value, txesc1_div);
412+
413+
if (div2_value < 10)
414+
txesc2_div = div2_value;
415+
else
416+
txesc2_div = 10;
417+
418+
I915_WRITE(MIPIO_TXESC_CLK_DIV1, txesc1_div & GLK_TX_ESC_CLK_DIV1_MASK);
419+
I915_WRITE(MIPIO_TXESC_CLK_DIV2, txesc2_div & GLK_TX_ESC_CLK_DIV2_MASK);
420+
}
421+
375422
/* Program BXT Mipi clocks and dividers */
376423
static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port,
377424
const struct intel_crtc_state *config)
@@ -474,7 +521,7 @@ static int gen9lp_compute_dsi_pll(struct intel_encoder *encoder,
474521
return 0;
475522
}
476523

477-
static void bxt_enable_dsi_pll(struct intel_encoder *encoder,
524+
static void gen9lp_enable_dsi_pll(struct intel_encoder *encoder,
478525
const struct intel_crtc_state *config)
479526
{
480527
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
@@ -492,6 +539,8 @@ static void bxt_enable_dsi_pll(struct intel_encoder *encoder,
492539
if (IS_BROXTON(dev_priv)) {
493540
for_each_dsi_port(port, intel_dsi->ports)
494541
bxt_dsi_program_clocks(encoder->base.dev, port, config);
542+
} else {
543+
glk_dsi_program_esc_clock(encoder->base.dev, config);
495544
}
496545

497546
/* Enable DSI PLL */
@@ -543,7 +592,7 @@ void intel_enable_dsi_pll(struct intel_encoder *encoder,
543592
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
544593
vlv_enable_dsi_pll(encoder, config);
545594
else if (IS_GEN9_LP(dev_priv))
546-
bxt_enable_dsi_pll(encoder, config);
595+
gen9lp_enable_dsi_pll(encoder, config);
547596
}
548597

549598
void intel_disable_dsi_pll(struct intel_encoder *encoder)
@@ -571,6 +620,14 @@ static void gen9lp_dsi_reset_clocks(struct intel_encoder *encoder,
571620
tmp &= ~(BXT_MIPI_8X_BY3_DIVIDER_MASK(port));
572621
tmp &= ~(BXT_MIPI_RX_ESCLK_LOWER_FIXDIV_MASK(port));
573622
I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
623+
} else {
624+
tmp = I915_READ(MIPIO_TXESC_CLK_DIV1);
625+
tmp &= ~GLK_TX_ESC_CLK_DIV1_MASK;
626+
I915_WRITE(MIPIO_TXESC_CLK_DIV1, tmp);
627+
628+
tmp = I915_READ(MIPIO_TXESC_CLK_DIV2);
629+
tmp &= ~GLK_TX_ESC_CLK_DIV2_MASK;
630+
I915_WRITE(MIPIO_TXESC_CLK_DIV2, tmp);
574631
}
575632
I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
576633
}

0 commit comments

Comments
 (0)