viafb: use proper pci config API
[linux/fpc-iii.git] / drivers / video / backlight / corgi_lcd.c
blob73bdd8454c943ed587b6fd3bf7abbf83a64ef622
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 <asm/mach/sharpsl_param.h>
29 #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
31 /* Register Addresses */
32 #define RESCTL_ADRS 0x00
33 #define PHACTRL_ADRS 0x01
34 #define DUTYCTRL_ADRS 0x02
35 #define POWERREG0_ADRS 0x03
36 #define POWERREG1_ADRS 0x04
37 #define GPOR3_ADRS 0x05
38 #define PICTRL_ADRS 0x06
39 #define POLCTRL_ADRS 0x07
41 /* Register Bit Definitions */
42 #define RESCTL_QVGA 0x01
43 #define RESCTL_VGA 0x00
45 #define POWER1_VW_ON 0x01 /* VW Supply FET ON */
46 #define POWER1_GVSS_ON 0x02 /* GVSS(-8V) Power Supply ON */
47 #define POWER1_VDD_ON 0x04 /* VDD(8V),SVSS(-4V) Power Supply ON */
49 #define POWER1_VW_OFF 0x00 /* VW Supply FET OFF */
50 #define POWER1_GVSS_OFF 0x00 /* GVSS(-8V) Power Supply OFF */
51 #define POWER1_VDD_OFF 0x00 /* VDD(8V),SVSS(-4V) Power Supply OFF */
53 #define POWER0_COM_DCLK 0x01 /* COM Voltage DC Bias DAC Serial Data Clock */
54 #define POWER0_COM_DOUT 0x02 /* COM Voltage DC Bias DAC Serial Data Out */
55 #define POWER0_DAC_ON 0x04 /* DAC Power Supply ON */
56 #define POWER0_COM_ON 0x08 /* COM Power Supply ON */
57 #define POWER0_VCC5_ON 0x10 /* VCC5 Power Supply ON */
59 #define POWER0_DAC_OFF 0x00 /* DAC Power Supply OFF */
60 #define POWER0_COM_OFF 0x00 /* COM Power Supply OFF */
61 #define POWER0_VCC5_OFF 0x00 /* VCC5 Power Supply OFF */
63 #define PICTRL_INIT_STATE 0x01
64 #define PICTRL_INIOFF 0x02
65 #define PICTRL_POWER_DOWN 0x04
66 #define PICTRL_COM_SIGNAL_OFF 0x08
67 #define PICTRL_DAC_SIGNAL_OFF 0x10
69 #define POLCTRL_SYNC_POL_FALL 0x01
70 #define POLCTRL_EN_POL_FALL 0x02
71 #define POLCTRL_DATA_POL_FALL 0x04
72 #define POLCTRL_SYNC_ACT_H 0x08
73 #define POLCTRL_EN_ACT_L 0x10
75 #define POLCTRL_SYNC_POL_RISE 0x00
76 #define POLCTRL_EN_POL_RISE 0x00
77 #define POLCTRL_DATA_POL_RISE 0x00
78 #define POLCTRL_SYNC_ACT_L 0x00
79 #define POLCTRL_EN_ACT_H 0x00
81 #define PHACTRL_PHASE_MANUAL 0x01
82 #define DEFAULT_PHAD_QVGA (9)
83 #define DEFAULT_COMADJ (125)
85 struct corgi_lcd {
86 struct spi_device *spi_dev;
87 struct lcd_device *lcd_dev;
88 struct backlight_device *bl_dev;
90 int limit_mask;
91 int intensity;
92 int power;
93 int mode;
94 char buf[2];
96 int gpio_backlight_on;
97 int gpio_backlight_cont;
98 int gpio_backlight_cont_inverted;
100 void (*kick_battery)(void);
103 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int reg, uint8_t val);
105 static struct corgi_lcd *the_corgi_lcd;
106 static unsigned long corgibl_flags;
107 #define CORGIBL_SUSPENDED 0x01
108 #define CORGIBL_BATTLOW 0x02
111 * This is only a psuedo I2C interface. We can't use the standard kernel
112 * routines as the interface is write only. We just assume the data is acked...
114 static void lcdtg_ssp_i2c_send(struct corgi_lcd *lcd, uint8_t data)
116 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, data);
117 udelay(10);
120 static void lcdtg_i2c_send_bit(struct corgi_lcd *lcd, uint8_t data)
122 lcdtg_ssp_i2c_send(lcd, data);
123 lcdtg_ssp_i2c_send(lcd, data | POWER0_COM_DCLK);
124 lcdtg_ssp_i2c_send(lcd, data);
127 static void lcdtg_i2c_send_start(struct corgi_lcd *lcd, uint8_t base)
129 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT);
130 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK);
131 lcdtg_ssp_i2c_send(lcd, base);
134 static void lcdtg_i2c_send_stop(struct corgi_lcd *lcd, uint8_t base)
136 lcdtg_ssp_i2c_send(lcd, base);
137 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK);
138 lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT);
141 static void lcdtg_i2c_send_byte(struct corgi_lcd *lcd,
142 uint8_t base, uint8_t data)
144 int i;
145 for (i = 0; i < 8; i++) {
146 if (data & 0x80)
147 lcdtg_i2c_send_bit(lcd, base | POWER0_COM_DOUT);
148 else
149 lcdtg_i2c_send_bit(lcd, base);
150 data <<= 1;
154 static void lcdtg_i2c_wait_ack(struct corgi_lcd *lcd, uint8_t base)
156 lcdtg_i2c_send_bit(lcd, base);
159 static void lcdtg_set_common_voltage(struct corgi_lcd *lcd,
160 uint8_t base_data, uint8_t data)
162 /* Set Common Voltage to M62332FP via I2C */
163 lcdtg_i2c_send_start(lcd, base_data);
164 lcdtg_i2c_send_byte(lcd, base_data, 0x9c);
165 lcdtg_i2c_wait_ack(lcd, base_data);
166 lcdtg_i2c_send_byte(lcd, base_data, 0x00);
167 lcdtg_i2c_wait_ack(lcd, base_data);
168 lcdtg_i2c_send_byte(lcd, base_data, data);
169 lcdtg_i2c_wait_ack(lcd, base_data);
170 lcdtg_i2c_send_stop(lcd, base_data);
173 static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int adrs, uint8_t data)
175 struct spi_message msg;
176 struct spi_transfer xfer = {
177 .len = 1,
178 .cs_change = 1,
179 .tx_buf = lcd->buf,
182 lcd->buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f);
183 spi_message_init(&msg);
184 spi_message_add_tail(&xfer, &msg);
186 return spi_sync(lcd->spi_dev, &msg);
189 /* Set Phase Adjust */
190 static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode)
192 int adj;
194 switch(mode) {
195 case CORGI_LCD_MODE_VGA:
196 /* Setting for VGA */
197 adj = sharpsl_param.phadadj;
198 adj = (adj < 0) ? PHACTRL_PHASE_MANUAL :
199 PHACTRL_PHASE_MANUAL | ((adj & 0xf) << 1);
200 break;
201 case CORGI_LCD_MODE_QVGA:
202 default:
203 /* Setting for QVGA */
204 adj = (DEFAULT_PHAD_QVGA << 1) | PHACTRL_PHASE_MANUAL;
205 break;
208 corgi_ssp_lcdtg_send(lcd, PHACTRL_ADRS, adj);
211 static void corgi_lcd_power_on(struct corgi_lcd *lcd)
213 int comadj;
215 /* Initialize Internal Logic & Port */
216 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
217 PICTRL_POWER_DOWN | PICTRL_INIOFF |
218 PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF |
219 PICTRL_DAC_SIGNAL_OFF);
221 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
222 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_OFF |
223 POWER0_COM_OFF | POWER0_VCC5_OFF);
225 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
226 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
228 /* VDD(+8V), SVSS(-4V) ON */
229 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
230 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
231 mdelay(3);
233 /* DAC ON */
234 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
235 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
236 POWER0_COM_OFF | POWER0_VCC5_OFF);
238 /* INIB = H, INI = L */
239 /* PICTL[0] = H , PICTL[1] = PICTL[2] = PICTL[4] = L */
240 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
241 PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF);
243 /* Set Common Voltage */
244 comadj = sharpsl_param.comadj;
245 if (comadj < 0)
246 comadj = DEFAULT_COMADJ;
248 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF |
249 POWER0_VCC5_OFF, comadj);
251 /* VCC5 ON, DAC ON */
252 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
253 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
254 POWER0_COM_OFF | POWER0_VCC5_ON);
256 /* GVSS(-8V) ON, VDD ON */
257 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
258 POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
259 mdelay(2);
261 /* COM SIGNAL ON (PICTL[3] = L) */
262 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_INIT_STATE);
264 /* COM ON, DAC ON, VCC5_ON */
265 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
266 POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON |
267 POWER0_COM_ON | POWER0_VCC5_ON);
269 /* VW ON, GVSS ON, VDD ON */
270 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
271 POWER1_VW_ON | POWER1_GVSS_ON | POWER1_VDD_ON);
273 /* Signals output enable */
274 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, 0);
276 /* Set Phase Adjust */
277 lcdtg_set_phadadj(lcd, lcd->mode);
279 /* Initialize for Input Signals from ATI */
280 corgi_ssp_lcdtg_send(lcd, POLCTRL_ADRS,
281 POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE |
282 POLCTRL_DATA_POL_RISE | POLCTRL_SYNC_ACT_L |
283 POLCTRL_EN_ACT_H);
284 udelay(1000);
286 switch (lcd->mode) {
287 case CORGI_LCD_MODE_VGA:
288 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA);
289 break;
290 case CORGI_LCD_MODE_QVGA:
291 default:
292 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA);
293 break;
297 static void corgi_lcd_power_off(struct corgi_lcd *lcd)
299 /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */
300 msleep(34);
302 /* (1)VW OFF */
303 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
304 POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON);
306 /* (2)COM OFF */
307 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF);
308 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
309 POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON);
311 /* (3)Set Common Voltage Bias 0V */
312 lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF |
313 POWER0_VCC5_ON, 0);
315 /* (4)GVSS OFF */
316 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
317 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON);
319 /* (5)VCC5 OFF */
320 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
321 POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF);
323 /* (6)Set PDWN, INIOFF, DACOFF */
324 corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS,
325 PICTRL_INIOFF | PICTRL_DAC_SIGNAL_OFF |
326 PICTRL_POWER_DOWN | PICTRL_COM_SIGNAL_OFF);
328 /* (7)DAC OFF */
329 corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS,
330 POWER0_DAC_OFF | POWER0_COM_OFF | POWER0_VCC5_OFF);
332 /* (8)VDD OFF */
333 corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS,
334 POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF);
337 static int corgi_lcd_set_mode(struct lcd_device *ld, struct fb_videomode *m)
339 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
340 int mode = CORGI_LCD_MODE_QVGA;
342 if (m->xres == 640 || m->xres == 480)
343 mode = CORGI_LCD_MODE_VGA;
345 if (lcd->mode == mode)
346 return 0;
348 lcdtg_set_phadadj(lcd, mode);
350 switch (mode) {
351 case CORGI_LCD_MODE_VGA:
352 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA);
353 break;
354 case CORGI_LCD_MODE_QVGA:
355 default:
356 corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA);
357 break;
360 lcd->mode = mode;
361 return 0;
364 static int corgi_lcd_set_power(struct lcd_device *ld, int power)
366 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
368 if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power))
369 corgi_lcd_power_on(lcd);
371 if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power))
372 corgi_lcd_power_off(lcd);
374 lcd->power = power;
375 return 0;
378 static int corgi_lcd_get_power(struct lcd_device *ld)
380 struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev);
382 return lcd->power;
385 static struct lcd_ops corgi_lcd_ops = {
386 .get_power = corgi_lcd_get_power,
387 .set_power = corgi_lcd_set_power,
388 .set_mode = corgi_lcd_set_mode,
391 static int corgi_bl_get_intensity(struct backlight_device *bd)
393 struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev);
395 return lcd->intensity;
398 static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
400 int cont;
402 if (intensity > 0x10)
403 intensity += 0x10;
405 corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity);
407 /* Bit 5 via GPIO_BACKLIGHT_CONT */
408 cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted;
410 if (gpio_is_valid(lcd->gpio_backlight_cont))
411 gpio_set_value(lcd->gpio_backlight_cont, cont);
413 if (gpio_is_valid(lcd->gpio_backlight_on))
414 gpio_set_value(lcd->gpio_backlight_on, intensity);
416 if (lcd->kick_battery)
417 lcd->kick_battery();
419 lcd->intensity = intensity;
420 return 0;
423 static int corgi_bl_update_status(struct backlight_device *bd)
425 struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev);
426 int intensity = bd->props.brightness;
428 if (bd->props.power != FB_BLANK_UNBLANK)
429 intensity = 0;
431 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
432 intensity = 0;
434 if (corgibl_flags & CORGIBL_SUSPENDED)
435 intensity = 0;
437 if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask)
438 intensity = lcd->limit_mask;
440 return corgi_bl_set_intensity(lcd, intensity);
443 void corgi_lcd_limit_intensity(int limit)
445 if (limit)
446 corgibl_flags |= CORGIBL_BATTLOW;
447 else
448 corgibl_flags &= ~CORGIBL_BATTLOW;
450 backlight_update_status(the_corgi_lcd->bl_dev);
452 EXPORT_SYMBOL(corgi_lcd_limit_intensity);
454 static const struct backlight_ops corgi_bl_ops = {
455 .get_brightness = corgi_bl_get_intensity,
456 .update_status = corgi_bl_update_status,
459 #ifdef CONFIG_PM
460 static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state)
462 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
464 corgibl_flags |= CORGIBL_SUSPENDED;
465 corgi_bl_set_intensity(lcd, 0);
466 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
467 return 0;
470 static int corgi_lcd_resume(struct spi_device *spi)
472 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
474 corgibl_flags &= ~CORGIBL_SUSPENDED;
475 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
476 backlight_update_status(lcd->bl_dev);
477 return 0;
479 #else
480 #define corgi_lcd_suspend NULL
481 #define corgi_lcd_resume NULL
482 #endif
484 static int setup_gpio_backlight(struct corgi_lcd *lcd,
485 struct corgi_lcd_platform_data *pdata)
487 struct spi_device *spi = lcd->spi_dev;
488 int err;
490 lcd->gpio_backlight_on = -1;
491 lcd->gpio_backlight_cont = -1;
493 if (gpio_is_valid(pdata->gpio_backlight_on)) {
494 err = gpio_request(pdata->gpio_backlight_on, "BL_ON");
495 if (err) {
496 dev_err(&spi->dev, "failed to request GPIO%d for "
497 "backlight_on\n", pdata->gpio_backlight_on);
498 return err;
501 lcd->gpio_backlight_on = pdata->gpio_backlight_on;
502 gpio_direction_output(lcd->gpio_backlight_on, 0);
505 if (gpio_is_valid(pdata->gpio_backlight_cont)) {
506 err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT");
507 if (err) {
508 dev_err(&spi->dev, "failed to request GPIO%d for "
509 "backlight_cont\n", pdata->gpio_backlight_cont);
510 goto err_free_backlight_on;
513 lcd->gpio_backlight_cont = pdata->gpio_backlight_cont;
515 /* spitz and akita use both GPIOs for backlight, and
516 * have inverted polarity of GPIO_BACKLIGHT_CONT
518 if (gpio_is_valid(lcd->gpio_backlight_on)) {
519 lcd->gpio_backlight_cont_inverted = 1;
520 gpio_direction_output(lcd->gpio_backlight_cont, 1);
521 } else {
522 lcd->gpio_backlight_cont_inverted = 0;
523 gpio_direction_output(lcd->gpio_backlight_cont, 0);
526 return 0;
528 err_free_backlight_on:
529 if (gpio_is_valid(lcd->gpio_backlight_on))
530 gpio_free(lcd->gpio_backlight_on);
531 return err;
534 static int __devinit corgi_lcd_probe(struct spi_device *spi)
536 struct backlight_properties props;
537 struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
538 struct corgi_lcd *lcd;
539 int ret = 0;
541 if (pdata == NULL) {
542 dev_err(&spi->dev, "platform data not available\n");
543 return -EINVAL;
546 lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL);
547 if (!lcd) {
548 dev_err(&spi->dev, "failed to allocate memory\n");
549 return -ENOMEM;
552 lcd->spi_dev = spi;
554 lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev,
555 lcd, &corgi_lcd_ops);
556 if (IS_ERR(lcd->lcd_dev)) {
557 ret = PTR_ERR(lcd->lcd_dev);
558 goto err_free_lcd;
560 lcd->power = FB_BLANK_POWERDOWN;
561 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
563 memset(&props, 0, sizeof(struct backlight_properties));
564 props.max_brightness = pdata->max_intensity;
565 lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
566 &corgi_bl_ops, &props);
567 if (IS_ERR(lcd->bl_dev)) {
568 ret = PTR_ERR(lcd->bl_dev);
569 goto err_unregister_lcd;
571 lcd->bl_dev->props.brightness = pdata->default_intensity;
572 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
574 ret = setup_gpio_backlight(lcd, pdata);
575 if (ret)
576 goto err_unregister_bl;
578 lcd->kick_battery = pdata->kick_battery;
580 dev_set_drvdata(&spi->dev, lcd);
581 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
582 backlight_update_status(lcd->bl_dev);
584 lcd->limit_mask = pdata->limit_mask;
585 the_corgi_lcd = lcd;
586 return 0;
588 err_unregister_bl:
589 backlight_device_unregister(lcd->bl_dev);
590 err_unregister_lcd:
591 lcd_device_unregister(lcd->lcd_dev);
592 err_free_lcd:
593 kfree(lcd);
594 return ret;
597 static int __devexit corgi_lcd_remove(struct spi_device *spi)
599 struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev);
601 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
602 lcd->bl_dev->props.brightness = 0;
603 backlight_update_status(lcd->bl_dev);
604 backlight_device_unregister(lcd->bl_dev);
606 if (gpio_is_valid(lcd->gpio_backlight_on))
607 gpio_free(lcd->gpio_backlight_on);
609 if (gpio_is_valid(lcd->gpio_backlight_cont))
610 gpio_free(lcd->gpio_backlight_cont);
612 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
613 lcd_device_unregister(lcd->lcd_dev);
614 kfree(lcd);
616 return 0;
619 static struct spi_driver corgi_lcd_driver = {
620 .driver = {
621 .name = "corgi-lcd",
622 .owner = THIS_MODULE,
624 .probe = corgi_lcd_probe,
625 .remove = __devexit_p(corgi_lcd_remove),
626 .suspend = corgi_lcd_suspend,
627 .resume = corgi_lcd_resume,
630 static int __init corgi_lcd_init(void)
632 return spi_register_driver(&corgi_lcd_driver);
634 module_init(corgi_lcd_init);
636 static void __exit corgi_lcd_exit(void)
638 spi_unregister_driver(&corgi_lcd_driver);
640 module_exit(corgi_lcd_exit);
642 MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00");
643 MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>");
644 MODULE_LICENSE("GPL");
645 MODULE_ALIAS("spi:corgi-lcd");