aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-03-31 05:31:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-31 15:19:00 -0500
commit2c0f5fb08e8ad59f396b1bda41ccd93cbb00a09f (patch)
tree9b53b4ffd3b118561d5210ca3962c592a428d7cd
parent5f27a27bd77fcfd4b90ed33668940bc3cf72768b (diff)
[PATCH] backlight: corgi_bl: Generalise to support other Sharp SL hardware
Generalise the Corgi backlight driver by moving the default intensity and limit mask settings into the platform specific data structure. This enables the driver to support other Zaurus hardware, specifically the SL-6000x (Tosa) model. Also change the spinlock to a mutex (the spinlock is overkill). Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Antonino Daplas <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/arm/mach-pxa/corgi.c2
-rw-r--r--arch/arm/mach-pxa/spitz.c2
-rw-r--r--drivers/video/backlight/Kconfig4
-rw-r--r--drivers/video/backlight/corgi_bl.c31
-rw-r--r--include/asm-arm/arch-pxa/sharpsl.h2
5 files changed, 21 insertions, 20 deletions
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 99604a544629..d6d726036361 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -141,6 +141,8 @@ struct corgissp_machinfo corgi_ssp_machinfo = {
141 */ 141 */
142static struct corgibl_machinfo corgi_bl_machinfo = { 142static struct corgibl_machinfo corgi_bl_machinfo = {
143 .max_intensity = 0x2f, 143 .max_intensity = 0x2f,
144 .default_intensity = 0x1f,
145 .limit_mask = 0x0b,
144 .set_bl_intensity = corgi_bl_set_intensity, 146 .set_bl_intensity = corgi_bl_set_intensity,
145}; 147};
146 148
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index ebe473053392..19b372df544a 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -220,6 +220,8 @@ struct corgissp_machinfo spitz_ssp_machinfo = {
220 * Spitz Backlight Device 220 * Spitz Backlight Device
221 */ 221 */
222static struct corgibl_machinfo spitz_bl_machinfo = { 222static struct corgibl_machinfo spitz_bl_machinfo = {
223 .default_intensity = 0x1f,
224 .limit_mask = 0x0b,
223 .max_intensity = 0x2f, 225 .max_intensity = 0x2f,
224}; 226};
225 227
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 9d996f2c10d5..b895eaaa73fd 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -43,11 +43,11 @@ config LCD_DEVICE
43 default y 43 default y
44 44
45config BACKLIGHT_CORGI 45config BACKLIGHT_CORGI
46 tristate "Sharp Corgi Backlight Driver (SL-C7xx Series)" 46 tristate "Sharp Corgi Backlight Driver (SL Series)"
47 depends on BACKLIGHT_DEVICE && PXA_SHARPSL 47 depends on BACKLIGHT_DEVICE && PXA_SHARPSL
48 default y 48 default y
49 help 49 help
50 If you have a Sharp Zaurus SL-C7xx, say y to enable the 50 If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y to enable the
51 backlight driver. 51 backlight driver.
52 52
53config BACKLIGHT_HP680 53config BACKLIGHT_HP680
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index f86213b4a8fb..2ebbfd95145f 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Backlight Driver for Sharp Corgi 2 * Backlight Driver for Sharp Zaurus Handhelds (various models)
3 * 3 *
4 * Copyright (c) 2004-2005 Richard Purdie 4 * Copyright (c) 2004-2006 Richard Purdie
5 * 5 *
6 * Based on Sharp's 2.4 Backlight Driver 6 * Based on Sharp's 2.4 Backlight Driver
7 * 7 *
@@ -15,21 +15,17 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/spinlock.h> 18#include <linux/mutex.h>
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/backlight.h> 20#include <linux/backlight.h>
21
22#include <asm/arch/sharpsl.h> 21#include <asm/arch/sharpsl.h>
23#include <asm/hardware/sharpsl_pm.h> 22#include <asm/hardware/sharpsl_pm.h>
24 23
25#define CORGI_DEFAULT_INTENSITY 0x1f
26#define CORGI_LIMIT_MASK 0x0b
27
28static int corgibl_intensity; 24static int corgibl_intensity;
29static void (*corgibl_mach_set_intensity)(int intensity); 25static DEFINE_MUTEX(bl_mutex);
30static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED;
31static struct backlight_properties corgibl_data; 26static struct backlight_properties corgibl_data;
32static struct backlight_device *corgi_backlight_device; 27static struct backlight_device *corgi_backlight_device;
28static struct corgibl_machinfo *bl_machinfo;
33 29
34static unsigned long corgibl_flags; 30static unsigned long corgibl_flags;
35#define CORGIBL_SUSPENDED 0x01 31#define CORGIBL_SUSPENDED 0x01
@@ -37,7 +33,6 @@ static unsigned long corgibl_flags;
37 33
38static int corgibl_send_intensity(struct backlight_device *bd) 34static int corgibl_send_intensity(struct backlight_device *bd)
39{ 35{
40 unsigned long flags;
41 void (*corgi_kick_batt)(void); 36 void (*corgi_kick_batt)(void);
42 int intensity = bd->props->brightness; 37 int intensity = bd->props->brightness;
43 38
@@ -48,13 +43,11 @@ static int corgibl_send_intensity(struct backlight_device *bd)
48 if (corgibl_flags & CORGIBL_SUSPENDED) 43 if (corgibl_flags & CORGIBL_SUSPENDED)
49 intensity = 0; 44 intensity = 0;
50 if (corgibl_flags & CORGIBL_BATTLOW) 45 if (corgibl_flags & CORGIBL_BATTLOW)
51 intensity &= CORGI_LIMIT_MASK; 46 intensity &= bl_machinfo->limit_mask;
52
53 spin_lock_irqsave(&bl_lock, flags);
54
55 corgibl_mach_set_intensity(intensity);
56 47
57 spin_unlock_irqrestore(&bl_lock, flags); 48 mutex_lock(&bl_mutex);
49 bl_machinfo->set_bl_intensity(intensity);
50 mutex_unlock(&bl_mutex);
58 51
59 corgibl_intensity = intensity; 52 corgibl_intensity = intensity;
60 53
@@ -122,8 +115,10 @@ static int __init corgibl_probe(struct platform_device *pdev)
122{ 115{
123 struct corgibl_machinfo *machinfo = pdev->dev.platform_data; 116 struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
124 117
118 bl_machinfo = machinfo;
125 corgibl_data.max_brightness = machinfo->max_intensity; 119 corgibl_data.max_brightness = machinfo->max_intensity;
126 corgibl_mach_set_intensity = machinfo->set_bl_intensity; 120 if (!machinfo->limit_mask)
121 machinfo->limit_mask = -1;
127 122
128 corgi_backlight_device = backlight_device_register ("corgi-bl", 123 corgi_backlight_device = backlight_device_register ("corgi-bl",
129 NULL, &corgibl_data); 124 NULL, &corgibl_data);
@@ -131,7 +126,7 @@ static int __init corgibl_probe(struct platform_device *pdev)
131 return PTR_ERR (corgi_backlight_device); 126 return PTR_ERR (corgi_backlight_device);
132 127
133 corgibl_data.power = FB_BLANK_UNBLANK; 128 corgibl_data.power = FB_BLANK_UNBLANK;
134 corgibl_data.brightness = CORGI_DEFAULT_INTENSITY; 129 corgibl_data.brightness = machinfo->default_intensity;
135 corgibl_send_intensity(corgi_backlight_device); 130 corgibl_send_intensity(corgi_backlight_device);
136 131
137 printk("Corgi Backlight Driver Initialized.\n"); 132 printk("Corgi Backlight Driver Initialized.\n");
diff --git a/include/asm-arm/arch-pxa/sharpsl.h b/include/asm-arm/arch-pxa/sharpsl.h
index 0b43495d24b4..94cb4982af82 100644
--- a/include/asm-arm/arch-pxa/sharpsl.h
+++ b/include/asm-arm/arch-pxa/sharpsl.h
@@ -27,6 +27,8 @@ struct corgits_machinfo {
27 */ 27 */
28struct corgibl_machinfo { 28struct corgibl_machinfo {
29 int max_intensity; 29 int max_intensity;
30 int default_intensity;
31 int limit_mask;
30 void (*set_bl_intensity)(int intensity); 32 void (*set_bl_intensity)(int intensity);
31}; 33};
32extern void corgibl_limit_intensity(int limit); 34extern void corgibl_limit_intensity(int limit);