aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pxa/corgi.c9
-rw-r--r--arch/arm/mach-pxa/spitz.c23
-rw-r--r--drivers/video/backlight/corgi_lcd.c83
-rw-r--r--include/linux/spi/corgi_lcd.h3
4 files changed, 90 insertions, 28 deletions
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index f8fd1d872157..5c08c4e9cd22 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -444,12 +444,6 @@ static struct pxa2xx_spi_chip corgi_ads7846_chip = {
444 .cs_control = corgi_ads7846_cs, 444 .cs_control = corgi_ads7846_cs,
445}; 445};
446 446
447static void corgi_notify_intensity(int intensity)
448{
449 /* Bit 5 is via SCOOP */
450 gpio_set_value(CORGI_GPIO_BACKLIGHT_CONT, !!(intensity & 0x0020));
451}
452
453static void corgi_bl_kick_battery(void) 447static void corgi_bl_kick_battery(void)
454{ 448{
455 void (*kick_batt)(void); 449 void (*kick_batt)(void);
@@ -466,7 +460,8 @@ static struct corgi_lcd_platform_data corgi_lcdcon_info = {
466 .max_intensity = 0x2f, 460 .max_intensity = 0x2f,
467 .default_intensity = 0x1f, 461 .default_intensity = 0x1f,
468 .limit_mask = 0x0b, 462 .limit_mask = 0x0b,
469 .notify = corgi_notify_intensity, 463 .gpio_backlight_cont = CORGI_GPIO_BACKLIGHT_CONT,
464 .gpio_backlight_on = -1,
470 .kick_battery = corgi_bl_kick_battery, 465 .kick_battery = corgi_bl_kick_battery,
471}; 466};
472 467
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 1d8654d2fb96..245890d2b6b5 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -305,21 +305,6 @@ static struct pxa2xx_spi_chip spitz_ads7846_chip = {
305 .cs_control = spitz_ads7846_cs, 305 .cs_control = spitz_ads7846_cs,
306}; 306};
307 307
308static void spitz_notify_intensity(int intensity)
309{
310 if (machine_is_spitz() || machine_is_borzoi()) {
311 gpio_set_value(SPITZ_GPIO_BACKLIGHT_CONT, !(intensity & 0x20));
312 gpio_set_value(SPITZ_GPIO_BACKLIGHT_ON, intensity);
313 return;
314 }
315
316 if (machine_is_akita()) {
317 gpio_set_value(AKITA_GPIO_BACKLIGHT_CONT, !(intensity & 0x20));
318 gpio_set_value(AKITA_GPIO_BACKLIGHT_ON, intensity);
319 return;
320 }
321}
322
323static void spitz_bl_kick_battery(void) 308static void spitz_bl_kick_battery(void)
324{ 309{
325 void (*kick_batt)(void); 310 void (*kick_batt)(void);
@@ -336,7 +321,8 @@ static struct corgi_lcd_platform_data spitz_lcdcon_info = {
336 .max_intensity = 0x2f, 321 .max_intensity = 0x2f,
337 .default_intensity = 0x1f, 322 .default_intensity = 0x1f,
338 .limit_mask = 0x0b, 323 .limit_mask = 0x0b,
339 .notify = spitz_notify_intensity, 324 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
325 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
340 .kick_battery = spitz_bl_kick_battery, 326 .kick_battery = spitz_bl_kick_battery,
341}; 327};
342 328
@@ -399,6 +385,11 @@ static void __init spitz_init_spi(void)
399 if (err) 385 if (err)
400 goto err_free_2; 386 goto err_free_2;
401 387
388 if (machine_is_akita()) {
389 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
390 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
391 }
392
402 pxa2xx_set_spi_info(2, &spitz_spi_info); 393 pxa2xx_set_spi_info(2, &spitz_spi_info);
403 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); 394 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
404 return; 395 return;
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 068f14864099..2afd47eefe74 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/gpio.h>
22#include <linux/fb.h> 23#include <linux/fb.h>
23#include <linux/lcd.h> 24#include <linux/lcd.h>
24#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
@@ -92,7 +93,10 @@ struct corgi_lcd {
92 int mode; 93 int mode;
93 char buf[2]; 94 char buf[2];
94 95
95 void (*notify)(int intensity); 96 int gpio_backlight_on;
97 int gpio_backlight_cont;
98 int gpio_backlight_cont_inverted;
99
96 void (*kick_battery)(void); 100 void (*kick_battery)(void);
97}; 101};
98 102
@@ -393,18 +397,26 @@ static int corgi_bl_get_intensity(struct backlight_device *bd)
393 397
394static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) 398static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
395{ 399{
400 int cont;
401
396 if (intensity > 0x10) 402 if (intensity > 0x10)
397 intensity += 0x10; 403 intensity += 0x10;
398 404
399 corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity); 405 corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity);
400 lcd->intensity = intensity;
401 406
402 if (lcd->notify) 407 /* Bit 5 via GPIO_BACKLIGHT_CONT */
403 lcd->notify(intensity); 408 cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted;
409
410 if (gpio_is_valid(lcd->gpio_backlight_cont))
411 gpio_set_value(lcd->gpio_backlight_cont, cont);
412
413 if (gpio_is_valid(lcd->gpio_backlight_on))
414 gpio_set_value(lcd->gpio_backlight_on, intensity);
404 415
405 if (lcd->kick_battery) 416 if (lcd->kick_battery)
406 lcd->kick_battery(); 417 lcd->kick_battery();
407 418
419 lcd->intensity = intensity;
408 return 0; 420 return 0;
409} 421}
410 422
@@ -468,6 +480,56 @@ static int corgi_lcd_resume(struct spi_device *spi)
468#define corgi_lcd_resume NULL 480#define corgi_lcd_resume NULL
469#endif 481#endif
470 482
483static int setup_gpio_backlight(struct corgi_lcd *lcd,
484 struct corgi_lcd_platform_data *pdata)
485{
486 struct spi_device *spi = lcd->spi_dev;
487 int err;
488
489 lcd->gpio_backlight_on = -1;
490 lcd->gpio_backlight_cont = -1;
491
492 if (gpio_is_valid(pdata->gpio_backlight_on)) {
493 err = gpio_request(pdata->gpio_backlight_on, "BL_ON");
494 if (err) {
495 dev_err(&spi->dev, "failed to request GPIO%d for "
496 "backlight_on\n", pdata->gpio_backlight_on);
497 return err;
498 }
499
500 lcd->gpio_backlight_on = pdata->gpio_backlight_on;
501 gpio_direction_output(lcd->gpio_backlight_on, 0);
502 }
503
504 if (gpio_is_valid(pdata->gpio_backlight_cont)) {
505 err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT");
506 if (err) {
507 dev_err(&spi->dev, "failed to request GPIO%d for "
508 "backlight_cont\n", pdata->gpio_backlight_cont);
509 goto err_free_backlight_on;
510 }
511
512 lcd->gpio_backlight_cont = pdata->gpio_backlight_cont;
513
514 /* spitz and akita use both GPIOs for backlight, and
515 * have inverted polarity of GPIO_BACKLIGHT_CONT
516 */
517 if (gpio_is_valid(lcd->gpio_backlight_on)) {
518 lcd->gpio_backlight_cont_inverted = 1;
519 gpio_direction_output(lcd->gpio_backlight_cont, 1);
520 } else {
521 lcd->gpio_backlight_cont_inverted = 0;
522 gpio_direction_output(lcd->gpio_backlight_cont, 0);
523 }
524 }
525 return 0;
526
527err_free_backlight_on:
528 if (gpio_is_valid(lcd->gpio_backlight_on))
529 gpio_free(lcd->gpio_backlight_on);
530 return err;
531}
532
471static int __devinit corgi_lcd_probe(struct spi_device *spi) 533static int __devinit corgi_lcd_probe(struct spi_device *spi)
472{ 534{
473 struct corgi_lcd_platform_data *pdata = spi->dev.platform_data; 535 struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
@@ -506,7 +568,10 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
506 lcd->bl_dev->props.brightness = pdata->default_intensity; 568 lcd->bl_dev->props.brightness = pdata->default_intensity;
507 lcd->bl_dev->props.power = FB_BLANK_UNBLANK; 569 lcd->bl_dev->props.power = FB_BLANK_UNBLANK;
508 570
509 lcd->notify = pdata->notify; 571 ret = setup_gpio_backlight(lcd, pdata);
572 if (ret)
573 goto err_unregister_bl;
574
510 lcd->kick_battery = pdata->kick_battery; 575 lcd->kick_battery = pdata->kick_battery;
511 576
512 dev_set_drvdata(&spi->dev, lcd); 577 dev_set_drvdata(&spi->dev, lcd);
@@ -517,6 +582,8 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
517 the_corgi_lcd = lcd; 582 the_corgi_lcd = lcd;
518 return 0; 583 return 0;
519 584
585err_unregister_bl:
586 backlight_device_unregister(lcd->bl_dev);
520err_unregister_lcd: 587err_unregister_lcd:
521 lcd_device_unregister(lcd->lcd_dev); 588 lcd_device_unregister(lcd->lcd_dev);
522err_free_lcd: 589err_free_lcd:
@@ -533,6 +600,12 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi)
533 backlight_update_status(lcd->bl_dev); 600 backlight_update_status(lcd->bl_dev);
534 backlight_device_unregister(lcd->bl_dev); 601 backlight_device_unregister(lcd->bl_dev);
535 602
603 if (gpio_is_valid(lcd->gpio_backlight_on))
604 gpio_free(lcd->gpio_backlight_on);
605
606 if (gpio_is_valid(lcd->gpio_backlight_cont))
607 gpio_free(lcd->gpio_backlight_cont);
608
536 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); 609 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
537 lcd_device_unregister(lcd->lcd_dev); 610 lcd_device_unregister(lcd->lcd_dev);
538 kfree(lcd); 611 kfree(lcd);
diff --git a/include/linux/spi/corgi_lcd.h b/include/linux/spi/corgi_lcd.h
index b6161aae2752..6692b3418ccf 100644
--- a/include/linux/spi/corgi_lcd.h
+++ b/include/linux/spi/corgi_lcd.h
@@ -10,6 +10,9 @@ struct corgi_lcd_platform_data {
10 int default_intensity; 10 int default_intensity;
11 int limit_mask; 11 int limit_mask;
12 12
13 int gpio_backlight_on; /* -1 if n/a */
14 int gpio_backlight_cont; /* -1 if n/a */
15
13 void (*notify)(int intensity); 16 void (*notify)(int intensity);
14 void (*kick_battery)(void); 17 void (*kick_battery)(void);
15}; 18};