Skip to content

Commit 37f4dd1

Browse files
author
Laurent Pinchart
committed
ARM: mach-shmobile: ag5evm: Use the backlight API for brightness control
Don't hook up brightness control in the display on/off operations, use the backlight API instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Simon Horman <horms@verge.net.au>
1 parent f70f471 commit 37f4dd1

1 file changed

Lines changed: 29 additions & 16 deletions

File tree

‎arch/arm/mach-shmobile/board-ag5evm.c‎

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,38 @@ static unsigned char lcd_backlight_seq[3][2] = {
295295
{ 0x03, 0x01 },
296296
};
297297

298-
static void lcd_backlight_on(void)
298+
static int lcd_backlight_set_brightness(int brightness)
299299
{
300-
struct i2c_adapter *a;
300+
struct i2c_adapter *adap;
301301
struct i2c_msg msg;
302-
int k;
302+
unsigned int i;
303+
int ret;
304+
305+
if (brightness == 0) {
306+
/* Reset the chip */
307+
gpio_set_value(GPIO_PORT235, 0);
308+
mdelay(24);
309+
gpio_set_value(GPIO_PORT235, 1);
310+
return 0;
311+
}
312+
313+
adap = i2c_get_adapter(1);
314+
if (adap == NULL)
315+
return -ENODEV;
303316

304-
a = i2c_get_adapter(1);
305-
for (k = 0; a && k < 3; k++) {
317+
for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) {
306318
msg.addr = 0x6d;
307-
msg.buf = &lcd_backlight_seq[k][0];
319+
msg.buf = &lcd_backlight_seq[i][0];
308320
msg.len = 2;
309321
msg.flags = 0;
310-
if (i2c_transfer(a, &msg, 1) != 1)
322+
323+
ret = i2c_transfer(adap, &msg, 1);
324+
if (ret < 0)
311325
break;
312326
}
313-
}
314327

315-
static void lcd_backlight_reset(void)
316-
{
317-
gpio_set_value(GPIO_PORT235, 0);
318-
mdelay(24);
319-
gpio_set_value(GPIO_PORT235, 1);
328+
i2c_put_adapter(adap);
329+
return ret < 0 ? ret : 0;
320330
}
321331

322332
/* LCDC0 */
@@ -348,8 +358,11 @@ static struct sh_mobile_lcdc_info lcdc0_info = {
348358
.panel_cfg = {
349359
.width = 44,
350360
.height = 79,
351-
.display_on = lcd_backlight_on,
352-
.display_off = lcd_backlight_reset,
361+
},
362+
.bl_info = {
363+
.name = "sh_mobile_lcdc_bl",
364+
.max_brightness = 1,
365+
.set_brightness = lcd_backlight_set_brightness,
353366
},
354367
.tx_dev = &mipidsi0_device,
355368
}
@@ -622,7 +635,7 @@ static void __init ag5evm_init(void)
622635
/* LCD backlight controller */
623636
gpio_request(GPIO_PORT235, NULL); /* RESET */
624637
gpio_direction_output(GPIO_PORT235, 0);
625-
lcd_backlight_reset();
638+
lcd_backlight_set_brightness(0);
626639

627640
/* enable SDHI0 on CN15 [SD I/F] */
628641
gpio_request(GPIO_FN_SDHIWP0, NULL);

0 commit comments

Comments
 (0)