From 1552c51b244b71d57b73edef14047682e70717ca Mon Sep 17 00:00:00 2001 From: Balaji Rao Date: Thu, 20 Nov 2008 19:46:50 +0000 Subject: pcf50633-backlight.patch Move backlight support out of pcf50633 driver. backlight support now uses corgibl aka generic backlight support. Set CONFIG_BACKLIGHT_CORGI=y to use it. --- arch/arm/mach-s3c2440/mach-gta02.c | 60 +++++++++++++++--- drivers/i2c/chips/pcf50633.c | 123 +------------------------------------ drivers/video/display/jbt6k74.c | 3 + include/linux/jbt6k74.h | 3 + include/linux/pcf50633.h | 4 -- 5 files changed, 57 insertions(+), 136 deletions(-) diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c index 96f4502b2b2..a0cebaec1b9 100644 --- a/arch/arm/mach-s3c2440/mach-gta02.c +++ b/arch/arm/mach-s3c2440/mach-gta02.c @@ -46,7 +46,7 @@ #include #include - +#include #include #include @@ -683,8 +683,6 @@ struct pcf50633_platform_data gta02_pcf_pdata = { }, }, }, - .defer_resume_backlight = 1, - .resume_backlight_ramp_speed = 5, .attach_child_devices = gta02_pcf50633_attach_child_devices, .regulator_registered = gta02_pcf50633_regulator_registered, @@ -984,24 +982,66 @@ static struct s3c2410_ts_mach_info gta02_ts_cfg = { }, }; +/* Backlight control */ + +static void gta02_bl_set_intensity(int intensity) +{ + struct pcf50633_data *pcf = gta02_pcf_pdata.pcf; + + int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); + int ret; + + if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 3)) + old_intensity = 0; + + /* + * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60) + * if seen, you have to re-enable the LED unit + */ + if (!intensity || !old_intensity) + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0); + + if (!intensity) /* illegal to set LEDOUT to 0 */ + ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2); + else + ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, + intensity); + + if (intensity) + pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 2); +} + +static struct generic_bl_info gta02_bl_info = { + .name = "gta02-bl", + .max_intensity = 0xff, + .default_intensity = 0xff, + .set_bl_intensity = gta02_bl_set_intensity, +}; + +static struct platform_device gta02_bl_dev = { + .name = "generic-bl", + .id = 1, + .dev = { + .platform_data = >a02_bl_info, + }, +}; + /* SPI: LCM control interface attached to Glamo3362 */ static void gta02_jbt6k74_reset(int devidx, int level) { glamo_lcm_reset(level); -} +} -/* finally bring up deferred backlight resume now LCM is resumed itself */ - -static void gta02_jbt6k74_resuming(int devidx) +static void gta02_jbt6k74_probe_completed(struct device *dev) { - pcf50633_backlight_resume(gta02_pcf_pdata.pcf); + gta02_bl_dev.dev.parent = dev; + platform_device_register(>a02_bl_dev); } - const struct jbt6k74_platform_data jbt6k74_pdata = { .reset = gta02_jbt6k74_reset, - .resuming = gta02_jbt6k74_resuming, + .probe_completed = gta02_jbt6k74_probe_completed, }; static struct spi_board_info gta02_spi_board_info[] = { diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c index 568369141f0..87f7a844ee4 100644 --- a/drivers/i2c/chips/pcf50633.c +++ b/drivers/i2c/chips/pcf50633.c @@ -24,7 +24,6 @@ * - charging control for main and backup battery * - rtc / alarm * - adc driver (hw_sensors like) - * - backlight * */ @@ -42,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -1812,68 +1810,6 @@ static struct rtc_class_ops pcf50633_rtc_ops = { .set_alarm = pcf50633_rtc_set_alarm, }; -/*********************************************************************** - * Backlight device - ***********************************************************************/ - -static int pcf50633bl_get_intensity(struct backlight_device *bd) -{ - struct pcf50633_data *pcf = bl_get_data(bd); - int intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); - - return intensity & 0x3f; -} - -static int __pcf50633bl_set_intensity(struct pcf50633_data *pcf, int intensity) -{ - int old_intensity = pcf50633_reg_read(pcf, PCF50633_REG_LEDOUT); - u_int8_t ledena = 2; - int ret; - - if (!(pcf50633_reg_read(pcf, PCF50633_REG_LEDENA) & 1)) - old_intensity = 0; - - if ((pcf->backlight->props.power != FB_BLANK_UNBLANK) || - (pcf->backlight->props.fb_blank != FB_BLANK_UNBLANK)) - intensity = 0; - - /* - * The PCF50633 cannot handle LEDOUT = 0 (datasheet p60) - * if seen, you have to re-enable the LED unit - */ - - if (!intensity || !old_intensity) - reg_write(pcf, PCF50633_REG_LEDENA, 0); - - if (!intensity) /* illegal to set LEDOUT to 0 */ - ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2); - else - ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, - intensity); - - if (intensity) - reg_write(pcf, PCF50633_REG_LEDENA, 2); - - return ret; -} - -static int pcf50633bl_set_intensity(struct backlight_device *bd) -{ - struct pcf50633_data *pcf = bl_get_data(bd); - int intensity = bd->props.brightness; - - if ((bd->props.power != FB_BLANK_UNBLANK) || - (bd->props.fb_blank != FB_BLANK_UNBLANK)) - intensity = 0; - - return __pcf50633bl_set_intensity(pcf, intensity); -} - -static struct backlight_ops pcf50633bl_ops = { - .get_brightness = pcf50633bl_get_intensity, - .update_status = pcf50633bl_set_intensity, -}; - /* * Charger type */ @@ -2116,6 +2052,7 @@ static int pcf50633_probe(struct i2c_client *client, const struct i2c_device_id /* we want SECOND to kick for the coldplug initialisation */ pcf50633_reg_write(pcf, PCF50633_REG_INT1M, 0x00); + pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00); pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00); pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00); @@ -2153,22 +2090,6 @@ static int pcf50633_probe(struct i2c_client *client, const struct i2c_device_id } } - if (pcf->pdata->used_features & PCF50633_FEAT_PWM_BL) { - pcf->backlight = backlight_device_register("pcf50633-bl", - &client->dev, - pcf, - &pcf50633bl_ops); - if (!pcf->backlight) - goto exit_rtc; - - pcf->backlight->props.max_brightness = 0x3f; - pcf->backlight->props.power = FB_BLANK_UNBLANK; - pcf->backlight->props.fb_blank = FB_BLANK_UNBLANK; - pcf->backlight->props.brightness = - pcf->backlight->props.max_brightness; - backlight_update_status(pcf->backlight); - } - if (pcf->pdata->flag_use_apm_emulation) apm_get_power_status = NULL; @@ -2234,9 +2155,6 @@ static int pcf50633_remove(struct i2c_client *client) input_unregister_device(pcf->input_dev); - if (pcf->pdata->used_features & PCF50633_FEAT_PWM_BL) - backlight_device_unregister(pcf->backlight); - if (pcf->pdata->used_features & PCF50633_FEAT_RTC) rtc_device_unregister(pcf->rtc); @@ -2387,11 +2305,6 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) __reg_write(pcf, regulator_registers[i] + 1, tmp & 0xfe); } - /* turn off the backlight */ - __reg_write(pcf, PCF50633_REG_LEDDIM, 0); - __reg_write(pcf, PCF50633_REG_LEDOUT, 2); - __reg_write(pcf, PCF50633_REG_LEDENA, 0x00); - /* set interrupt masks so only those sources we want to wake * us are able to */ @@ -2450,29 +2363,6 @@ int pcf50633_wait_for_ready(struct pcf50633_data *pcf, int timeout_ms, } EXPORT_SYMBOL_GPL(pcf50633_wait_for_ready); -/* - * if backlight resume is selected to be deferred by platform, then it - * can call this to finally reset backlight status (after LCM is resumed - * for example - */ - -void pcf50633_backlight_resume(struct pcf50633_data *pcf) -{ - dev_err(&pcf->client->dev, "pcf50633_backlight_resume\n"); - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x00); - pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, 0x01); - pcf50633_reg_write(pcf, PCF50633_REG_LEDENA, 0x01); - pcf50633_reg_write(pcf, PCF50633_REG_LEDOUT, 0x3f); - - /* platform defines resume ramp speed */ - pcf50633_reg_write(pcf, PCF50633_REG_LEDDIM, - pcf->pdata->resume_backlight_ramp_speed); - - __pcf50633bl_set_intensity(pcf, pcf->backlight->props.brightness); -} -EXPORT_SYMBOL_GPL(pcf50633_backlight_resume); - - static int pcf50633_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -2493,13 +2383,6 @@ static int pcf50633_resume(struct device *dev) memcpy(misc, pcf->standby_regs.misc, sizeof(pcf->standby_regs.misc)); - if (pcf->pdata->defer_resume_backlight) { - misc[PCF50633_REG_LEDOUT - PCF50633_REG_AUTOOUT] = 1; - misc[PCF50633_REG_LEDENA - PCF50633_REG_AUTOOUT] = 0x20; - misc[PCF50633_REG_LEDCTL - PCF50633_REG_AUTOOUT] = 1; - misc[PCF50633_REG_LEDDIM - PCF50633_REG_AUTOOUT] = 1; - } - /* regulator voltages and enable states */ ret = i2c_smbus_write_i2c_block_data(pcf->client, PCF50633_REG_AUTOOUT, @@ -2508,10 +2391,6 @@ static int pcf50633_resume(struct device *dev) if (ret) dev_err(dev, "Failed to restore misc :-( %d\n", ret); - /* platform can choose to defer backlight bringup */ - if (!pcf->pdata->defer_resume_backlight) - pcf50633_backlight_resume(pcf); - /* regulator voltages and enable states */ ret = i2c_smbus_write_i2c_block_data(pcf->client, PCF50633_REG_LDO1OUT, diff --git a/drivers/video/display/jbt6k74.c b/drivers/video/display/jbt6k74.c index 754ac02213b..cd2e2713f51 100644 --- a/drivers/video/display/jbt6k74.c +++ b/drivers/video/display/jbt6k74.c @@ -697,6 +697,9 @@ static int __devinit jbt_probe(struct spi_device *spi) goto err_sysfs; } + if (jbt6k74_pdata->probe_completed) + jbt6k74_pdata->probe_completed(&spi->dev); + return 0; err_sysfs: diff --git a/include/linux/jbt6k74.h b/include/linux/jbt6k74.h index 50e39347c20..1023eac429d 100644 --- a/include/linux/jbt6k74.h +++ b/include/linux/jbt6k74.h @@ -2,10 +2,13 @@ #define __JBT6K74_H__ #include +#include + struct jbt6k74_platform_data { void (*reset)(int devindex, int level); void (*resuming)(int devindex); /* called when LCM is resumed */ + void (*probe_completed)(struct device *dev); }; #endif diff --git a/include/linux/pcf50633.h b/include/linux/pcf50633.h index 2968191d0a0..fbfb2601106 100644 --- a/include/linux/pcf50633.h +++ b/include/linux/pcf50633.h @@ -201,10 +201,6 @@ struct pcf50633_platform_data { } charger; pmu_cb cb; - /* post-resume backlight bringup */ - int defer_resume_backlight; - u8 resume_backlight_ramp_speed; - struct regulator_init_data reg_init_data[__NUM_PCF50633_REGULATORS]; /* Called when a regulator has been registered */ -- cgit v1.2.3