Commit b64dc5a4 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight

* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight:
  backlight: Rename the corgi backlight driver to generic
  backlight: add support for Toppoly TDO35S series to tdo24m lcd driver
  backlight: Add suspend/resume support to the backlight core
  bd->props.brightness doesn't reflect the actual backlight level.
  backlight: Support VGA/QVGA mode switching in tosa_lcd
  backlight: Catch invalid input in sysfs attributes
  backlight: Value of ILI9320_RGB_IF2 register should not be hardcoded
  backlight: crbllcd_bl - Use platform_device_register_simple()
  backlight: progear_bl - Use platform_device_register_simple()
  backlight: hp680_bl - Use platform_device_register_simple()
parents 73d59314 d00ba726
...@@ -52,11 +52,11 @@ config LCD_ILI9320 ...@@ -52,11 +52,11 @@ config LCD_ILI9320
then say y to include a power driver for it. then say y to include a power driver for it.
config LCD_TDO24M config LCD_TDO24M
tristate "Toppoly TDO24M LCD Panels support" tristate "Toppoly TDO24M and TDO35S LCD Panels support"
depends on LCD_CLASS_DEVICE && SPI_MASTER depends on LCD_CLASS_DEVICE && SPI_MASTER
default n default n
help help
If you have a Toppoly TDO24M series LCD panel, say y here to If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
include the support for it. include the support for it.
config LCD_VGG2432A4 config LCD_VGG2432A4
...@@ -123,17 +123,14 @@ config BACKLIGHT_ATMEL_PWM ...@@ -123,17 +123,14 @@ config BACKLIGHT_ATMEL_PWM
To compile this driver as a module, choose M here: the module will be To compile this driver as a module, choose M here: the module will be
called atmel-pwm-bl. called atmel-pwm-bl.
config BACKLIGHT_CORGI config BACKLIGHT_GENERIC
tristate "Generic (aka Sharp Corgi) Backlight Driver (DEPRECATED)" tristate "Generic (aka Sharp Corgi) Backlight Driver"
depends on BACKLIGHT_CLASS_DEVICE depends on BACKLIGHT_CLASS_DEVICE
default n default y
help help
Say y to enable the generic platform backlight driver previously Say y to enable the generic platform backlight driver previously
known as the Corgi backlight driver. If you have a Sharp Zaurus known as the Corgi backlight driver. If you have a Sharp Zaurus
SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. SL-C7xx, SL-Cxx00 or SL-6000x say y.
Note: this driver is marked as deprecated, try enable SPI and
use the new corgi_lcd driver with integrated backlight control
config BACKLIGHT_LOCOMO config BACKLIGHT_LOCOMO
tristate "Sharp LOCOMO LCD/Backlight Driver" tristate "Sharp LOCOMO LCD/Backlight Driver"
......
...@@ -11,7 +11,7 @@ obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o ...@@ -11,7 +11,7 @@ obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
......
...@@ -40,6 +40,10 @@ static int fb_notifier_callback(struct notifier_block *self, ...@@ -40,6 +40,10 @@ static int fb_notifier_callback(struct notifier_block *self,
if (!bd->ops->check_fb || if (!bd->ops->check_fb ||
bd->ops->check_fb(evdata->info)) { bd->ops->check_fb(evdata->info)) {
bd->props.fb_blank = *(int *)evdata->data; bd->props.fb_blank = *(int *)evdata->data;
if (bd->props.fb_blank == FB_BLANK_UNBLANK)
bd->props.state &= ~BL_CORE_FBBLANK;
else
bd->props.state |= BL_CORE_FBBLANK;
backlight_update_status(bd); backlight_update_status(bd);
} }
mutex_unlock(&bd->ops_lock); mutex_unlock(&bd->ops_lock);
...@@ -80,20 +84,18 @@ static ssize_t backlight_show_power(struct device *dev, ...@@ -80,20 +84,18 @@ static ssize_t backlight_show_power(struct device *dev,
static ssize_t backlight_store_power(struct device *dev, static ssize_t backlight_store_power(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
int rc = -ENXIO; int rc;
char *endp;
struct backlight_device *bd = to_backlight_device(dev); struct backlight_device *bd = to_backlight_device(dev);
int power = simple_strtoul(buf, &endp, 0); unsigned long power;
size_t size = endp - buf;
if (*endp && isspace(*endp)) rc = strict_strtoul(buf, 0, &power);
size++; if (rc)
if (size != count) return rc;
return -EINVAL;
rc = -ENXIO;
mutex_lock(&bd->ops_lock); mutex_lock(&bd->ops_lock);
if (bd->ops) { if (bd->ops) {
pr_debug("backlight: set power to %d\n", power); pr_debug("backlight: set power to %lu\n", power);
if (bd->props.power != power) { if (bd->props.power != power) {
bd->props.power = power; bd->props.power = power;
backlight_update_status(bd); backlight_update_status(bd);
...@@ -116,28 +118,25 @@ static ssize_t backlight_show_brightness(struct device *dev, ...@@ -116,28 +118,25 @@ static ssize_t backlight_show_brightness(struct device *dev,
static ssize_t backlight_store_brightness(struct device *dev, static ssize_t backlight_store_brightness(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
int rc = -ENXIO; int rc;
char *endp;
struct backlight_device *bd = to_backlight_device(dev); struct backlight_device *bd = to_backlight_device(dev);
int brightness = simple_strtoul(buf, &endp, 0); unsigned long brightness;
size_t size = endp - buf;
rc = strict_strtoul(buf, 0, &brightness);
if (rc)
return rc;
if (*endp && isspace(*endp)) rc = -ENXIO;
size++;
if (size != count)
return -EINVAL;
mutex_lock(&bd->ops_lock); mutex_lock(&bd->ops_lock);
if (bd->ops) { if (bd->ops) {
if (brightness > bd->props.max_brightness) if (brightness > bd->props.max_brightness)
rc = -EINVAL; rc = -EINVAL;
else { else {
pr_debug("backlight: set brightness to %d\n", pr_debug("backlight: set brightness to %lu\n",
brightness); brightness);
if (bd->props.brightness != brightness) {
bd->props.brightness = brightness; bd->props.brightness = brightness;
backlight_update_status(bd); backlight_update_status(bd);
}
rc = count; rc = count;
} }
} }
...@@ -170,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev, ...@@ -170,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev,
static struct class *backlight_class; static struct class *backlight_class;
static int backlight_suspend(struct device *dev, pm_message_t state)
{
struct backlight_device *bd = to_backlight_device(dev);
if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
mutex_lock(&bd->ops_lock);
bd->props.state |= BL_CORE_SUSPENDED;
backlight_update_status(bd);
mutex_unlock(&bd->ops_lock);
}
return 0;
}
static int backlight_resume(struct device *dev)
{
struct backlight_device *bd = to_backlight_device(dev);
if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
mutex_lock(&bd->ops_lock);
bd->props.state &= ~BL_CORE_SUSPENDED;
backlight_update_status(bd);
mutex_unlock(&bd->ops_lock);
}
return 0;
}
static void bl_device_release(struct device *dev) static void bl_device_release(struct device *dev)
{ {
struct backlight_device *bd = to_backlight_device(dev); struct backlight_device *bd = to_backlight_device(dev);
...@@ -286,6 +313,8 @@ static int __init backlight_class_init(void) ...@@ -286,6 +313,8 @@ static int __init backlight_class_init(void)
} }
backlight_class->dev_attrs = bl_device_attributes; backlight_class->dev_attrs = bl_device_attributes;
backlight_class->suspend = backlight_suspend;
backlight_class->resume = backlight_resume;
return 0; return 0;
} }
......
...@@ -259,22 +259,18 @@ static int __init cr_backlight_init(void) ...@@ -259,22 +259,18 @@ static int __init cr_backlight_init(void)
{ {
int ret = platform_driver_register(&cr_backlight_driver); int ret = platform_driver_register(&cr_backlight_driver);
if (!ret) { if (ret)
crp = platform_device_alloc("cr_backlight", -1); return ret;
if (!crp)
return -ENOMEM;
ret = platform_device_add(crp);
if (ret) { crp = platform_device_register_simple("cr_backlight", -1, NULL, 0);
platform_device_put(crp); if (IS_ERR(crp)) {
platform_driver_unregister(&cr_backlight_driver); platform_driver_unregister(&cr_backlight_driver);
} return PTR_ERR(crp);
} }
printk("Carillo Ranch Backlight Driver Initialized.\n"); printk("Carillo Ranch Backlight Driver Initialized.\n");
return ret; return 0;
} }
static void __exit cr_backlight_exit(void) static void __exit cr_backlight_exit(void)
......
/* /*
* Backlight Driver for Sharp Zaurus Handhelds (various models) * Generic Backlight Driver
* *
* Copyright (c) 2004-2006 Richard Purdie * Copyright (c) 2004-2008 Richard Purdie
*
* Based on Sharp's 2.4 Backlight Driver
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -19,31 +17,29 @@ ...@@ -19,31 +17,29 @@
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/backlight.h> #include <linux/backlight.h>
static int corgibl_intensity; static int genericbl_intensity;
static struct backlight_properties corgibl_data; static struct backlight_device *generic_backlight_device;
static struct backlight_device *corgi_backlight_device;
static struct generic_bl_info *bl_machinfo; static struct generic_bl_info *bl_machinfo;
static unsigned long corgibl_flags; /* Flag to signal when the battery is low */
#define CORGIBL_SUSPENDED 0x01 #define GENERICBL_BATTLOW BL_CORE_DRIVER1
#define CORGIBL_BATTLOW 0x02
static int corgibl_send_intensity(struct backlight_device *bd) static int genericbl_send_intensity(struct backlight_device *bd)
{ {
int intensity = bd->props.brightness; int intensity = bd->props.brightness;
if (bd->props.power != FB_BLANK_UNBLANK) if (bd->props.power != FB_BLANK_UNBLANK)
intensity = 0; intensity = 0;
if (bd->props.fb_blank != FB_BLANK_UNBLANK) if (bd->props.state & BL_CORE_FBBLANK)
intensity = 0; intensity = 0;
if (corgibl_flags & CORGIBL_SUSPENDED) if (bd->props.state & BL_CORE_SUSPENDED)
intensity = 0; intensity = 0;
if (corgibl_flags & CORGIBL_BATTLOW) if (bd->props.state & GENERICBL_BATTLOW)
intensity &= bl_machinfo->limit_mask; intensity &= bl_machinfo->limit_mask;
bl_machinfo->set_bl_intensity(intensity); bl_machinfo->set_bl_intensity(intensity);
corgibl_intensity = intensity; genericbl_intensity = intensity;
if (bl_machinfo->kick_battery) if (bl_machinfo->kick_battery)
bl_machinfo->kick_battery(); bl_machinfo->kick_battery();
...@@ -51,32 +47,9 @@ static int corgibl_send_intensity(struct backlight_device *bd) ...@@ -51,32 +47,9 @@ static int corgibl_send_intensity(struct backlight_device *bd)
return 0; return 0;
} }
#ifdef CONFIG_PM static int genericbl_get_intensity(struct backlight_device *bd)
static int corgibl_suspend(struct platform_device *pdev, pm_message_t state)
{ {
struct backlight_device *bd = platform_get_drvdata(pdev); return genericbl_intensity;
corgibl_flags |= CORGIBL_SUSPENDED;
backlight_update_status(bd);
return 0;
}
static int corgibl_resume(struct platform_device *pdev)
{
struct backlight_device *bd = platform_get_drvdata(pdev);
corgibl_flags &= ~CORGIBL_SUSPENDED;
backlight_update_status(bd);
return 0;
}
#else
#define corgibl_suspend NULL
#define corgibl_resume NULL
#endif
static int corgibl_get_intensity(struct backlight_device *bd)
{
return corgibl_intensity;
} }
/* /*
...@@ -85,24 +58,29 @@ static int corgibl_get_intensity(struct backlight_device *bd) ...@@ -85,24 +58,29 @@ static int corgibl_get_intensity(struct backlight_device *bd)
*/ */
void corgibl_limit_intensity(int limit) void corgibl_limit_intensity(int limit)
{ {
struct backlight_device *bd = generic_backlight_device;
mutex_lock(&bd->ops_lock);
if (limit) if (limit)
corgibl_flags |= CORGIBL_BATTLOW; bd->props.state |= GENERICBL_BATTLOW;
else else
corgibl_flags &= ~CORGIBL_BATTLOW; bd->props.state &= ~GENERICBL_BATTLOW;
backlight_update_status(corgi_backlight_device); backlight_update_status(generic_backlight_device);
mutex_unlock(&bd->ops_lock);
} }
EXPORT_SYMBOL(corgibl_limit_intensity); EXPORT_SYMBOL(corgibl_limit_intensity);
static struct backlight_ops genericbl_ops = {
static struct backlight_ops corgibl_ops = { .options = BL_CORE_SUSPENDRESUME,
.get_brightness = corgibl_get_intensity, .get_brightness = genericbl_get_intensity,
.update_status = corgibl_send_intensity, .update_status = genericbl_send_intensity,
}; };
static int corgibl_probe(struct platform_device *pdev) static int genericbl_probe(struct platform_device *pdev)
{ {
struct generic_bl_info *machinfo = pdev->dev.platform_data; struct generic_bl_info *machinfo = pdev->dev.platform_data;
const char *name = "generic-bl"; const char *name = "generic-bl";
struct backlight_device *bd;
bl_machinfo = machinfo; bl_machinfo = machinfo;
if (!machinfo->limit_mask) if (!machinfo->limit_mask)
...@@ -111,59 +89,59 @@ static int corgibl_probe(struct platform_device *pdev) ...@@ -111,59 +89,59 @@ static int corgibl_probe(struct platform_device *pdev)
if (machinfo->name) if (machinfo->name)
name = machinfo->name; name = machinfo->name;
corgi_backlight_device = backlight_device_register (name, bd = backlight_device_register (name,
&pdev->dev, NULL, &corgibl_ops); &pdev->dev, NULL, &genericbl_ops);
if (IS_ERR (corgi_backlight_device)) if (IS_ERR (bd))
return PTR_ERR (corgi_backlight_device); return PTR_ERR (bd);
platform_set_drvdata(pdev, corgi_backlight_device); platform_set_drvdata(pdev, bd);
bd->props.max_brightness = machinfo->max_intensity;
bd->props.power = FB_BLANK_UNBLANK;
bd->props.brightness = machinfo->default_intensity;
backlight_update_status(bd);
corgi_backlight_device->props.max_brightness = machinfo->max_intensity; generic_backlight_device = bd;
corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
corgi_backlight_device->props.brightness = machinfo->default_intensity;
backlight_update_status(corgi_backlight_device);
printk("Corgi Backlight Driver Initialized.\n"); printk("Generic Backlight Driver Initialized.\n");
return 0; return 0;
} }
static int corgibl_remove(struct platform_device *pdev) static int genericbl_remove(struct platform_device *pdev)
{ {
struct backlight_device *bd = platform_get_drvdata(pdev); struct backlight_device *bd = platform_get_drvdata(pdev);
corgibl_data.power = 0; bd->props.power = 0;
corgibl_data.brightness = 0; bd->props.brightness = 0;
backlight_update_status(bd); backlight_update_status(bd);
backlight_device_unregister(bd); backlight_device_unregister(bd);
printk("Corgi Backlight Driver Unloaded\n"); printk("Generic Backlight Driver Unloaded\n");
return 0; return 0;
} }
static struct platform_driver corgibl_driver = { static struct platform_driver genericbl_driver = {
.probe = corgibl_probe, .probe = genericbl_probe,
.remove = corgibl_remove, .remove = genericbl_remove,
.suspend = corgibl_suspend,
.resume = corgibl_resume,
.driver = { .driver = {
.name = "generic-bl", .name = "generic-bl",
}, },
}; };
static int __init corgibl_init(void) static int __init genericbl_init(void)
{ {
return platform_driver_register(&corgibl_driver); return platform_driver_register(&genericbl_driver);
} }
static void __exit corgibl_exit(void) static void __exit genericbl_exit(void)
{ {
platform_driver_unregister(&corgibl_driver); platform_driver_unregister(&genericbl_driver);
} }
module_init(corgibl_init); module_init(genericbl_init);
module_exit(corgibl_exit); module_exit(genericbl_exit);
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
MODULE_DESCRIPTION("Corgi Backlight Driver"); MODULE_DESCRIPTION("Generic Backlight Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -151,19 +151,15 @@ static int __init hp680bl_init(void) ...@@ -151,19 +151,15 @@ static int __init hp680bl_init(void)
int ret; int ret;
ret = platform_driver_register(&hp680bl_driver); ret = platform_driver_register(&hp680bl_driver);
if (!ret) { if (ret)
hp680bl_device = platform_device_alloc("hp680-bl", -1); return ret;
if (!hp680bl_device) hp680bl_device = platform_device_register_simple("hp680-bl", -1,
return -ENOMEM; NULL, 0);
if (IS_ERR(hp680bl_device)) {
ret = platform_device_add(hp680bl_device);
if (ret) {
platform_device_put(hp680bl_device);
platform_driver_unregister(&hp680bl_driver); platform_driver_unregister(&hp680bl_driver);
return PTR_ERR(hp680bl_device);
} }
} return 0;
return ret;
} }
static void __exit hp680bl_exit(void) static void __exit hp680bl_exit(void)
......
...@@ -70,6 +70,7 @@ static int mbp_get_intensity(struct backlight_device *bd) ...@@ -70,6 +70,7 @@ static int mbp_get_intensity(struct backlight_device *bd)
} }
static struct backlight_ops mbp_ops = { static struct backlight_ops mbp_ops = {
.options = BL_CORE_SUSPENDRESUME,
.get_brightness = mbp_get_intensity, .get_brightness = mbp_get_intensity,
.update_status = mbp_send_intensity, .update_status = mbp_send_intensity,
}; };
......
...@@ -119,20 +119,16 @@ static int __init progearbl_init(void) ...@@ -119,20 +119,16 @@ static int __init progearbl_init(void)
{ {
int ret = platform_driver_register(&progearbl_driver); int ret = platform_driver_register(&progearbl_driver);
if (!ret) { if (ret)
progearbl_device = platform_device_alloc("progear-bl", -1); return ret;
if (!progearbl_device) progearbl_device = platform_device_register_simple("progear-bl", -1,
return -ENOMEM; NULL, 0);
if (IS_ERR(progearbl_device)) {
ret = platform_device_add(progearbl_device);
if (ret) {
platform_device_put(progearbl_device);
platform_driver_unregister(&progearbl_driver); platform_driver_unregister(&progearbl_driver);
} return PTR_ERR(progearbl_device);
} }
return ret; return 0;
} }
static void __exit progearbl_exit(void) static void __exit progearbl_exit(void)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/tdo24m.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/lcd.h> #include <linux/lcd.h>
...@@ -31,6 +32,9 @@ struct tdo24m { ...@@ -31,6 +32,9 @@ struct tdo24m {
struct spi_transfer xfer; struct spi_transfer xfer;
uint8_t *buf; uint8_t *buf;
int (*adj_mode)(struct tdo24m *lcd, int mode);
int color_invert;
int power; int power;
int mode; int mode;
}; };
...@@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = { ...@@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = {
CMD_NULL, CMD_NULL,
}; };
static uint32_t lcd_vga_pass_through[] = { static uint32_t lcd_vga_pass_through_tdo24m[] = {
CMD1(0xB0, 0x16), CMD1(0xB0, 0x16),
CMD1(0xBC, 0x80), CMD1(0xBC, 0x80),
CMD1(0xE1, 0x00), CMD1(0xE1, 0x00),
...@@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = { ...@@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = {
CMD_NULL, CMD_NULL,
}; };
static uint32_t lcd_qvga_pass_through[] = { static uint32_t lcd_qvga_pass_through_tdo24m[] = {
CMD1(0xB0, 0x16), CMD1(0xB0, 0x16),
CMD1(0xBC, 0x81), CMD1(0xBC, 0x81),
CMD1(0xE1, 0x00), CMD1(0xE1, 0x00),
...@@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = { ...@@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = {
CMD_NULL, CMD_NULL,
}; };
static uint32_t lcd_vga_transfer[] = { static uint32_t lcd_vga_transfer_tdo24m[] = {
CMD1(0xcf, 0x02), /* Blanking period control (1) */ CMD1(0xcf, 0x02), /* Blanking period control (1) */
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
CMD1(0xd1, 0x01), /* CKV timing control on/off */ CMD1(0xd1, 0x01), /* CKV timing control on/off */
...@@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = { ...@@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = {
CMD_NULL, CMD_NULL,
}; };
static uint32_t lcd_vga_pass_through_tdo35s[] = {
CMD1(0xB0, 0x16),
CMD1(0xBC, 0x80),
CMD1(0xE1, 0x00),
CMD1(0x3B, 0x00),
CMD_NULL,
};
static uint32_t lcd_qvga_pass_through_tdo35s[] = {
CMD1(0xB0, 0x16),
CMD1(0xBC, 0x81),
CMD1(0xE1, 0x00),
CMD1(0x3B, 0x22),
CMD_NULL,
};
static uint32_t lcd_vga_transfer_tdo35s[] = {
CMD1(0xcf, 0x02), /* Blanking period control (1) */
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
CMD1(0xd1, 0x01), /* CKV timing control on/off */
CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
CMD2(0xd3, 0x14, 0x28), /* OEV timing control */
CMD2(0xd4, 0x28, 0x64), /* ASW timing control (1) */
CMD1(0xd5, 0x28), /* ASW timing control (2) */
CMD0(0x21), /* Invert for normally black display */
CMD0(0x29), /* Display on */
CMD_NULL,
};
static uint32_t lcd_panel_config[] = { static uint32_t lcd_panel_config[] = {
CMD2(0xb8, 0xff, 0xf9), /* Output control */ CMD2(0xb8, 0xff, 0xf9), /* Output control */
CMD0(0x11), /* sleep out */ CMD0(0x11), /* sleep out */
...@@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array) ...@@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array)
int nparams, err = 0; int nparams, err = 0;
for (; *p != CMD_NULL; p++) { for (; *p != CMD_NULL; p++) {
if (!lcd->color_invert && *p == CMD0(0x21))
continue;
nparams = (*p >> 30) & 0x3; nparams = (*p >> 30) & 0x3;
...@@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode) ...@@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode)
{ {
switch (mode) { switch (mode) {
case MODE_VGA: case MODE_VGA:
tdo24m_writes(lcd, lcd_vga_pass_through); tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
tdo24m_writes(lcd, lcd_panel_config); tdo24m_writes(lcd, lcd_panel_config);
tdo24m_writes(lcd, lcd_vga_transfer); tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
break; break;
case MODE_QVGA: case MODE_QVGA:
tdo24m_writes(lcd, lcd_qvga_pass_through); tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
tdo24m_writes(lcd, lcd_panel_config);
tdo24m_writes(lcd, lcd_qvga_transfer);
break;
default:
return -EINVAL;
}
lcd->mode = mode;
return 0;
}
static int tdo35s_adj_mode(struct tdo24m *lcd, int mode)
{
switch (mode) {
case MODE_VGA:
tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
tdo24m_writes(lcd, lcd_panel_config);
tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
break;
case MODE_QVGA:
tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
tdo24m_writes(lcd, lcd_panel_config); tdo24m_writes(lcd, lcd_panel_config);
tdo24m_writes(lcd, lcd_qvga_transfer); tdo24m_writes(lcd, lcd_qvga_transfer);
break; break;
...@@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd) ...@@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd)
if (err) if (err)
goto out; goto out;
err = tdo24m_adj_mode(lcd, lcd->mode); err = lcd->adj_mode(lcd, lcd->mode);
out: out:
return err; return err;
} }
...@@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m) ...@@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m)
if (lcd->mode == mode) if (lcd->mode == mode)
return 0; return 0;
return tdo24m_adj_mode(lcd, mode); return lcd->adj_mode(lcd, mode);
} }
static struct lcd_ops tdo24m_ops = { static struct lcd_ops tdo24m_ops = {
...@@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
struct tdo24m *lcd; struct tdo24m *lcd;
struct spi_message *m; struct spi_message *m;
struct spi_transfer *x; struct spi_transfer *x;
struct tdo24m_platform_data *pdata;
enum tdo24m_model model;
int err; int err;
pdata = spi->dev.platform_data;
if (pdata)
model = pdata->model;
else
model = TDO24M;
spi->bits_per_word = 8; spi->bits_per_word = 8;
spi->mode = SPI_MODE_3; spi->mode = SPI_MODE_3;
err = spi_setup(spi); err = spi_setup(spi);
...@@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi) ...@@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
x->tx_buf = &lcd->buf[0]; x->tx_buf = &lcd->buf[0];
spi_message_add_tail(x, m); spi_message_add_tail(x, m);
switch (model) {
case TDO24M:
lcd->color_invert = 1;
lcd->adj_mode = tdo24m_adj_mode;
break;
case TDO35S:
lcd->adj_mode = tdo35s_adj_mode;
lcd->color_invert = 0;
break;
default:
dev_err(&spi->dev, "Unsupported model");
goto out_free;
}
lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
lcd, &tdo24m_ops); lcd, &tdo24m_ops);
if (IS_ERR(lcd->lcd_dev)) { if (IS_ERR(lcd->lcd_dev)) {
......
...@@ -39,6 +39,7 @@ struct tosa_lcd_data { ...@@ -39,6 +39,7 @@ struct tosa_lcd_data {
struct i2c_client *i2c; struct i2c_client *i2c;
int lcd_power; int lcd_power;
bool is_vga;
}; };
static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data) static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data)
...@@ -81,8 +82,12 @@ static void tosa_lcd_tg_init(struct tosa_lcd_data *data) ...@@ -81,8 +82,12 @@ static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
static void tosa_lcd_tg_on(struct tosa_lcd_data *data) static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
{ {
struct spi_device *spi = data->spi; struct spi_device *spi = data->spi;
const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */
if (data->is_vga)
value |= TG_REG0_VQV;
tosa_tg_send(spi, TG_PNLCTL, value);
/* TG LCD pannel power up */ /* TG LCD pannel power up */
tosa_tg_send(spi, TG_PINICTL,0x4); tosa_tg_send(spi, TG_PINICTL,0x4);
...@@ -142,9 +147,25 @@ static int tosa_lcd_get_power(struct lcd_device *lcd) ...@@ -142,9 +147,25 @@ static int tosa_lcd_get_power(struct lcd_device *lcd)
return data->lcd_power; return data->lcd_power;
} }
static int tosa_lcd_set_mode(struct lcd_device *lcd, struct fb_videomode *mode)
{
struct tosa_lcd_data *data = lcd_get_data(lcd);
if (mode->xres == 320 || mode->yres == 320)
data->is_vga = false;
else
data->is_vga = true;
if (POWER_IS_ON(data->lcd_power))
tosa_lcd_tg_on(data);
return 0;
}
static struct lcd_ops tosa_lcd_ops = { static struct lcd_ops tosa_lcd_ops = {
.set_power = tosa_lcd_set_power, .set_power = tosa_lcd_set_power,
.get_power = tosa_lcd_get_power, .get_power = tosa_lcd_get_power,
.set_mode = tosa_lcd_set_mode,
}; };
static int __devinit tosa_lcd_probe(struct spi_device *spi) static int __devinit tosa_lcd_probe(struct spi_device *spi)
...@@ -156,6 +177,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi) ...@@ -156,6 +177,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
data->is_vga = true; /* defaut to VGA mode */
/* /*
* bits_per_word cannot be configured in platform data * bits_per_word cannot be configured in platform data
*/ */
......
...@@ -137,7 +137,7 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd, ...@@ -137,7 +137,7 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd,
ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1); ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1);
ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0); ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0);
ili9320_write(lcd, ILI9320_RGB_IF2, ILI9320_RGBIF2_DPL); ili9320_write(lcd, ILI9320_RGB_IF2, cfg->rgb_if2);
ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1)); ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1));
if (ret != 0) if (ret != 0)
......
...@@ -31,6 +31,10 @@ struct backlight_device; ...@@ -31,6 +31,10 @@ struct backlight_device;
struct fb_info; struct fb_info;
struct backlight_ops { struct backlight_ops {
unsigned int options;
#define BL_CORE_SUSPENDRESUME (1 << 0)
/* Notify the backlight driver some property has changed */ /* Notify the backlight driver some property has changed */
int (*update_status)(struct backlight_device *); int (*update_status)(struct backlight_device *);
/* Return the current backlight brightness (accounting for power, /* Return the current backlight brightness (accounting for power,
...@@ -51,7 +55,19 @@ struct backlight_properties { ...@@ -51,7 +55,19 @@ struct backlight_properties {
modes; 4: full off), see FB_BLANK_XXX */ modes; 4: full off), see FB_BLANK_XXX */
int power; int power;
/* FB Blanking active? (values as for power) */ /* FB Blanking active? (values as for power) */
/* Due to be removed, please use (state & BL_CORE_FBBLANK) */
int fb_blank; int fb_blank;
/* Flags used to signal drivers of state changes */
/* Upper 4 bits are reserved for driver internal use */
unsigned int state;
#define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */
#define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */
#define BL_CORE_DRIVER4 (1 << 28) /* reserved for driver specific use */
#define BL_CORE_DRIVER3 (1 << 29) /* reserved for driver specific use */
#define BL_CORE_DRIVER2 (1 << 30) /* reserved for driver specific use */
#define BL_CORE_DRIVER1 (1 << 31) /* reserved for driver specific use */
}; };
struct backlight_device { struct backlight_device {
......
#ifndef __TDO24M_H__
#define __TDO24M_H__
enum tdo24m_model {
TDO24M,
TDO35S,
};
struct tdo24m_platform_data {
enum tdo24m_model model;
};
#endif /* __TDO24M_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment