aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/da8xx-fb.c
diff options
context:
space:
mode:
authorChaithrika U S <chaithrika@ti.com>2009-12-15 19:46:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 10:20:01 -0500
commit8097b1749f9265be0f3dbc43c3700da31eb422fd (patch)
tree307f93951b9433329636b241c914512c6e8b8887 /drivers/video/da8xx-fb.c
parent2ec509b96cce5e6d19ee43fdd818eab78e76328d (diff)
davinci: fb: calculate the clock divider from pixel clock info
The clock divider value can be calculated from the pixel clock value for the panel. This gives more flexiblity to the driver to change the divider value on the fly as in the case of cpufreq feature- support for which will be added shortly. Signed-off-by: Chaithrika U S <chaithrika@ti.com> Cc: Sudhakar Rajashekhara <sudhakar.raj@ti.com> Cc: Steve Chen <schen@mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/da8xx-fb.c')
-rw-r--r--drivers/video/da8xx-fb.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index ea1fd3f47511..fe0025213a82 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -113,6 +113,7 @@ struct da8xx_fb_par {
113 unsigned short pseudo_palette[16]; 113 unsigned short pseudo_palette[16];
114 unsigned int databuf_sz; 114 unsigned int databuf_sz;
115 unsigned int palette_sz; 115 unsigned int palette_sz;
116 unsigned int pxl_clk;
116}; 117};
117 118
118/* Variable Screen Information */ 119/* Variable Screen Information */
@@ -155,7 +156,7 @@ struct da8xx_panel {
155 int vfp; /* Vertical front porch */ 156 int vfp; /* Vertical front porch */
156 int vbp; /* Vertical back porch */ 157 int vbp; /* Vertical back porch */
157 int vsw; /* Vertical Sync Pulse Width */ 158 int vsw; /* Vertical Sync Pulse Width */
158 int pxl_clk; /* Pixel clock */ 159 unsigned int pxl_clk; /* Pixel clock */
159 unsigned char invert_pxl_clk; /* Invert Pixel clock */ 160 unsigned char invert_pxl_clk; /* Invert Pixel clock */
160}; 161};
161 162
@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
171 .vfp = 2, 172 .vfp = 2,
172 .vbp = 2, 173 .vbp = 2,
173 .vsw = 0, 174 .vsw = 0,
174 .pxl_clk = 0x10, 175 .pxl_clk = 4608000,
175 .invert_pxl_clk = 1, 176 .invert_pxl_clk = 1,
176 }, 177 },
177 /* Sharp LK043T1DG01 */ 178 /* Sharp LK043T1DG01 */
@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
185 .vfp = 2, 186 .vfp = 2,
186 .vbp = 2, 187 .vbp = 2,
187 .vsw = 10, 188 .vsw = 10,
188 .pxl_clk = 0x12, 189 .pxl_clk = 7833600,
189 .invert_pxl_clk = 0, 190 .invert_pxl_clk = 0,
190 }, 191 },
191}; 192};
@@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
451 lcdc_write(0, LCD_RASTER_CTRL_REG); 452 lcdc_write(0, LCD_RASTER_CTRL_REG);
452} 453}
453 454
455static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
456{
457 unsigned int lcd_clk, div;
458
459 lcd_clk = clk_get_rate(par->lcdc_clk);
460 div = lcd_clk / par->pxl_clk;
461
462 /* Configure the LCD clock divisor. */
463 lcdc_write(LCD_CLK_DIVISOR(div) |
464 (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
465}
466
454static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, 467static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
455 struct da8xx_panel *panel) 468 struct da8xx_panel *panel)
456{ 469{
@@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
459 472
460 lcd_reset(par); 473 lcd_reset(par);
461 474
462 /* Configure the LCD clock divisor. */ 475 /* Calculate the divider */
463 lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) | 476 lcd_calc_clk_divider(par);
464 (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
465 477
466 if (panel->invert_pxl_clk) 478 if (panel->invert_pxl_clk)
467 lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) | 479 lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
@@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device)
721 } 733 }
722 734
723 par = da8xx_fb_info->par; 735 par = da8xx_fb_info->par;
736 par->lcdc_clk = fb_clk;
737 par->pxl_clk = lcdc_info->pxl_clk;
724 738
725 if (lcd_init(par, lcd_cfg, lcdc_info) < 0) { 739 if (lcd_init(par, lcd_cfg, lcdc_info) < 0) {
726 dev_err(&device->dev, "lcd_init failed\n"); 740 dev_err(&device->dev, "lcd_init failed\n");
@@ -754,8 +768,6 @@ static int __init fb_probe(struct platform_device *device)
754 da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz; 768 da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz;
755 da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8; 769 da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8;
756 770
757 par->lcdc_clk = fb_clk;
758
759 par->irq = platform_get_irq(device, 0); 771 par->irq = platform_get_irq(device, 0);
760 if (par->irq < 0) { 772 if (par->irq < 0) {
761 ret = -ENOENT; 773 ret = -ENOENT;