From 0a1182796f6475b8cb2ff1781dad873a744b3197 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Sat, 21 Jul 2012 23:04:45 +0200 Subject: samsung opensource update3 --- drivers/video/samsung/Kconfig | 32 +- drivers/video/samsung/lcdfreq.c | 31 +- drivers/video/samsung/mdnie.c | 90 +++- drivers/video/samsung/mdnie.h | 13 +- drivers/video/samsung/s3cfb.h | 18 +- drivers/video/samsung/s3cfb_fimd6x.c | 87 +++- drivers/video/samsung/s3cfb_ielcd.c | 34 +- drivers/video/samsung/s3cfb_ielcd.h | 4 +- drivers/video/samsung/s3cfb_main.c | 98 ++--- drivers/video/samsung/s3cfb_mdnie.c | 16 +- drivers/video/samsung/s3cfb_mdnie.h | 4 +- drivers/video/samsung/s3cfb_ops.c | 37 +- drivers/video/samsung/s3cfb_s6e39a0.c | 52 +-- drivers/video/samsung/s3cfb_s6e8aa0.c | 107 ++--- drivers/video/samsung/s3cfb_s6e8ab0.c | 50 +-- drivers/video/samsung/s5p-dsim.c | 753 +++++++++++++++++----------------- drivers/video/samsung/s5p-dsim.h | 44 +- drivers/video/samsung/s6d6aa1.c | 70 ++-- drivers/video/samsung/s6dr171.c | 49 +-- drivers/video/samsung/s6e8aa0_param.h | 4 +- drivers/video/samsung/smart_dimming.c | 2 +- 21 files changed, 837 insertions(+), 758 deletions(-) (limited to 'drivers/video/samsung') diff --git a/drivers/video/samsung/Kconfig b/drivers/video/samsung/Kconfig index 10d7474..3cb946f 100644 --- a/drivers/video/samsung/Kconfig +++ b/drivers/video/samsung/Kconfig @@ -154,7 +154,7 @@ config FB_S5P_S6F1202A config FB_S5P_LD9040 bool "LD9040" - depends on MACH_U1 || MACH_MIDAS + depends on MACH_U1 || MACH_MIDAS || MACH_TRATS select LCD_CLASS_DEVICE select SPI select SPI_GPIO @@ -164,7 +164,7 @@ config FB_S5P_LD9040 config FB_S5P_NT35560 bool "Sony NT35560" - depends on MACH_U1 && !FB_S5P_MIPI_DSIM + depends on (MACH_U1 || MACH_TRATS) && !FB_S5P_MIPI_DSIM select LCD_CLASS_DEVICE select SPI select SPI_GPIO @@ -188,13 +188,13 @@ config FB_S5P_DUMMY_MIPI_LCD config FB_S5P_S6E8AA0 bool "S6E8AA0 MIPI LCD" - depends on (MACH_U1 || MACH_MIDAS) && FB_S5P_MIPI_DSIM + depends on FB_S5P_MIPI_DSIM ---help--- This enables support for Samsung S6E8AA0 MIPI LCD config FB_S5P_S6E8AB0 bool "S6E8AB0 MIPI LCD" - depends on MACH_P8 && FB_S5P_MIPI_DSIM + depends on MACH_PX && FB_S5P_MIPI_DSIM ---help--- This enables support for Samsung S6E8AB0 MIPI LCD @@ -203,6 +203,30 @@ config FB_S5P_S6D6AA1 depends on FB_S5P_MIPI_DSIM ---help--- This enables support for Samsung S6D6AA1 MIPI LCD + +config FB_S5P_S6E63M0 + bool "S6E63M0 MIPI LCD" + depends on (MACH_MIDAS) && FB_S5P_MIPI_DSIM + ---help--- + This enables support for Samsung S6E63M0 MIPI LCD + +endchoice + +choice + prompt "Select PANEL Type" + depends on FB_S5P_S6E8AA0 + default S6E8AA0_AMS480GYXX + +config S6E8AA0_AMS529HA01 + bool "AMS529HA01(Q1)" + ---help--- + This enables support for Samsung S6E8AA0 AMS529HA01(Q1) PANEL + +config S6E8AA0_AMS480GYXX + bool "AMS480GYXX(M0)" + ---help--- + This enables support for Samsung S6E8AA0 AMS480GYXX(M0) PANEL + endchoice config AID_DIMMING diff --git a/drivers/video/samsung/lcdfreq.c b/drivers/video/samsung/lcdfreq.c index 6895bf8..8c25c22 100644 --- a/drivers/video/samsung/lcdfreq.c +++ b/drivers/video/samsung/lcdfreq.c @@ -50,12 +50,7 @@ struct lcdfreq_info { struct notifier_block pm_noti; struct notifier_block reboot_noti; - unsigned long time_stamp[LCDFREQ_LEVEL_END]; - unsigned long previous_time; - unsigned long current_time; - struct delayed_work work; - u32 count; struct early_suspend early_suspend; }; @@ -108,7 +103,7 @@ int set_div(struct s3cfb_global *ctrl, u32 div) } while (count); /* } while (time_before(jiffies, timeout)); */ - dev_err(ctrl->dev, "%s fail\n", __func__); + dev_err(ctrl->dev, "%s fail, div=%d\n", __func__, div); return -EINVAL; } @@ -121,11 +116,12 @@ static int set_lcdfreq_div(struct device *dev, enum lcdfreq_level_idx level) struct lcdfreq_info *lcdfreq = fbdev->data; - u32 div = 0, ret = 0; + u32 div, ret; mutex_lock(&lcdfreq->lock); if (unlikely(fbdev->system_state == POWER_OFF || !lcdfreq->enable)) { + dev_err(dev, "%s reject. %d, %d\n", __func__, fbdev->system_state, lcdfreq->enable); ret = -EINVAL; goto exit; } @@ -135,7 +131,7 @@ static int set_lcdfreq_div(struct device *dev, enum lcdfreq_level_idx level) ret = set_div(fbdev, div); if (ret) { - dev_info(dev, "fail to change lcd freq\n"); + dev_err(dev, "fail to change lcd freq\n"); goto exit; } @@ -193,7 +189,6 @@ static int lcdfreq_lock_free(struct device *dev) mutex_lock(&lcdfreq->lock); atomic_dec(&lcdfreq->usage); mutex_unlock(&lcdfreq->lock); - lcdfreq->count = 0; cancel_delayed_work(&lcdfreq->work); } @@ -229,7 +224,7 @@ int get_divider(struct fb_info *fb) for (i = 0; i < LCDFREQ_LEVEL_END; i++) { lcdfreq->table[i].cmu_clkdiv--; - dev_info(fb->dev, "%dHz divider is %d\n", + dev_info(fb->dev, "%dHZ divider is %d\n", lcdfreq->table[i].hz, lcdfreq->table[i].cmu_clkdiv); } @@ -256,6 +251,11 @@ static ssize_t level_show(struct device *dev, struct s3cfb_global *fbdev = get_fimd_global(win->id); struct lcdfreq_info *lcdfreq = fbdev->data; + if (unlikely(fbdev->system_state == POWER_OFF || !lcdfreq->enable)) { + dev_err(dev, "%s reject. %d, %d\n", __func__, fbdev->system_state, lcdfreq->enable); + return -EINVAL; + } + return sprintf(buf, "%dHZ, div=%d\n", lcdfreq->table[lcdfreq->level].hz, get_div(fbdev)); } @@ -298,12 +298,10 @@ static ssize_t usage_show(struct device *dev, static DEVICE_ATTR(level, S_IRUGO|S_IWUSR, level_show, level_store); static DEVICE_ATTR(usage, S_IRUGO, usage_show, NULL); -static DEVICE_ATTR(time_stamp, S_IRUGO, NULL, NULL); static struct attribute *lcdfreq_attributes[] = { &dev_attr_level.attr, &dev_attr_usage.attr, - &dev_attr_time_stamp.attr, NULL, }; @@ -390,17 +388,13 @@ static void lcdfreq_status_work(struct work_struct *work) struct lcdfreq_info *lcdfreq = container_of(work, struct lcdfreq_info, work.work); - u32 hz = lcdfreq->table[lcdfreq->level].hz; cancel_delayed_work(&lcdfreq->work); - if (!(lcdfreq->count % 2)) - dev_info(lcdfreq->dev, "\thz=%d, usage=%d\n", hz, atomic_read(&lcdfreq->usage)); - - schedule_delayed_work(&lcdfreq->work, HZ*60); + dev_info(lcdfreq->dev, "\tHZ=%d, usage=%d\n", hz, atomic_read(&lcdfreq->usage)); - lcdfreq->count++; + schedule_delayed_work(&lcdfreq->work, HZ*120); } int lcdfreq_init(struct fb_info *fb) @@ -425,7 +419,6 @@ int lcdfreq_init(struct fb_info *fb) lcdfreq->dev = fb->dev; lcdfreq->level = LEVEL_NORMAL; - lcdfreq->previous_time = lcdfreq->current_time = jiffies; vclk = (lcd->freq * (var->left_margin + var->right_margin diff --git a/drivers/video/samsung/mdnie.c b/drivers/video/samsung/mdnie.c index bb672bd..d45d3e9 100644 --- a/drivers/video/samsung/mdnie.c +++ b/drivers/video/samsung/mdnie.c @@ -48,6 +48,8 @@ #else /* CONFIG_CPU_EXYNOS4210 */ #if defined(CONFIG_FB_S5P_S6E8AA0) #include "mdnie_table_c1m0.h" +#elif defined(CONFIG_FB_S5P_S6E63M0) +#include "mdnie_table_c1m0.h" #elif defined(CONFIG_FB_S5P_S6C1372) #include "mdnie_table_p4note.h" #elif defined(CONFIG_FB_S5P_S6D6AA1) @@ -72,7 +74,7 @@ #define DIM_BACKLIGHT_VALUE 16 #define CABC_CUTOFF_BACKLIGHT_VALUE 40 /* 2.5% */ #elif defined(CONFIG_FB_S5P_S6C1372) -#define MAX_BACKLIGHT_VALUE 1329 +#define MAX_BACKLIGHT_VALUE 1441 //90% #define MID_BACKLIGHT_VALUE 784 #define LOW_BACKLIGHT_VALUE 16 #define DIM_BACKLIGHT_VALUE 16 @@ -104,15 +106,16 @@ struct class *mdnie_class; struct mdnie_info *g_mdnie; +#ifdef CONFIG_MACH_P4NOTE +static struct mdnie_backlight_value b_value; +#endif + int mdnie_send_sequence(struct mdnie_info *mdnie, const unsigned short *seq) { int ret = 0, i = 0; const unsigned short *wbuf; - if (!mdnie->enable) { - dev_err(mdnie->dev, "do not configure mDNIe after LCD/mDNIe power off\n"); - return -EPERM; - } else if (IS_ERR_OR_NULL(seq)) { + if (IS_ERR_OR_NULL(seq)) { dev_err(mdnie->dev, "mdnie sequence is null\n"); return -EPERM; } @@ -135,12 +138,12 @@ int mdnie_send_sequence(struct mdnie_info *mdnie, const unsigned short *seq) return ret; } -void set_mdnie_value(struct mdnie_info *mdnie) +void set_mdnie_value(struct mdnie_info *mdnie, u8 force) { u8 idx; - if (!mdnie->enable) { - dev_err(mdnie->dev, "do not configure mDNIe after LCD/mDNIe power off\n"); + if ((!mdnie->enable) && (!force)) { + dev_err(mdnie->dev, "mdnie states is off\n"); return; } @@ -152,7 +155,7 @@ void set_mdnie_value(struct mdnie_info *mdnie) mdnie->tone = TONE_NORMAL; if (mdnie->tunning) { - dev_info(mdnie->dev, "mDNIe tunning mode is enabled\n"); + dev_info(mdnie->dev, "mdnie tunning mode is enabled\n"); return; } @@ -200,7 +203,9 @@ void set_mdnie_value(struct mdnie_info *mdnie) tunning_table[mdnie->cabc][mdnie->mode][mdnie->scenario].name); } +#if defined(CONFIG_TDMB) || defined(CONFIG_TARGET_LOCALE_NTT) etc: +#endif if (!IS_ERR_OR_NULL(etc_table[mdnie->cabc][mdnie->outdoor][mdnie->tone].seq)) { mdnie_send_sequence(mdnie, etc_table[mdnie->cabc][mdnie->outdoor][mdnie->tone].seq); dev_info(mdnie->dev, "%s\n", etc_table[mdnie->cabc][mdnie->outdoor][mdnie->tone].name); @@ -213,6 +218,34 @@ exit: } #if defined(CONFIG_FB_MDNIE_PWM) +#ifdef CONFIG_MACH_P4NOTE +static int get_backlight_level_from_brightness(unsigned int brightness) +{ + unsigned int value; + + /* brightness tuning*/ + if (brightness >= MID_BRIGHTNESS_LEVEL) + value = (brightness - MID_BRIGHTNESS_LEVEL) * (b_value.max-b_value.mid) / (MAX_BRIGHTNESS_LEVEL-MID_BRIGHTNESS_LEVEL) + b_value.mid; + else if (brightness >= LOW_BRIGHTNESS_LEVEL) + value = (brightness - LOW_BRIGHTNESS_LEVEL) * (b_value.mid-b_value.low) / (MID_BRIGHTNESS_LEVEL-LOW_BRIGHTNESS_LEVEL) + b_value.low; + else if (brightness >= DIM_BRIGHTNESS_LEVEL) + value = (brightness - DIM_BRIGHTNESS_LEVEL) * (b_value.low-b_value.dim) / (LOW_BRIGHTNESS_LEVEL-DIM_BRIGHTNESS_LEVEL) + b_value.dim; + else if (brightness > 0) + value = b_value.dim; + else + return 0; + + if (value > 1600) + value = 1600; + + if (value < 16) + value = 1; + else + value = value >> 4; + + return value; +} +#else static int get_backlight_level_from_brightness(unsigned int brightness) { unsigned int value; @@ -227,7 +260,7 @@ static int get_backlight_level_from_brightness(unsigned int brightness) else if (brightness > 0) value = DIM_BACKLIGHT_VALUE; else - value = brightness; + return 0; if (value > 1600) value = 1600; @@ -239,6 +272,7 @@ static int get_backlight_level_from_brightness(unsigned int brightness) return value; } +#endif #if defined(CONFIG_CPU_EXYNOS4210) static void mdnie_pwm_control(struct mdnie_info *mdnie, int value) @@ -283,8 +317,7 @@ static void mdnie_pwm_control_cabc(struct mdnie_info *mdnie, int value) mutex_unlock(&mdnie->dev_lock); } -#endif -#if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) +#elif defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) static void mdnie_pwm_control(struct mdnie_info *mdnie, int value) { mutex_lock(&mdnie->dev_lock); @@ -329,6 +362,11 @@ static void mdnie_pwm_control_cabc(struct mdnie_info *mdnie, int value) } #endif +void set_mdnie_pwm_value(struct mdnie_info *mdnie, int value) +{ + mdnie_pwm_control(mdnie, value); +} + static int update_brightness(struct mdnie_info *mdnie) { unsigned int value; @@ -413,7 +451,7 @@ static ssize_t mode_store(struct device *dev, mdnie->mode = value; mutex_unlock(&mdnie->lock); - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); #if defined(CONFIG_FB_MDNIE_PWM) if ((mdnie->enable) && (mdnie->bd_enable)) update_brightness(mdnie); @@ -454,7 +492,7 @@ static ssize_t scenario_store(struct device *dev, mdnie->scenario = value; mutex_unlock(&mdnie->lock); - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); #if defined(CONFIG_FB_MDNIE_PWM) if ((mdnie->enable) && (mdnie->bd_enable)) update_brightness(mdnie); @@ -492,7 +530,7 @@ static ssize_t outdoor_store(struct device *dev, mdnie->outdoor = value; mutex_unlock(&mdnie->lock); - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); return count; } @@ -527,7 +565,7 @@ static ssize_t cabc_store(struct device *dev, mdnie->cabc = value; mutex_unlock(&mdnie->lock); - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); if ((mdnie->enable) && (mdnie->bd_enable)) update_brightness(mdnie); @@ -609,7 +647,7 @@ static ssize_t negative_store(struct device *dev, mdnie->negative = value; mutex_unlock(&mdnie->lock); - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); } return count; } @@ -756,6 +794,22 @@ static int mdnie_probe(struct platform_device *pdev) #endif #endif +#if defined(CONFIG_FB_S5P_S6C1372) + check_lcd_type(); + dev_info(mdnie->dev, "lcdtype = %d\n", pdata->display_type); + if (pdata->display_type == 1) { + b_value.max = 1441; + b_value.mid = 784; + b_value.low = 16; + b_value.dim = 16; + } else { + b_value.max = 1137; /* 71% */ + b_value.mid = 482; /* 38% */ + b_value.low = 16; /* 1% */ + b_value.dim = 16; /* 1% */ + } +#endif + #if defined(CONFIG_FB_S5P_S6F1202A) if (pdata->display_type == 0) { memcpy(tunning_table, tunning_table_hy, sizeof(tunning_table)); @@ -777,7 +831,7 @@ static int mdnie_probe(struct platform_device *pdev) g_mdnie = mdnie; - set_mdnie_value(mdnie); + set_mdnie_value(mdnie, 0); dev_info(mdnie->dev, "registered successfully\n"); diff --git a/drivers/video/samsung/mdnie.h b/drivers/video/samsung/mdnie.h index f5098aa..4c37418 100644 --- a/drivers/video/samsung/mdnie.h +++ b/drivers/video/samsung/mdnie.h @@ -111,7 +111,18 @@ struct mdnie_info { extern struct mdnie_info *g_mdnie; int mdnie_send_sequence(struct mdnie_info *mdnie, const unsigned short *seq); -extern void set_mdnie_value(struct mdnie_info *mdnie); +extern void set_mdnie_value(struct mdnie_info *mdnie, u8 force); +#if defined(CONFIG_FB_MDNIE_PWM) +extern void set_mdnie_pwm_value(struct mdnie_info *mdnie, int value); +#endif extern int mdnie_txtbuf_to_parsing(char const *pFilepath); +extern void check_lcd_type(void); +struct mdnie_backlight_value { + unsigned int max; + unsigned int mid; + unsigned char low; + unsigned char dim; +}; + #endif /* __MDNIE_H__ */ diff --git a/drivers/video/samsung/s3cfb.h b/drivers/video/samsung/s3cfb.h index 8f38995..fc4e10d 100644 --- a/drivers/video/samsung/s3cfb.h +++ b/drivers/video/samsung/s3cfb.h @@ -167,6 +167,7 @@ struct s3cfb_global { void __iomem *ielcd_regs; void *data; struct mutex lock; + spinlock_t slock; struct device *dev; #ifdef CONFIG_BUSFREQ_OPP struct device *bus_dev; @@ -327,6 +328,7 @@ extern int s3cfb_set_window_control(struct s3cfb_global *ctrl, int id); extern int s3cfb_set_alpha_mode(struct s3cfb_global *ctrl, int id, unsigned int mode); extern int s3cfb_set_alpha_value_width(struct s3cfb_global *ctrl, int id); extern int s3cfb_set_alpha_blending(struct s3cfb_global *ctrl, int id); +extern int s3cfb_set_oneshot(struct s3cfb_global *ctrl, int value); extern int s3cfb_set_alpha_value(struct s3cfb_global *ctrl, int value); extern int s3cfb_set_window_position(struct s3cfb_global *ctrl, int id); extern int s3cfb_set_window_size(struct s3cfb_global *ctrl, int id); @@ -336,12 +338,11 @@ extern int s3cfb_set_buffer_size(struct s3cfb_global *ctrl, int id); extern int s3cfb_set_chroma_key(struct s3cfb_global *ctrl, int id); extern int s3cfb_channel_localpath_on(struct s3cfb_global *ctrl, int id); extern int s3cfb_channel_localpath_off(struct s3cfb_global *ctrl, int id); -#ifdef CONFIG_FB_S5P_MIPI_DSIM -extern void s3cfb_set_trigger(struct s3cfb_global *ctrl); -extern void s3cfb_trigger(void); -#endif extern int s3cfb_check_vsync_status(struct s3cfb_global *ctrl); +extern int s3cfb_set_dualrgb(struct s3cfb_global *ctrl, int mode); +#ifdef CONFIG_FB_S5P_MIPI_DSIM extern int s3cfb_vsync_status_check(void); +#endif #ifdef CONFIG_HAS_WAKELOCK #ifdef CONFIG_HAS_EARLYSUSPEND @@ -356,11 +357,16 @@ extern void s3cfb_set_lcd_info(struct s3cfb_global *ctrl); #ifdef CONFIG_FB_S5P_MIPI_DSIM extern void s5p_dsim_early_suspend(void); extern void s5p_dsim_late_resume(void); +#ifdef CONFIG_FB_S5P_S6E63M0 +extern void s6e63m0_early_suspend(void); +extern void s6e63m0_late_resume(void); +#else extern void s6e8ax0_early_suspend(void); extern void s6e8ax0_late_resume(void); +#endif extern int s5p_dsim_fifo_clear(void); extern void set_dsim_hs_clk_toggle_count(u8 count); -extern void set_dsim_lcd_enabled(void); +extern void set_dsim_lcd_enabled(u8 enable); extern u32 read_dsim_register(u32 num); #endif @@ -374,7 +380,7 @@ extern void ams369fg06_gpio_cfg(void); extern void lms501kf03_ldi_disable(void); #endif -#if defined(CONFIG_FB_S5P_S6C1372) +#if defined(CONFIG_FB_S5P_S6C1372) || defined(CONFIG_FB_S5P_S6F1202A) extern void s5c1372_ldi_enable(void); extern void s5c1372_ldi_disable(void); #endif diff --git a/drivers/video/samsung/s3cfb_fimd6x.c b/drivers/video/samsung/s3cfb_fimd6x.c index 3813852..71a24ae 100644 --- a/drivers/video/samsung/s3cfb_fimd6x.c +++ b/drivers/video/samsung/s3cfb_fimd6x.c @@ -41,7 +41,14 @@ void s3cfb_check_line_count(struct s3cfb_global *ctrl) int s3cfb_check_vsync_status(struct s3cfb_global *ctrl) { - u32 cfg = (readl(ctrl->regs + S3C_VIDCON1) & S3C_VIDCON1_VSTATUS_MASK); + u32 cfg; + + if (unlikely(!ctrl->regs)) { + dev_err(ctrl->dev, "reg is zero\n"); + return 0; + } + + cfg = (readl(ctrl->regs + S3C_VIDCON1) & S3C_VIDCON1_VSTATUS_MASK); if (cfg != S3C_VIDCON1_VSTATUS_ACTIVE && cfg != S3C_VIDCON1_VSTATUS_BACK) return 1; @@ -794,6 +801,76 @@ int s3cfb_set_alpha_blending(struct s3cfb_global *ctrl, int id) return 0; } +int s3cfb_set_oneshot(struct s3cfb_global *ctrl, int id) +{ + struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); + struct fb_var_screeninfo *var = &ctrl->fb[id]->var; + struct fb_fix_screeninfo *fix = &ctrl->fb[id]->fix; + struct s3cfb_window *win = ctrl->fb[id]->par; + u32 cfg, shw; + u32 offset = (var->xres_virtual - var->xres) * var->bits_per_pixel / 8; + dma_addr_t start_addr = 0, end_addr = 0; + + /* Shadow Register Protection */ + if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { + shw = readl(ctrl->regs + S3C_WINSHMAP); + shw |= S3C_WINSHMAP_PROTECT(id); + writel(shw, ctrl->regs + S3C_WINSHMAP); + } + + /* s3cfb_set_window_position */ + cfg = S3C_VIDOSD_LEFT_X(win->x) | S3C_VIDOSD_TOP_Y(win->y); + writel(cfg, ctrl->regs + S3C_VIDOSD_A(id)); + + cfg = S3C_VIDOSD_RIGHT_X(win->x + var->xres - 1) | + S3C_VIDOSD_BOTTOM_Y(win->y + var->yres - 1); + writel(cfg, ctrl->regs + S3C_VIDOSD_B(id)); + + dev_dbg(ctrl->dev, "[fb%d] offset: (%d, %d, %d, %d)\n", id, + win->x, win->y, win->x + var->xres - 1, win->y + var->yres - 1); + + /* s3cfb_set_buffer_address */ + if (fix->smem_start) { + start_addr = fix->smem_start + ((var->xres_virtual * + var->yoffset + var->xoffset) * + (var->bits_per_pixel / 8)); + + end_addr = start_addr + fix->line_length * var->yres; + } + + writel(start_addr, ctrl->regs + S3C_VIDADDR_START0(id)); + writel(end_addr, ctrl->regs + S3C_VIDADDR_END0(id)); + + dev_dbg(ctrl->dev, "[fb%d] start_addr: 0x%08x, end_addr: 0x%08x\n", + id, start_addr, end_addr); + + /* s3cfb_set_window_size */ + if (id <= 2) { + cfg = S3C_VIDOSD_SIZE(var->xres * var->yres); + if (id == 0) + writel(cfg, ctrl->regs + S3C_VIDOSD_C(id)); + else + writel(cfg, ctrl->regs + S3C_VIDOSD_D(id)); + + dev_dbg(ctrl->dev, "[fb%d] resolution: %d x %d\n", id, + var->xres, var->yres); + } + + /* s3cfb_set_buffer_size */ + cfg = S3C_VIDADDR_PAGEWIDTH(var->xres * var->bits_per_pixel / 8); + cfg |= S3C_VIDADDR_OFFSIZE(offset); + writel(cfg, ctrl->regs + S3C_VIDADDR_SIZE(id)); + + /* Shadow Register Un-Protection */ + if ((pdata->hw_ver == 0x62) || (pdata->hw_ver == 0x70)) { + shw = readl(ctrl->regs + S3C_WINSHMAP); + shw &= ~(S3C_WINSHMAP_PROTECT(id)); + writel(shw, ctrl->regs + S3C_WINSHMAP); + } + + return 0; +} + int s3cfb_set_window_position(struct s3cfb_global *ctrl, int id) { struct fb_var_screeninfo *var = &ctrl->fb[id]->var; @@ -911,3 +988,11 @@ int s3cfb_set_chroma_key(struct s3cfb_global *ctrl, int id) return 0; } + +int s3cfb_set_dualrgb(struct s3cfb_global *ctrl, int mode) +{ + writel(mode, ctrl->regs + S3C_DUALRGB); + + return 0; +} + diff --git a/drivers/video/samsung/s3cfb_ielcd.c b/drivers/video/samsung/s3cfb_ielcd.c index 9550327..b86d6f5 100644 --- a/drivers/video/samsung/s3cfb_ielcd.c +++ b/drivers/video/samsung/s3cfb_ielcd.c @@ -78,7 +78,7 @@ int s3c_ielcd_logic_stop(void) return 0; } -int s3c_ielcd_start(void) +int s3c_ielcd_display_on(void) { unsigned int cfg; @@ -90,7 +90,7 @@ int s3c_ielcd_start(void) } #if 0 -int s3c_ielcd_stop(void) +int s3c_ielcd_display_off(void) { unsigned int cfg; @@ -102,13 +102,13 @@ int s3c_ielcd_stop(void) return 0; } #else -int s3c_ielcd_stop(void) +int s3c_ielcd_display_off(void) { - unsigned int cfg = 0, ielcd_count = 0; + unsigned int cfg, ielcd_count = 0; cfg = s3c_ielcd_readl(S3C_VIDCON0); cfg |= S3C_VIDCON0_ENVID_ENABLE; - cfg &= ~S3C_VIDCON0_ENVID_F_ENABLE; + cfg &= ~(S3C_VIDCON0_ENVID_F_ENABLE); s3c_ielcd_writel(cfg, S3C_VIDCON0); @@ -121,7 +121,6 @@ int s3c_ielcd_stop(void) if (!(s3c_ielcd_readl(S3C_VIDCON1) & 0xffff0000)) return 0; } while (1); - } #endif @@ -136,31 +135,26 @@ int s3c_ielcd_init_global(struct s3cfb_global *ctrl) s3cfb_set_timing(ielcd_fbdev); s3cfb_set_lcd_size(ielcd_fbdev); - s3c_ielcd_writel(0, S3C_DITHMODE); - + /* vclock divider setting , same as FIMD */ cfg = readl(ctrl->regs + S3C_VIDCON0); - cfg &= ~(S3C_VIDCON0_VIDOUT_MASK | S3C_VIDCON0_VCLKEN_MASK | S3C_VIDCON0_ENVID_F_ENABLE); + cfg &= ~(S3C_VIDCON0_VIDOUT_MASK | S3C_VIDCON0_VCLKEN_MASK); cfg |= S3C_VIDCON0_VIDOUT_RGB; -#ifdef CONFIG_FB_S5P_MIPI_DSIM cfg |= S3C_VIDCON0_VCLKEN_NORMAL; -#else - cfg |= S3C_VIDCON0_VCLKEN_FREERUN; -#endif s3c_ielcd_writel(cfg, S3C_VIDCON0); - /* s3c_ielcd_writel(1<<5, S3C_VIDINTCON0); */ /* for what? */ - - s3cfb_set_vsync_interrupt(ielcd_fbdev, 0); - s3cfb_set_global_interrupt(ielcd_fbdev, 0); - + /* window0 position setting , fixed */ s3c_ielcd_writel(0, S3C_VIDOSD0A); + + /* window0 position setting */ cfg = S3C_VIDOSD_RIGHT_X(ctrl->lcd->width - 1); cfg |= S3C_VIDOSD_BOTTOM_Y(ctrl->lcd->height - 1); s3c_ielcd_writel(cfg, S3C_VIDOSD0B); + + /* window0 osd size setting */ s3c_ielcd_writel((ctrl->lcd->width * ctrl->lcd->height), S3C_VIDOSD0C); - cfg = S3C_WINCON_DATAPATH_LOCAL | S3C_WINCON_BPPMODE_32BPP; - cfg |= S3C_WINCON_INRGB_RGB; + /* window0 setting , fixed */ + cfg = S3C_WINCON_DATAPATH_LOCAL | S3C_WINCON_BPPMODE_32BPP | S3C_WINCON_INRGB_RGB; s3c_ielcd_writel(cfg, S3C_WINCON0); s3cfb_window_on(ielcd_fbdev, 0); diff --git a/drivers/video/samsung/s3cfb_ielcd.h b/drivers/video/samsung/s3cfb_ielcd.h index 0684a7f..e5b637b 100644 --- a/drivers/video/samsung/s3cfb_ielcd.h +++ b/drivers/video/samsung/s3cfb_ielcd.h @@ -23,8 +23,8 @@ int s3c_ielcd_hw_init(void); int s3c_ielcd_logic_start(void); int s3c_ielcd_logic_stop(void); -int s3c_ielcd_start(void); -int s3c_ielcd_stop(void); +int s3c_ielcd_display_on(void); +int s3c_ielcd_display_off(void); int s3c_ielcd_init_global(struct s3cfb_global *ctrl); diff --git a/drivers/video/samsung/s3cfb_main.c b/drivers/video/samsung/s3cfb_main.c index 3abbb4c..a6e4564 100644 --- a/drivers/video/samsung/s3cfb_main.c +++ b/drivers/video/samsung/s3cfb_main.c @@ -192,6 +192,7 @@ void read_lcd_register(void) (i*16), reg_val[i*4], reg_val[i*4+1], reg_val[i*4+2], reg_val[i*4+3]); #endif } + static int s3cfb_sysfs_show_win_power(struct device *dev, struct device_attribute *attr, char *buf) { @@ -289,15 +290,15 @@ static ssize_t fimd_dump_show(struct device *dev, } static DEVICE_ATTR(fimd_dump, 0444, fimd_dump_show, NULL); -#ifdef CONFIG_FB_S5P_MIPI_DSIM +#if 0 /* def CONFIG_FB_S5P_MIPI_DSIM */ void s3cfb_display_on_remote(void) { struct s3cfb_global *fbdev = fbfimd->fbdev[0]; struct s3c_platform_fb *pdata = to_fb_plat(fbdev->dev); if (pdata == NULL) { - dev_err(fbdev->dev, "failed to get defualt window number.\n"); - return; + dev_err(fbdev->dev, "failed to get defualt window number.\n"); + return; } s3cfb_display_on(fbdev); } @@ -324,7 +325,6 @@ static int s3cfb_probe(struct platform_device *pdev) struct s3cfb_global *fbdev[2]; int ret = 0; int i = 0; - u32 reg; #ifdef CONFIG_EXYNOS_DEV_PD /* to use the runtime PM helper functions */ @@ -421,6 +421,8 @@ static int s3cfb_probe(struct platform_device *pdev) fbdev[i]->system_state = POWER_ON; + spin_lock_init(&fbdev[i]->slock); + /* alloc fb_info */ if (s3cfb_alloc_framebuffer(fbdev[i], i)) { dev_err(fbdev[i]->dev, "alloc error fimd[%d]\n", i); @@ -440,20 +442,14 @@ static int s3cfb_probe(struct platform_device *pdev) #ifdef CONFIG_FB_S5P_MDNIE /* only FIMD0 is supported */ if (i == 0) { - reg = readl(S3C_VA_SYS + 0x0210); - reg &= ~(1<<13); - reg &= ~(1<<12); - reg &= ~(3<<10); - reg |= (1<<0); - reg &= ~(1<<1); - writel(reg, S3C_VA_SYS + 0x0210); - writel(3, fbdev[i]->regs + 0x27c); + if (pdata->set_display_path) + pdata->set_display_path(); + s3cfb_set_dualrgb(fbdev[i], S3C_DUALRGB_MDNIE); s3c_mdnie_init_global(fbdev[i]); - s3c_mdnie_start(fbdev[i]); + s3c_mdnie_display_on(fbdev[i]); } #endif - s3cfb_enable_window(fbdev[0], pdata->default_win); s3cfb_update_power_state(fbdev[i], pdata->default_win, @@ -462,9 +458,7 @@ static int s3cfb_probe(struct platform_device *pdev) /* Set alpha value width to 8-bit */ s3cfb_set_alpha_value_width(fbdev[i], i); -#ifndef CONFIG_MACH_JENGA s3cfb_display_on(fbdev[i]); -#endif #if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) #ifdef CONFIG_BUSFREQ_OPP @@ -654,7 +648,7 @@ void s3cfb_lcd0_power_domain_stop(void) void s3cfb_lcd0_pmu_off(void) { s3cfb_lcd0_power_domain_stop(); - msleep(5); + usleep_range(5000, 5000); s3cfb_lcd0_power_domain_start(); printk(KERN_WARNING "lcd0 pmu re_start!!!\n"); } @@ -668,13 +662,16 @@ void s3cfb_early_suspend(struct early_suspend *h) struct platform_device *pdev = to_platform_device(info->dev); struct s3cfb_global *fbdev[2]; int i, ret; - u32 reg; printk(KERN_INFO "+%s\n", __func__); -#if defined(CONFIG_FB_S5P_S6E8AA0) || defined(CONFIG_FB_S5P_S6E8AB0) || defined(CONFIG_FB_S5P_S6D6AA1) +#ifdef CONFIG_FB_S5P_MIPI_DSIM +#if defined(CONFIG_FB_S5P_S6E63M0) + s6e63m0_early_suspend(); +#else s6e8ax0_early_suspend(); #endif +#endif for (i = 0; i < FIMD_MAX; i++) { fbdev[i] = fbfimd->fbdev[i]; @@ -694,36 +691,29 @@ void s3cfb_early_suspend(struct early_suspend *h) #elif defined(CONFIG_FB_S5P_LMS501KF03) lms501kf03_ldi_disable(); #endif - ret = s3cfb_display_off(fbdev[i]); #ifdef CONFIG_FB_S5P_MDNIE - ret += s3c_mdnie_stop(); + ret += s3c_mdnie_display_off(); #endif if (ret > 0) s3cfb_lcd0_pmu_off(); -#ifdef CONFIG_FB_S5P_MDNIE - writel(0, fbdev[i]->regs + 0x27c); - msleep(20); - reg = readl(S3C_VA_SYS + 0x0210); - reg |= (1<<1); - writel(reg, S3C_VA_SYS + 0x0210); -#endif - info->system_state = POWER_OFF; if (fbdev[i]->regs) { fbdev[i]->regs_org = fbdev[i]->regs; + spin_lock(&fbdev[i]->slock); fbdev[i]->regs = 0; + spin_unlock(&fbdev[i]->slock); } if (pdata->clk_off) pdata->clk_off(pdev, &fbdev[i]->clock); } -#if defined(CONFIG_FB_S5P_S6C1372) +#if defined(CONFIG_FB_S5P_S6C1372) || defined(CONFIG_FB_S5P_S6F1202A) s5c1372_ldi_disable(); #endif @@ -750,7 +740,6 @@ void s3cfb_late_resume(struct early_suspend *h) struct s3cfb_global *fbdev[2]; int i, j; struct platform_device *pdev = to_platform_device(info->dev); - u32 reg; printk(KERN_INFO "+%s\n", __func__); @@ -767,13 +756,13 @@ void s3cfb_late_resume(struct early_suspend *h) if (s5p_dsim_fifo_clear() == 0) { s5p_dsim_early_suspend(); - msleep(10); + usleep_range(10000, 10000); s5p_dsim_late_resume(); if (s5p_dsim_fifo_clear() == 0) pr_info("dsim resume fail!!!\n"); } - msleep(10); + usleep_range(10000, 10000); #endif #if defined(CONFIG_FB_S5P_DUMMYLCD) @@ -791,18 +780,15 @@ void s3cfb_late_resume(struct early_suspend *h) /* fbdev[i]->regs_org should be non-zero value */ BUG(); - info->system_state = POWER_ON; + if (pdata->set_display_path) + pdata->set_display_path(); #ifdef CONFIG_FB_S5P_MDNIE - reg = readl(S3C_VA_SYS + 0x0210); - reg &= ~(1<<13); - reg &= ~(1<<12); - reg &= ~(3<<10); - reg |= (1<<0); - reg &= ~(1<<1); - writel(reg, S3C_VA_SYS + 0x0210); - writel(3, fbdev[i]->regs + 0x27c); + s3cfb_set_dualrgb(fbdev[i], S3C_DUALRGB_MDNIE); #endif + + info->system_state = POWER_ON; + s3cfb_init_global(fbdev[i]); s3cfb_set_clock(fbdev[i]); /* Set Alpha value width to 8-bit alpha value @@ -810,18 +796,15 @@ void s3cfb_late_resume(struct early_suspend *h) * 2 : 4bit mode */ s3cfb_set_alpha_value(fbdev[i], 1); -#if defined(CONFIG_FB_S5P_S6C1372) +#ifdef CONFIG_FB_S5P_MDNIE +#if defined(CONFIG_FB_S5P_S6C1372) || defined(CONFIG_FB_S5P_S6F1202A) s5c1372_ldi_enable(); #endif - -#ifdef CONFIG_FB_S5P_MDNIE s3c_mdnie_init_global(fbdev[i]); - s3c_mdnie_start(fbdev[i]); + set_mdnie_value(g_mdnie, 1); + s3c_mdnie_display_on(fbdev[i]); #endif s3cfb_display_on(fbdev[i]); -#ifdef CONFIG_FB_S5P_MDNIE - set_mdnie_value(g_mdnie); -#endif /* Set alpha value width to 8-bit */ s3cfb_set_alpha_value_width(fbdev[i], i); @@ -836,11 +819,6 @@ void s3cfb_late_resume(struct early_suspend *h) } } -#ifdef CONFIG_FB_S5P_AMS369FG06 - ams369fg06_gpio_cfg(); - ams369fg06_ldi_init(); - ams369fg06_ldi_enable(); -#endif if (pdata->cfg_gpio) pdata->cfg_gpio(pdev); @@ -854,9 +832,13 @@ void s3cfb_late_resume(struct early_suspend *h) pdata->backlight_on(pdev); } -#if defined(CONFIG_FB_S5P_S6E8AA0) || defined(CONFIG_FB_S5P_S6E8AB0) || defined(CONFIG_FB_S5P_S6D6AA1) +#ifdef CONFIG_FB_S5P_MIPI_DSIM +#if defined(CONFIG_FB_S5P_S6E63M0) + s6e63m0_late_resume(); +#else s6e8ax0_late_resume(); #endif +#endif printk(KERN_INFO "-%s\n", __func__); @@ -880,7 +862,7 @@ int s3cfb_suspend(struct platform_device *pdev, pm_message_t state) reg = readl(S3C_VA_SYS + 0x0210); reg |= (1<<1); writel(reg, S3C_VA_SYS + 0x0210); - s3c_mdnie_stop(); + s3c_mdnie_display_off(); #endif if (atomic_read(&fbdev[i]->enabled_win) > 0) { /* lcd_off and backlight_off isn't needed. */ @@ -956,7 +938,7 @@ int s3cfb_resume(struct platform_device *pdev) s3cfb_set_clock(fbdev[i]); #ifdef CONFIG_FB_S5P_MDNIE s3c_mdnie_init_global(fbdev[i]); - s3c_mdnie_start(fbdev[i]); + s3c_mdnie_display_on(fbdev[i]); #endif for (j = 0; j < pdata->nr_wins; j++) { fb = fbdev[i]->fb[j]; @@ -974,9 +956,7 @@ int s3cfb_resume(struct platform_device *pdev) s3cfb_set_alpha_value_width(fbdev[i], i); -#ifndef CONFIG_MACH_JENGA s3cfb_display_on(fbdev[i]); -#endif if (pdata->backlight_on) pdata->backlight_on(pdev); diff --git a/drivers/video/samsung/s3cfb_mdnie.c b/drivers/video/samsung/s3cfb_mdnie.c index 6860e59..0fa2f60 100644 --- a/drivers/video/samsung/s3cfb_mdnie.c +++ b/drivers/video/samsung/s3cfb_mdnie.c @@ -146,9 +146,9 @@ int s3c_mdnie_init_global(struct s3cfb_global *s3cfb_ctrl) return 0; } -int s3c_mdnie_start(struct s3cfb_global *ctrl) +int s3c_mdnie_display_on(struct s3cfb_global *ctrl) { - s3c_ielcd_start(); + s3c_ielcd_display_on(); if (!IS_ERR_OR_NULL(g_mdnie)) g_mdnie->enable = TRUE; @@ -156,22 +156,22 @@ int s3c_mdnie_start(struct s3cfb_global *ctrl) return 0; } -int s3c_mdnie_off(void) +int s3c_mdnie_display_off(void) { if (!IS_ERR_OR_NULL(g_mdnie)) g_mdnie->enable = FALSE; - s3c_ielcd_logic_stop(); - - return 0; + return s3c_ielcd_display_off(); } -int s3c_mdnie_stop(void) +int s3c_mdnie_off(void) { if (!IS_ERR_OR_NULL(g_mdnie)) g_mdnie->enable = FALSE; - return s3c_ielcd_stop(); + s3c_ielcd_logic_stop(); + + return 0; } int s3c_mdnie_hw_init(void) diff --git a/drivers/video/samsung/s3cfb_mdnie.h b/drivers/video/samsung/s3cfb_mdnie.h index 962b342..329a40a 100644 --- a/drivers/video/samsung/s3cfb_mdnie.h +++ b/drivers/video/samsung/s3cfb_mdnie.h @@ -326,9 +326,9 @@ int s3c_mdnie_setup(void); int s3c_mdnie_init_global(struct s3cfb_global *s3cfb_ctrl); -int s3c_mdnie_start(struct s3cfb_global *ctrl); +int s3c_mdnie_display_on(struct s3cfb_global *ctrl); +int s3c_mdnie_display_off(void); int s3c_mdnie_off(void); -int s3c_mdnie_stop(void); int mdnie_write(unsigned int addr, unsigned int val); int s3c_mdnie_mask(void); diff --git a/drivers/video/samsung/s3cfb_ops.c b/drivers/video/samsung/s3cfb_ops.c index c6cfab3..3ff2f05 100644 --- a/drivers/video/samsung/s3cfb_ops.c +++ b/drivers/video/samsung/s3cfb_ops.c @@ -104,15 +104,12 @@ int s3cfb_draw_logo(struct fb_info *fb) #else /* #ifdef RGB_BOOTSCREEN */ u8 *logo_virt_buf; - if (bootloaderfb) - printk(KERN_INFO "Bootloader sent 'bootloaderfb' to Kernel Successfully : %d", bootloaderfb); - else { - bootloaderfb = BOOT_FB_BASE_ADDR; - printk(KERN_ERR "Fail to get 'bootloaderfb' from Bootloader. so we must set this value as %d", bootloaderfb); + if (bootloaderfb) { + logo_virt_buf = phys_to_virt(bootloaderfb); + memcpy(fb->screen_base, logo_virt_buf, fb->var.yres * fb->fix.line_length); + printk(KERN_INFO "Bootloader sent 'bootloaderfb' : %08X\n", bootloaderfb); } - logo_virt_buf = phys_to_virt(bootloaderfb); - memcpy(fb->screen_base, logo_virt_buf, fb->var.yres * fb->fix.line_length); #endif /* #ifdef RGB_BOOTSCREEN */ #endif #endif @@ -393,7 +390,8 @@ int s3cfb_map_default_video_memory(struct s3cfb_global *fbdev, (unsigned int)fix->smem_start, (unsigned int)fb->screen_base, fix->smem_len); - memset(fb->screen_base, 0, fix->smem_len); + if (bootloaderfb) + memset(fb->screen_base, 0, fix->smem_len); win->owner = DMA_MEM_FIMD; return 0; @@ -552,10 +550,14 @@ int s3cfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fb) void s3cfb_set_win_params(struct s3cfb_global *fbdev, int id) { s3cfb_set_window_control(fbdev, id); +#if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) + s3cfb_set_oneshot(fbdev, id); +#else s3cfb_set_window_position(fbdev, id); s3cfb_set_window_size(fbdev, id); s3cfb_set_buffer_address(fbdev, id); s3cfb_set_buffer_size(fbdev, id); +#endif if (id > 0) { s3cfb_set_alpha_blending(fbdev, id); @@ -1031,22 +1033,32 @@ int s3cfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fb) { struct s3cfb_window *win = fb->par; struct s3cfb_global *fbdev = get_fimd_global(win->id); + struct s3c_platform_fb *pdata = to_fb_plat(fbdev->dev); + + if (win->id == pdata->default_win) + spin_lock(&fbdev->slock); #ifdef CONFIG_EXYNOS_DEV_PD if (unlikely(fbdev->system_state == POWER_OFF) || fbdev->regs == 0) { dev_err(fbdev->dev, "%s::system_state is POWER_OFF, fb%d\n", __func__, win->id); - return 0; + if (win->id == pdata->default_win) + spin_unlock(&fbdev->slock); + return -EINVAL; } #endif if (var->yoffset + var->yres > var->yres_virtual) { dev_err(fbdev->dev, "invalid yoffset value\n"); + if (win->id == pdata->default_win) + spin_unlock(&fbdev->slock); return -EINVAL; } #if defined(CONFIG_CPU_EXYNOS4210) if (unlikely(var->xoffset + var->xres > var->xres_virtual)) { dev_err(fbdev->dev, "invalid xoffset value\n"); + if (win->id == pdata->default_win) + spin_unlock(&fbdev->slock); return -EINVAL; } fb->var.xoffset = var->xoffset; @@ -1059,6 +1071,8 @@ int s3cfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fb) s3cfb_set_buffer_address(fbdev, win->id); + if (win->id == pdata->default_win) + spin_unlock(&fbdev->slock); return 0; } @@ -1143,6 +1157,10 @@ int s3cfb_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg) sizeof(p.user_window))) ret = -EFAULT; else { +#if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) + win->x = p.user_window.x; + win->y = p.user_window.y; +#else if (p.user_window.x < 0) p.user_window.x = 0; @@ -1160,6 +1178,7 @@ int s3cfb_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg) win->y = p.user_window.y; s3cfb_set_window_position(fbdev, win->id); +#endif } break; diff --git a/drivers/video/samsung/s3cfb_s6e39a0.c b/drivers/video/samsung/s3cfb_s6e39a0.c index 4e9fa8f..3d0f534 100644 --- a/drivers/video/samsung/s3cfb_s6e39a0.c +++ b/drivers/video/samsung/s3cfb_s6e39a0.c @@ -106,9 +106,9 @@ struct lcd_info { #endif unsigned int irq; unsigned int connected; -}; -static struct mipi_ddi_platform_data *ddi_pd; + struct dsim_global *dsim; +}; static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len) { @@ -124,11 +124,11 @@ static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len wbuf = seq; if (size == 1) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_NO_PARA, wbuf[0], 0); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_NO_PARA, wbuf[0], 0); else if (size == 2) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_1_PARA, wbuf[0], wbuf[1]); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_1_PARA, wbuf[0], wbuf[1]); else - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_LONG_WR, (unsigned int)wbuf, size); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_LONG_WR, (unsigned int)wbuf, size); mutex_unlock(&lcd->lock); @@ -144,44 +144,14 @@ static int s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf) mutex_lock(&lcd->lock); - if (ddi_pd->cmd_read) - ret = ddi_pd->cmd_read(ddi_pd->dsim_base, addr, count, buf); + if (lcd->dsim->ops->cmd_read) + ret = lcd->dsim->ops->cmd_read(lcd->dsim, addr, count, buf); mutex_unlock(&lcd->lock); return ret; } -static int s6e8ax0_set_link(void *pd, unsigned int dsim_base, - unsigned char (*cmd_write) (unsigned int dsim_base, unsigned int data0, - unsigned int data1, unsigned int data2), - int (*cmd_read) (unsigned int reg_base, u8 addr, u16 count, u8 *buf)) -{ - struct mipi_ddi_platform_data *temp_pd = NULL; - - temp_pd = (struct mipi_ddi_platform_data *) pd; - if (temp_pd == NULL) { - printk(KERN_ERR "mipi_ddi_platform_data is null.\n"); - return -EPERM; - } - - ddi_pd = temp_pd; - - ddi_pd->dsim_base = dsim_base; - - if (cmd_write) - ddi_pd->cmd_write = cmd_write; - else - printk(KERN_WARNING "cmd_write function is null.\n"); - - if (cmd_read) - ddi_pd->cmd_read = cmd_read; - else - printk(KERN_WARNING "cmd_read function is null.\n"); - - return 0; -} - static int get_backlight_level_from_brightness(int brightness) { int backlightlevel; @@ -362,8 +332,7 @@ static int update_brightness(struct lcd_info *lcd) { int ret; -#if defined(CONFIG_MACH_MIDAS_01_BD) || defined(CONFIG_MACH_MIDAS_02_BD) || \ - defined(CONFIG_MACH_C1) || defined(CONFIG_MACH_C1VZW) || \ +#if defined(CONFIG_MACH_C1) || defined(CONFIG_MACH_C1VZW) || \ defined(CONFIG_MACH_M0) || defined(CONFIG_MACH_SLP_PQ) || \ defined(CONFIG_MACH_SLP_PQ_LTE) || defined(CONFIG_MACH_M3) #else @@ -956,8 +925,7 @@ static void s6e8aa0_check_id(struct lcd_info *lcd, u8 *idbuf) lcd->elvss.reference = lcd->smart.panelid[2]; printk(KERN_DEBUG "Dynamic ELVSS Information\n"); - printk(KERN_DEBUG "Refrence : %02x , manual_version = %02x,\ - lcd->aid= %02x\n", lcd->elvss.reference, lcd->manual_version, lcd->aid); + printk(KERN_DEBUG "Refrence : %02x , manual_version = %02x, lcd->aid= %02x\n", lcd->elvss.reference, lcd->manual_version, lcd->aid); } else if ((idbuf[0] == PANEL_A1_M3) || (idbuf[0] == PANEL_A2_M3)) { lcd->support_elvss = 0; printk(KERN_DEBUG "ID-3 is 0xff does not support dynamic elvss\n"); @@ -1003,6 +971,7 @@ static int s6e8ax0_probe(struct device *dev) } lcd->dev = dev; + lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = DEFAULT_GAMMA_LEVEL; @@ -1103,7 +1072,6 @@ static void s6e8ax0_shutdown(struct device *dev) static struct mipi_lcd_driver s6e8ax0_mipi_driver = { .name = "s6e8aa0", - .set_link = s6e8ax0_set_link, .probe = s6e8ax0_probe, .remove = __devexit_p(s6e8ax0_remove), .shutdown = s6e8ax0_shutdown, diff --git a/drivers/video/samsung/s3cfb_s6e8aa0.c b/drivers/video/samsung/s3cfb_s6e8aa0.c index e9581e9..987b215 100644 --- a/drivers/video/samsung/s3cfb_s6e8aa0.c +++ b/drivers/video/samsung/s3cfb_s6e8aa0.c @@ -34,7 +34,7 @@ #include "s3cfb.h" #include "s6e8aa0_gamma_l.h" -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) #include "s6e8aa0_gamma_q1.h" #define SMART_DIMMING #else @@ -53,7 +53,7 @@ #define MIN_BRIGHTNESS 0 #define MAX_BRIGHTNESS 255 -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) #define MAX_GAMMA 290 #define DEFAULT_BRIGHTNESS 150 #define DEFAULT_GAMMA_LEVEL GAMMA_150CD @@ -122,13 +122,12 @@ struct lcd_info { unsigned int connected; #if defined(GPIO_OLED_DET) - struct delayed_work hs_clk_toggle; - unsigned int esd_detection_count; + struct delayed_work oled_detection; + unsigned int oled_detection_count; #endif + struct dsim_global *dsim; }; -static struct mipi_ddi_platform_data *ddi_pd; - #ifdef CONFIG_AID_DIMMING static const unsigned int candela_table[GAMMA_MAX] = { 20, 30, 40, 50, 60, 70, 80, 90, 100, @@ -183,19 +182,19 @@ static unsigned int elvss_offset_table[ELVSS_STATUS_MAX] = { #endif #if defined(GPIO_OLED_DET) -static void hs_clk_toggle_work(struct work_struct *work) +static void oled_detection_work(struct work_struct *work) { struct lcd_info *lcd = - container_of(work, struct lcd_info, hs_clk_toggle.work); + container_of(work, struct lcd_info, oled_detection.work); int oled_det_level = gpio_get_value(GPIO_OLED_DET); - printk(KERN_INFO "%s, %d, %d\n", __func__, lcd->esd_detection_count, oled_det_level); + dev_info(&lcd->ld->dev, "%s, %d, %d\n", __func__, lcd->oled_detection_count, oled_det_level); if (!oled_det_level) { - if (lcd->esd_detection_count < 10) { - schedule_delayed_work(&lcd->hs_clk_toggle, HZ/8); - lcd->esd_detection_count++; + if (lcd->oled_detection_count < 10) { + schedule_delayed_work(&lcd->oled_detection, HZ/8); + lcd->oled_detection_count++; set_dsim_hs_clk_toggle_count(15); } else set_dsim_hs_clk_toggle_count(0); @@ -204,14 +203,14 @@ static void hs_clk_toggle_work(struct work_struct *work) } -static irqreturn_t oled_det_int(int irq, void *_lcd) +static irqreturn_t oled_detection_int(int irq, void *_lcd) { struct lcd_info *lcd = _lcd; - printk(KERN_INFO "%s\n", __func__); + dev_info(&lcd->ld->dev, "%s\n", __func__); - lcd->esd_detection_count = 0; - schedule_delayed_work(&lcd->hs_clk_toggle, HZ/16); + lcd->oled_detection_count = 0; + schedule_delayed_work(&lcd->oled_detection, HZ/16); return IRQ_HANDLED; } @@ -231,11 +230,11 @@ static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len wbuf = seq; if (size == 1) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_NO_PARA, wbuf[0], 0); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_NO_PARA, wbuf[0], 0); else if (size == 2) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_1_PARA, wbuf[0], wbuf[1]); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_1_PARA, wbuf[0], wbuf[1]); else - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_LONG_WR, (unsigned int)wbuf, size); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_LONG_WR, (unsigned int)wbuf, size); mutex_unlock(&lcd->lock); @@ -251,44 +250,14 @@ static int _s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf mutex_lock(&lcd->lock); - if (ddi_pd->cmd_read) - ret = ddi_pd->cmd_read(ddi_pd->dsim_base, addr, count, buf); + if (lcd->dsim->ops->cmd_read) + ret = lcd->dsim->ops->cmd_read(lcd->dsim, addr, count, buf); mutex_unlock(&lcd->lock); return ret; } -static int s6e8ax0_set_link(void *pd, unsigned int dsim_base, - unsigned char (*cmd_write) (unsigned int dsim_base, unsigned int data0, - unsigned int data1, unsigned int data2), - int (*cmd_read) (u32 reg_base, u8 addr, u16 count, u8 *buf)) -{ - struct mipi_ddi_platform_data *temp_pd = NULL; - - temp_pd = (struct mipi_ddi_platform_data *) pd; - if (temp_pd == NULL) { - printk(KERN_ERR "mipi_ddi_platform_data is null.\n"); - return -EPERM; - } - - ddi_pd = temp_pd; - - ddi_pd->dsim_base = dsim_base; - - if (cmd_write) - ddi_pd->cmd_write = cmd_write; - else - printk(KERN_WARNING "cmd_write function is null.\n"); - - if (cmd_read) - ddi_pd->cmd_read = cmd_read; - else - printk(KERN_WARNING "cmd_read function is null.\n"); - - return 0; -} - static int s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf, u8 retry_cnt) { int ret = 0; @@ -456,7 +425,7 @@ static int s6e8ax0_gamma_ctl(struct lcd_info *lcd) return 0; } -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) static int s6e8ax0_set_acl(struct lcd_info *lcd) { int ret = 0; @@ -605,7 +574,7 @@ static int s6e8ax0_set_acl(struct lcd_info *lcd) #ifdef SMART_DIMMING #ifdef CONFIG_AID_DIMMING -static int s6e8ax0_set_elvss(struct lcd_info *lcd) +static int s6e8ax0_set_elvss(struct lcd_info *lcd, u8 force) { int ret = 0, elvss_level = 0; u32 candela = candela_table[lcd->bl]; @@ -673,7 +642,7 @@ static int s6e8ax0_set_elvss(struct lcd_info *lcd) break; } - if (lcd->current_elvss != lcd->elvss_table[elvss_level][2]) { + if ((lcd->current_elvss != lcd->elvss_table[elvss_level][2]) || force) { ret = s6e8ax0_write(lcd, lcd->elvss_table[elvss_level], ELVSS_PARAM_SIZE); lcd->current_elvss = lcd->elvss_table[elvss_level][2]; } @@ -689,7 +658,7 @@ elvss_err: return ret; } #else -static int s6e8ax0_set_elvss(struct lcd_info *lcd) +static int s6e8ax0_set_elvss(struct lcd_info *lcd, u8 force) { int ret = 0, elvss_level = 0; u32 candela = candela_table[lcd->bl]; @@ -711,7 +680,7 @@ static int s6e8ax0_set_elvss(struct lcd_info *lcd) break; } - if (lcd->current_elvss != lcd->elvss_table[elvss_level][2]) { + if ((lcd->current_elvss != lcd->elvss_table[elvss_level][2]) || force) { ret = s6e8ax0_write(lcd, lcd->elvss_table[elvss_level], ELVSS_PARAM_SIZE); lcd->current_elvss = lcd->elvss_table[elvss_level][2]; } @@ -947,7 +916,7 @@ static int update_brightness(struct lcd_info *lcd, u8 force) #endif s6e8ax0_set_acl(lcd); - s6e8ax0_set_elvss(lcd); + s6e8ax0_set_elvss(lcd, force); lcd->current_bl = lcd->bl; @@ -963,11 +932,11 @@ static int s6e8ax0_ldi_init(struct lcd_info *lcd) { int ret = 0; -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) s6e8ax0_write(lcd, SEQ_APPLY_LEVEL_2_KEY, ARRAY_SIZE(SEQ_APPLY_LEVEL_2_KEY)); - msleep(20); + s6e8ax0_write(lcd, SEQ_LTPS_DELAY, ARRAY_SIZE(SEQ_LTPS_DELAY)); s6e8ax0_write(lcd, SEQ_SLEEP_OUT, ARRAY_SIZE(SEQ_SLEEP_OUT)); - usleep_range(5000, 5000); + msleep(22); s6e8ax0_write(lcd, SEQ_PANEL_CONDITION_SET, ARRAY_SIZE(SEQ_PANEL_CONDITION_SET)); s6e8ax0_write(lcd, SEQ_DISPLAY_CONDITION_SET, ARRAY_SIZE(SEQ_DISPLAY_CONDITION_SET)); s6e8ax0_gamma_ctl(lcd); @@ -980,7 +949,7 @@ static int s6e8ax0_ldi_init(struct lcd_info *lcd) s6e8ax0_write(lcd, SEQ_APPLY_LEVEL_2, ARRAY_SIZE(SEQ_APPLY_LEVEL_2)); s6e8ax0_write(lcd, SEQ_APPLY_MTP_KEY_ENABLE, ARRAY_SIZE(SEQ_APPLY_MTP_KEY_ENABLE)); s6e8ax0_write(lcd, SEQ_SLEEP_OUT, ARRAY_SIZE(SEQ_SLEEP_OUT)); - usleep_range(22000, 22000); + msleep(22); /* 4.8" HD for M0/C1*/ if (lcd->id[1] == 0x20 || lcd->id[1] == 0x40 || lcd->id[1] == 0x60) { @@ -1209,7 +1178,7 @@ static ssize_t lcd_type_show(struct device *dev, struct device_attribute *attr, char *buf) { char temp[15]; -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) sprintf(temp, "SMD_AMS529HA01\n"); #else sprintf(temp, "SMD_AMS480GYXX\n"); @@ -1286,6 +1255,8 @@ void s6e8ax0_early_suspend(void) { struct lcd_info *lcd = g_lcd; + set_dsim_lcd_enabled(0); + dev_info(&lcd->ld->dev, "+%s\n", __func__); #if defined(GPIO_OLED_DET) disable_irq(lcd->irq); @@ -1314,7 +1285,7 @@ void s6e8ax0_late_resume(void) #endif dev_info(&lcd->ld->dev, "-%s\n", __func__); - set_dsim_lcd_enabled(); + set_dsim_lcd_enabled(1); return ; } @@ -1341,7 +1312,7 @@ static int s6e8ax0_read_mtp(struct lcd_info *lcd, u8 *mtp_data) return ret; } -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) static void s6e8aa0_check_id(struct lcd_info *lcd, u8 *idbuf) { u32 i; @@ -1409,6 +1380,7 @@ static int s6e8ax0_probe(struct device *dev) } lcd->dev = dev; + lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = DEFAULT_GAMMA_LEVEL; @@ -1490,14 +1462,14 @@ static int s6e8ax0_probe(struct device *dev) #if defined(GPIO_OLED_DET) if (lcd->connected) { - INIT_DELAYED_WORK(&lcd->hs_clk_toggle, hs_clk_toggle_work); + INIT_DELAYED_WORK(&lcd->oled_detection, oled_detection_work); lcd->irq = gpio_to_irq(GPIO_OLED_DET); s3c_gpio_cfgpin(GPIO_OLED_DET, S3C_GPIO_SFN(0xf)); s3c_gpio_setpull(GPIO_OLED_DET, S3C_GPIO_PULL_NONE); - if (request_irq(lcd->irq, oled_det_int, - IRQF_TRIGGER_FALLING, "esd_detection", lcd)) + if (request_irq(lcd->irq, oled_detection_int, + IRQF_TRIGGER_FALLING, "oled_detection", lcd)) pr_err("failed to reqeust irq. %d\n", lcd->irq); } #endif @@ -1540,7 +1512,6 @@ static void s6e8ax0_shutdown(struct device *dev) static struct mipi_lcd_driver s6e8ax0_mipi_driver = { .name = "s6e8aa0", - .set_link = s6e8ax0_set_link, .probe = s6e8ax0_probe, .remove = __devexit_p(s6e8ax0_remove), .shutdown = s6e8ax0_shutdown, diff --git a/drivers/video/samsung/s3cfb_s6e8ab0.c b/drivers/video/samsung/s3cfb_s6e8ab0.c index 185bab0..bc47c37 100644 --- a/drivers/video/samsung/s3cfb_s6e8ab0.c +++ b/drivers/video/samsung/s3cfb_s6e8ab0.c @@ -101,9 +101,9 @@ struct lcd_info { struct str_elvss elvss; #endif unsigned int connected; -}; -static struct mipi_ddi_platform_data *ddi_pd; + struct dsim_global *dsim; +}; static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len) { @@ -119,11 +119,11 @@ static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len wbuf = seq; if (size == 1) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_NO_PARA, wbuf[0], 0); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_NO_PARA, wbuf[0], 0); else if (size == 2) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_1_PARA, wbuf[0], wbuf[1]); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_1_PARA, wbuf[0], wbuf[1]); else - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_LONG_WR, (unsigned int)wbuf, size); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_LONG_WR, (unsigned int)wbuf, size); mutex_unlock(&lcd->lock); @@ -139,44 +139,14 @@ static int _s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf mutex_lock(&lcd->lock); - if (ddi_pd->cmd_read) - ret = ddi_pd->cmd_read(ddi_pd->dsim_base, addr, count, buf); + if (lcd->dsim->ops->cmd_read) + ret = lcd->dsim->ops->cmd_read(lcd->dsim, addr, count, buf); mutex_unlock(&lcd->lock); return ret; } -static int s6e8ax0_set_link(void *pd, unsigned int dsim_base, - unsigned char (*cmd_write) (unsigned int dsim_base, unsigned int data0, - unsigned int data1, unsigned int data2), - int (*cmd_read) (u32 reg_base, u8 addr, u16 count, u8 *buf)) -{ - struct mipi_ddi_platform_data *temp_pd = NULL; - - temp_pd = (struct mipi_ddi_platform_data *) pd; - if (temp_pd == NULL) { - printk(KERN_ERR "mipi_ddi_platform_data is null.\n"); - return -EPERM; - } - - ddi_pd = temp_pd; - - ddi_pd->dsim_base = dsim_base; - - if (cmd_write) - ddi_pd->cmd_write = cmd_write; - else - printk(KERN_WARNING "cmd_write function is null.\n"); - - if (cmd_read) - ddi_pd->cmd_read = cmd_read; - else - printk(KERN_WARNING "cmd_read function is null.\n"); - - return 0; -} - static int s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf, u8 retry_cnt) { int ret = 0; @@ -781,6 +751,8 @@ void s6e8ax0_early_suspend(void) { struct lcd_info *lcd = g_lcd; + set_dsim_lcd_enabled(0); + dev_info(&lcd->ld->dev, "+%s\n", __func__); s6e8ax0_power(lcd, FB_BLANK_POWERDOWN); dev_info(&lcd->ld->dev, "-%s\n", __func__); @@ -796,7 +768,7 @@ void s6e8ax0_late_resume(void) s6e8ax0_power(lcd, FB_BLANK_UNBLANK); dev_info(&lcd->ld->dev, "-%s\n", __func__); - set_dsim_lcd_enabled(); + set_dsim_lcd_enabled(1); return ; } @@ -884,6 +856,7 @@ static int s6e8ax0_probe(struct device *dev) } lcd->dev = dev; + lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = DEFAULT_GAMMA_LEVEL; @@ -990,7 +963,6 @@ static void s6e8ax0_shutdown(struct device *dev) static struct mipi_lcd_driver s6e8ax0_mipi_driver = { .name = "s6e8ab0", - .set_link = s6e8ax0_set_link, .probe = s6e8ax0_probe, .remove = __devexit_p(s6e8ax0_remove), .shutdown = s6e8ax0_shutdown, diff --git a/drivers/video/samsung/s5p-dsim.c b/drivers/video/samsung/s5p-dsim.c index 540a75b..4f2cb7f 100644 --- a/drivers/video/samsung/s5p-dsim.c +++ b/drivers/video/samsung/s5p-dsim.c @@ -50,38 +50,6 @@ #include #endif - -/* Indicates the state of the device */ -struct dsim_global { - struct device *dev; - struct clk *clock; - struct s5p_platform_dsim *pd; - struct dsim_config *dsim_info; - struct dsim_lcd_config *dsim_lcd_info; - /* lcd panel data. */ - struct s3cfb_lcd *lcd_panel_info; - /* platform and machine specific data for lcd panel driver. */ - struct mipi_ddi_platform_data *mipi_ddi_pd; - /* lcd panel driver based on MIPI-DSI. */ - struct mipi_lcd_driver *mipi_drv; - - unsigned int irq; - unsigned int te_irq; - unsigned int reg_base; - unsigned char state; - unsigned int data_lane; - enum dsim_byte_clk_src e_clk_src; - unsigned long hs_clk; - unsigned long byte_clk; - unsigned long escape_clk; - unsigned char freq_band; - char header_fifo_index[DSIM_HEADER_FIFO_SZ]; -#ifdef CONFIG_HAS_WAKELOCK - struct early_suspend early_suspend; - struct wake_lock idle_lock; -#endif -}; - struct mipi_lcd_info { struct list_head list; struct mipi_lcd_driver *mipi_drv; @@ -134,82 +102,83 @@ static DECLARE_COMPLETION(dsim_wr_comp); static LIST_HEAD(lcd_info_list); static DEFINE_MUTEX(mipi_lock); -static struct dsim_global dsim; -struct delayed_work dsim_work; -struct delayed_work check_hs_toggle_work; +static struct dsim_global *g_dsim; -static unsigned int dsim_toggle_per_frame_count; +static struct s5p_platform_dsim *to_dsim_plat(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + + return (struct s5p_platform_dsim *)pdev->dev.platform_data; +} -void s5p_dsim_frame_done_interrupt_enable(u8 enable) +static void s5p_dsim_frame_done_interrupt_enable(struct dsim_global *dsim, u8 enable) { u32 intmsk; u8 state = !enable; - if (!dsim.mipi_ddi_pd->resume_complete) + if (!dsim->mipi_ddi_pd->resume_complete) return; -#if 0 - if (state == 0) /* enable Frame Done interrupts */ - writel(0xF237FFFF, dsim.reg_base + S5P_DSIM_INTMSK); - else /* disable Frame Done interrupts */ - writel(0xF337FFFF, dsim.reg_base + S5P_DSIM_INTMSK); -#else - intmsk = readl(dsim.reg_base + S5P_DSIM_INTMSK); + intmsk = readl(dsim->reg_base + S5P_DSIM_INTMSK); - if (state == 0) + if (state == 0) /* enable Frame Done interrupts */ intmsk &= ~(0x01 << S5P_DSIM_INT_MSK_FRAME_DONE); - else + else /* disable Frame Done interrupts */ intmsk |= (0x01 << S5P_DSIM_INT_MSK_FRAME_DONE); - writel(intmsk, dsim.reg_base + S5P_DSIM_INTMSK); -#endif + writel(intmsk, dsim->reg_base + S5P_DSIM_INTMSK); } -void set_dsim_lcd_enabled(void) +void set_dsim_lcd_enabled(u8 enable) { - dsim.dsim_lcd_info->lcd_enabled = 1; - if (dsim.dsim_info->hs_toggle) - s5p_dsim_frame_done_interrupt_enable(1); + struct dsim_global *dsim = g_dsim; + + dsim->dsim_lcd_info->lcd_enabled = enable; + if (dsim->dsim_info->hs_toggle) + s5p_dsim_frame_done_interrupt_enable(dsim, enable); } void set_dsim_hs_clk_toggle_count(u8 count) { - dsim_toggle_per_frame_count = count; - if (dsim.dsim_lcd_info->lcd_enabled) - s5p_dsim_frame_done_interrupt_enable(count ? 1 : 0); + struct dsim_global *dsim = g_dsim; + + dsim->dsim_toggle_per_frame_count = count; + if (dsim->dsim_lcd_info->lcd_enabled) + s5p_dsim_frame_done_interrupt_enable(dsim, count ? 1 : 0); } static void dsim_work_q_handler(struct work_struct *work) { - s5p_dsim_frame_done_interrupt_enable(1); -} + struct dsim_global *dsim = + container_of(work, struct dsim_global, dsim_work.work); -static void dsim_check_hs_toggle_work_q_handler(struct work_struct *work) -{ - if (dsim.dsim_info->hs_toggle) { - dev_info(dsim.dev, "check_hs_toggle.\n"); - schedule_delayed_work(&check_hs_toggle_work,\ - msecs_to_jiffies(120000)); - } + s5p_dsim_frame_done_interrupt_enable(dsim, 1); } -struct s5p_platform_dsim *to_dsim_plat(struct device *dev) +static void dsim_check_hs_toggle_work_q_handler(struct work_struct *work) { - struct platform_device *pdev = to_platform_device(dev); + struct dsim_global *dsim = + container_of(work, struct dsim_global, check_hs_toggle_work.work); - return (struct s5p_platform_dsim *)pdev->dev.platform_data; + if (dsim->dsim_info->hs_toggle) { + dev_info(dsim->dev, "check_hs_toggle\n"); + schedule_delayed_work(&dsim->check_hs_toggle_work, msecs_to_jiffies(120000)); + } } -unsigned char s5p_dsim_wr_data(unsigned int dsim_base, +unsigned char s5p_dsim_wr_data(void *ptr, unsigned int data_id, unsigned int data0, unsigned int data1) { - if (dsim.state == DSIM_STATE_ULPS) { - dev_err(dsim.dev, "state is ULPS\n"); + struct dsim_global *dsim = ptr; + unsigned int dsim_base = dsim->reg_base; + + if (dsim->state == DSIM_STATE_ULPS) { + dev_err(dsim->dev, "DSIM state: ULPS\n"); return DSIM_FALSE; } - if (dsim.mipi_ddi_pd->resume_complete == 0) { - printk(KERN_INFO "DSIM Status: SUSPEND\n"); + if (dsim->mipi_ddi_pd->resume_complete == 0) { + dev_err(dsim->dev, "DSIM Status: SUSPEND\n"); return DSIM_FALSE; } @@ -278,7 +247,7 @@ unsigned char s5p_dsim_wr_data(unsigned int dsim_base, (unsigned char) ((((unsigned short) data1) & 0xff00) >> 8)); if (!wait_for_completion_interruptible_timeout(&dsim_wr_comp, DSIM_TIMEOUT)) { - printk(KERN_ERR "[DSIM:ERROR] %s Timeout\n", __func__); + dev_err(dsim->dev, "[DSIM:ERROR] %s Timeout\n", __func__); mutex_unlock(&dsim_rd_wr_mutex); return DSIM_FALSE; } @@ -293,13 +262,13 @@ unsigned char s5p_dsim_wr_data(unsigned int dsim_base, mutex_unlock(&dsim_rd_wr_mutex); return DSIM_TRUE; /* response should be implemented. */ default: - dev_warn(dsim.dev, "data id %x is not supported current DSI spec.\n", data_id); + dev_warn(dsim->dev, "data id %x is not supported current DSI spec\n", data_id); mutex_unlock(&dsim_rd_wr_mutex); return DSIM_FALSE; } } -int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) +int s5p_dsim_rd_data(void *ptr, u8 addr, u16 count, u8 *buf) { u32 i, temp; u8 response = 0; @@ -307,11 +276,11 @@ int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) u32 txhd; u32 rxhd; int j; + struct dsim_global *dsim = ptr; + unsigned int reg_base = dsim->reg_base; - printk(KERN_INFO "%s called, count : %d\n", __func__, count); - - if (dsim.mipi_ddi_pd->resume_complete == 0) { - printk(KERN_INFO "DSIM Status: SUSPEND\n"); + if (dsim->mipi_ddi_pd->resume_complete == 0) { + dev_err(dsim->dev, "DSIM Status: SUSPEND\n"); return DSIM_FALSE; } @@ -341,15 +310,15 @@ int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) writel(txhd, reg_base + S5P_DSIM_PKTHDR); if (!wait_for_completion_interruptible_timeout(&dsim_rd_comp, DSIM_TIMEOUT)) { - printk(KERN_ERR "ERROR:%s timout\n", __func__); + dev_err(dsim->dev, "ERROR:%s timout\n", __func__); mutex_unlock(&dsim_rd_wr_mutex); return 0; } rxhd = readl(reg_base + S5P_DSIM_RXFIFO); - printk(KERN_INFO "rxhd : %x\n", rxhd); + dev_info(dsim->dev, "rxhd : %x\n", rxhd); if ((u8)(rxhd & 0xff) != response) { - printk(KERN_ERR "[DSIM:ERROR]:%s wrong response rxhd : %x, response:%x\n" + dev_err(dsim->dev, "[DSIM:ERROR]:%s wrong response rxhd : %x, response:%x\n" , __func__, rxhd, response); goto clear_rx_fifo; } @@ -361,16 +330,16 @@ int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) } else { /* for long packet */ rxsize = (u16)((rxhd & 0x00ffff00) >> 8); - printk(KERN_INFO "rcv size : %d\n", rxsize); + dev_info(dsim->dev, "rcv size : %d\n", rxsize); if (rxsize != count) { - printk(KERN_ERR "[DSIM:ERROR]:%s received data size mismatch received : %d, requested : %d\n", + dev_err(dsim->dev, "[DSIM:ERROR]:%s received data size mismatch received : %d, requested : %d\n", __func__, rxsize, count); goto clear_rx_fifo; } for (i = 0; i < rxsize>>2; i++) { temp = readl(reg_base + S5P_DSIM_RXFIFO); - printk(KERN_INFO "pkt : %08x\n", temp); + dev_info(dsim->dev, "pkt : %08x\n", temp); for (j = 0; j < 4; j++) { buf[(i*4)+j] = (u8)(temp>>(j*8))&0xff; /* printk("Value : %02x\n",(temp>>(j*8))&0xff); */ @@ -378,7 +347,7 @@ int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) } if (rxsize % 4) { temp = readl(reg_base + S5P_DSIM_RXFIFO); - printk(KERN_INFO "pkt-l : %08x\n", temp); + dev_info(dsim->dev, "pkt-l : %08x\n", temp); for (j = 0; j < rxsize%4; j++) { buf[(i*4)+j] = (u8)(temp>>(j*8))&0xff; /* printk("Value : %02x\n",(temp>>(j*8))&0xff); */ @@ -389,7 +358,7 @@ int s5p_dsim_rd_data(unsigned int reg_base, u8 addr, u16 count, u8 *buf) temp = readl(reg_base + S5P_DSIM_RXFIFO); if (temp != DSIM_RX_FIFO_READ_DONE) { - printk(KERN_WARNING "[DSIM:WARN]:%s Can't found RX FIFO READ DONE FLAG : %x\n", __func__, temp); + dev_warn(dsim->dev, "[DSIM:WARN]:%s Can't found RX FIFO READ DONE FLAG : %x\n", __func__, temp); goto clear_rx_fifo; } @@ -402,10 +371,10 @@ clear_rx_fifo: temp = readl(reg_base+S5P_DSIM_RXFIFO); if ((temp == DSIM_RX_FIFO_READ_DONE) || (i > DSIM_MAX_RX_FIFO)) break; - printk(KERN_INFO "[DSIM:INFO] : %s clear rx fifo : %08x\n", __func__, temp); + dev_info(dsim->dev, "[DSIM:INFO] : %s clear rx fifo : %08x\n", __func__, temp); i++; } - printk(KERN_INFO "[DSIM:INFO] : %s done count : %d, temp : %08x\n", __func__, i, temp); + dev_info(dsim->dev, "[DSIM:INFO] : %s done count : %d, temp : %08x\n", __func__, i, temp); mutex_unlock(&dsim_rd_wr_mutex); return 0; @@ -417,16 +386,16 @@ static irqreturn_t s5p_dsim_isr(int irq, void *dev_id) int i; unsigned int intsrc = 0; unsigned int intmsk = 0; - struct dsim_global *pdsim = NULL; + struct dsim_global *dsim = NULL; - pdsim = (struct dsim_global *)dev_id; - if (!pdsim) { + dsim = (struct dsim_global *)dev_id; + if (!dsim) { printk(KERN_ERR "%s:error:wrong parameter\n", __func__); return IRQ_HANDLED; } - intsrc = readl(pdsim->reg_base + S5P_DSIM_INTSRC); - intmsk = readl(pdsim->reg_base + S5P_DSIM_INTMSK); + intsrc = readl(dsim->reg_base + S5P_DSIM_INTSRC); + intmsk = readl(dsim->reg_base + S5P_DSIM_INTMSK); intmsk = ~(intmsk) & intsrc; @@ -464,16 +433,18 @@ static irqreturn_t s5p_dsim_isr(int irq, void *dev_id) break; case S5P_DSIM_INT_MSK_FRAME_DONE: /* printk("S5P_DSIM_INT_MSK_FRAME_DONE\n"); */ - if (s3cfb_vsync_status_check() && dsim.mipi_ddi_pd->resume_complete == 1) { + if (dsim->dsim_lcd_info->lcd_enabled && dsim->mipi_ddi_pd->resume_complete) { if (completion_done(&dsim_wr_comp) && completion_done(&dsim_rd_comp)) { - s5p_dsim_toggle_hs_clock(dsim.reg_base); - if (!dsim_toggle_per_frame_count) { - s5p_dsim_frame_done_interrupt_enable(0); - if (likely(dsim.dsim_info->hs_toggle - 1)) - schedule_delayed_work(&dsim_work, dsim.dsim_info->hs_toggle); + if (s3cfb_vsync_status_check()) { + s5p_dsim_toggle_hs_clock(dsim->reg_base); + if (!dsim->dsim_toggle_per_frame_count) { + s5p_dsim_frame_done_interrupt_enable(dsim, 0); + if (likely(dsim->dsim_info->hs_toggle - 1)) + schedule_delayed_work(&dsim->dsim_work, dsim->dsim_info->hs_toggle); + } + if (dsim->dsim_toggle_per_frame_count) + dsim->dsim_toggle_per_frame_count--; } - if (dsim_toggle_per_frame_count) - dsim_toggle_per_frame_count--; } } break; @@ -481,20 +452,20 @@ static irqreturn_t s5p_dsim_isr(int irq, void *dev_id) } } /* clear irq */ - writel(intsrc, pdsim->reg_base + S5P_DSIM_INTSRC); + writel(intsrc, dsim->reg_base + S5P_DSIM_INTSRC); return IRQ_HANDLED; } -static void s5p_dsim_init_header_fifo(void) +static void s5p_dsim_init_header_fifo(struct dsim_global *dsim) { unsigned int cnt; for (cnt = 0; cnt < DSIM_HEADER_FIFO_SZ; cnt++) - dsim.header_fifo_index[cnt] = -1; + dsim->header_fifo_index[cnt] = -1; return; } -unsigned char s5p_dsim_pll_on(unsigned int dsim_base, unsigned char enable) +static unsigned char s5p_dsim_pll_on(unsigned int dsim_base, unsigned char enable) { if (enable) { int sw_timeout = 1000; @@ -513,19 +484,20 @@ unsigned char s5p_dsim_pll_on(unsigned int dsim_base, unsigned char enable) return DSIM_TRUE; } -static unsigned long s5p_dsim_change_pll(unsigned int dsim_base, unsigned char pre_divider, +static unsigned long s5p_dsim_change_pll(struct dsim_global *dsim, unsigned char pre_divider, unsigned short main_divider, unsigned char scaler) { unsigned long dfin_pll, dfvco, dpll_out; unsigned char freq_band; unsigned char temp0 = 0, temp1 = 0; + unsigned int dsim_base = dsim->reg_base; dfin_pll = (MIPI_FIN / pre_divider); if (dfin_pll < 6 * 1000 * 1000 || dfin_pll > 12 * 1000 * 1000) { - dev_warn(dsim.dev, "warning!!\n"); - dev_warn(dsim.dev, "fin_pll range is 6MHz ~ 12MHz\n"); - dev_warn(dsim.dev, "fin_pll of mipi dphy pll is %luMHz\n", (dfin_pll / 1000000)); + dev_warn(dsim->dev, "warning!!\n"); + dev_warn(dsim->dev, "fin_pll range is 6MHz ~ 12MHz\n"); + dev_warn(dsim->dev, "fin_pll of mipi dphy pll is %luMHz\n", (dfin_pll / 1000000)); s5p_dsim_enable_afc(dsim_base, 0, 0); } else { @@ -544,16 +516,16 @@ static unsigned long s5p_dsim_change_pll(unsigned int dsim_base, unsigned char p } dfvco = dfin_pll * main_divider; - dev_dbg(dsim.dev, "dfvco = %lu, dfin_pll = %lu, main_divider = %d\n", + dev_dbg(dsim->dev, "dfvco = %lu, dfin_pll = %lu, main_divider = %d\n", dfvco, dfin_pll, main_divider); if (dfvco < 500000000 || dfvco > 1000000000) { - dev_warn(dsim.dev, "Caution!!\n"); - dev_warn(dsim.dev, "fvco range is 500MHz ~ 1000MHz\n"); - dev_warn(dsim.dev, "fvco of mipi dphy pll is %luMHz\n", (dfvco / 1000000)); + dev_warn(dsim->dev, "Caution!!\n"); + dev_warn(dsim->dev, "fvco range is 500MHz ~ 1000MHz\n"); + dev_warn(dsim->dev, "fvco of mipi dphy pll is %luMHz\n", (dfvco / 1000000)); } dpll_out = dfvco / (1 << scaler); - dev_dbg(dsim.dev, "dpll_out = %lu, dfvco = %lu, scaler = %d\n", + dev_dbg(dsim->dev, "dpll_out = %lu, dfvco = %lu, scaler = %d\n", dpll_out, dfvco, scaler); if (dpll_out < 100 * 1000000) freq_band = 0x0; @@ -588,7 +560,7 @@ static unsigned long s5p_dsim_change_pll(unsigned int dsim_base, unsigned char p else freq_band = 0xf; - dev_dbg(dsim.dev, "freq_band = %d\n", freq_band); + dev_dbg(dsim->dev, "freq_band = %d\n", freq_band); s5p_dsim_pll_freq(dsim_base, pre_divider, main_divider, scaler); @@ -599,51 +571,52 @@ static unsigned long s5p_dsim_change_pll(unsigned int dsim_base, unsigned char p s5p_dsim_pll_freq_band(dsim_base, freq_band); /* Stable time */ - s5p_dsim_pll_stable_time(dsim_base, dsim.dsim_info->pll_stable_time); + s5p_dsim_pll_stable_time(dsim_base, dsim->dsim_info->pll_stable_time); /* Enable PLL */ - dev_dbg(dsim.dev, "FOUT of mipi dphy pll is %luMHz\n", (dpll_out / 1000000)); + dev_dbg(dsim->dev, "FOUT of mipi dphy pll is %luMHz\n", (dpll_out / 1000000)); return dpll_out; } -static void s5p_dsim_set_clock(unsigned int dsim_base, +static void s5p_dsim_set_clock(struct dsim_global *dsim, unsigned char byte_clk_sel, unsigned char enable) { unsigned int esc_div; unsigned long esc_clk_error_rate; + unsigned int dsim_base = dsim->reg_base; if (enable) { - dsim.e_clk_src = byte_clk_sel; + dsim->e_clk_src = byte_clk_sel; /* Escape mode clock and byte clock source */ s5p_dsim_set_byte_clock_src(dsim_base, byte_clk_sel); /* DPHY, DSIM Link : D-PHY clock out */ if (byte_clk_sel == DSIM_PLL_OUT_DIV8) { - dsim.hs_clk = s5p_dsim_change_pll(dsim_base, dsim.dsim_info->p, - dsim.dsim_info->m, dsim.dsim_info->s); - dsim.byte_clk = dsim.hs_clk / 8; + dsim->hs_clk = s5p_dsim_change_pll(dsim, dsim->dsim_info->p, + dsim->dsim_info->m, dsim->dsim_info->s); + dsim->byte_clk = dsim->hs_clk / 8; s5p_dsim_enable_pll_bypass(dsim_base, 0); s5p_dsim_pll_on(dsim_base, 1); usleep_range(1000, 1000); /* DPHY : D-PHY clock out, DSIM link : external clock out */ } else if (byte_clk_sel == DSIM_EXT_CLK_DIV8) - dev_warn(dsim.dev, "this project is not supported external clock source for MIPI DSIM\n"); + dev_warn(dsim->dev, "this project is not supported external clock source for MIPI DSIM\n"); else if (byte_clk_sel == DSIM_EXT_CLK_BYPASS) - dev_warn(dsim.dev, "this project is not supported external clock source for MIPI DSIM\n"); + dev_warn(dsim->dev, "this project is not supported external clock source for MIPI DSIM\n"); /* escape clock divider */ - esc_div = dsim.byte_clk / (dsim.dsim_info->esc_clk); - dev_dbg(dsim.dev, "esc_div = %d, byte_clk = %lu, esc_clk = %lu\n", - esc_div, dsim.byte_clk, dsim.dsim_info->esc_clk); - if ((dsim.byte_clk / esc_div) >= 20000000 || - (dsim.byte_clk / esc_div) > dsim.dsim_info->esc_clk) + esc_div = dsim->byte_clk / (dsim->dsim_info->esc_clk); + dev_dbg(dsim->dev, "esc_div = %d, byte_clk = %lu, esc_clk = %lu\n", + esc_div, dsim->byte_clk, dsim->dsim_info->esc_clk); + if ((dsim->byte_clk / esc_div) >= 20000000 || + (dsim->byte_clk / esc_div) > dsim->dsim_info->esc_clk) esc_div += 1; - dsim.escape_clk = dsim.byte_clk / esc_div; - dev_dbg(dsim.dev, "escape_clk = %lu, byte_clk = %lu, esc_div = %d\n", - dsim.escape_clk, dsim.byte_clk, esc_div); + dsim->escape_clk = dsim->byte_clk / esc_div; + dev_dbg(dsim->dev, "escape_clk = %lu, byte_clk = %lu, esc_div = %d\n", + dsim->escape_clk, dsim->byte_clk, esc_div); /* * enable escclk on lane @@ -653,22 +626,22 @@ static void s5p_dsim_set_clock(unsigned int dsim_base, /* enable byte clk and escape clock */ s5p_dsim_set_esc_clk_prs(dsim_base, 1, esc_div); /* escape clock on lane */ - s5p_dsim_enable_esc_clk_on_lane(dsim_base, (DSIM_LANE_CLOCK | dsim.data_lane), 1); - - dev_dbg(dsim.dev, "byte clock is %luMHz\n", (dsim.byte_clk / 1000000)); - dev_dbg(dsim.dev, "escape clock that user's need is %lu\n", (dsim.dsim_info->esc_clk / 1000000)); - dev_dbg(dsim.dev, "escape clock divider is %x\n", esc_div); - dev_dbg(dsim.dev, "escape clock is %luMHz\n", ((dsim.byte_clk / esc_div) / 1000000)); - - if ((dsim.byte_clk / esc_div) > dsim.escape_clk) { - esc_clk_error_rate = dsim.escape_clk / (dsim.byte_clk / esc_div); - dev_warn(dsim.dev, "error rate is %lu over.\n", (esc_clk_error_rate / 100)); - } else if ((dsim.byte_clk / esc_div) < (dsim.escape_clk)) { - esc_clk_error_rate = (dsim.byte_clk / esc_div) / dsim.escape_clk; - dev_warn(dsim.dev, "error rate is %lu under.\n", (esc_clk_error_rate / 100)); + s5p_dsim_enable_esc_clk_on_lane(dsim_base, (DSIM_LANE_CLOCK | dsim->data_lane), 1); + + dev_dbg(dsim->dev, "byte clock is %luMHz\n", (dsim->byte_clk / 1000000)); + dev_dbg(dsim->dev, "escape clock that user's need is %lu\n", (dsim->dsim_info->esc_clk / 1000000)); + dev_dbg(dsim->dev, "escape clock divider is %x\n", esc_div); + dev_dbg(dsim->dev, "escape clock is %luMHz\n", ((dsim->byte_clk / esc_div) / 1000000)); + + if ((dsim->byte_clk / esc_div) > dsim->escape_clk) { + esc_clk_error_rate = dsim->escape_clk / (dsim->byte_clk / esc_div); + dev_warn(dsim->dev, "error rate is %lu over\n", (esc_clk_error_rate / 100)); + } else if ((dsim->byte_clk / esc_div) < (dsim->escape_clk)) { + esc_clk_error_rate = (dsim->byte_clk / esc_div) / dsim->escape_clk; + dev_warn(dsim->dev, "error rate is %lu under\n", (esc_clk_error_rate / 100)); } } else { - s5p_dsim_enable_esc_clk_on_lane(dsim_base, (DSIM_LANE_CLOCK | dsim.data_lane), 0); + s5p_dsim_enable_esc_clk_on_lane(dsim_base, (DSIM_LANE_CLOCK | dsim->data_lane), 0); s5p_dsim_set_esc_clk_prs(dsim_base, 0, 0); s5p_dsim_enable_byte_clock(dsim_base, DSIM_FALSE); @@ -678,88 +651,93 @@ static void s5p_dsim_set_clock(unsigned int dsim_base, } } -static int s5p_dsim_late_resume_init_dsim(unsigned int dsim_base) +static int s5p_dsim_late_resume_init_dsim(struct dsim_global *dsim) { - if (dsim.pd->init_d_phy) - dsim.pd->init_d_phy(dsim.reg_base); + unsigned int dsim_base = dsim->reg_base; - dsim.state = DSIM_STATE_RESET; + if (dsim->pd->init_d_phy) + dsim->pd->init_d_phy(dsim->reg_base); - switch (dsim.dsim_info->e_no_data_lane) { + dsim->state = DSIM_STATE_RESET; + + switch (dsim->dsim_info->e_no_data_lane) { case DSIM_DATA_LANE_1: - dsim.data_lane = DSIM_LANE_DATA0; + dsim->data_lane = DSIM_LANE_DATA0; break; case DSIM_DATA_LANE_2: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1; + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1; break; case DSIM_DATA_LANE_3: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | DSIM_LANE_DATA2; break; case DSIM_DATA_LANE_4: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | DSIM_LANE_DATA2 | DSIM_LANE_DATA3; break; default: - dev_info(dsim.dev, "data lane is invalid.\n"); + dev_info(dsim->dev, "data lane is invalid\n"); return -1; }; - s5p_dsim_init_header_fifo(); + s5p_dsim_init_header_fifo(dsim); s5p_dsim_sw_reset(dsim_base); - s5p_dsim_dp_dn_swap(dsim_base, dsim.dsim_info->e_lane_swap); + s5p_dsim_dp_dn_swap(dsim_base, dsim->dsim_info->e_lane_swap); /* enable only frame done interrupt */ /* s5p_dsim_clear_interrupt(dsim_base, AllDsimIntr); */ - /* s5p_dsim_set_interrupt_mask(dsim.reg_base, AllDsimIntr, 1); */ + /* s5p_dsim_set_interrupt_mask(dsim->reg_base, AllDsimIntr, 1); */ return 0; } #if 0 -static int s5p_dsim_init_dsim(unsigned int dsim_base) +static int s5p_dsim_init_dsim(struct dsim_global *dsim) { - if (dsim.pd->init_d_phy) - dsim.pd->init_d_phy(dsim.reg_base); + unsigned int dsim_base = dsim->reg_base; + + if (dsim->pd->init_d_phy) + dsim->pd->init_d_phy(dsim->reg_base); - dsim.state = DSIM_STATE_RESET; + dsim->state = DSIM_STATE_RESET; - switch (dsim.dsim_info->e_no_data_lane) { + switch (dsim->dsim_info->e_no_data_lane) { case DSIM_DATA_LANE_1: - dsim.data_lane = DSIM_LANE_DATA0; + dsim->data_lane = DSIM_LANE_DATA0; break; case DSIM_DATA_LANE_2: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1; + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1; break; case DSIM_DATA_LANE_3: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | DSIM_LANE_DATA2; break; case DSIM_DATA_LANE_4: - dsim.data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | + dsim->data_lane = DSIM_LANE_DATA0 | DSIM_LANE_DATA1 | DSIM_LANE_DATA2 | DSIM_LANE_DATA3; break; default: - dev_info(dsim.dev, "data lane is invalid.\n"); + dev_info(dsim->dev, "data lane is invalid\n"); return -1; }; - s5p_dsim_init_header_fifo(); - s5p_dsim_dp_dn_swap(dsim_base, dsim.dsim_info->e_lane_swap); + s5p_dsim_init_header_fifo(dsim); + s5p_dsim_dp_dn_swap(dsim_base, dsim->dsim_info->e_lane_swap); /* enable only frame done interrupt */ /* s5p_dsim_clear_interrupt(dsim_base, AllDsimIntr); */ - /* s5p_dsim_set_interrupt_mask(dsim.reg_base, AllDsimIntr, 1); */ + /* s5p_dsim_set_interrupt_mask(dsim->reg_base, AllDsimIntr, 1); */ return 0; } #endif -static void s5p_dsim_set_display_mode(unsigned int dsim_base, +static void s5p_dsim_set_display_mode(struct dsim_global *dsim, struct dsim_lcd_config *main_lcd, struct dsim_lcd_config *sub_lcd) { struct s3cfb_lcd *main_lcd_panel_info = NULL, *sub_lcd_panel_info = NULL; struct s3cfb_lcd_timing *main_timing = NULL; + unsigned int dsim_base = dsim->reg_base; if (main_lcd != NULL) { if (main_lcd->lcd_panel_info != NULL) { @@ -770,18 +748,18 @@ static void s5p_dsim_set_display_mode(unsigned int dsim_base, main_lcd_panel_info->height, main_lcd_panel_info->width); } else - dev_warn(dsim.dev, "lcd panel info of main lcd is NULL.\n"); + dev_warn(dsim->dev, "lcd panel info of main lcd is NULL\n"); } else { - dev_err(dsim.dev, "main lcd is NULL.\n"); + dev_err(dsim->dev, "main lcd is NULL\n"); return; } /* in case of VIDEO MODE (RGB INTERFACE) */ - if (dsim.dsim_lcd_info->e_interface == (u32) DSIM_VIDEO) { + if (dsim->dsim_lcd_info->e_interface == (u32)DSIM_VIDEO) { main_timing = &main_lcd_panel_info->timing; if (main_timing == NULL) { - dev_err(dsim.dev, "main_timing is NULL.\n"); + dev_err(dsim->dev, "main_timing is NULL\n"); return; } @@ -805,130 +783,131 @@ static void s5p_dsim_set_display_mode(unsigned int dsim_base, sub_lcd_panel_info->height, sub_lcd_panel_info->width); } else - dev_warn(dsim.dev, "lcd panel info of sub lcd is NULL.\n"); + dev_warn(dsim->dev, "lcd panel info of sub lcd is NULL\n"); } } - s5p_dsim_display_config(dsim_base, dsim.dsim_lcd_info, NULL); + s5p_dsim_display_config(dsim_base, dsim->dsim_lcd_info, NULL); } -static int s5p_dsim_init_link(unsigned int dsim_base) +static int s5p_dsim_init_link(struct dsim_global *dsim) { unsigned int time_out = 100; + unsigned int dsim_base = dsim->reg_base; - switch (dsim.state) { + switch (dsim->state) { case DSIM_STATE_RESET: case DSIM_STATE_INIT: - printk(KERN_INFO "%s\n", __func__); s5p_dsim_init_fifo_pointer(dsim_base, 0x0); usleep_range(10000, 10000); s5p_dsim_init_fifo_pointer(dsim_base, 0x1f); /* dsi configuration */ - s5p_dsim_init_config(dsim_base, dsim.dsim_lcd_info, NULL, dsim.dsim_info); + s5p_dsim_init_config(dsim_base, dsim->dsim_lcd_info, NULL, dsim->dsim_info); s5p_dsim_enable_lane(dsim_base, DSIM_LANE_CLOCK, 1); - s5p_dsim_enable_lane(dsim_base, dsim.data_lane, 1); + s5p_dsim_enable_lane(dsim_base, dsim->data_lane, 1); /* set clock configuration */ - s5p_dsim_set_clock(dsim_base, dsim.dsim_info->e_byte_clk, 1); + s5p_dsim_set_clock(dsim, dsim->dsim_info->e_byte_clk, 1); usleep_range(5000, 5000); /* check clock and data lane state is stop state */ while (!(s5p_dsim_is_lane_state(dsim_base, DSIM_LANE_CLOCK) == DSIM_LANE_STATE_STOP) && - !(s5p_dsim_is_lane_state(dsim_base, dsim.data_lane) == DSIM_LANE_STATE_STOP)) { + !(s5p_dsim_is_lane_state(dsim_base, dsim->data_lane) == DSIM_LANE_STATE_STOP)) { time_out--; if (time_out == 0) { - dev_info(dsim.dev, "DSI Master state is not stop state!!!\n"); - dev_info(dsim.dev, "Please check initialization process\n"); + dev_info(dsim->dev, "DSI Master state is not stop state!!!\n"); + dev_info(dsim->dev, "Please check initialization process\n"); return DSIM_FALSE; } } if (time_out != 0) { - /* dev_info(dsim.dev, "initialization of DSI Master is successful\n"); */ - /* dev_info(dsim.dev, "DSI Master state is stop state\n"); */ + /* dev_info(dsim->dev, "initialization of DSI Master is successful\n"); */ + /* dev_info(dsim->dev, "DSI Master state is stop state\n"); */ } - dsim.state = DSIM_STATE_STOP; + dsim->state = DSIM_STATE_STOP; /* BTA sequence counters */ - s5p_dsim_set_stop_state_counter(dsim_base, dsim.dsim_info->stop_holding_cnt); - s5p_dsim_set_bta_timeout(dsim_base, dsim.dsim_info->bta_timeout); - s5p_dsim_set_lpdr_timeout(dsim_base, dsim.dsim_info->rx_timeout); + s5p_dsim_set_stop_state_counter(dsim_base, dsim->dsim_info->stop_holding_cnt); + s5p_dsim_set_bta_timeout(dsim_base, dsim->dsim_info->bta_timeout); + s5p_dsim_set_lpdr_timeout(dsim_base, dsim->dsim_info->rx_timeout); /* default LPDT by both cpu and lcd controller */ - s5p_dsim_set_data_mode(dsim_base, DSIM_TRANSFER_BOTH, - DSIM_STATE_STOP); + s5p_dsim_set_data_mode(dsim_base, DSIM_TRANSFER_BOTH, DSIM_STATE_STOP); return DSIM_TRUE; default: - dev_info(dsim.dev, "DSI Master is already init.\n"); + dev_info(dsim->dev, "DSI Master is already init\n"); return DSIM_FALSE; } } -unsigned char s5p_dsim_set_hs_enable(unsigned int dsim_base) +static unsigned char s5p_dsim_set_hs_enable(struct dsim_global *dsim) { u8 ret = DSIM_FALSE; + unsigned int dsim_base = dsim->reg_base; - if (dsim.state == DSIM_STATE_STOP) { - if (dsim.e_clk_src != DSIM_EXT_CLK_BYPASS) { - dsim.state = DSIM_STATE_HSCLKEN; - s5p_dsim_set_data_mode(dsim_base, DSIM_TRANSFER_BOTH, - DSIM_STATE_HSCLKEN); + if (dsim->state == DSIM_STATE_STOP) { + if (dsim->e_clk_src != DSIM_EXT_CLK_BYPASS) { + dsim->state = DSIM_STATE_HSCLKEN; + s5p_dsim_set_data_mode(dsim_base, DSIM_TRANSFER_BOTH, DSIM_STATE_HSCLKEN); s5p_dsim_enable_hs_clock(dsim_base, 1); ret = DSIM_TRUE; } else - dev_warn(dsim.dev, "clock source is external bypass.\n"); + dev_warn(dsim->dev, "clock source is external bypass\n"); } else - dev_warn(dsim.dev, "DSIM is not stop state.\n"); + dev_warn(dsim->dev, "DSIM is not stop state\n"); return ret; } #if 0 -static unsigned char s5p_dsim_set_stopstate(unsigned int dsim_base) +static unsigned char s5p_dsim_set_stopstate(struct dsim_global *dsim) { u8 ret = DSIM_FALSE; + unsigned int dsim_base = dsim->reg_base; - if (dsim.state == DSIM_STATE_HSCLKEN) { - if (dsim.e_clk_src != DSIM_EXT_CLK_BYPASS) { - dsim.state = DSIM_STATE_STOP; + if (dsim->state == DSIM_STATE_HSCLKEN) { + if (dsim->e_clk_src != DSIM_EXT_CLK_BYPASS) { + dsim->state = DSIM_STATE_STOP; s5p_dsim_enable_hs_clock(dsim_base, 0); ret = DSIM_TRUE; } else - dev_warn(dsim.dev, "clock source is external bypass.\n"); - } else if (dsim.state == DSIM_STATE_ULPS) { + dev_warn(dsim->dev, "clock source is external bypass\n"); + } else if (dsim->state == DSIM_STATE_ULPS) { /* will be update for exiting ulps */ ret = DSIM_TRUE; - } else if (dsim.state == DSIM_STATE_STOP) { - dev_warn(dsim.dev, "DSIM is already stop state.\n"); + } else if (dsim->state == DSIM_STATE_STOP) { + dev_warn(dsim->dev, "DSIM is already stop state\n"); ret = DSIM_TRUE; } else - dev_warn(dsim.dev, "DSIM is not stop state.\n"); + dev_warn(dsim->dev, "DSIM is not stop state\n"); return ret; } #endif -static unsigned char s5p_dsim_set_data_transfer_mode(unsigned int dsim_base, +static unsigned char s5p_dsim_set_data_transfer_mode(struct dsim_global *dsim, unsigned char data_path, unsigned char hs_enable) { u8 ret = DSIM_FALSE; + unsigned int dsim_base = dsim->reg_base; if (hs_enable) { - if (dsim.state == DSIM_STATE_HSCLKEN) { + if (dsim->state == DSIM_STATE_HSCLKEN) { s5p_dsim_set_data_mode(dsim_base, data_path, DSIM_STATE_HSCLKEN); ret = DSIM_TRUE; } else { - dev_err(dsim.dev, "HS Clock lane is not enabled.\n"); + dev_err(dsim->dev, "HS Clock lane is not enabled\n"); ret = DSIM_FALSE; } } else { - if (dsim.state == DSIM_STATE_INIT || dsim.state == DSIM_STATE_ULPS) { - dev_err(dsim.dev, "DSI Master is not STOP or HSDT state.\n"); + if (dsim->state == DSIM_STATE_INIT || dsim->state == DSIM_STATE_ULPS) { + dev_err(dsim->dev, "DSI Master is not STOP or HSDT state\n"); ret = DSIM_FALSE; } else { s5p_dsim_set_data_mode(dsim_base, data_path, DSIM_STATE_STOP); @@ -941,7 +920,8 @@ static unsigned char s5p_dsim_set_data_transfer_mode(unsigned int dsim_base, int s5p_dsim_register_lcd_driver(struct mipi_lcd_driver *lcd_drv) { - struct mipi_lcd_info *lcd_info = NULL; + struct mipi_lcd_info *lcd_info = NULL; + struct dsim_global *dsim = g_dsim; lcd_info = kmalloc(sizeof(struct mipi_lcd_info), GFP_KERNEL); if (lcd_info == NULL) @@ -959,45 +939,42 @@ int s5p_dsim_register_lcd_driver(struct mipi_lcd_driver *lcd_drv) list_add_tail(&lcd_info->list, &lcd_info_list); mutex_unlock(&mipi_lock); - dev_dbg(dsim.dev, "registered lcd panel driver(%s) to mipi-dsi driver.\n", - lcd_drv->name); + dev_dbg(dsim->dev, "registered lcd panel driver(%s) to mipi-dsi driver\n", lcd_drv->name); return 0; } -struct mipi_lcd_driver *scan_mipi_driver(const char *name) +static struct mipi_lcd_driver *scan_mipi_driver(struct dsim_global *dsim, const char *name) { struct mipi_lcd_info *lcd_info; struct mipi_lcd_driver *mipi_drv = NULL; mutex_lock(&mipi_lock); - dev_dbg(dsim.dev, "find lcd panel driver(%s).\n", - name); + dev_dbg(dsim->dev, "find lcd panel driver(%s)\n", name); list_for_each_entry(lcd_info, &lcd_info_list, list) { mipi_drv = lcd_info->mipi_drv; if ((strcmp(mipi_drv->name, name)) == 0) { mutex_unlock(&mipi_lock); - dev_dbg(dsim.dev, "found!!!(%s).\n", mipi_drv->name); + dev_dbg(dsim->dev, "found!!!(%s)\n", mipi_drv->name); return mipi_drv; } } - dev_warn(dsim.dev, "failed to find lcd panel driver(%s).\n", - name); + dev_warn(dsim->dev, "failed to find lcd panel driver(%s)\n", name); mutex_unlock(&mipi_lock); return NULL; } -void s5p_dsim_interrupt_mask_set(void) +static void s5p_dsim_interrupt_mask_set(struct dsim_global *dsim) { u32 int_stat; - int_stat = readl(dsim.reg_base + S5P_DSIM_INTMSK); + int_stat = readl(dsim->reg_base + S5P_DSIM_INTMSK); int_stat &= ~((0x01<reg_base + S5P_DSIM_INTMSK); } int s5p_dsim_fifo_clear(void) { int dsim_count = 0, ret; + struct dsim_global *dsim = g_dsim; - writel(SwRstRelease, dsim.reg_base + S5P_DSIM_INTSRC); + writel(SwRstRelease, dsim->reg_base + S5P_DSIM_INTSRC); - writel(DSIM_FUNCRST, dsim.reg_base + S5P_DSIM_SWRST); + writel(DSIM_FUNCRST, dsim->reg_base + S5P_DSIM_SWRST); do { if (++dsim_count > 90000) { - printk(KERN_ERR "dsim fifo clear fail re_try dsim resume\n"); + dev_err(dsim->dev, "dsim fifo clear fail re_try dsim resume\n"); ret = 0; break; } - if (readl(dsim.reg_base + S5P_DSIM_INTSRC) & SwRstRelease) { - s5p_dsim_interrupt_mask_set(); + if (readl(dsim->reg_base + S5P_DSIM_INTSRC) & SwRstRelease) { + s5p_dsim_interrupt_mask_set(dsim); ret = 1; break; } @@ -1038,16 +1016,17 @@ void s5p_dsim_early_suspend(void) { u32 int_stat = 0; pm_message_t state; + struct dsim_global *dsim = g_dsim; - printk(KERN_INFO "+%s\n", __func__); + dev_info(dsim->dev, "+%s\n", __func__); - if (dsim.mipi_ddi_pd->resume_complete == 0) + if (dsim->mipi_ddi_pd->resume_complete == 0) return; - dsim.mipi_ddi_pd->resume_complete = 0; - dsim.dsim_lcd_info->lcd_enabled = 0; + dsim->mipi_ddi_pd->resume_complete = 0; + dsim->dsim_lcd_info->lcd_enabled = 0; - /* int_stat = readl(dsim.reg_base + S5P_DSIM_INTMSK); */ + /* int_stat = readl(dsim->reg_base + S5P_DSIM_INTMSK); */ int_stat |= ((0x01<reg_base + S5P_DSIM_INTMSK); - /* disable_irq(dsim.irq); */ + /* disable_irq(dsim->irq); */ state.event = PM_EVENT_SUSPEND; - if (dsim.mipi_drv->suspend) - dsim.mipi_drv->suspend(dsim.dev, state); + if (dsim->mipi_drv->suspend) + dsim->mipi_drv->suspend(dsim->dev, state); - if (dsim.mipi_ddi_pd->lcd_power_on) - dsim.mipi_ddi_pd->lcd_power_on(dsim.dev, 0); + if (dsim->mipi_ddi_pd->lcd_power_on) + dsim->mipi_ddi_pd->lcd_power_on(dsim->dev, 0); - s5p_dsim_enable_hs_clock(dsim.reg_base, 0); - s5p_dsim_set_clock(dsim.reg_base, dsim.dsim_info->e_byte_clk, 0); + s5p_dsim_enable_hs_clock(dsim->reg_base, 0); + s5p_dsim_set_clock(dsim, dsim->dsim_info->e_byte_clk, 0); #if defined(CONFIG_CPU_EXYNOS4210) - writel(0x1, dsim.reg_base + S5P_DSIM_SWRST); + writel(0x1, dsim->reg_base + S5P_DSIM_SWRST); #endif - if (dsim.pd->exit_d_phy) - dsim.pd->exit_d_phy(dsim.reg_base); + if (dsim->pd->exit_d_phy) + dsim->pd->exit_d_phy(dsim->reg_base); - clk_disable(dsim.clock); + clk_disable(dsim->clock); - if (dsim.pd->mipi_power) - dsim.pd->mipi_power(0); + if (dsim->pd->mipi_power) + dsim->pd->mipi_power(0); - printk(KERN_INFO "-%s\n", __func__); + dev_info(dsim->dev, "-%s\n", __func__); return; } void s5p_dsim_late_resume(void) { - printk(KERN_INFO "+%s\n", __func__); + struct dsim_global *dsim = g_dsim; + + dev_info(dsim->dev, "+%s\n", __func__); /* MIPI SIGNAL ON */ - if (dsim.pd->mipi_power) - dsim.pd->mipi_power(1); + if (dsim->pd->mipi_power) + dsim->pd->mipi_power(1); - clk_enable(dsim.clock); + clk_enable(dsim->clock); usleep_range(10000, 10000); - if (dsim.mipi_ddi_pd->lcd_power_on) - dsim.mipi_ddi_pd->lcd_power_on(dsim.dev, 1); + if (dsim->mipi_ddi_pd->lcd_power_on) + dsim->mipi_ddi_pd->lcd_power_on(dsim->dev, 1); usleep_range(25000, 25000); - if (dsim.mipi_ddi_pd->lcd_reset) - dsim.mipi_ddi_pd->lcd_reset(); + if (dsim->mipi_ddi_pd->lcd_reset) + dsim->mipi_ddi_pd->lcd_reset(); usleep_range(5000, 5000); - s5p_dsim_late_resume_init_dsim(dsim.reg_base); - s5p_dsim_init_link(dsim.reg_base); + s5p_dsim_late_resume_init_dsim(dsim); + s5p_dsim_init_link(dsim); usleep_range(10000, 10000); - s5p_dsim_set_hs_enable(dsim.reg_base); - s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYCPU, 1); - s5p_dsim_set_display_mode(dsim.reg_base, dsim.dsim_lcd_info, NULL); - s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYLCDC, 1); - /* s5p_dsim_set_interrupt_mask(dsim.reg_base, AllDsimIntr, 0); */ + s5p_dsim_set_hs_enable(dsim); + s5p_dsim_set_data_transfer_mode(dsim, DSIM_TRANSFER_BYCPU, 1); + s5p_dsim_set_display_mode(dsim, dsim->dsim_lcd_info, NULL); + s5p_dsim_set_data_transfer_mode(dsim, DSIM_TRANSFER_BYLCDC, 1); + /* s5p_dsim_set_interrupt_mask(dsim->reg_base, AllDsimIntr, 0); */ - dsim.mipi_ddi_pd->resume_complete = 1; + dsim->mipi_ddi_pd->resume_complete = 1; - printk(KERN_INFO "-%s\n", __func__); + dev_info(dsim->dev, "-%s\n", __func__); return; } #else #ifdef CONFIG_PM -int s5p_dsim_suspend(struct platform_device *pdev, pm_message_t state) +static int s5p_dsim_suspend(struct platform_device *pdev, pm_message_t state) { - printk(KERN_INFO "%s\n", __func__); + struct dsim_global *dsim = platform_get_drvdata(pdev); + + dev_info(&pdev->dev, "%s\n", __func__); - dsim.mipi_ddi_pd->resume_complete = 0; + dsim->mipi_ddi_pd->resume_complete = 0; - if (dsim.mipi_drv->suspend) - dsim.mipi_drv->suspend(&pdev->dev, state); + if (dsim->mipi_drv->suspend) + dsim->mipi_drv->suspend(&pdev->dev, state); else - dev_warn(&pdev->dev, "suspend func is null.\n"); + dev_warn(&pdev->dev, "suspend func is null\n"); - clk_disable(dsim.clock); + clk_disable(dsim->clock); - if (dsim.pd->mipi_power) - dsim.pd->mipi_power(0); + if (dsim->pd->mipi_power) + dsim->pd->mipi_power(0); else - dev_warn(&pdev->dev, "mipi_power func is null.\n"); + dev_warn(&pdev->dev, "mipi_power func is null\n"); return 0; } -int s5p_dsim_resume(struct platform_device *pdev) +static int s5p_dsim_resume(struct platform_device *pdev) { u32 int_stat; - printk(KERN_INFO "%s\n", __func__); + struct dsim_global *dsim = platform_get_drvdata(pdev); + + dev_info(&pdev->dev, "%s\n", __func__); - if (dsim.pd->mipi_power) - dsim.pd->mipi_power(1); + if (dsim->pd->mipi_power) + dsim->pd->mipi_power(1); else - dev_warn(&pdev->dev, "mipi_power func is null.\n"); + dev_warn(&pdev->dev, "mipi_power func is null\n"); usleep_range(10000, 10000); - clk_enable(dsim.clock); + clk_enable(dsim->clock); - if (dsim.mipi_drv->resume) - dsim.mipi_drv->resume(&pdev->dev); + if (dsim->mipi_drv->resume) + dsim->mipi_drv->resume(&pdev->dev); else - dev_warn(&pdev->dev, "resume func is null.\n"); + dev_warn(&pdev->dev, "resume func is null\n"); - s5p_dsim_init_dsim(dsim.reg_base); - s5p_dsim_init_link(dsim.reg_base); + s5p_dsim_init_dsim(dsim); + s5p_dsim_init_link(dsim); - s5p_dsim_set_hs_enable(dsim.reg_base); - s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYCPU, 1); + s5p_dsim_set_hs_enable(dsim); + s5p_dsim_set_data_transfer_mode(dsim, DSIM_TRANSFER_BYCPU, 1); msleep(120); /* initialize lcd panel */ - if (dsim.mipi_drv->init) - dsim.mipi_drv->init(&pdev->dev); + if (dsim->mipi_drv->init) + dsim->mipi_drv->init(&pdev->dev); else - dev_warn(&pdev->dev, "init func is null.\n"); + dev_warn(&pdev->dev, "init func is null\n"); - s5p_dsim_set_display_mode(dsim.reg_base, dsim.dsim_lcd_info, NULL); + s5p_dsim_set_display_mode(dsim, dsim->dsim_lcd_info, NULL); - s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYLCDC, 1); + s5p_dsim_set_data_transfer_mode(dsim, DSIM_TRANSFER_BYLCDC, 1); - int_stat = readl(dsim.reg_base + S5P_DSIM_INTMSK); + int_stat = readl(dsim->reg_base + S5P_DSIM_INTMSK); int_stat &= ~((0x01<reg_base + S5P_DSIM_INTMSK); - dsim.mipi_ddi_pd->resume_complete = 1; + dsim->mipi_ddi_pd->resume_complete = 1; return 0; } @@ -1201,17 +1186,21 @@ int s5p_dsim_resume(struct platform_device *pdev) #define s5p_dsim_resume NULL #endif #endif + u32 read_dsim_register(u32 num) { - return readl(dsim.reg_base + (num*4)); + struct dsim_global *dsim = g_dsim; + + return readl(dsim->reg_base + (num*4)); } static ssize_t hs_toggle_show(struct device *dev, struct device_attribute *attr, char *buf) { char temp[3]; + struct dsim_global *dsim = container_of(dev, struct dsim_global, panel); - sprintf(temp, "%d\n", jiffies_to_msecs(dsim.dsim_info->hs_toggle)); + sprintf(temp, "%d\n", jiffies_to_msecs(dsim->dsim_info->hs_toggle)); strcpy(buf, temp); return strlen(buf); @@ -1222,22 +1211,22 @@ static int hs_toggle_store(struct device *dev, { int value; int rc; + struct dsim_global *dsim = container_of(dev, struct dsim_global, panel); rc = strict_strtoul(buf, (unsigned int)0, (unsigned long *)&value); if (rc < 0) return rc; else { - dev_info(dev, "%s - %d, %d\n", __func__, jiffies_to_msecs(dsim.dsim_info->hs_toggle), value); + dev_info(dev, "%s - %d, %d\n", __func__, jiffies_to_msecs(dsim->dsim_info->hs_toggle), value); if (value == 1) { - dsim.dsim_info->hs_toggle = msecs_to_jiffies(3000); - s5p_dsim_frame_done_interrupt_enable(1); - schedule_delayed_work(&check_hs_toggle_work,\ - msecs_to_jiffies(120000)); + dsim->dsim_info->hs_toggle = msecs_to_jiffies(3000); + s5p_dsim_frame_done_interrupt_enable(dsim, 1); + schedule_delayed_work(&dsim->check_hs_toggle_work, msecs_to_jiffies(120000)); } else { - dsim.dsim_info->hs_toggle = 0; - s5p_dsim_frame_done_interrupt_enable(0); - cancel_delayed_work(&check_hs_toggle_work); + dsim->dsim_info->hs_toggle = 0; + s5p_dsim_frame_done_interrupt_enable(dsim, 0); + cancel_delayed_work(&dsim->check_hs_toggle_work); } } return size; @@ -1250,10 +1239,11 @@ static ssize_t dsim_dump_show(struct device *dev, { int reg_val, i; char temp[50]; + struct dsim_global *dsim = dev_get_drvdata(dev); for (i = 0; i < 25; i++) { - reg_val = readl(dsim.reg_base + i*4); - sprintf(temp, "[DSIM]0x11c8_00%02X = 0x%08X\n", (i*4), reg_val); + reg_val = readl(dsim->reg_base + i*4); + sprintf(temp, "[DSIM]0x11C8_00%02X = 0x%08X\n", (i*4), reg_val); strcat(buf, temp); } @@ -1261,43 +1251,57 @@ static ssize_t dsim_dump_show(struct device *dev, } static DEVICE_ATTR(dsim_dump, 0444, dsim_dump_show, NULL); +static struct dsim_ops s5p_dsim_ops = { + .cmd_write = s5p_dsim_wr_data, + .cmd_read = s5p_dsim_rd_data, + .suspend = s5p_dsim_early_suspend, + .resume = s5p_dsim_late_resume, +}; + static int s5p_dsim_probe(struct platform_device *pdev) { struct resource *res; int ret = -1; u32 int_stat; - INIT_DELAYED_WORK(&dsim_work, dsim_work_q_handler); - INIT_DELAYED_WORK(&check_hs_toggle_work, \ - dsim_check_hs_toggle_work_q_handler); + struct dsim_global *dsim; + + dsim = kzalloc(sizeof(struct dsim_global), GFP_KERNEL); + if (!dsim) { + pr_err("failed to allocate for dsim_global\n"); + ret = -ENOMEM; + goto err_alloc; + } - dsim.pd = to_dsim_plat(&pdev->dev); - if (!dsim.pd) { + g_dsim = dsim; + + dsim->pd = to_dsim_plat(&pdev->dev); + if (!dsim->pd) { dev_err(&pdev->dev, "platform data is NULL\n"); return -EINVAL; } - dsim.dev = &pdev->dev; + dsim->dev = &pdev->dev; /* set dsim config data, dsim lcd config data and lcd panel data. */ - dsim.dsim_info = dsim.pd->dsim_info; - dsim.dsim_lcd_info = dsim.pd->dsim_lcd_info; - dsim.lcd_panel_info = (struct s3cfb_lcd *) dsim.dsim_lcd_info->lcd_panel_info; - dsim.mipi_ddi_pd = (struct mipi_ddi_platform_data *) dsim.dsim_lcd_info->mipi_ddi_pd; - dsim.mipi_ddi_pd->te_irq = dsim.pd->te_irq; + dsim->dsim_info = dsim->pd->dsim_info; + dsim->dsim_lcd_info = dsim->pd->dsim_lcd_info; + dsim->lcd_panel_info = (struct s3cfb_lcd *) dsim->dsim_lcd_info->lcd_panel_info; + dsim->mipi_ddi_pd = (struct mipi_ddi_platform_data *) dsim->dsim_lcd_info->mipi_ddi_pd; + dsim->mipi_ddi_pd->te_irq = dsim->pd->te_irq; - if (dsim.pd->mipi_power) - dsim.pd->mipi_power(1); + if (dsim->pd->mipi_power) + dsim->pd->mipi_power(1); - strcpy(dsim.pd->lcd_panel_name, dsim.lcd_panel_info->name); + strcpy(dsim->pd->lcd_panel_name, dsim->lcd_panel_info->name); /* clock */ - dsim.clock = clk_get(&pdev->dev, dsim.pd->clk_name); - if (IS_ERR(dsim.clock)) { + dsim->clock = clk_get(&pdev->dev, dsim->pd->clk_name); + if (IS_ERR(dsim->clock)) { dev_err(&pdev->dev, "failed to get dsim clock source\n"); return -EINVAL; } - clk_enable(dsim.clock); + clk_enable(dsim->clock); /* io memory */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1317,9 +1321,9 @@ static int s5p_dsim_probe(struct platform_device *pdev) } /* ioremap for register block */ - dsim.reg_base = (unsigned int) ioremap(res->start, + dsim->reg_base = (unsigned int)ioremap(res->start, res->end - res->start + 1); - if (!dsim.reg_base) { + if (!dsim->reg_base) { dev_err(&pdev->dev, "failed to remap io region\n"); ret = -EINVAL; goto err_clk_disable; @@ -1331,15 +1335,15 @@ static int s5p_dsim_probe(struct platform_device *pdev) ret = -EINVAL; goto err_clk_disable; } - /* dsim.irq = res->start; */ + /* dsim->irq = res->start; */ /* clear interrupt */ - /* int_stat = readl(dsim.reg_base + S5P_DSIM_INTSRC); */ + /* int_stat = readl(dsim->reg_base + S5P_DSIM_INTSRC); */ int_stat = 0xffffffff; - writel(int_stat, dsim.reg_base + S5P_DSIM_INTSRC); + writel(int_stat, dsim->reg_base + S5P_DSIM_INTSRC); /* enable interrupts */ - int_stat = readl(dsim.reg_base + S5P_DSIM_INTMSK); + int_stat = readl(dsim->reg_base + S5P_DSIM_INTMSK); int_stat &= ~((0x01<reg_base + S5P_DSIM_INTMSK); init_completion(&dsim_rd_comp); init_completion(&dsim_wr_comp); mutex_init(&dsim_rd_wr_mutex); - dsim.mipi_ddi_pd->resume_complete = 1; - dsim.dsim_lcd_info->lcd_enabled = 1; + dsim->mipi_ddi_pd->resume_complete = 1; + dsim->dsim_lcd_info->lcd_enabled = 1; - ret = request_irq(res->start, (void *)s5p_dsim_isr, IRQF_DISABLED, pdev->name, &dsim); + ret = request_irq(res->start, (void *)s5p_dsim_isr, IRQF_DISABLED, pdev->name, dsim); if (ret != 0) { dev_err(&pdev->dev, "failed to request dsim irq\n"); ret = -EINVAL; goto err_clk_disable; } - /* find lcd panel driver registered to mipi-dsi driver. */ - dsim.mipi_drv = scan_mipi_driver(dsim.pd->lcd_panel_name); - if (dsim.mipi_drv == NULL) { - dev_err(&pdev->dev, "mipi_drv is NULL.\n"); + INIT_DELAYED_WORK(&dsim->dsim_work, dsim_work_q_handler); + INIT_DELAYED_WORK(&dsim->check_hs_toggle_work, dsim_check_hs_toggle_work_q_handler); + + dsim->ops = &s5p_dsim_ops; + + platform_set_drvdata(pdev, dsim); + + dsim->panel.parent = &pdev->dev; + dev_set_name(&dsim->panel, dsim->pd->lcd_panel_name); + ret = device_register(&dsim->panel); + if (ret < 0) { + dev_err(&pdev->dev, "faild device register\n"); ret = -EINVAL; goto mipi_drv_err; } - /* set lcd panel driver link */ - ret = dsim.mipi_drv->set_link((void *) dsim.mipi_ddi_pd, dsim.reg_base, - s5p_dsim_wr_data, s5p_dsim_rd_data); - if (ret < 0) { - dev_err(&pdev->dev, "[DSIM : ERROR] faild set_link()\n"); + /* find lcd panel driver registered to mipi-dsi driver. */ + dsim->mipi_drv = scan_mipi_driver(dsim, dsim->pd->lcd_panel_name); + if (dsim->mipi_drv == NULL) { + dev_err(&pdev->dev, "mipi_drv is NULL\n"); ret = -EINVAL; goto mipi_drv_err; } - ret = dsim.mipi_drv->probe(&pdev->dev); + ret = dsim->mipi_drv->probe(&dsim->panel); if (ret < 0) { - dev_err(&pdev->dev, "[DSIM : ERROR] faild probe()\n"); + dev_err(&pdev->dev, "faild probe\n"); ret = -EINVAL; goto mipi_drv_err; } - dsim.state = DSIM_STATE_HSCLKEN; + dsim->state = DSIM_STATE_HSCLKEN; ret = device_create_file(&(pdev->dev), &dev_attr_dsim_dump); if (ret < 0) dev_err(&pdev->dev, "failed to add sysfs entries, %d\n", __LINE__); - ret = device_create_file(&(pdev->dev), &dev_attr_hs_toggle); - if (ret < 0) - dev_err(&pdev->dev, "failed to add sysfs entries, %d\n", __LINE__); + if (!dsim->dsim_info->hs_toggle) { + ret = device_create_file(&dsim->panel, &dev_attr_hs_toggle); + if (ret < 0) + dev_err(&pdev->dev, "failed to add sysfs entries, %d\n", __LINE__); + } - if (dsim.dsim_info->hs_toggle) - s5p_dsim_frame_done_interrupt_enable(1); + if (dsim->dsim_info->hs_toggle) + s5p_dsim_frame_done_interrupt_enable(dsim, 1); - dev_info(&pdev->dev, "mipi-dsi driver has been probed.\n"); + dev_info(&pdev->dev, "mipi-dsi driver has been probed\n"); #if 0 #ifdef CONFIG_HAS_WAKELOCK #ifdef CONFIG_HAS_EARLYSUSPEND - dsim.early_suspend.suspend = s5p_dsim_early_suspend; - dsim.early_suspend.resume = s5p_dsim_late_resume; - dsim.early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1; - register_early_suspend(&dsim.early_suspend); + dsim->early_suspend.suspend = s5p_dsim_early_suspend; + dsim->early_suspend.resume = s5p_dsim_late_resume; + dsim->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1; + register_early_suspend(&dsim->early_suspend); #endif #endif #endif @@ -1416,11 +1429,11 @@ static int s5p_dsim_probe(struct platform_device *pdev) mipi_drv_err: free_irq(res->start, &dsim); - dsim.pd->mipi_power(0); + dsim->pd->mipi_power(0); err_clk_disable: - clk_disable(dsim.clock); - + clk_disable(dsim->clock); +err_alloc: return ret; } diff --git a/drivers/video/samsung/s5p-dsim.h b/drivers/video/samsung/s5p-dsim.h index 77870a0..baf8f66 100644 --- a/drivers/video/samsung/s5p-dsim.h +++ b/drivers/video/samsung/s5p-dsim.h @@ -34,9 +34,6 @@ struct mipi_lcd_driver { s32 (*init)(struct device *dev); void (*display_on)(struct device *dev); - s32 (*set_link)(void *pd, u32 dsim_base, - u8 (*cmd_write)(u32 dsim_base, u32 data0, u32 data1, u32 data2), - int (*cmd_read)(u32 reg_base, u8 addr, u16 count, u8 *buf)); s32 (*probe)(struct device *dev); s32 (*remove)(struct device *dev); void (*shutdown)(struct device *dev); @@ -44,6 +41,47 @@ struct mipi_lcd_driver { s32 (*resume)(struct device *dev); }; +struct dsim_ops { + u8 (*cmd_write)(void *ptr, u32 data0, u32 data1, u32 data2); + int (*cmd_read)(void *ptr, u8 addr, u16 count, u8 *buf); + void (*suspend)(void); + void (*resume)(void); +}; + +/* Indicates the state of the device */ +struct dsim_global { + struct device *dev; + struct device panel; + struct clk *clock; + struct s5p_platform_dsim *pd; + struct dsim_config *dsim_info; + struct dsim_lcd_config *dsim_lcd_info; + /* lcd panel data. */ + struct s3cfb_lcd *lcd_panel_info; + /* platform and machine specific data for lcd panel driver. */ + struct mipi_ddi_platform_data *mipi_ddi_pd; + /* lcd panel driver based on MIPI-DSI. */ + struct mipi_lcd_driver *mipi_drv; + + unsigned int irq; + unsigned int te_irq; + unsigned int reg_base; + unsigned char state; + unsigned int data_lane; + enum dsim_byte_clk_src e_clk_src; + unsigned long hs_clk; + unsigned long byte_clk; + unsigned long escape_clk; + unsigned char freq_band; + char header_fifo_index[DSIM_HEADER_FIFO_SZ]; + + struct delayed_work dsim_work; + struct delayed_work check_hs_toggle_work; + unsigned int dsim_toggle_per_frame_count; + + struct dsim_ops *ops; +}; + int s5p_dsim_register_lcd_driver(struct mipi_lcd_driver *lcd_drv); #endif /* _S5P_DSIM_LOWLEVEL_H */ diff --git a/drivers/video/samsung/s6d6aa1.c b/drivers/video/samsung/s6d6aa1.c index 2efb506..2a4c4ad 100644 --- a/drivers/video/samsung/s6d6aa1.c +++ b/drivers/video/samsung/s6d6aa1.c @@ -37,7 +37,7 @@ #define MIN_BRIGHTNESS 0 #define MAX_BRIGHTNESS 255 -#define DEFAULT_BRIGHTNESS 160 +#define DEFAULT_BRIGHTNESS 170 struct lcd_info { unsigned int bl; @@ -57,9 +57,9 @@ struct lcd_info { unsigned int irq; unsigned int connected; -}; -static struct mipi_ddi_platform_data *ddi_pd; + struct dsim_global *dsim; +}; static const unsigned char SEQ_SLPOUT[] = { 0x11, @@ -67,13 +67,13 @@ static const unsigned char SEQ_SLPOUT[] = { 0x00 }; -static unsigned char SEQ_DSCTL[] = { +static const unsigned char SEQ_DSCTL[] = { 0x36, 0x00, 0x00 }; -static unsigned char SEQ_WRDISBV[] = { +static const unsigned char SEQ_WRDISBV[] = { 0x51, 0xFF, 0x00 @@ -109,6 +109,13 @@ static const unsigned char SEQ_SLPIN[] = { 0x00 }; +static unsigned char SEQ_WRDISBV_CTL[] = { + 0x51, + 0xFF, + 0x00 +}; + + static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len) { int size; @@ -123,11 +130,11 @@ static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len wbuf = seq; if (size == 1) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_NO_PARA, wbuf[0], 0); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_NO_PARA, wbuf[0], 0); else if (size == 2) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_1_PARA, wbuf[0], wbuf[1]); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_1_PARA, wbuf[0], wbuf[1]); else - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_LONG_WR, (unsigned int)wbuf, size); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_LONG_WR, (unsigned int)wbuf, size); mutex_unlock(&lcd->lock); @@ -143,44 +150,14 @@ static int _s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf mutex_lock(&lcd->lock); - if (ddi_pd->cmd_read) - ret = ddi_pd->cmd_read(ddi_pd->dsim_base, addr, count, buf); + if (lcd->dsim->ops->cmd_read) + ret = lcd->dsim->ops->cmd_read(lcd->dsim, addr, count, buf); mutex_unlock(&lcd->lock); return ret; } -static int s6e8ax0_set_link(void *pd, unsigned int dsim_base, - unsigned char (*cmd_write) (unsigned int dsim_base, unsigned int data0, - unsigned int data1, unsigned int data2), - int (*cmd_read) (u32 reg_base, u8 addr, u16 count, u8 *buf)) -{ - struct mipi_ddi_platform_data *temp_pd = NULL; - - temp_pd = (struct mipi_ddi_platform_data *) pd; - if (temp_pd == NULL) { - printk(KERN_ERR "mipi_ddi_platform_data is null.\n"); - return -EPERM; - } - - ddi_pd = temp_pd; - - ddi_pd->dsim_base = dsim_base; - - if (cmd_write) - ddi_pd->cmd_write = cmd_write; - else - printk(KERN_WARNING "cmd_write function is null.\n"); - - if (cmd_read) - ddi_pd->cmd_read = cmd_read; - else - printk(KERN_WARNING "cmd_read function is null.\n"); - - return 0; -} - static int s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf, u8 retry_cnt) { int ret = 0; @@ -231,8 +208,9 @@ static int update_brightness(struct lcd_info *lcd, u8 force) if ((force) || ((lcd->ldi_enable) && (lcd->current_bl != lcd->bl))) { lcd->current_bl = lcd->bl; - SEQ_WRDISBV[1] = lcd->bl; - s6e8ax0_write(lcd, SEQ_WRDISBV, ARRAY_SIZE(SEQ_WRDISBV)); + SEQ_WRDISBV_CTL[1] = lcd->bl; + s6e8ax0_write(lcd, SEQ_WRDISBV_CTL, \ + ARRAY_SIZE(SEQ_WRDISBV_CTL)); dev_info(&lcd->ld->dev, "brightness=%d, bl=%d\n", brightness, lcd->bl); } @@ -250,7 +228,7 @@ static int s6e8ax0_ldi_init(struct lcd_info *lcd) msleep(200); - s6e8ax0_write(lcd, SEQ_DSCTL, ARRAY_SIZE(SEQ_WRDISBV)); + s6e8ax0_write(lcd, SEQ_DSCTL, ARRAY_SIZE(SEQ_DSCTL)); s6e8ax0_write(lcd, SEQ_WRDISBV, ARRAY_SIZE(SEQ_WRDISBV)); s6e8ax0_write(lcd, SEQ_WRCTRLD, ARRAY_SIZE(SEQ_WRCTRLD)); s6e8ax0_write(lcd, SEQ_WRCABC, ARRAY_SIZE(SEQ_WRCABC)); @@ -459,6 +437,8 @@ void s6e8ax0_early_suspend(void) { struct lcd_info *lcd = g_lcd; + set_dsim_lcd_enabled(0); + dev_info(&lcd->ld->dev, "+%s\n", __func__); s6e8ax0_power(lcd, FB_BLANK_POWERDOWN); @@ -478,7 +458,7 @@ void s6e8ax0_late_resume(void) dev_info(&lcd->ld->dev, "-%s\n", __func__); - set_dsim_lcd_enabled(); + set_dsim_lcd_enabled(1); return ; } @@ -526,6 +506,7 @@ static int s6e8ax0_probe(struct device *dev) } lcd->dev = dev; + lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = 0; @@ -591,7 +572,6 @@ static void s6e8ax0_shutdown(struct device *dev) static struct mipi_lcd_driver s6e8ax0_mipi_driver = { .name = "s6d6aa1", - .set_link = s6e8ax0_set_link, .probe = s6e8ax0_probe, .remove = __devexit_p(s6e8ax0_remove), .shutdown = s6e8ax0_shutdown, diff --git a/drivers/video/samsung/s6dr171.c b/drivers/video/samsung/s6dr171.c index b48e40a..167f658 100644 --- a/drivers/video/samsung/s6dr171.c +++ b/drivers/video/samsung/s6dr171.c @@ -76,10 +76,9 @@ struct lcd_info { unsigned int irq; unsigned int connected; + struct dsim_global *dsim; }; -static struct mipi_ddi_platform_data *ddi_pd; - static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len) { int size; @@ -94,11 +93,11 @@ static int s6e8ax0_write(struct lcd_info *lcd, const unsigned char *seq, int len wbuf = seq; if (size == 1) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_NO_PARA, wbuf[0], 0); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_NO_PARA, wbuf[0], 0); else if (size == 2) - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_WR_1_PARA, wbuf[0], wbuf[1]); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_WR_1_PARA, wbuf[0], wbuf[1]); else - ddi_pd->cmd_write(ddi_pd->dsim_base, DCS_LONG_WR, (unsigned int)wbuf, size); + lcd->dsim->ops->cmd_write(lcd->dsim, DCS_LONG_WR, (unsigned int)wbuf, size); mutex_unlock(&lcd->lock); @@ -114,44 +113,14 @@ static int _s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf mutex_lock(&lcd->lock); - if (ddi_pd->cmd_read) - ret = ddi_pd->cmd_read(ddi_pd->dsim_base, addr, count, buf); + if (lcd->dsim->ops->cmd_read) + ret = lcd->dsim->ops->cmd_read(lcd->dsim, addr, count, buf); mutex_unlock(&lcd->lock); return ret; } -static int s6e8ax0_set_link(void *pd, unsigned int dsim_base, - unsigned char (*cmd_write) (unsigned int dsim_base, unsigned int data0, - unsigned int data1, unsigned int data2), - int (*cmd_read) (u32 reg_base, u8 addr, u16 count, u8 *buf)) -{ - struct mipi_ddi_platform_data *temp_pd = NULL; - - temp_pd = (struct mipi_ddi_platform_data *) pd; - if (temp_pd == NULL) { - printk(KERN_ERR "mipi_ddi_platform_data is null.\n"); - return -EPERM; - } - - ddi_pd = temp_pd; - - ddi_pd->dsim_base = dsim_base; - - if (cmd_write) - ddi_pd->cmd_write = cmd_write; - else - printk(KERN_WARNING "cmd_write function is null.\n"); - - if (cmd_read) - ddi_pd->cmd_read = cmd_read; - else - printk(KERN_WARNING "cmd_read function is null.\n"); - - return 0; -} - static int s6e8ax0_read(struct lcd_info *lcd, const u8 addr, u16 count, u8 *buf, u8 retry_cnt) { int ret = 0; @@ -424,6 +393,8 @@ void s6e8ax0_early_suspend(void) { struct lcd_info *lcd = g_lcd; + set_dsim_lcd_enabled(0); + dev_info(&lcd->ld->dev, "+%s\n", __func__); s6e8ax0_power(lcd, FB_BLANK_POWERDOWN); dev_info(&lcd->ld->dev, "-%s\n", __func__); @@ -439,7 +410,7 @@ void s6e8ax0_late_resume(void) s6e8ax0_power(lcd, FB_BLANK_UNBLANK); dev_info(&lcd->ld->dev, "-%s\n", __func__); - set_dsim_lcd_enabled(); + set_dsim_lcd_enabled(1); return ; } @@ -496,6 +467,7 @@ static int s6e8ax0_probe(struct device *dev) } lcd->dev = dev; + lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = DEFAULT_GAMMA_LEVEL; @@ -577,7 +549,6 @@ static void s6e8ax0_shutdown(struct device *dev) static struct mipi_lcd_driver s6e8ax0_mipi_driver = { .name = "s6e8aa0", - .set_link = s6e8ax0_set_link, .probe = s6e8ax0_probe, .remove = __devexit_p(s6e8ax0_remove), .shutdown = s6e8ax0_shutdown, diff --git a/drivers/video/samsung/s6e8aa0_param.h b/drivers/video/samsung/s6e8aa0_param.h index b40932d..3ac11ad 100644 --- a/drivers/video/samsung/s6e8aa0_param.h +++ b/drivers/video/samsung/s6e8aa0_param.h @@ -55,13 +55,13 @@ enum { #define ELVSS_OFFSET_300 0x00 #define ELVSS_OFFSET_200 0x08 #define ELVSS_OFFSET_160 0x0D -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) #define ELVSS_OFFSET_100 0x11 #else #define ELVSS_OFFSET_100 0x12 #endif -#if defined(CONFIG_MACH_Q1_BD) +#if defined(CONFIG_S6E8AA0_AMS529HA01) #define ELVSS_OFFSET_MAX ELVSS_OFFSET_300 #define ELVSS_OFFSET_1 ELVSS_OFFSET_200 #define ELVSS_OFFSET_2 ELVSS_OFFSET_160 diff --git a/drivers/video/samsung/smart_dimming.c b/drivers/video/samsung/smart_dimming.c index a1c428d..d356009 100644 --- a/drivers/video/samsung/smart_dimming.c +++ b/drivers/video/samsung/smart_dimming.c @@ -20,7 +20,7 @@ #define V1_255_calc_param (V1_255_div_1000 / VREG_OUT_1000) #endif -#ifdef CONFIG_MACH_Q1_BD +#if defined(CONFIG_S6E8AA0_AMS529HA01) #define VREG_OUT_1000 4600 #else #ifdef CONFIG_AID_DIMMING -- cgit v1.1