Lines Matching +full:- +full:refclk
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2011 Intel Corporation
24 int refclk, struct gma_clock_t *best_clock);
56 /* The single-channel range is 25-112Mhz, and dual-channel
57 * is 80-224Mhz. Prefer single channel as much as possible.
117 ret__ = -ETIMEDOUT; \
216 int pipe = gma_crtc->pipe; in cdv_dpll_set_clock_cdv()
271 m |= ((clock->m2) << SB_M_DIVIDER_SHIFT); in cdv_dpll_set_clock_cdv()
287 n_vco |= ((clock->n) << SB_N_DIVIDER_SHIFT); in cdv_dpll_set_clock_cdv()
289 if (clock->vco < 2250000) { in cdv_dpll_set_clock_cdv()
292 } else if (clock->vco < 2750000) { in cdv_dpll_set_clock_cdv()
295 } else if (clock->vco < 3300000) { in cdv_dpll_set_clock_cdv()
311 p |= SET_FIELD(clock->p1, SB_P1_DIVIDER); in cdv_dpll_set_clock_cdv()
312 switch (clock->p2) { in cdv_dpll_set_clock_cdv()
326 DRM_ERROR("Bad P2 clock: %d\n", clock->p2); in cdv_dpll_set_clock_cdv()
327 return -EINVAL; in cdv_dpll_set_clock_cdv()
364 int refclk) in cdv_intel_limit() argument
369 * Now only single-channel LVDS is supported on CDV. If it is in cdv_intel_limit()
370 * incorrect, please add the dual-channel LVDS. in cdv_intel_limit()
372 if (refclk == 96000) in cdv_intel_limit()
378 if (refclk == 27000) in cdv_intel_limit()
383 if (refclk == 27000) in cdv_intel_limit()
392 static void cdv_intel_clock(int refclk, struct gma_clock_t *clock) in cdv_intel_clock() argument
394 clock->m = clock->m2 + 2; in cdv_intel_clock()
395 clock->p = clock->p1 * clock->p2; in cdv_intel_clock()
396 clock->vco = (refclk * clock->m) / clock->n; in cdv_intel_clock()
397 clock->dot = clock->vco / clock->p; in cdv_intel_clock()
402 int refclk, in cdv_intel_find_dp_pll() argument
410 switch (refclk) { in cdv_intel_find_dp_pll()
447 gma_crtc->clock_funcs->clock(refclk, &clock); in cdv_intel_find_dp_pll()
461 crtc = dev_priv->pipe_to_crtc_mapping[pipe]; in cdv_intel_pipe_enabled()
464 if (crtc->primary->fb == NULL || !gma_crtc->active) in cdv_intel_pipe_enabled()
473 /* Disable self-refresh before adjust WM */ in cdv_disable_sr()
482 REG_WRITE(OV_OVADD, 0/*dev_priv->ovl_offset*/); in cdv_disable_sr()
518 if (gma_crtc->pipe == 1 && in cdv_update_wm()
533 /* enable self-refresh for single pipe active */ in cdv_update_wm()
550 dev_priv->ops->disable_sr(dev); in cdv_update_wm()
556 * or -1 if the panel fitter is not present or not in use
566 return -1; in cdv_intel_panel_fitter_pipe()
576 struct drm_device *dev = crtc->dev; in cdv_intel_crtc_mode_set()
579 int pipe = gma_crtc->pipe; in cdv_intel_crtc_mode_set()
580 const struct psb_offset *map = &dev_priv->regmap[pipe]; in cdv_intel_crtc_mode_set()
581 int refclk; in cdv_intel_crtc_mode_set() local
598 if (!connector->encoder in cdv_intel_crtc_mode_set()
599 || connector->encoder->crtc != crtc) in cdv_intel_crtc_mode_set()
602 ddi_select = gma_encoder->ddi_select; in cdv_intel_crtc_mode_set()
603 switch (gma_encoder->type) { in cdv_intel_crtc_mode_set()
626 if (dev_priv->dplla_96mhz) in cdv_intel_crtc_mode_set()
627 /* low-end sku, 96/100 mhz */ in cdv_intel_crtc_mode_set()
628 refclk = 96000; in cdv_intel_crtc_mode_set()
630 /* high-end sku, 27/100 mhz */ in cdv_intel_crtc_mode_set()
631 refclk = 27000; in cdv_intel_crtc_mode_set()
634 * Based on the spec the low-end SKU has only CRT/LVDS. So it is in cdv_intel_crtc_mode_set()
636 * On the high-end SKU, it will use the 27/100M reference clk in cdv_intel_crtc_mode_set()
642 refclk = 27000; in cdv_intel_crtc_mode_set()
644 refclk = 100000; in cdv_intel_crtc_mode_set()
647 if (is_lvds && dev_priv->lvds_use_ssc) { in cdv_intel_crtc_mode_set()
648 refclk = dev_priv->lvds_ssc_freq * 1000; in cdv_intel_crtc_mode_set()
649 DRM_DEBUG_KMS("Use SSC reference clock %d Mhz\n", dev_priv->lvds_ssc_freq); in cdv_intel_crtc_mode_set()
654 limit = gma_crtc->clock_funcs->limit(crtc, refclk); in cdv_intel_crtc_mode_set()
656 ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk, in cdv_intel_crtc_mode_set()
660 adjusted_mode->clock, clock.dot); in cdv_intel_crtc_mode_set()
683 pipeconf = REG_READ(map->conf); in cdv_intel_crtc_mode_set()
687 switch (dev_priv->edp.bpp) { in cdv_intel_crtc_mode_set()
702 /* the BPC will be 6 if it is 18-bit LVDS panel */ in cdv_intel_crtc_mode_set()
721 REG_WRITE(map->dpll, dpll | DPLL_VGA_MODE_DIS | DPLL_SYNCLOCK_ENABLE); in cdv_intel_crtc_mode_set()
722 REG_READ(map->dpll); in cdv_intel_crtc_mode_set()
739 /* Set the B0-B3 data pairs corresponding to in cdv_intel_crtc_mode_set()
741 * set the DPLLs for dual-channel mode or not. in cdv_intel_crtc_mode_set()
748 /* It would be nice to set 24 vs 18-bit mode (LVDS_A3_POWER_UP) in cdv_intel_crtc_mode_set()
766 REG_WRITE(map->dpll, in cdv_intel_crtc_mode_set()
767 (REG_READ(map->dpll) & ~DPLL_LOCK) | DPLL_VCO_ENABLE); in cdv_intel_crtc_mode_set()
768 REG_READ(map->dpll); in cdv_intel_crtc_mode_set()
772 if (!(REG_READ(map->dpll) & DPLL_LOCK)) { in cdv_intel_crtc_mode_set()
773 dev_err(dev->dev, "Failed to get DPLL lock\n"); in cdv_intel_crtc_mode_set()
774 return -EBUSY; in cdv_intel_crtc_mode_set()
778 int sdvo_pixel_multiply = adjusted_mode->clock / mode->clock; in cdv_intel_crtc_mode_set()
779 …REG_WRITE(map->dpll_md, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) | ((sdvo_pixel_multiply - 1) << DPLL_MD_U… in cdv_intel_crtc_mode_set()
782 REG_WRITE(map->htotal, (adjusted_mode->crtc_hdisplay - 1) | in cdv_intel_crtc_mode_set()
783 ((adjusted_mode->crtc_htotal - 1) << 16)); in cdv_intel_crtc_mode_set()
784 REG_WRITE(map->hblank, (adjusted_mode->crtc_hblank_start - 1) | in cdv_intel_crtc_mode_set()
785 ((adjusted_mode->crtc_hblank_end - 1) << 16)); in cdv_intel_crtc_mode_set()
786 REG_WRITE(map->hsync, (adjusted_mode->crtc_hsync_start - 1) | in cdv_intel_crtc_mode_set()
787 ((adjusted_mode->crtc_hsync_end - 1) << 16)); in cdv_intel_crtc_mode_set()
788 REG_WRITE(map->vtotal, (adjusted_mode->crtc_vdisplay - 1) | in cdv_intel_crtc_mode_set()
789 ((adjusted_mode->crtc_vtotal - 1) << 16)); in cdv_intel_crtc_mode_set()
790 REG_WRITE(map->vblank, (adjusted_mode->crtc_vblank_start - 1) | in cdv_intel_crtc_mode_set()
791 ((adjusted_mode->crtc_vblank_end - 1) << 16)); in cdv_intel_crtc_mode_set()
792 REG_WRITE(map->vsync, (adjusted_mode->crtc_vsync_start - 1) | in cdv_intel_crtc_mode_set()
793 ((adjusted_mode->crtc_vsync_end - 1) << 16)); in cdv_intel_crtc_mode_set()
797 REG_WRITE(map->size, in cdv_intel_crtc_mode_set()
798 ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); in cdv_intel_crtc_mode_set()
799 REG_WRITE(map->pos, 0); in cdv_intel_crtc_mode_set()
800 REG_WRITE(map->src, in cdv_intel_crtc_mode_set()
801 ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); in cdv_intel_crtc_mode_set()
802 REG_WRITE(map->conf, pipeconf); in cdv_intel_crtc_mode_set()
803 REG_READ(map->conf); in cdv_intel_crtc_mode_set()
807 REG_WRITE(map->cntr, dspcntr); in cdv_intel_crtc_mode_set()
812 crtc->helper_private; in cdv_intel_crtc_mode_set()
813 crtc_funcs->mode_set_base(crtc, x, y, old_fb); in cdv_intel_crtc_mode_set()
821 /** Derive the pixel clock for the given refclk and divisors for 8xx chips. */
825 static void i8xx_clock(int refclk, struct gma_clock_t *clock) in i8xx_clock() argument
827 clock->m = 5 * (clock->m1 + 2) + (clock->m2 + 2); in i8xx_clock()
828 clock->p = clock->p1 * clock->p2; in i8xx_clock()
829 clock->vco = refclk * clock->m / (clock->n + 2); in i8xx_clock()
830 clock->dot = clock->vco / clock->p; in i8xx_clock()
839 int pipe = gma_crtc->pipe; in cdv_intel_crtc_clock_get()
840 const struct psb_offset *map = &dev_priv->regmap[pipe]; in cdv_intel_crtc_clock_get()
845 struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; in cdv_intel_crtc_clock_get()
848 dpll = REG_READ(map->dpll); in cdv_intel_crtc_clock_get()
850 fp = REG_READ(map->fp0); in cdv_intel_crtc_clock_get()
852 fp = REG_READ(map->fp1); in cdv_intel_crtc_clock_get()
856 dpll = p->dpll; in cdv_intel_crtc_clock_get()
858 fp = p->fp0; in cdv_intel_crtc_clock_get()
860 fp = p->fp1; in cdv_intel_crtc_clock_get()
863 (dev_priv->regs.psb.saveLVDS & LVDS_PORT_EN); in cdv_intel_crtc_clock_get()
877 dev_err(dev->dev, "PLL %d\n", dpll); in cdv_intel_crtc_clock_get()
917 int pipe = gma_crtc->pipe; in cdv_intel_crtc_mode_get()
919 struct psb_pipe *p = &dev_priv->regs.pipe[pipe]; in cdv_intel_crtc_mode_get()
920 const struct psb_offset *map = &dev_priv->regmap[pipe]; in cdv_intel_crtc_mode_get()
928 htot = REG_READ(map->htotal); in cdv_intel_crtc_mode_get()
929 hsync = REG_READ(map->hsync); in cdv_intel_crtc_mode_get()
930 vtot = REG_READ(map->vtotal); in cdv_intel_crtc_mode_get()
931 vsync = REG_READ(map->vsync); in cdv_intel_crtc_mode_get()
934 htot = p->htotal; in cdv_intel_crtc_mode_get()
935 hsync = p->hsync; in cdv_intel_crtc_mode_get()
936 vtot = p->vtotal; in cdv_intel_crtc_mode_get()
937 vsync = p->vsync; in cdv_intel_crtc_mode_get()
944 mode->clock = cdv_intel_crtc_clock_get(dev, crtc); in cdv_intel_crtc_mode_get()
945 mode->hdisplay = (htot & 0xffff) + 1; in cdv_intel_crtc_mode_get()
946 mode->htotal = ((htot & 0xffff0000) >> 16) + 1; in cdv_intel_crtc_mode_get()
947 mode->hsync_start = (hsync & 0xffff) + 1; in cdv_intel_crtc_mode_get()
948 mode->hsync_end = ((hsync & 0xffff0000) >> 16) + 1; in cdv_intel_crtc_mode_get()
949 mode->vdisplay = (vtot & 0xffff) + 1; in cdv_intel_crtc_mode_get()
950 mode->vtotal = ((vtot & 0xffff0000) >> 16) + 1; in cdv_intel_crtc_mode_get()
951 mode->vsync_start = (vsync & 0xffff) + 1; in cdv_intel_crtc_mode_get()
952 mode->vsync_end = ((vsync & 0xffff0000) >> 16) + 1; in cdv_intel_crtc_mode_get()