USB: convert some miscellanies drivers to use module_usb_driver()
[zen-stable.git] / drivers / video / backlight / corgi_lcd.c
blobc6533bad26f86cb647792198cf4de02446cd64a8
1 /*
2 * LCD/Backlight Driver for Sharp Zaurus Handhelds (various models)
4 * Copyright (c) 2004-2006 Richard Purdie
6 * Based on Sharp's 2.4 Backlight Driver
8 * Copyright (c) 2008 Marvell International Ltd.
9 * Converted to SPI device based LCD/Backlight device driver
10 * by Eric Miao <eric.miao@marvell.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/gpio.h>
23 #include <linux/fb.h>
24 #include <linux/lcd.h>
25 #include <linux/spi/spi.h>
26 #include <linux/spi/corgi_lcd.h>
27 #include <linux/slab.h>
28 #include <asm/mach/sharpsl_param.h>
30 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
32 /* Register Addresses */
33 #define RESCTL_ADRS 0x00
34 #define PHACTRL_ADRS 0x01
35 #define DUTYCTRL_ADRS 0x02
36 #define POWERREG0_ADRS 0x03
37 #define POWERREG1_ADRS 0x04
38 #define GPOR3_ADRS 0x05
39 #define PICTRL_ADRS 0x06
40 #define POLCTRL_ADRS 0x07
42 /* Register Bit Definitions */
43 #define RESCTL_QVGA 0x01
44 #define RESCTL_VGA 0x00
46 #define POWER1_VW_ON 0x01 /* VW Supply FET ON */
47 #define POWER1_GVSS_ON 0x02 /* GVSS(-8V) Power Supply ON */
48 #define POWER1_VDD_ON 0x04 /* VDD(8V),SVSS(-4V) Power Supply ON */
50 #define POWER1_VW_OFF 0x00 /* VW Supply FET OFF */
51 #define POWER1_GVSS_OFF 0x00 /* GVSS(-8V) Power Supply OFF */
52 #define POWER1_VDD_OFF 0x00 /* VDD(8V),SVSS(-4V) Power Supply OFF */
54 #define POWER0_COM_DCLK 0x01 /* COM Voltage DC Bias DAC Serial Data Clock */
55 #define POWER0_COM_DOUT 0x02 /* COM Voltage DC Bias DAC Serial Data Out */
56 #define POWER0_DAC_ON 0x04 /* DAC Power Supply ON */
57 #define POWER0_COM_ON 0x08 /* COM Power Supply ON */
58 #define POWER0_VCC5_ON 0x10 /* VCC5 Power Supply ON */
60 #define POWER0_DAC_OFF 0x00 /* DAC Power Supply OFF */
61 #define POWER0_COM_OFF 0x00 /* COM Power Supply OFF */
62 #define POWER0_VCC5_OFF 0x00 /* VCC5 Power Supply OFF */
64 #define PICTRL_INIT_STATE 0x01
65 #define PICTRL_INIOFF 0x02
66 #define PICTRL_POWER_DOWN 0x04
67 #define PICTRL_COM_SIGNAL_OFF 0x08
68 #define PICTRL_DAC_SIGNAL_OFF 0x10
70 #define POLCTRL_SYNC_POL_FALL 0x01
71 #define POLCTRL_EN_POL_FALL 0x02
72 #define POLCTRL_DATA_POL_FALL 0x04
73 #define POLCTRL_SYNC_ACT_H 0x08
74 #define POLCTRL_EN_ACT_L 0x10
76 #define POLCTRL_SYNC_POL_RISE 0x00
77 #define POLCTRL_EN_POL_RISE 0x00
78 #define POLCTRL_DATA_POL_RISE 0x00
79 #define POLCTRL_SYNC_ACT_L 0x00
80 #define POLCTRL_EN_ACT_H 0x00
82 #define PHACTRL_PHASE_MANUAL 0x01
83 #define DEFAULT_PHAD_QVGA (9)
84 #define DEFAULT_COMADJ (125)
86 struct corgi_lcd {
87 struct spi_device *spi_dev;
88 struct lcd_device *lcd_dev;
89 struct backlight_device *bl_dev;
91 int limit_mask;
92 int intensity;
93 int power;
94 int mode;
95 char buf[2];
97 int gpio_backlight_on;
98 int gpio_backlight_cont;
99 int gpio_backlight_cont_inverted;
101 void (*kick_battery)(void);
104 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int reg, uint8_t val);
106 static struct corgi_lcd *the_corgi_lcd;
107 static unsigned long corgibl_flags;
108 #define CORGIBL_SUSPENDED 0x01
109 #define CORGIBL_BATTLOW 0x02
112 * This is only a pseudo I2C interface. We can't use the standard kernel
113 * routines as the interface is write only. We just assume the data is acked...
115 static void lcdtg_ssp_i2c_send(struct corgi_lcd *lcd, uint8_t data)
117 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, data);
118 udelay(10);
121 static void lcdtg_i2c_send_bit(struct corgi_lcd *lcd, uint8_t data)
123 lcdtg_ssp_i2c_send(lcd, data);
124 lcdtg_ssp_i2c_send(lcd, data | POWER0_COM_DCLK);
125 lcdtg_ssp_i2c_send(lcd, data);
128 static void lcdtg_i2c_send_start(struct corgi_lcd *lcd, uint8_t base)
130 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT);
131 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK);
132 lcdtg_ssp_i2c_send(lcd, base);
135 static void lcdtg_i2c_send_stop(struct corgi_lcd *lcd, uint8_t base)
137 lcdtg_ssp_i2c_send(lcd, base);
138 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK);
139 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT);
142 static void lcdtg_i2c_send_byte(struct corgi_lcd *lcd,
143 uint8_t base, uint8_t data)
145 int i;
146 for (i = 0; i < 8; i++) {
147 if (data & 0x80)
148 lcdtg_i2c_send_bit(lcd, base | POWER0_COM_DOUT);
149 else
150 lcdtg_i2c_send_bit(lcd, base);
151 data <<= 1;
155 static void lcdtg_i2c_wait_ack(struct corgi_lcd *lcd, uint8_t base)
157 lcdtg_i2c_send_bit(lcd, base);
160 static void lcdtg_set_common_voltage(struct corgi_lcd *lcd,
161 uint8_t base_data, uint8_t data)
163 /* Set Common Voltage to M62332FP via I2C */
164 lcdtg_i2c_send_start(lcd, base_data);
165 lcdtg_i2c_send_byte(lcd, base_data, 0x9c);
166 lcdtg_i2c_wait_ack(lcd, base_data);
167 lcdtg_i2c_send_byte(lcd, base_data, 0x00);
168 lcdtg_i2c_wait_ack(lcd, base_data);
169 lcdtg_i2c_send_byte(lcd, base_data, data);
170 lcdtg_i2c_wait_ack(lcd, base_data);
171 lcdtg_i2c_send_stop(lcd, base_data);
174 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int adrs, uint8_t data)
176 struct spi_message msg;
177 struct spi_transfer xfer = {
178 .len = 1,
179 .cs_change = 1,
180 .tx_buf = lcd->buf,
183 lcd->buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f);
184 spi_message_init(&msg);
185 spi_message_add_tail(&xfer, &msg);
187 return spi_sync(lcd->spi_dev, &msg);
190 /* Set Phase Adjust */
191 static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode)
193 int adj;
195 switch(mode) {
196 case CORGI_LCD_MODE_VGA:
197 /* Setting for VGA */
198 adj = sharpsl_param.phadadj;
199 adj = (adj < 0) ? PHACTRL_PHASE_MANUAL :
200 PHACTRL_PHASE_MANUAL | ((adj & 0xf) << 1);
201 break;
202 case CORGI_LCD_MODE_QVGA:
203 default:
204 /* Setting for QVGA */
205 adj = (DEFAULT_PHAD_QVGA << 1) | PHACTRL_PHASE_MANUAL;
206 break;
209 corgi_ssp_lcdtg_send(lcd, PHACTRL_ADRS, adj);
212 static void corgi_lcd_power_on(struct corgi_lcd *lcd)
214 int comadj;
216 /* Initialize Internal Logic & Port */
217 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
218 PICTRL_POWER_DOWN | PICTRL_INIOFF |
219 PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF |
220 PICTRL_DAC_SIGNAL_OFF);
222 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
223 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_OFF |
224 POWER0_COM_OFF | POWER0_VCC5_OFF);
226 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
227 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
229 /* VDD(+8V), SVSS(-4V) ON */
230 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
231 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
232 mdelay(3);
234 /* DAC ON */
235 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
236 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
237 POWER0_COM_OFF | POWER0_VCC5_OFF);
239 /* INIB = H, INI = L */
240 /* PICTL[0] = H , PICTL[1] = PICTL[2] = PICTL[4] = L */
241 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
242 PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF);
244 /* Set Common Voltage */
245 comadj = sharpsl_param.comadj;
246 if (comadj < 0)
247 comadj = DEFAULT_COMADJ;
249 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF |
250 POWER0_VCC5_OFF, comadj);
252 /* VCC5 ON, DAC ON */
253 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
254 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
255 POWER0_COM_OFF | POWER0_VCC5_ON);
257 /* GVSS(-8V) ON, VDD ON */
258 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
259 POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
260 mdelay(2);
262 /* COM SIGNAL ON (PICTL[3] = L) */
263 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_INIT_STATE);
265 /* COM ON, DAC ON, VCC5_ON */
266 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
267 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
268 POWER0_COM_ON | POWER0_VCC5_ON);
270 /* VW ON, GVSS ON, VDD ON */
271 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
272 POWER1_VW_ON | POWER1_GVSS_ON | POWER1_VDD_ON);
274 /* Signals output enable */
275 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, 0);
277 /* Set Phase Adjust */
278 lcdtg_set_phadadj(lcd, lcd->mode);
280 /* Initialize for Input Signals from ATI */
281 corgi_ssp_lcdtg_send(lcd, POLCTRL_ADRS,
282 POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE |
283 POLCTRL_DATA_POL_RISE | POLCTRL_SYNC_ACT_L |
284 POLCTRL_EN_ACT_H);
285 udelay(1000);
287 switch (lcd->mode) {
288 case CORGI_LCD_MODE_VGA:
289 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA);
290 break;
291 case CORGI_LCD_MODE_QVGA:
292 default:
293 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA);
294 break;
298 static void corgi_lcd_power_off(struct corgi_lcd *lcd)
300 /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */
301 msleep(34);
303 /* (1)VW OFF */
304 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
305 POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
307 /* (2)COM OFF */
308 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF);
309 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
310 POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON);
312 /* (3)Set Common Voltage Bias 0V */
313 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF |
314 POWER0_VCC5_ON, 0);
316 /* (4)GVSS OFF */
317 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
318 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
320 /* (5)VCC5 OFF */
321 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
322 POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF);
324 /* (6)Set PDWN, INIOFF, DACOFF */
325 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
326 PICTRL_INIOFF | PICTRL_DAC_SIGNAL_OFF |
327 PICTRL_POWER_DOWN | PICTRL_COM_SIGNAL_OFF);
329 /* (7)DAC OFF */
330 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
331 POWER0_DAC_OFF | POWER0_COM_OFF | POWER0_VCC5_OFF);
333 /* (8)VDD OFF */
334 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
335 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
338 static int corgi_lcd_set_mode(struct lcd_device *ld, struct fb_videomode *m)
340 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
341 int mode = CORGI_LCD_MODE_QVGA;
343 if (m->xres == 640 || m->xres == 480)
344 mode = CORGI_LCD_MODE_VGA;
346 if (lcd->mode == mode)
347 return 0;
349 lcdtg_set_phadadj(lcd, mode);
351 switch (mode) {
352 case CORGI_LCD_MODE_VGA:
353 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA);
354 break;
355 case CORGI_LCD_MODE_QVGA:
356 default:
357 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA);
358 break;
361 lcd->mode = mode;
362 return 0;
365 static int corgi_lcd_set_power(struct lcd_device *ld, int power)
367 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
369 if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power))
370 corgi_lcd_power_on(lcd);
372 if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power))
373 corgi_lcd_power_off(lcd);
375 lcd->power = power;
376 return 0;
379 static int corgi_lcd_get_power(struct lcd_device *ld)
381 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
383 return lcd->power;
386 static struct lcd_ops corgi_lcd_ops = {
387 .get_power = corgi_lcd_get_power,
388 .set_power = corgi_lcd_set_power,
389 .set_mode = corgi_lcd_set_mode,
392 static int corgi_bl_get_intensity(struct backlight_device *bd)
394 struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev);
396 return lcd->intensity;
399 static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
401 int cont;
403 if (intensity > 0x10)
404 intensity += 0x10;
406 corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity);
408 /* Bit 5 via GPIO_BACKLIGHT_CONT */
409 cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted;
411 if (gpio_is_valid(lcd->gpio_backlight_cont))
412 gpio_set_value(lcd->gpio_backlight_cont, cont);
414 if (gpio_is_valid(lcd->gpio_backlight_on))
415 gpio_set_value(lcd->gpio_backlight_on, intensity);
417 if (lcd->kick_battery)
418 lcd->kick_battery();
420 lcd->intensity = intensity;
421 return 0;
424 static int corgi_bl_update_status(struct backlight_device *bd)
426 struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev);
427 int intensity = bd->props.brightness;
429 if (bd->props.power != FB_BLANK_UNBLANK)
430 intensity = 0;
432 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
433 intensity = 0;
435 if (corgibl_flags & CORGIBL_SUSPENDED)
436 intensity = 0;
438 if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask)
439 intensity = lcd->limit_mask;
441 return corgi_bl_set_intensity(lcd, intensity);
444 void corgi_lcd_limit_intensity(int limit)
446 if (limit)
447 corgibl_flags |= CORGIBL_BATTLOW;
448 else
449 corgibl_flags &= ~CORGIBL_BATTLOW;
451 backlight_update_status(the_corgi_lcd->bl_dev);
453 EXPORT_SYMBOL(corgi_lcd_limit_intensity);
455 static const struct backlight_ops corgi_bl_ops = {
456 .get_brightness = corgi_bl_get_intensity,
457 .update_status = corgi_bl_update_status,
460 #ifdef CONFIG_PM
461 static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state)
463 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
465 corgibl_flags |= CORGIBL_SUSPENDED;
466 corgi_bl_set_intensity(lcd, 0);
467 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
468 return 0;
471 static int corgi_lcd_resume(struct spi_device *spi)
473 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
475 corgibl_flags &= ~CORGIBL_SUSPENDED;
476 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
477 backlight_update_status(lcd->bl_dev);
478 return 0;
480 #else
481 #define corgi_lcd_suspend NULL
482 #define corgi_lcd_resume NULL
483 #endif
485 static int setup_gpio_backlight(struct corgi_lcd *lcd,
486 struct corgi_lcd_platform_data *pdata)
488 struct spi_device *spi = lcd->spi_dev;
489 int err;
491 lcd->gpio_backlight_on = -1;
492 lcd->gpio_backlight_cont = -1;
494 if (gpio_is_valid(pdata->gpio_backlight_on)) {
495 err = gpio_request(pdata->gpio_backlight_on, "BL_ON");
496 if (err) {
497 dev_err(&spi->dev, "failed to request GPIO%d for "
498 "backlight_on\n", pdata->gpio_backlight_on);
499 return err;
502 lcd->gpio_backlight_on = pdata->gpio_backlight_on;
503 gpio_direction_output(lcd->gpio_backlight_on, 0);
506 if (gpio_is_valid(pdata->gpio_backlight_cont)) {
507 err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT");
508 if (err) {
509 dev_err(&spi->dev, "failed to request GPIO%d for "
510 "backlight_cont\n", pdata->gpio_backlight_cont);
511 goto err_free_backlight_on;
514 lcd->gpio_backlight_cont = pdata->gpio_backlight_cont;
516 /* spitz and akita use both GPIOs for backlight, and
517 * have inverted polarity of GPIO_BACKLIGHT_CONT
519 if (gpio_is_valid(lcd->gpio_backlight_on)) {
520 lcd->gpio_backlight_cont_inverted = 1;
521 gpio_direction_output(lcd->gpio_backlight_cont, 1);
522 } else {
523 lcd->gpio_backlight_cont_inverted = 0;
524 gpio_direction_output(lcd->gpio_backlight_cont, 0);
527 return 0;
529 err_free_backlight_on:
530 if (gpio_is_valid(lcd->gpio_backlight_on))
531 gpio_free(lcd->gpio_backlight_on);
532 return err;
535 static int __devinit corgi_lcd_probe(struct spi_device *spi)
537 struct backlight_properties props;
538 struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
539 struct corgi_lcd *lcd;
540 int ret = 0;
542 if (pdata == NULL) {
543 dev_err(&spi->dev, "platform data not available\n");
544 return -EINVAL;
547 lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL);
548 if (!lcd) {
549 dev_err(&spi->dev, "failed to allocate memory\n");
550 return -ENOMEM;
553 lcd->spi_dev = spi;
555 lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev,
556 lcd, &corgi_lcd_ops);
557 if (IS_ERR(lcd->lcd_dev)) {
558 ret = PTR_ERR(lcd->lcd_dev);
559 goto err_free_lcd;
561 lcd->power = FB_BLANK_POWERDOWN;
562 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
564 memset(&props, 0, sizeof(struct backlight_properties));
565 props.type = BACKLIGHT_RAW;
566 props.max_brightness = pdata->max_intensity;
567 lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
568 &corgi_bl_ops, &props);
569 if (IS_ERR(lcd->bl_dev)) {
570 ret = PTR_ERR(lcd->bl_dev);
571 goto err_unregister_lcd;
573 lcd->bl_dev->props.brightness = pdata->default_intensity;
574 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
576 ret = setup_gpio_backlight(lcd, pdata);
577 if (ret)
578 goto err_unregister_bl;
580 lcd->kick_battery = pdata->kick_battery;
582 dev_set_drvdata(&spi->dev, lcd);
583 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
584 backlight_update_status(lcd->bl_dev);
586 lcd->limit_mask = pdata->limit_mask;
587 the_corgi_lcd = lcd;
588 return 0;
590 err_unregister_bl:
591 backlight_device_unregister(lcd->bl_dev);
592 err_unregister_lcd:
593 lcd_device_unregister(lcd->lcd_dev);
594 err_free_lcd:
595 kfree(lcd);
596 return ret;
599 static int __devexit corgi_lcd_remove(struct spi_device *spi)
601 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
603 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
604 lcd->bl_dev->props.brightness = 0;
605 backlight_update_status(lcd->bl_dev);
606 backlight_device_unregister(lcd->bl_dev);
608 if (gpio_is_valid(lcd->gpio_backlight_on))
609 gpio_free(lcd->gpio_backlight_on);
611 if (gpio_is_valid(lcd->gpio_backlight_cont))
612 gpio_free(lcd->gpio_backlight_cont);
614 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
615 lcd_device_unregister(lcd->lcd_dev);
616 kfree(lcd);
618 return 0;
621 static struct spi_driver corgi_lcd_driver = {
622 .driver = {
623 .name = "corgi-lcd",
624 .owner = THIS_MODULE,
626 .probe = corgi_lcd_probe,
627 .remove = __devexit_p(corgi_lcd_remove),
628 .suspend = corgi_lcd_suspend,
629 .resume = corgi_lcd_resume,
632 static int __init corgi_lcd_init(void)
634 return spi_register_driver(&corgi_lcd_driver);
636 module_init(corgi_lcd_init);
638 static void __exit corgi_lcd_exit(void)
640 spi_unregister_driver(&corgi_lcd_driver);
642 module_exit(corgi_lcd_exit);
644 MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00");
645 MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
646 MODULE_LICENSE("GPL");
647 MODULE_ALIAS("spi:corgi-lcd");