Skip to content

Commit 6efa61a

Browse files
Dharma Balasubiramanimanikandan-m11
authored andcommitted
drm: atmel-hlcdc: disable clock divider to match LCDC_PCK with the src clk
When utilizing the LVDS interface, enable the ATMEL_XLCDC_CLKBYP bit in LCDC_CFG0 for XLCDC. This configuration ensures that the LCDC pixel clock aligns with the source clock (LVDS PLL). Signed-off-by: Dharma Balasubiramani <dharma.b@microchip.com>
1 parent 953f785 commit 6efa61a

2 files changed

Lines changed: 31 additions & 25 deletions

File tree

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,39 +130,44 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
130130
(adj->crtc_hdisplay - 1) |
131131
((adj->crtc_vdisplay - 1) << 16));
132132

133-
prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
134-
mode_rate = adj->crtc_clock * 1000;
135-
if (!crtc->dc->desc->fixed_clksrc) {
136-
prate *= 2;
137-
cfg |= ATMEL_HLCDC_CLKSEL;
138-
mask |= ATMEL_HLCDC_CLKSEL;
139-
}
133+
if (crtc->dc->hlcdc->lvds_pll_clk) {
134+
cfg |= ATMEL_XLCDC_CLKBYP;
135+
mask |= ATMEL_XLCDC_CLKBYP;
136+
} else {
137+
prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
138+
mode_rate = adj->crtc_clock * 1000;
139+
if (!crtc->dc->desc->fixed_clksrc) {
140+
prate *= 2;
141+
cfg |= ATMEL_HLCDC_CLKSEL;
142+
mask |= ATMEL_HLCDC_CLKSEL;
143+
}
140144

141-
div = DIV_ROUND_UP(prate, mode_rate);
142-
if (div < 2) {
143-
div = 2;
144-
} else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) {
145-
/* The divider ended up too big, try a lower base rate. */
146-
cfg &= ~ATMEL_HLCDC_CLKSEL;
147-
prate /= 2;
148145
div = DIV_ROUND_UP(prate, mode_rate);
149-
if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK)
150-
div = ATMEL_HLCDC_CLKDIV_MASK;
151-
} else {
152-
int div_low = prate / mode_rate;
146+
if (div < 2) {
147+
div = 2;
148+
} else if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK) {
149+
/* The divider ended up too big, try a lower base rate. */
150+
cfg &= ~ATMEL_HLCDC_CLKSEL;
151+
prate /= 2;
152+
div = DIV_ROUND_UP(prate, mode_rate);
153+
if (ATMEL_HLCDC_CLKDIV(div) & ~ATMEL_HLCDC_CLKDIV_MASK)
154+
div = ATMEL_HLCDC_CLKDIV_MASK;
155+
} else {
156+
int div_low = prate / mode_rate;
153157

154-
if (div_low >= 2 &&
155-
(10 * (prate / div_low - mode_rate) <
156-
(mode_rate - prate / div)))
157158
/*
158-
* At least 10 times better when using a higher
159+
* Its better to use a higher Pixel clock
159160
* frequency than requested, instead of a lower.
160161
* So, go with that.
161162
*/
162-
div = div_low;
163-
}
164163

165-
cfg |= ATMEL_HLCDC_CLKDIV(div);
164+
if (div_low >= 2 &&
165+
((prate / div_low >= mode_rate) &&
166+
(prate / div < mode_rate)))
167+
div = div_low;
168+
}
169+
cfg |= ATMEL_HLCDC_CLKDIV(div);
170+
}
166171

167172
if (connector &&
168173
connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)

include/linux/mfd/atmel-hlcdc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#define ATMEL_XLCDC_HEO_UPDATE BIT(3)
4545

4646
#define ATMEL_HLCDC_CLKPOL BIT(0)
47+
#define ATMEL_XLCDC_CLKBYP BIT(1)
4748
#define ATMEL_HLCDC_CLKSEL BIT(2)
4849
#define ATMEL_HLCDC_CLKPWMSEL BIT(3)
4950
#define ATMEL_HLCDC_CGDIS(i) BIT(8 + (i))

0 commit comments

Comments
 (0)