Commit 8097b174 authored by Chaithrika U S's avatar Chaithrika U S Committed by Linus Torvalds

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: default avatarChaithrika U S <chaithrika@ti.com>
Cc: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
Cc: Steve Chen <schen@mvista.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2ec509b9
...@@ -113,6 +113,7 @@ struct da8xx_fb_par { ...@@ -113,6 +113,7 @@ struct da8xx_fb_par {
unsigned short pseudo_palette[16]; unsigned short pseudo_palette[16];
unsigned int databuf_sz; unsigned int databuf_sz;
unsigned int palette_sz; unsigned int palette_sz;
unsigned int pxl_clk;
}; };
/* Variable Screen Information */ /* Variable Screen Information */
...@@ -155,7 +156,7 @@ struct da8xx_panel { ...@@ -155,7 +156,7 @@ struct da8xx_panel {
int vfp; /* Vertical front porch */ int vfp; /* Vertical front porch */
int vbp; /* Vertical back porch */ int vbp; /* Vertical back porch */
int vsw; /* Vertical Sync Pulse Width */ int vsw; /* Vertical Sync Pulse Width */
int pxl_clk; /* Pixel clock */ unsigned int pxl_clk; /* Pixel clock */
unsigned char invert_pxl_clk; /* Invert Pixel clock */ unsigned char invert_pxl_clk; /* Invert Pixel clock */
}; };
...@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = { ...@@ -171,7 +172,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2, .vfp = 2,
.vbp = 2, .vbp = 2,
.vsw = 0, .vsw = 0,
.pxl_clk = 0x10, .pxl_clk = 4608000,
.invert_pxl_clk = 1, .invert_pxl_clk = 1,
}, },
/* Sharp LK043T1DG01 */ /* Sharp LK043T1DG01 */
...@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = { ...@@ -185,7 +186,7 @@ static struct da8xx_panel known_lcd_panels[] = {
.vfp = 2, .vfp = 2,
.vbp = 2, .vbp = 2,
.vsw = 10, .vsw = 10,
.pxl_clk = 0x12, .pxl_clk = 7833600,
.invert_pxl_clk = 0, .invert_pxl_clk = 0,
}, },
}; };
...@@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par) ...@@ -451,6 +452,18 @@ static void lcd_reset(struct da8xx_fb_par *par)
lcdc_write(0, LCD_RASTER_CTRL_REG); lcdc_write(0, LCD_RASTER_CTRL_REG);
} }
static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
{
unsigned int lcd_clk, div;
lcd_clk = clk_get_rate(par->lcdc_clk);
div = lcd_clk / par->pxl_clk;
/* Configure the LCD clock divisor. */
lcdc_write(LCD_CLK_DIVISOR(div) |
(LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
}
static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
struct da8xx_panel *panel) struct da8xx_panel *panel)
{ {
...@@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, ...@@ -459,9 +472,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
lcd_reset(par); lcd_reset(par);
/* Configure the LCD clock divisor. */ /* Calculate the divider */
lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) | lcd_calc_clk_divider(par);
(LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
if (panel->invert_pxl_clk) if (panel->invert_pxl_clk)
lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) | lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
...@@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device) ...@@ -721,6 +733,8 @@ static int __init fb_probe(struct platform_device *device)
} }
par = da8xx_fb_info->par; par = da8xx_fb_info->par;
par->lcdc_clk = fb_clk;
par->pxl_clk = lcdc_info->pxl_clk;
if (lcd_init(par, lcd_cfg, lcdc_info) < 0) { if (lcd_init(par, lcd_cfg, lcdc_info) < 0) {
dev_err(&device->dev, "lcd_init failed\n"); dev_err(&device->dev, "lcd_init failed\n");
...@@ -754,8 +768,6 @@ static int __init fb_probe(struct platform_device *device) ...@@ -754,8 +768,6 @@ static int __init fb_probe(struct platform_device *device)
da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz; da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz;
da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8; da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8;
par->lcdc_clk = fb_clk;
par->irq = platform_get_irq(device, 0); par->irq = platform_get_irq(device, 0);
if (par->irq < 0) { if (par->irq < 0) {
ret = -ENOENT; ret = -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment