From 09e647d30d0d8feff0aee77bd17342fbc79a3bf8 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 11 Dec 2008 14:06:43 +0800 Subject: [ARM] pxafb: remove now unused pxafb_setup_gpio() and related stuffs platform should now initialize the pin usage for the LCD controller to correctly work. Signed-off-by: Eric Miao --- drivers/video/pxafb.c | 54 --------------------------------------------------- 1 file changed, 54 deletions(-) (limited to 'drivers/video/pxafb.c') diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index d6aa07b978ed..ab60537314fb 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -986,57 +985,6 @@ static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on) fbi->lcd_power(on, &fbi->fb.var); } -static void pxafb_setup_gpio(struct pxafb_info *fbi) -{ - int gpio, ldd_bits; - unsigned int lccr0 = fbi->lccr0; - - /* - * setup is based on type of panel supported - */ - - /* 4 bit interface */ - if ((lccr0 & LCCR0_CMS) == LCCR0_Mono && - (lccr0 & LCCR0_SDS) == LCCR0_Sngl && - (lccr0 & LCCR0_DPD) == LCCR0_4PixMono) - ldd_bits = 4; - - /* 8 bit interface */ - else if (((lccr0 & LCCR0_CMS) == LCCR0_Mono && - ((lccr0 & LCCR0_SDS) == LCCR0_Dual || - (lccr0 & LCCR0_DPD) == LCCR0_8PixMono)) || - ((lccr0 & LCCR0_CMS) == LCCR0_Color && - (lccr0 & LCCR0_PAS) == LCCR0_Pas && - (lccr0 & LCCR0_SDS) == LCCR0_Sngl)) - ldd_bits = 8; - - /* 16 bit interface */ - else if ((lccr0 & LCCR0_CMS) == LCCR0_Color && - ((lccr0 & LCCR0_SDS) == LCCR0_Dual || - (lccr0 & LCCR0_PAS) == LCCR0_Act)) - ldd_bits = 16; - - else { - printk(KERN_ERR "pxafb_setup_gpio: unable to determine " - "bits per pixel\n"); - return; - } - - for (gpio = 58; ldd_bits; gpio++, ldd_bits--) - pxa_gpio_mode(gpio | GPIO_ALT_FN_2_OUT); - /* 18 bit interface */ - if (fbi->fb.var.bits_per_pixel > 16) { - pxa_gpio_mode(86 | GPIO_ALT_FN_2_OUT); - pxa_gpio_mode(87 | GPIO_ALT_FN_2_OUT); - } - pxa_gpio_mode(GPIO74_LCD_FCLK_MD); - pxa_gpio_mode(GPIO75_LCD_LCLK_MD); - pxa_gpio_mode(GPIO76_LCD_PCLK_MD); - - if ((lccr0 & LCCR0_PAS) == 0) - pxa_gpio_mode(GPIO77_LCD_ACBIAS_MD); -} - static void pxafb_enable_controller(struct pxafb_info *fbi) { pr_debug("pxafb: Enabling LCD controller\n"); @@ -1179,7 +1127,6 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state) if (old_state == C_ENABLE) { __pxafb_lcd_power(fbi, 0); pxafb_disable_controller(fbi); - pxafb_setup_gpio(fbi); pxafb_enable_controller(fbi); __pxafb_lcd_power(fbi, 1); } @@ -1202,7 +1149,6 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state) */ if (old_state != C_ENABLE) { fbi->state = C_ENABLE; - pxafb_setup_gpio(fbi); pxafb_enable_controller(fbi); __pxafb_lcd_power(fbi, 1); __pxafb_backlight_power(fbi, 1); -- cgit v1.2.3 From 07df1c4fea1474ae6db2c8554d2915cf5cf81369 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Thu, 4 Dec 2008 11:14:11 +0800 Subject: [ARM] pxafb: small cleanup of the smart panel code Group smart panel related code in a more compact fasion, avoid abused usage of #ifdef .. #endif. Also fix the incorrect condition in pxafb_smart_init() to decide if it is a smart panel or not. (should be '&' instead of '|') Signed-off-by: Eric Miao --- drivers/video/pxafb.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'drivers/video/pxafb.c') diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index ab60537314fb..62d2dd0c1fa1 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -800,14 +800,19 @@ static int pxafb_smart_thread(void *arg) static int pxafb_smart_init(struct pxafb_info *fbi) { - if (!(fbi->lccr0 | LCCR0_LCDT)) + if (!(fbi->lccr0 & LCCR0_LCDT)) return 0; + fbi->smart_cmds = (uint16_t *) fbi->dma_buff->cmd_buff; + fbi->n_smart_cmds = 0; + + init_completion(&fbi->command_done); + init_completion(&fbi->refresh_done); + fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi, "lcd_refresh"); if (IS_ERR(fbi->smart_thread)) { - printk(KERN_ERR "%s: unable to create kernel thread\n", - __func__); + pr_err("%s: unable to create kernel thread\n", __func__); return PTR_ERR(fbi->smart_thread); } @@ -823,7 +828,9 @@ int pxafb_smart_flush(struct fb_info *info) { return 0; } -#endif /* CONFIG_FB_SMART_PANEL */ + +static inline int pxafb_smart_init(struct pxafb_info *fbi) { return 0; } +#endif /* CONFIG_FB_PXA_SMARTPANEL */ static void setup_parallel_timing(struct pxafb_info *fbi, struct fb_var_screeninfo *var) @@ -1286,11 +1293,6 @@ static int __devinit pxafb_map_video_memory(struct pxafb_info *fbi) fbi->palette_cpu = (u16 *) fbi->dma_buff->palette; pr_debug("pxafb: palette_mem_size = 0x%08x\n", fbi->palette_size*sizeof(u16)); - -#ifdef CONFIG_FB_PXA_SMARTPANEL - fbi->smart_cmds = (uint16_t *) fbi->dma_buff->cmd_buff; - fbi->n_smart_cmds = 0; -#endif } return fbi->map_cpu ? 0 : -ENOMEM; @@ -1412,10 +1414,6 @@ static struct pxafb_info * __devinit pxafb_init_fbinfo(struct device *dev) INIT_WORK(&fbi->task, pxafb_task); mutex_init(&fbi->ctrlr_lock); init_completion(&fbi->disable_done); -#ifdef CONFIG_FB_PXA_SMARTPANEL - init_completion(&fbi->command_done); - init_completion(&fbi->refresh_done); -#endif return fbi; } @@ -1747,13 +1745,12 @@ static int __devinit pxafb_probe(struct platform_device *dev) goto failed_free_mem; } -#ifdef CONFIG_FB_PXA_SMARTPANEL ret = pxafb_smart_init(fbi); if (ret) { dev_err(&dev->dev, "failed to initialize smartpanel\n"); goto failed_free_irq; } -#endif + /* * This makes sure that our colour bitfield * descriptors are correctly initialised. -- cgit v1.2.3 From c1f99c215c58111629984a49ba87b2b145dd1f5b Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Mon, 8 Dec 2008 18:35:03 +0800 Subject: [ARM] pxafb: allow better platform configurable smart panel timing For smart panels (LCD panel with internal framebuffer), the following LCCR3 register bits have different meanings than the parallel one: LCCR3_PCP - controls the L_PCLK_WR polarity LCCR3_HSP - controls the L_LCLK_A0 polarity LCCR3_VSP - controls the L_FCLK_RD polarity To keep minimum change to the original parallel timing, the .lcd_conn flags and 'pxafb_mode_info.sync' are re-used to reflect this: LCD_PCLK_EDGE_{RISE,FALL} - configures LCCR3_PCP sync & FB_SYNC_{HOR,VERT}_HIGH_ACT - configures LCCR3_{HSP,VSP} Signed-off-by: Eric Miao --- arch/arm/mach-pxa/include/mach/pxafb.h | 4 ++++ drivers/video/pxafb.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/video/pxafb.c') diff --git a/arch/arm/mach-pxa/include/mach/pxafb.h b/arch/arm/mach-pxa/include/mach/pxafb.h index cb44410cd456..4201a889ff4e 100644 --- a/arch/arm/mach-pxa/include/mach/pxafb.h +++ b/arch/arm/mach-pxa/include/mach/pxafb.h @@ -95,6 +95,10 @@ struct pxafb_mode_info { * in pxa27x and pxa3xx, initialize them to the same value or * the larger one will be used * 3. same to {rd,wr}_pulse_width + * + * 4. LCD_PCLK_EDGE_{RISE,FALL} controls the L_PCLK_WR polarity + * 5. sync & FB_SYNC_HOR_HIGH_ACT controls the L_LCLK_A0 + * 6. sync & FB_SYNC_VERT_HIGH_ACT controls the L_LCLK_RD */ unsigned a0csrd_set_hld; /* A0 and CS Setup/Hold Time before/after L_FCLK_RD */ unsigned a0cswr_set_hld; /* A0 and CS Setup/Hold Time before/after L_PCLK_WR */ diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 62d2dd0c1fa1..d6de84b42036 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -760,7 +760,9 @@ static void setup_smart_timing(struct pxafb_info *fbi, LCCR1_HorSnchWdth(__smart_timing(t3, lclk)); fbi->reg_lccr2 = LCCR2_DisHght(var->yres); - fbi->reg_lccr3 = LCCR3_PixClkDiv(__smart_timing(t4, lclk)); + fbi->reg_lccr3 = fbi->lccr3 | LCCR3_PixClkDiv(__smart_timing(t4, lclk)); + fbi->reg_lccr3 |= (var->sync & FB_SYNC_HOR_HIGH_ACT) ? LCCR3_HSP : 0; + fbi->reg_lccr3 |= (var->sync & FB_SYNC_VERT_HIGH_ACT) ? LCCR3_VSP : 0; /* FIXME: make this configurable */ fbi->reg_cmdcr = 1; -- cgit v1.2.3 From 69bdea7047fbac88beb8b7ba9e428c4f0e53f563 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Mon, 8 Dec 2008 18:46:00 +0800 Subject: [ARM] pxafb: allow insertion of delay to the smart panel command sequence Some smart panel requires a delay between command sequences, while PXA LCD controller didn't provide such one, let's emulate this by software. A software delay marker can be inserted into the command sequence, once pxafb_smart_queue() detects this, it flushes the previous commands and delay for a specified number of milliseconds. Signed-off-by: Eric Miao --- arch/arm/mach-pxa/include/mach/regs-lcd.h | 7 +++++++ drivers/video/pxafb.c | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'drivers/video/pxafb.c') diff --git a/arch/arm/mach-pxa/include/mach/regs-lcd.h b/arch/arm/mach-pxa/include/mach/regs-lcd.h index c689c4ea769c..f817878d256b 100644 --- a/arch/arm/mach-pxa/include/mach/regs-lcd.h +++ b/arch/arm/mach-pxa/include/mach/regs-lcd.h @@ -177,4 +177,11 @@ #define SMART_CMD(x) (SMART_CMD_WRITE_COMMAND | ((x) & 0xff)) #define SMART_DAT(x) (SMART_CMD_WRITE_DATA | ((x) & 0xff)) + +/* SMART_DELAY() is introduced for software controlled delay primitive which + * can be inserted between command sequences, unused command 0x6 is used here + * and delay ranges from 0ms ~ 255ms + */ +#define SMART_CMD_DELAY (0x6 << 9) +#define SMART_DELAY(ms) (SMART_CMD_DELAY | ((ms) & 0xff)) #endif /* __ASM_ARCH_REGS_LCD_H */ diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index d6de84b42036..1e1c4ec0d3b9 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -723,12 +723,19 @@ int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int n_cmds) int i; struct pxafb_info *fbi = container_of(info, struct pxafb_info, fb); - /* leave 2 commands for INTERRUPT and WAIT_FOR_SYNC */ - for (i = 0; i < n_cmds; i++) { + for (i = 0; i < n_cmds; i++, cmds++) { + /* if it is a software delay, flush and delay */ + if ((*cmds & 0xff00) == SMART_CMD_DELAY) { + pxafb_smart_flush(info); + mdelay(*cmds & 0xff); + continue; + } + + /* leave 2 commands for INTERRUPT and WAIT_FOR_SYNC */ if (fbi->n_smart_cmds == CMD_BUFF_SIZE - 8) pxafb_smart_flush(info); - fbi->smart_cmds[fbi->n_smart_cmds++] = *cmds++; + fbi->smart_cmds[fbi->n_smart_cmds++] = *cmds; } return 0; -- cgit v1.2.3 From 07f651c72ac0530033883c113939d9b9c7fa75e5 Mon Sep 17 00:00:00 2001 From: Eric Miao Date: Mon, 8 Dec 2008 18:51:01 +0800 Subject: [ARM] pxafb: avoid the racing condition in pxafb_smart_thread fbi->state change shall really be protected by fbi->ctrlr_lock, where the change is sheltered. There is a possibility that pxafb_smart_thread will start update the LCD panel when fbi->state == C_ENABLE, while all other initialization isn't done. Signed-off-by: Eric Miao --- drivers/video/pxafb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/video/pxafb.c') diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index 1e1c4ec0d3b9..ab689597f259 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c @@ -794,11 +794,15 @@ static int pxafb_smart_thread(void *arg) if (try_to_freeze()) continue; + mutex_lock(&fbi->ctrlr_lock); + if (fbi->state == C_ENABLE) { inf->smart_update(&fbi->fb); complete(&fbi->refresh_done); } + mutex_unlock(&fbi->ctrlr_lock); + set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(30 * HZ / 1000); } -- cgit v1.2.3