diff options
Diffstat (limited to 'drivers/video/backlight/ams369fg06.c')
-rw-r--r-- | drivers/video/backlight/ams369fg06.c | 104 |
1 files changed, 31 insertions, 73 deletions
diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c index f57e1905236a..d29e49443f29 100644 --- a/drivers/video/backlight/ams369fg06.c +++ b/drivers/video/backlight/ams369fg06.c | |||
@@ -10,25 +10,16 @@ | |||
10 | * under the terms of the GNU General Public License as published by the | 10 | * under the terms of the GNU General Public License as published by the |
11 | * Free Software Foundation; either version 2 of the License, or (at your | 11 | * Free Software Foundation; either version 2 of the License, or (at your |
12 | * option) any later version. | 12 | * option) any later version. |
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | */ | 13 | */ |
23 | 14 | ||
24 | #include <linux/wait.h> | 15 | #include <linux/backlight.h> |
25 | #include <linux/module.h> | ||
26 | #include <linux/fb.h> | ||
27 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/fb.h> | ||
28 | #include <linux/gpio.h> | 18 | #include <linux/gpio.h> |
29 | #include <linux/spi/spi.h> | ||
30 | #include <linux/lcd.h> | 19 | #include <linux/lcd.h> |
31 | #include <linux/backlight.h> | 20 | #include <linux/module.h> |
21 | #include <linux/spi/spi.h> | ||
22 | #include <linux/wait.h> | ||
32 | 23 | ||
33 | #define SLEEPMSEC 0x1000 | 24 | #define SLEEPMSEC 0x1000 |
34 | #define ENDDEF 0x2000 | 25 | #define ENDDEF 0x2000 |
@@ -210,8 +201,9 @@ static int ams369fg06_panel_send_sequence(struct ams369fg06 *lcd, | |||
210 | ret = ams369fg06_spi_write(lcd, wbuf[i], wbuf[i+1]); | 201 | ret = ams369fg06_spi_write(lcd, wbuf[i], wbuf[i+1]); |
211 | if (ret) | 202 | if (ret) |
212 | break; | 203 | break; |
213 | } else | 204 | } else { |
214 | mdelay(wbuf[i+1]); | 205 | msleep(wbuf[i+1]); |
206 | } | ||
215 | i += 2; | 207 | i += 2; |
216 | } | 208 | } |
217 | 209 | ||
@@ -313,41 +305,32 @@ static int ams369fg06_ldi_disable(struct ams369fg06 *lcd) | |||
313 | 305 | ||
314 | static int ams369fg06_power_is_on(int power) | 306 | static int ams369fg06_power_is_on(int power) |
315 | { | 307 | { |
316 | return ((power) <= FB_BLANK_NORMAL); | 308 | return power <= FB_BLANK_NORMAL; |
317 | } | 309 | } |
318 | 310 | ||
319 | static int ams369fg06_power_on(struct ams369fg06 *lcd) | 311 | static int ams369fg06_power_on(struct ams369fg06 *lcd) |
320 | { | 312 | { |
321 | int ret = 0; | 313 | int ret = 0; |
322 | struct lcd_platform_data *pd = NULL; | 314 | struct lcd_platform_data *pd; |
323 | struct backlight_device *bd = NULL; | 315 | struct backlight_device *bd; |
324 | 316 | ||
325 | pd = lcd->lcd_pd; | 317 | pd = lcd->lcd_pd; |
326 | if (!pd) { | ||
327 | dev_err(lcd->dev, "platform data is NULL.\n"); | ||
328 | return -EFAULT; | ||
329 | } | ||
330 | |||
331 | bd = lcd->bd; | 318 | bd = lcd->bd; |
332 | if (!bd) { | ||
333 | dev_err(lcd->dev, "backlight device is NULL.\n"); | ||
334 | return -EFAULT; | ||
335 | } | ||
336 | 319 | ||
337 | if (!pd->power_on) { | 320 | if (!pd->power_on) { |
338 | dev_err(lcd->dev, "power_on is NULL.\n"); | 321 | dev_err(lcd->dev, "power_on is NULL.\n"); |
339 | return -EFAULT; | 322 | return -EINVAL; |
340 | } else { | 323 | } else { |
341 | pd->power_on(lcd->ld, 1); | 324 | pd->power_on(lcd->ld, 1); |
342 | mdelay(pd->power_on_delay); | 325 | msleep(pd->power_on_delay); |
343 | } | 326 | } |
344 | 327 | ||
345 | if (!pd->reset) { | 328 | if (!pd->reset) { |
346 | dev_err(lcd->dev, "reset is NULL.\n"); | 329 | dev_err(lcd->dev, "reset is NULL.\n"); |
347 | return -EFAULT; | 330 | return -EINVAL; |
348 | } else { | 331 | } else { |
349 | pd->reset(lcd->ld); | 332 | pd->reset(lcd->ld); |
350 | mdelay(pd->reset_delay); | 333 | msleep(pd->reset_delay); |
351 | } | 334 | } |
352 | 335 | ||
353 | ret = ams369fg06_ldi_init(lcd); | 336 | ret = ams369fg06_ldi_init(lcd); |
@@ -374,14 +357,10 @@ static int ams369fg06_power_on(struct ams369fg06 *lcd) | |||
374 | 357 | ||
375 | static int ams369fg06_power_off(struct ams369fg06 *lcd) | 358 | static int ams369fg06_power_off(struct ams369fg06 *lcd) |
376 | { | 359 | { |
377 | int ret = 0; | 360 | int ret; |
378 | struct lcd_platform_data *pd = NULL; | 361 | struct lcd_platform_data *pd; |
379 | 362 | ||
380 | pd = lcd->lcd_pd; | 363 | pd = lcd->lcd_pd; |
381 | if (!pd) { | ||
382 | dev_err(lcd->dev, "platform data is NULL\n"); | ||
383 | return -EFAULT; | ||
384 | } | ||
385 | 364 | ||
386 | ret = ams369fg06_ldi_disable(lcd); | 365 | ret = ams369fg06_ldi_disable(lcd); |
387 | if (ret) { | 366 | if (ret) { |
@@ -389,13 +368,9 @@ static int ams369fg06_power_off(struct ams369fg06 *lcd) | |||
389 | return -EIO; | 368 | return -EIO; |
390 | } | 369 | } |
391 | 370 | ||
392 | mdelay(pd->power_off_delay); | 371 | msleep(pd->power_off_delay); |
393 | 372 | ||
394 | if (!pd->power_on) { | 373 | pd->power_on(lcd->ld, 0); |
395 | dev_err(lcd->dev, "power_on is NULL.\n"); | ||
396 | return -EFAULT; | ||
397 | } else | ||
398 | pd->power_on(lcd->ld, 0); | ||
399 | 374 | ||
400 | return 0; | 375 | return 0; |
401 | } | 376 | } |
@@ -446,7 +421,7 @@ static int ams369fg06_set_brightness(struct backlight_device *bd) | |||
446 | { | 421 | { |
447 | int ret = 0; | 422 | int ret = 0; |
448 | int brightness = bd->props.brightness; | 423 | int brightness = bd->props.brightness; |
449 | struct ams369fg06 *lcd = dev_get_drvdata(&bd->dev); | 424 | struct ams369fg06 *lcd = bl_get_data(bd); |
450 | 425 | ||
451 | if (brightness < MIN_BRIGHTNESS || | 426 | if (brightness < MIN_BRIGHTNESS || |
452 | brightness > bd->props.max_brightness) { | 427 | brightness > bd->props.max_brightness) { |
@@ -501,7 +476,7 @@ static int ams369fg06_probe(struct spi_device *spi) | |||
501 | lcd->lcd_pd = spi->dev.platform_data; | 476 | lcd->lcd_pd = spi->dev.platform_data; |
502 | if (!lcd->lcd_pd) { | 477 | if (!lcd->lcd_pd) { |
503 | dev_err(&spi->dev, "platform data is NULL\n"); | 478 | dev_err(&spi->dev, "platform data is NULL\n"); |
504 | return -EFAULT; | 479 | return -EINVAL; |
505 | } | 480 | } |
506 | 481 | ||
507 | ld = lcd_device_register("ams369fg06", &spi->dev, lcd, | 482 | ld = lcd_device_register("ams369fg06", &spi->dev, lcd, |
@@ -534,10 +509,11 @@ static int ams369fg06_probe(struct spi_device *spi) | |||
534 | lcd->power = FB_BLANK_POWERDOWN; | 509 | lcd->power = FB_BLANK_POWERDOWN; |
535 | 510 | ||
536 | ams369fg06_power(lcd, FB_BLANK_UNBLANK); | 511 | ams369fg06_power(lcd, FB_BLANK_UNBLANK); |
537 | } else | 512 | } else { |
538 | lcd->power = FB_BLANK_UNBLANK; | 513 | lcd->power = FB_BLANK_UNBLANK; |
514 | } | ||
539 | 515 | ||
540 | dev_set_drvdata(&spi->dev, lcd); | 516 | spi_set_drvdata(spi, lcd); |
541 | 517 | ||
542 | dev_info(&spi->dev, "ams369fg06 panel driver has been probed.\n"); | 518 | dev_info(&spi->dev, "ams369fg06 panel driver has been probed.\n"); |
543 | 519 | ||
@@ -550,7 +526,7 @@ out_lcd_unregister: | |||
550 | 526 | ||
551 | static int ams369fg06_remove(struct spi_device *spi) | 527 | static int ams369fg06_remove(struct spi_device *spi) |
552 | { | 528 | { |
553 | struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev); | 529 | struct ams369fg06 *lcd = spi_get_drvdata(spi); |
554 | 530 | ||
555 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); | 531 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); |
556 | backlight_device_unregister(lcd->bd); | 532 | backlight_device_unregister(lcd->bd); |
@@ -560,44 +536,26 @@ static int ams369fg06_remove(struct spi_device *spi) | |||
560 | } | 536 | } |
561 | 537 | ||
562 | #if defined(CONFIG_PM) | 538 | #if defined(CONFIG_PM) |
563 | static unsigned int before_power; | ||
564 | |||
565 | static int ams369fg06_suspend(struct spi_device *spi, pm_message_t mesg) | 539 | static int ams369fg06_suspend(struct spi_device *spi, pm_message_t mesg) |
566 | { | 540 | { |
567 | int ret = 0; | 541 | struct ams369fg06 *lcd = spi_get_drvdata(spi); |
568 | struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev); | ||
569 | 542 | ||
570 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); | 543 | dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power); |
571 | 544 | ||
572 | before_power = lcd->power; | ||
573 | |||
574 | /* | 545 | /* |
575 | * when lcd panel is suspend, lcd panel becomes off | 546 | * when lcd panel is suspend, lcd panel becomes off |
576 | * regardless of status. | 547 | * regardless of status. |
577 | */ | 548 | */ |
578 | ret = ams369fg06_power(lcd, FB_BLANK_POWERDOWN); | 549 | return ams369fg06_power(lcd, FB_BLANK_POWERDOWN); |
579 | |||
580 | return ret; | ||
581 | } | 550 | } |
582 | 551 | ||
583 | static int ams369fg06_resume(struct spi_device *spi) | 552 | static int ams369fg06_resume(struct spi_device *spi) |
584 | { | 553 | { |
585 | int ret = 0; | 554 | struct ams369fg06 *lcd = spi_get_drvdata(spi); |
586 | struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev); | ||
587 | 555 | ||
588 | /* | 556 | lcd->power = FB_BLANK_POWERDOWN; |
589 | * after suspended, if lcd panel status is FB_BLANK_UNBLANK | ||
590 | * (at that time, before_power is FB_BLANK_UNBLANK) then | ||
591 | * it changes that status to FB_BLANK_POWERDOWN to get lcd on. | ||
592 | */ | ||
593 | if (before_power == FB_BLANK_UNBLANK) | ||
594 | lcd->power = FB_BLANK_POWERDOWN; | ||
595 | |||
596 | dev_dbg(&spi->dev, "before_power = %d\n", before_power); | ||
597 | 557 | ||
598 | ret = ams369fg06_power(lcd, before_power); | 558 | return ams369fg06_power(lcd, FB_BLANK_UNBLANK); |
599 | |||
600 | return ret; | ||
601 | } | 559 | } |
602 | #else | 560 | #else |
603 | #define ams369fg06_suspend NULL | 561 | #define ams369fg06_suspend NULL |
@@ -606,7 +564,7 @@ static int ams369fg06_resume(struct spi_device *spi) | |||
606 | 564 | ||
607 | static void ams369fg06_shutdown(struct spi_device *spi) | 565 | static void ams369fg06_shutdown(struct spi_device *spi) |
608 | { | 566 | { |
609 | struct ams369fg06 *lcd = dev_get_drvdata(&spi->dev); | 567 | struct ams369fg06 *lcd = spi_get_drvdata(spi); |
610 | 568 | ||
611 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); | 569 | ams369fg06_power(lcd, FB_BLANK_POWERDOWN); |
612 | } | 570 | } |