Skip to content

Commit

Permalink
ARM: h1940: Fix backlight and LCD power functions
Browse files Browse the repository at this point in the history
Current implementation of LCD and backlight power control functions
is not complete, as result PDA consumes power in suspend.
Fix this issue by managing state of some latch bits, just like
WinMobile does.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Vasily Khoruzhick authored and Ben Dooks committed Oct 29, 2010
1 parent 48cd65a commit 53193dd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-s3c2410/include/mach/h1940-latch.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/* SD layer latch */

#define H1940_LATCH_SDQ1 H1940_LATCH_GPIO(0)
#define H1940_LATCH_LCD_P0 H1940_LATCH_GPIO(0)
#define H1940_LATCH_LCD_P1 H1940_LATCH_GPIO(1)
#define H1940_LATCH_LCD_P2 H1940_LATCH_GPIO(2)
#define H1940_LATCH_LCD_P3 H1940_LATCH_GPIO(3)
Expand Down
80 changes: 65 additions & 15 deletions arch/arm/mach-s3c2410/mach-h1940.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,7 @@ static struct s3c2410_uartcfg h1940_uartcfgs[] __initdata = {

/* Board control latch control */

static unsigned int latch_state = H1940_LATCH_BIT(H1940_LATCH_LCD_P4) |
H1940_LATCH_BIT(H1940_LATCH_SM803_ENABLE) |
H1940_LATCH_BIT(H1940_LATCH_SDQ1) |
H1940_LATCH_BIT(H1940_LATCH_LCD_P1) |
H1940_LATCH_BIT(H1940_LATCH_LCD_P2) |
H1940_LATCH_BIT(H1940_LATCH_LCD_P3) |
H1940_LATCH_BIT(H1940_LATCH_MAX1698_nSHUTDOWN);
static unsigned int latch_state;

static void h1940_latch_control(unsigned int clear, unsigned int set)
{
Expand Down Expand Up @@ -275,22 +269,40 @@ static int h1940_backlight_init(struct device *dev)
gpio_direction_output(S3C2410_GPB(0), 0);
s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);

return 0;
}

static int h1940_backlight_notify(struct device *dev, int brightness)
{
if (!brightness) {
gpio_direction_output(S3C2410_GPB(0), 1);
gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
} else {
gpio_direction_output(S3C2410_GPB(0), 0);
s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 1);
}
return brightness;
}

static void h1940_backlight_exit(struct device *dev)
{
gpio_direction_output(S3C2410_GPB(0), 1);
gpio_set_value(H1940_LATCH_MAX1698_nSHUTDOWN, 0);
}


static struct platform_pwm_backlight_data backlight_data = {
.pwm_id = 0,
.max_brightness = 100,
.dft_brightness = 50,
/* tcnt = 0x31 */
.pwm_period_ns = 36296,
.init = h1940_backlight_init,
.notify = h1940_backlight_notify,
.exit = h1940_backlight_exit,
};

Expand All @@ -309,19 +321,37 @@ static void h1940_lcd_power_set(struct plat_lcd_data *pd,
int value;

if (!power) {
/* set to 3ec */
gpio_direction_output(S3C2410_GPC(0), 0);
gpio_set_value(S3C2410_GPC(0), 0);
/* wait for 3ac */
do {
value = gpio_get_value(S3C2410_GPC(6));
} while (value);
/* set to 38c */
gpio_direction_output(S3C2410_GPC(5), 0);

gpio_set_value(H1940_LATCH_LCD_P2, 0);
gpio_set_value(H1940_LATCH_LCD_P3, 0);
gpio_set_value(H1940_LATCH_LCD_P4, 0);

gpio_direction_output(S3C2410_GPC(1), 0);
gpio_direction_output(S3C2410_GPC(4), 0);

gpio_set_value(H1940_LATCH_LCD_P1, 0);
gpio_set_value(H1940_LATCH_LCD_P0, 0);

gpio_set_value(S3C2410_GPC(5), 0);

} else {
/* Set to 3ac */
gpio_direction_output(S3C2410_GPC(5), 1);
/* Set to 3ad */
gpio_direction_output(S3C2410_GPC(0), 1);
gpio_set_value(H1940_LATCH_LCD_P0, 1);
gpio_set_value(H1940_LATCH_LCD_P1, 1);

s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2));
s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2));

gpio_set_value(S3C2410_GPC(5), 1);
gpio_set_value(S3C2410_GPC(0), 1);

gpio_set_value(H1940_LATCH_LCD_P3, 1);
gpio_set_value(H1940_LATCH_LCD_P2, 1);
gpio_set_value(H1940_LATCH_LCD_P4, 1);
}
}

Expand Down Expand Up @@ -366,6 +396,8 @@ static void __init h1940_map_io(void)
#endif
s3c_pm_init();

/* Add latch gpio chip, set latch initial value */
h1940_latch_control(0, 0);
WARN_ON(gpiochip_add(&h1940_latch_gpiochip));
}

Expand Down Expand Up @@ -404,9 +436,27 @@ static void __init h1940_init(void)
writel(tmp, S3C2410_UPLLCON);

gpio_request(S3C2410_GPC(0), "LCD power");
gpio_request(S3C2410_GPC(1), "LCD power");
gpio_request(S3C2410_GPC(4), "LCD power");
gpio_request(S3C2410_GPC(5), "LCD power");
gpio_request(S3C2410_GPC(6), "LCD power");
gpio_request(H1940_LATCH_LCD_P0, "LCD power");
gpio_request(H1940_LATCH_LCD_P1, "LCD power");
gpio_request(H1940_LATCH_LCD_P2, "LCD power");
gpio_request(H1940_LATCH_LCD_P3, "LCD power");
gpio_request(H1940_LATCH_LCD_P4, "LCD power");
gpio_request(H1940_LATCH_MAX1698_nSHUTDOWN, "LCD power");
gpio_direction_output(S3C2410_GPC(0), 0);
gpio_direction_output(S3C2410_GPC(1), 0);
gpio_direction_output(S3C2410_GPC(4), 0);
gpio_direction_output(S3C2410_GPC(5), 0);
gpio_direction_input(S3C2410_GPC(6));
gpio_direction_output(H1940_LATCH_LCD_P0, 0);
gpio_direction_output(H1940_LATCH_LCD_P1, 0);
gpio_direction_output(H1940_LATCH_LCD_P2, 0);
gpio_direction_output(H1940_LATCH_LCD_P3, 0);
gpio_direction_output(H1940_LATCH_LCD_P4, 0);
gpio_direction_output(H1940_LATCH_MAX1698_nSHUTDOWN, 0);

gpio_request(H1940_LATCH_USB_DP, "USB pullup");
gpio_direction_output(H1940_LATCH_USB_DP, 0);
Expand Down

0 comments on commit 53193dd

Please sign in to comment.