diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-09-13 12:58:51 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2008-10-20 19:19:49 -0400 |
commit | fbd1b17b43b8783a5408ec18c293dd8ebdc7e2cd (patch) | |
tree | 4895da5d017d54da64d62b737d2fa8807b07058d | |
parent | 6da0b38f4433fb0f24615449d7966471b6e5eae0 (diff) |
backlight: add support for Sharp SL-6000 LCD and backlight drivers
On Sharp SL-6000 lcd/backlight is a bit complex, so add two drivers
one for lcd-driving chip, other one for dac regulating the backlight
LEDS.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
-rw-r--r-- | arch/arm/mach-pxa/include/mach/tosa.h | 3 | ||||
-rw-r--r-- | drivers/video/backlight/Kconfig | 18 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 3 | ||||
-rw-r--r-- | drivers/video/backlight/tosa_bl.c | 198 | ||||
-rw-r--r-- | drivers/video/backlight/tosa_lcd.c | 280 |
5 files changed, 502 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/include/mach/tosa.h b/arch/arm/mach-pxa/include/mach/tosa.h index 8bce6d8615b9..4df2d38507dc 100644 --- a/arch/arm/mach-pxa/include/mach/tosa.h +++ b/arch/arm/mach-pxa/include/mach/tosa.h | |||
@@ -193,4 +193,7 @@ | |||
193 | #define TOSA_KEY_MAIL KEY_MAIL | 193 | #define TOSA_KEY_MAIL KEY_MAIL |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | struct spi_device; | ||
197 | extern int tosa_bl_enable(struct spi_device *spi, int enable); | ||
198 | |||
196 | #endif /* _ASM_ARCH_TOSA_H_ */ | 199 | #endif /* _ASM_ARCH_TOSA_H_ */ |
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index c72a13562954..10b701f1089a 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -75,6 +75,15 @@ config LCD_PLATFORM | |||
75 | This driver provides a platform-device registered LCD power | 75 | This driver provides a platform-device registered LCD power |
76 | control interface. | 76 | control interface. |
77 | 77 | ||
78 | config LCD_TOSA | ||
79 | tristate "Sharp SL-6000 LCD Driver" | ||
80 | depends on LCD_CLASS_DEVICE && SPI | ||
81 | depends on MACH_TOSA | ||
82 | default n | ||
83 | help | ||
84 | If you have an Sharp SL-6000 Zaurus say Y to enable a driver | ||
85 | for its LCD. | ||
86 | |||
78 | # | 87 | # |
79 | # Backlight | 88 | # Backlight |
80 | # | 89 | # |
@@ -179,3 +188,12 @@ config BACKLIGHT_MBP_NVIDIA | |||
179 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y | 188 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y |
180 | to enable a driver for its backlight | 189 | to enable a driver for its backlight |
181 | 190 | ||
191 | config BACKLIGHT_TOSA | ||
192 | tristate "Sharp SL-6000 Backlight Driver" | ||
193 | depends on BACKLIGHT_CLASS_DEVICE && I2C | ||
194 | depends on MACH_TOSA && LCD_TOSA | ||
195 | default n | ||
196 | help | ||
197 | If you have an Sharp SL-6000 Zaurus say Y to enable a driver | ||
198 | for its backlight | ||
199 | |||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 3ec551eb472c..36f2026373a3 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -7,6 +7,7 @@ obj-$(CONFIG_LCD_ILI9320) += ili9320.o | |||
7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o | 7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o |
8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o | 8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o |
9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o | 9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o |
10 | obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o | ||
10 | 11 | ||
11 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 12 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
12 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | 13 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o |
@@ -18,4 +19,6 @@ obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o | |||
18 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o | 19 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o |
19 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 20 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
20 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | 21 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o |
22 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o | ||
23 | |||
21 | 24 | ||
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c new file mode 100644 index 000000000000..43edbada12d1 --- /dev/null +++ b/drivers/video/backlight/tosa_bl.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * LCD / Backlight control code for Sharp SL-6000x (tosa) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007,2008 Dmitry Baryshkov | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/fb.h> | ||
20 | #include <linux/backlight.h> | ||
21 | |||
22 | #include <asm/mach/sharpsl_param.h> | ||
23 | |||
24 | #include <mach/tosa.h> | ||
25 | |||
26 | #define COMADJ_DEFAULT 97 | ||
27 | |||
28 | #define DAC_CH1 0 | ||
29 | #define DAC_CH2 1 | ||
30 | |||
31 | struct tosa_bl_data { | ||
32 | struct i2c_client *i2c; | ||
33 | struct backlight_device *bl; | ||
34 | |||
35 | int comadj; | ||
36 | }; | ||
37 | |||
38 | static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness) | ||
39 | { | ||
40 | struct spi_device *spi = data->i2c->dev.platform_data; | ||
41 | |||
42 | i2c_smbus_write_byte_data(data->i2c, DAC_CH1, data->comadj); | ||
43 | |||
44 | /* SetBacklightDuty */ | ||
45 | i2c_smbus_write_byte_data(data->i2c, DAC_CH2, (u8)(brightness & 0xff)); | ||
46 | |||
47 | /* SetBacklightVR */ | ||
48 | gpio_set_value(TOSA_GPIO_BL_C20MA, brightness & 0x100); | ||
49 | |||
50 | tosa_bl_enable(spi, brightness); | ||
51 | } | ||
52 | |||
53 | static int tosa_bl_update_status(struct backlight_device *dev) | ||
54 | { | ||
55 | struct backlight_properties *props = &dev->props; | ||
56 | struct tosa_bl_data *data = dev_get_drvdata(&dev->dev); | ||
57 | int power = max(props->power, props->fb_blank); | ||
58 | int brightness = props->brightness; | ||
59 | |||
60 | if (power) | ||
61 | brightness = 0; | ||
62 | |||
63 | tosa_bl_set_backlight(data, brightness); | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static int tosa_bl_get_brightness(struct backlight_device *dev) | ||
69 | { | ||
70 | struct backlight_properties *props = &dev->props; | ||
71 | |||
72 | return props->brightness; | ||
73 | } | ||
74 | |||
75 | static struct backlight_ops bl_ops = { | ||
76 | .get_brightness = tosa_bl_get_brightness, | ||
77 | .update_status = tosa_bl_update_status, | ||
78 | }; | ||
79 | |||
80 | static int __devinit tosa_bl_probe(struct i2c_client *client, | ||
81 | const struct i2c_device_id *id) | ||
82 | { | ||
83 | struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL); | ||
84 | int ret = 0; | ||
85 | if (!data) | ||
86 | return -ENOMEM; | ||
87 | |||
88 | data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj; | ||
89 | |||
90 | ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); | ||
91 | if (ret) { | ||
92 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); | ||
93 | goto err_gpio_bl; | ||
94 | } | ||
95 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); | ||
96 | if (ret) | ||
97 | goto err_gpio_dir; | ||
98 | |||
99 | i2c_set_clientdata(client, data); | ||
100 | data->i2c = client; | ||
101 | |||
102 | data->bl = backlight_device_register("tosa-bl", &client->dev, | ||
103 | data, &bl_ops); | ||
104 | if (IS_ERR(data->bl)) { | ||
105 | ret = PTR_ERR(data->bl); | ||
106 | goto err_reg; | ||
107 | } | ||
108 | |||
109 | data->bl->props.brightness = 69; | ||
110 | data->bl->props.max_brightness = 512 - 1; | ||
111 | data->bl->props.power = FB_BLANK_UNBLANK; | ||
112 | |||
113 | backlight_update_status(data->bl); | ||
114 | |||
115 | return 0; | ||
116 | |||
117 | err_reg: | ||
118 | data->bl = NULL; | ||
119 | i2c_set_clientdata(client, NULL); | ||
120 | err_gpio_dir: | ||
121 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
122 | err_gpio_bl: | ||
123 | kfree(data); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static int __devexit tosa_bl_remove(struct i2c_client *client) | ||
128 | { | ||
129 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
130 | |||
131 | backlight_device_unregister(data->bl); | ||
132 | data->bl = NULL; | ||
133 | i2c_set_clientdata(client, NULL); | ||
134 | |||
135 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
136 | |||
137 | kfree(data); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | #ifdef CONFIG_PM | ||
143 | static int tosa_bl_suspend(struct i2c_client *client, pm_message_t pm) | ||
144 | { | ||
145 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
146 | |||
147 | tosa_bl_set_backlight(data, 0); | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static int tosa_bl_resume(struct i2c_client *client) | ||
153 | { | ||
154 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
155 | |||
156 | backlight_update_status(data->bl); | ||
157 | return 0; | ||
158 | } | ||
159 | #else | ||
160 | #define tosa_bl_suspend NULL | ||
161 | #define tosa_bl_resume NULL | ||
162 | #endif | ||
163 | |||
164 | static const struct i2c_device_id tosa_bl_id[] = { | ||
165 | { "tosa-bl", 0 }, | ||
166 | { }, | ||
167 | }; | ||
168 | |||
169 | |||
170 | static struct i2c_driver tosa_bl_driver = { | ||
171 | .driver = { | ||
172 | .name = "tosa-bl", | ||
173 | .owner = THIS_MODULE, | ||
174 | }, | ||
175 | .probe = tosa_bl_probe, | ||
176 | .remove = __devexit_p(tosa_bl_remove), | ||
177 | .suspend = tosa_bl_suspend, | ||
178 | .resume = tosa_bl_resume, | ||
179 | .id_table = tosa_bl_id, | ||
180 | }; | ||
181 | |||
182 | static int __init tosa_bl_init(void) | ||
183 | { | ||
184 | return i2c_add_driver(&tosa_bl_driver); | ||
185 | } | ||
186 | |||
187 | static void __exit tosa_bl_exit(void) | ||
188 | { | ||
189 | i2c_del_driver(&tosa_bl_driver); | ||
190 | } | ||
191 | |||
192 | module_init(tosa_bl_init); | ||
193 | module_exit(tosa_bl_exit); | ||
194 | |||
195 | MODULE_AUTHOR("Dmitry Baryshkov"); | ||
196 | MODULE_LICENSE("GPL v2"); | ||
197 | MODULE_DESCRIPTION("LCD/Backlight control for Sharp SL-6000 PDA"); | ||
198 | |||
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c new file mode 100644 index 000000000000..57a26649f1a5 --- /dev/null +++ b/drivers/video/backlight/tosa_lcd.c | |||
@@ -0,0 +1,280 @@ | |||
1 | /* | ||
2 | * LCD / Backlight control code for Sharp SL-6000x (tosa) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007,2008 Dmitry Baryshkov | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/lcd.h> | ||
21 | #include <linux/fb.h> | ||
22 | |||
23 | #include <asm/mach/sharpsl_param.h> | ||
24 | |||
25 | #include <mach/tosa.h> | ||
26 | |||
27 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
28 | |||
29 | #define TG_REG0_VQV 0x0001 | ||
30 | #define TG_REG0_COLOR 0x0002 | ||
31 | #define TG_REG0_UD 0x0004 | ||
32 | #define TG_REG0_LR 0x0008 | ||
33 | |||
34 | #define DAC_BASE 0x4e | ||
35 | |||
36 | struct tosa_lcd_data { | ||
37 | struct spi_device *spi; | ||
38 | struct lcd_device *lcd; | ||
39 | struct i2c_client *i2c; | ||
40 | |||
41 | int lcd_power; | ||
42 | }; | ||
43 | |||
44 | static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data) | ||
45 | { | ||
46 | u8 buf[1]; | ||
47 | struct spi_message msg; | ||
48 | struct spi_transfer xfer = { | ||
49 | .len = 1, | ||
50 | .cs_change = 1, | ||
51 | .tx_buf = buf, | ||
52 | }; | ||
53 | |||
54 | buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f); | ||
55 | spi_message_init(&msg); | ||
56 | spi_message_add_tail(&xfer, &msg); | ||
57 | |||
58 | return spi_sync(spi, &msg); | ||
59 | } | ||
60 | |||
61 | int tosa_bl_enable(struct spi_device *spi, int enable) | ||
62 | { | ||
63 | /* bl_enable GP04=1 otherwise GP04=0*/ | ||
64 | return tosa_tg_send(spi, TG_GPODR2, enable? 0x01 : 0x00); | ||
65 | } | ||
66 | EXPORT_SYMBOL(tosa_bl_enable); | ||
67 | |||
68 | static void tosa_lcd_tg_init(struct tosa_lcd_data *data) | ||
69 | { | ||
70 | /* TG on */ | ||
71 | gpio_set_value(TOSA_GPIO_TG_ON, 0); | ||
72 | |||
73 | mdelay(60); | ||
74 | |||
75 | /* delayed 0clk TCTL signal for VGA */ | ||
76 | tosa_tg_send(data->spi, TG_TPOSCTL, 0x00); | ||
77 | /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */ | ||
78 | tosa_tg_send(data->spi, TG_GPOSR, 0x02); | ||
79 | } | ||
80 | |||
81 | static void tosa_lcd_tg_on(struct tosa_lcd_data *data) | ||
82 | { | ||
83 | struct spi_device *spi = data->spi; | ||
84 | const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; | ||
85 | tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */ | ||
86 | |||
87 | /* TG LCD pannel power up */ | ||
88 | tosa_tg_send(spi, TG_PINICTL,0x4); | ||
89 | mdelay(50); | ||
90 | |||
91 | /* TG LCD GVSS */ | ||
92 | tosa_tg_send(spi, TG_PINICTL,0x0); | ||
93 | |||
94 | if (!data->i2c) { | ||
95 | /* after the pannel is powered up the first time, we can access the i2c bus */ | ||
96 | /* so probe for the DAC */ | ||
97 | struct i2c_adapter *adap = i2c_get_adapter(0); | ||
98 | struct i2c_board_info info = { | ||
99 | .type = "tosa-bl", | ||
100 | .addr = DAC_BASE, | ||
101 | .platform_data = data->spi, | ||
102 | }; | ||
103 | data->i2c = i2c_new_device(adap, &info); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static void tosa_lcd_tg_off(struct tosa_lcd_data *data) | ||
108 | { | ||
109 | struct spi_device *spi = data->spi; | ||
110 | |||
111 | /* TG LCD VHSA off */ | ||
112 | tosa_tg_send(spi, TG_PINICTL,0x4); | ||
113 | mdelay(50); | ||
114 | |||
115 | /* TG LCD signal off */ | ||
116 | tosa_tg_send(spi, TG_PINICTL,0x6); | ||
117 | mdelay(50); | ||
118 | |||
119 | /* TG Off */ | ||
120 | gpio_set_value(TOSA_GPIO_TG_ON, 1); | ||
121 | mdelay(100); | ||
122 | } | ||
123 | |||
124 | int tosa_lcd_set_power(struct lcd_device *lcd, int power) | ||
125 | { | ||
126 | struct tosa_lcd_data *data = lcd_get_data(lcd); | ||
127 | |||
128 | if (POWER_IS_ON(power) && !POWER_IS_ON(data->lcd_power)) | ||
129 | tosa_lcd_tg_on(data); | ||
130 | |||
131 | if (!POWER_IS_ON(power) && POWER_IS_ON(data->lcd_power)) | ||
132 | tosa_lcd_tg_off(data); | ||
133 | |||
134 | data->lcd_power = power; | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static int tosa_lcd_get_power(struct lcd_device *lcd) | ||
139 | { | ||
140 | struct tosa_lcd_data *data = lcd_get_data(lcd); | ||
141 | |||
142 | return data->lcd_power; | ||
143 | } | ||
144 | |||
145 | static struct lcd_ops tosa_lcd_ops = { | ||
146 | .set_power = tosa_lcd_set_power, | ||
147 | .get_power = tosa_lcd_get_power, | ||
148 | }; | ||
149 | |||
150 | static int __devinit tosa_lcd_probe(struct spi_device *spi) | ||
151 | { | ||
152 | int ret; | ||
153 | struct tosa_lcd_data *data; | ||
154 | |||
155 | data = kzalloc(sizeof(struct tosa_lcd_data), GFP_KERNEL); | ||
156 | if (!data) | ||
157 | return -ENOMEM; | ||
158 | |||
159 | /* | ||
160 | * bits_per_word cannot be configured in platform data | ||
161 | */ | ||
162 | spi->bits_per_word = 8; | ||
163 | |||
164 | ret = spi_setup(spi); | ||
165 | if (ret < 0) | ||
166 | goto err_spi; | ||
167 | |||
168 | data->spi = spi; | ||
169 | dev_set_drvdata(&spi->dev, data); | ||
170 | |||
171 | ret = gpio_request(TOSA_GPIO_TG_ON, "tg #pwr"); | ||
172 | if (ret < 0) | ||
173 | goto err_gpio_tg; | ||
174 | |||
175 | mdelay(60); | ||
176 | |||
177 | ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0); | ||
178 | if (ret < 0) | ||
179 | goto err_gpio_dir; | ||
180 | |||
181 | mdelay(60); | ||
182 | tosa_lcd_tg_init(data); | ||
183 | |||
184 | tosa_lcd_tg_on(data); | ||
185 | |||
186 | data->lcd = lcd_device_register("tosa-lcd", &spi->dev, data, | ||
187 | &tosa_lcd_ops); | ||
188 | |||
189 | if (IS_ERR(data->lcd)) { | ||
190 | ret = PTR_ERR(data->lcd); | ||
191 | data->lcd = NULL; | ||
192 | goto err_register; | ||
193 | } | ||
194 | |||
195 | return 0; | ||
196 | |||
197 | err_register: | ||
198 | tosa_lcd_tg_off(data); | ||
199 | err_gpio_dir: | ||
200 | gpio_free(TOSA_GPIO_TG_ON); | ||
201 | err_gpio_tg: | ||
202 | dev_set_drvdata(&spi->dev, NULL); | ||
203 | err_spi: | ||
204 | kfree(data); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | static int __devexit tosa_lcd_remove(struct spi_device *spi) | ||
209 | { | ||
210 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
211 | |||
212 | lcd_device_unregister(data->lcd); | ||
213 | |||
214 | if (data->i2c) | ||
215 | i2c_unregister_device(data->i2c); | ||
216 | |||
217 | tosa_lcd_tg_off(data); | ||
218 | |||
219 | gpio_free(TOSA_GPIO_TG_ON); | ||
220 | dev_set_drvdata(&spi->dev, NULL); | ||
221 | kfree(data); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | #ifdef CONFIG_PM | ||
227 | static int tosa_lcd_suspend(struct spi_device *spi, pm_message_t state) | ||
228 | { | ||
229 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
230 | |||
231 | tosa_lcd_tg_off(data); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int tosa_lcd_resume(struct spi_device *spi) | ||
237 | { | ||
238 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
239 | |||
240 | tosa_lcd_tg_init(data); | ||
241 | if (POWER_IS_ON(data->lcd_power)) | ||
242 | tosa_lcd_tg_on(data); | ||
243 | else | ||
244 | tosa_lcd_tg_off(data); | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | #else | ||
249 | #define tosa_lcd_suspend NULL | ||
250 | #define tosa_lcd_reume NULL | ||
251 | #endif | ||
252 | |||
253 | static struct spi_driver tosa_lcd_driver = { | ||
254 | .driver = { | ||
255 | .name = "tosa-lcd", | ||
256 | .owner = THIS_MODULE, | ||
257 | }, | ||
258 | .probe = tosa_lcd_probe, | ||
259 | .remove = __devexit_p(tosa_lcd_remove), | ||
260 | .suspend = tosa_lcd_suspend, | ||
261 | .resume = tosa_lcd_resume, | ||
262 | }; | ||
263 | |||
264 | static int __init tosa_lcd_init(void) | ||
265 | { | ||
266 | return spi_register_driver(&tosa_lcd_driver); | ||
267 | } | ||
268 | |||
269 | static void __exit tosa_lcd_exit(void) | ||
270 | { | ||
271 | spi_unregister_driver(&tosa_lcd_driver); | ||
272 | } | ||
273 | |||
274 | module_init(tosa_lcd_init); | ||
275 | module_exit(tosa_lcd_exit); | ||
276 | |||
277 | MODULE_AUTHOR("Dmitry Baryshkov"); | ||
278 | MODULE_LICENSE("GPL v2"); | ||
279 | MODULE_DESCRIPTION("LCD/Backlight control for Sharp SL-6000 PDA"); | ||
280 | |||