Commit 343b8891 authored by Chaithrika U S's avatar Chaithrika U S Committed by Kevin Hilman

davinci: fb: Updates the driver in preparation for addition of power management features

Add a helper function to enable raster. Also add one member in the
private data structure to track the current blank status, another
function pointer which takes in the platform specific callback function
to control panel power.

These updates will help in adding suspend/resume and frame buffer blank
operation features.
Signed-off-by: default avatarChaithrika U S <chaithrika@ti.com>
parent 62911d7f
...@@ -115,9 +115,11 @@ struct da8xx_fb_par { ...@@ -115,9 +115,11 @@ struct da8xx_fb_par {
unsigned int databuf_sz; unsigned int databuf_sz;
unsigned int palette_sz; unsigned int palette_sz;
unsigned int pxl_clk; unsigned int pxl_clk;
int blank;
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition; struct notifier_block freq_transition;
#endif #endif
void (*panel_power_ctrl)(int);
}; };
/* Variable Screen Information */ /* Variable Screen Information */
...@@ -195,8 +197,18 @@ static struct da8xx_panel known_lcd_panels[] = { ...@@ -195,8 +197,18 @@ static struct da8xx_panel known_lcd_panels[] = {
}, },
}; };
/* Enable the Raster Engine of the LCD Controller */
static inline void lcd_enable_raster(void)
{
u32 reg;
reg = lcdc_read(LCD_RASTER_CTRL_REG);
if (!(reg & LCD_RASTER_ENABLE))
lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
}
/* Disable the Raster Engine of the LCD Controller */ /* Disable the Raster Engine of the LCD Controller */
static void lcd_disable_raster(struct da8xx_fb_par *par) static inline void lcd_disable_raster(void)
{ {
u32 reg; u32 reg;
...@@ -448,8 +460,7 @@ static int fb_setcolreg(unsigned regno, unsigned red, unsigned green, ...@@ -448,8 +460,7 @@ static int fb_setcolreg(unsigned regno, unsigned red, unsigned green,
static void lcd_reset(struct da8xx_fb_par *par) static void lcd_reset(struct da8xx_fb_par *par)
{ {
/* Disable the Raster if previously Enabled */ /* Disable the Raster if previously Enabled */
if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE) lcd_disable_raster();
lcd_disable_raster(par);
/* DMA has to be disabled */ /* DMA has to be disabled */
lcdc_write(0, LCD_DMA_CTRL_REG); lcdc_write(0, LCD_DMA_CTRL_REG);
...@@ -530,13 +541,11 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg, ...@@ -530,13 +541,11 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
static irqreturn_t lcdc_irq_handler(int irq, void *arg) static irqreturn_t lcdc_irq_handler(int irq, void *arg)
{ {
u32 stat = lcdc_read(LCD_STAT_REG); u32 stat = lcdc_read(LCD_STAT_REG);
u32 reg;
if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) { if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
reg = lcdc_read(LCD_RASTER_CTRL_REG); lcd_disable_raster();
lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
lcdc_write(stat, LCD_STAT_REG); lcdc_write(stat, LCD_STAT_REG);
lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG); lcd_enable_raster();
} else } else
lcdc_write(stat, LCD_STAT_REG); lcdc_write(stat, LCD_STAT_REG);
...@@ -596,16 +605,13 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb, ...@@ -596,16 +605,13 @@ static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
unsigned long val, void *data) unsigned long val, void *data)
{ {
struct da8xx_fb_par *par; struct da8xx_fb_par *par;
unsigned int reg;
par = container_of(nb, struct da8xx_fb_par, freq_transition); par = container_of(nb, struct da8xx_fb_par, freq_transition);
if (val == CPUFREQ_PRECHANGE) { if (val == CPUFREQ_PRECHANGE) {
reg = lcdc_read(LCD_RASTER_CTRL_REG); lcd_disable_raster();
lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
} else if (val == CPUFREQ_POSTCHANGE) { } else if (val == CPUFREQ_POSTCHANGE) {
lcd_calc_clk_divider(par); lcd_calc_clk_divider(par);
reg = lcdc_read(LCD_RASTER_CTRL_REG); lcd_enable_raster();
lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
} }
return 0; return 0;
...@@ -636,8 +642,10 @@ static int __devexit fb_remove(struct platform_device *dev) ...@@ -636,8 +642,10 @@ static int __devexit fb_remove(struct platform_device *dev)
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
lcd_da8xx_cpufreq_deregister(par); lcd_da8xx_cpufreq_deregister(par);
#endif #endif
if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE) if (par->panel_power_ctrl)
lcd_disable_raster(par); par->panel_power_ctrl(0);
lcd_disable_raster();
lcdc_write(0, LCD_RASTER_CTRL_REG); lcdc_write(0, LCD_RASTER_CTRL_REG);
/* disable DMA */ /* disable DMA */
...@@ -778,6 +786,10 @@ static int __init fb_probe(struct platform_device *device) ...@@ -778,6 +786,10 @@ 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->lcdc_clk = fb_clk;
par->pxl_clk = lcdc_info->pxl_clk; par->pxl_clk = lcdc_info->pxl_clk;
if (fb_pdata->panel_power_ctrl) {
par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
par->panel_power_ctrl(1);
}
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");
...@@ -878,8 +890,7 @@ static int __init fb_probe(struct platform_device *device) ...@@ -878,8 +890,7 @@ static int __init fb_probe(struct platform_device *device)
#endif #endif
/* enable raster engine */ /* enable raster engine */
lcdc_write(lcdc_read(LCD_RASTER_CTRL_REG) | lcd_enable_raster();
LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
return 0; return 0;
......
...@@ -38,6 +38,7 @@ struct da8xx_lcdc_platform_data { ...@@ -38,6 +38,7 @@ struct da8xx_lcdc_platform_data {
const char manu_name[10]; const char manu_name[10];
void *controller_data; void *controller_data;
const char type[25]; const char type[25];
void (*panel_power_ctrl)(int);
}; };
struct lcd_ctrl_config { struct lcd_ctrl_config {
......
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