Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 283051
b: refs/heads/master
c: b148a27
h: refs/heads/master
i:
  283049: 55aaecb
  283047: 8e1c5f2
v: v3
  • Loading branch information
Donghwa Lee authored and Linus Torvalds committed Jan 11, 2012
1 parent 87b5e6c commit 9c72e11
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 81178e021689bf86c328f144aa0f0e1b50f5e94c
refs/heads/master: b148a272944549c2b9f180b53c4fcf35aca4ed3e
71 changes: 59 additions & 12 deletions trunk/drivers/video/backlight/ld9040.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/lcd.h>
#include <linux/backlight.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>

#include "ld9040_gamma.h"

Expand All @@ -53,8 +54,51 @@ struct ld9040 {
struct lcd_device *ld;
struct backlight_device *bd;
struct lcd_platform_data *lcd_pd;

struct mutex lock;
bool enabled;
};

static struct regulator_bulk_data supplies[] = {
{ .supply = "vdd3", },
{ .supply = "vci", },
};

static void ld9040_regulator_enable(struct ld9040 *lcd)
{
int ret = 0;
struct lcd_platform_data *pd = NULL;

pd = lcd->lcd_pd;
mutex_lock(&lcd->lock);
if (!lcd->enabled) {
ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies);
if (ret)
goto out;

lcd->enabled = true;
}
mdelay(pd->power_on_delay);
out:
mutex_unlock(&lcd->lock);
}

static void ld9040_regulator_disable(struct ld9040 *lcd)
{
int ret = 0;

mutex_lock(&lcd->lock);
if (lcd->enabled) {
ret = regulator_bulk_disable(ARRAY_SIZE(supplies), supplies);
if (ret)
goto out;

lcd->enabled = false;
}
out:
mutex_unlock(&lcd->lock);
}

static const unsigned short seq_swreset[] = {
0x01, COMMAND_ONLY,
ENDDEF, 0x00
Expand Down Expand Up @@ -532,13 +576,8 @@ static int ld9040_power_on(struct ld9040 *lcd)
return -EFAULT;
}

if (!pd->power_on) {
dev_err(lcd->dev, "power_on is NULL.\n");
return -EFAULT;
} else {
pd->power_on(lcd->ld, 1);
mdelay(pd->power_on_delay);
}
/* lcd power on */
ld9040_regulator_enable(lcd);

if (!pd->reset) {
dev_err(lcd->dev, "reset is NULL.\n");
Expand Down Expand Up @@ -582,11 +621,8 @@ static int ld9040_power_off(struct ld9040 *lcd)

mdelay(pd->power_off_delay);

if (!pd->power_on) {
dev_err(lcd->dev, "power_on is NULL.\n");
return -EFAULT;
} else
pd->power_on(lcd->ld, 0);
/* lcd power off */
ld9040_regulator_disable(lcd);

return 0;
}
Expand Down Expand Up @@ -693,6 +729,14 @@ static int ld9040_probe(struct spi_device *spi)
goto out_free_lcd;
}

mutex_init(&lcd->lock);

ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies);
if (ret) {
dev_err(lcd->dev, "Failed to get regulators: %d\n", ret);
goto out_free_lcd;
}

ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops);
if (IS_ERR(ld)) {
ret = PTR_ERR(ld);
Expand Down Expand Up @@ -739,6 +783,8 @@ static int ld9040_probe(struct spi_device *spi)
out_unregister_lcd:
lcd_device_unregister(lcd->ld);
out_free_lcd:
regulator_bulk_free(ARRAY_SIZE(supplies), supplies);

kfree(lcd);
return ret;
}
Expand All @@ -750,6 +796,7 @@ static int __devexit ld9040_remove(struct spi_device *spi)
ld9040_power(lcd, FB_BLANK_POWERDOWN);
backlight_device_unregister(lcd->bd);
lcd_device_unregister(lcd->ld);
regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
kfree(lcd);

return 0;
Expand Down

0 comments on commit 9c72e11

Please sign in to comment.