.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * LCD/Backlight Driver for Sharp Zaurus Handhelds (various models) |
---|
3 | 4 | * |
---|
.. | .. |
---|
8 | 9 | * Copyright (c) 2008 Marvell International Ltd. |
---|
9 | 10 | * Converted to SPI device based LCD/Backlight device driver |
---|
10 | 11 | * by Eric Miao <eric.miao@marvell.com> |
---|
11 | | - * |
---|
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. |
---|
15 | | - * |
---|
16 | 12 | */ |
---|
17 | 13 | |
---|
18 | 14 | #include <linux/module.h> |
---|
19 | 15 | #include <linux/kernel.h> |
---|
20 | 16 | #include <linux/init.h> |
---|
21 | 17 | #include <linux/delay.h> |
---|
22 | | -#include <linux/gpio.h> |
---|
| 18 | +#include <linux/gpio/consumer.h> |
---|
23 | 19 | #include <linux/fb.h> |
---|
24 | 20 | #include <linux/lcd.h> |
---|
25 | 21 | #include <linux/spi/spi.h> |
---|
.. | .. |
---|
94 | 90 | int mode; |
---|
95 | 91 | char buf[2]; |
---|
96 | 92 | |
---|
97 | | - int gpio_backlight_on; |
---|
98 | | - int gpio_backlight_cont; |
---|
99 | | - int gpio_backlight_cont_inverted; |
---|
| 93 | + struct gpio_desc *backlight_on; |
---|
| 94 | + struct gpio_desc *backlight_cont; |
---|
100 | 95 | |
---|
101 | 96 | void (*kick_battery)(void); |
---|
102 | 97 | }; |
---|
.. | .. |
---|
407 | 402 | corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity); |
---|
408 | 403 | |
---|
409 | 404 | /* Bit 5 via GPIO_BACKLIGHT_CONT */ |
---|
410 | | - cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted; |
---|
| 405 | + cont = !!(intensity & 0x20); |
---|
411 | 406 | |
---|
412 | | - if (gpio_is_valid(lcd->gpio_backlight_cont)) |
---|
413 | | - gpio_set_value_cansleep(lcd->gpio_backlight_cont, cont); |
---|
| 407 | + if (lcd->backlight_cont) |
---|
| 408 | + gpiod_set_value_cansleep(lcd->backlight_cont, cont); |
---|
414 | 409 | |
---|
415 | | - if (gpio_is_valid(lcd->gpio_backlight_on)) |
---|
416 | | - gpio_set_value_cansleep(lcd->gpio_backlight_on, intensity); |
---|
| 410 | + if (lcd->backlight_on) |
---|
| 411 | + gpiod_set_value_cansleep(lcd->backlight_on, intensity); |
---|
417 | 412 | |
---|
418 | 413 | if (lcd->kick_battery) |
---|
419 | 414 | lcd->kick_battery(); |
---|
.. | .. |
---|
425 | 420 | static int corgi_bl_update_status(struct backlight_device *bd) |
---|
426 | 421 | { |
---|
427 | 422 | struct corgi_lcd *lcd = bl_get_data(bd); |
---|
428 | | - int intensity = bd->props.brightness; |
---|
429 | | - |
---|
430 | | - if (bd->props.power != FB_BLANK_UNBLANK) |
---|
431 | | - intensity = 0; |
---|
432 | | - |
---|
433 | | - if (bd->props.fb_blank != FB_BLANK_UNBLANK) |
---|
434 | | - intensity = 0; |
---|
| 423 | + int intensity = backlight_get_brightness(bd); |
---|
435 | 424 | |
---|
436 | 425 | if (corgibl_flags & CORGIBL_SUSPENDED) |
---|
437 | 426 | intensity = 0; |
---|
.. | .. |
---|
486 | 475 | struct corgi_lcd_platform_data *pdata) |
---|
487 | 476 | { |
---|
488 | 477 | struct spi_device *spi = lcd->spi_dev; |
---|
489 | | - int err; |
---|
490 | 478 | |
---|
491 | | - lcd->gpio_backlight_on = -1; |
---|
492 | | - lcd->gpio_backlight_cont = -1; |
---|
| 479 | + lcd->backlight_on = devm_gpiod_get_optional(&spi->dev, |
---|
| 480 | + "BL_ON", GPIOD_OUT_LOW); |
---|
| 481 | + if (IS_ERR(lcd->backlight_on)) |
---|
| 482 | + return PTR_ERR(lcd->backlight_on); |
---|
493 | 483 | |
---|
494 | | - if (gpio_is_valid(pdata->gpio_backlight_on)) { |
---|
495 | | - err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_on, |
---|
496 | | - "BL_ON"); |
---|
497 | | - if (err) { |
---|
498 | | - dev_err(&spi->dev, |
---|
499 | | - "failed to request GPIO%d for backlight_on\n", |
---|
500 | | - pdata->gpio_backlight_on); |
---|
501 | | - return err; |
---|
502 | | - } |
---|
| 484 | + lcd->backlight_cont = devm_gpiod_get_optional(&spi->dev, "BL_CONT", |
---|
| 485 | + GPIOD_OUT_LOW); |
---|
| 486 | + if (IS_ERR(lcd->backlight_cont)) |
---|
| 487 | + return PTR_ERR(lcd->backlight_cont); |
---|
503 | 488 | |
---|
504 | | - lcd->gpio_backlight_on = pdata->gpio_backlight_on; |
---|
505 | | - gpio_direction_output(lcd->gpio_backlight_on, 0); |
---|
506 | | - } |
---|
507 | | - |
---|
508 | | - if (gpio_is_valid(pdata->gpio_backlight_cont)) { |
---|
509 | | - err = devm_gpio_request(&spi->dev, pdata->gpio_backlight_cont, |
---|
510 | | - "BL_CONT"); |
---|
511 | | - if (err) { |
---|
512 | | - dev_err(&spi->dev, |
---|
513 | | - "failed to request GPIO%d for backlight_cont\n", |
---|
514 | | - pdata->gpio_backlight_cont); |
---|
515 | | - return err; |
---|
516 | | - } |
---|
517 | | - |
---|
518 | | - lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; |
---|
519 | | - |
---|
520 | | - /* spitz and akita use both GPIOs for backlight, and |
---|
521 | | - * have inverted polarity of GPIO_BACKLIGHT_CONT |
---|
522 | | - */ |
---|
523 | | - if (gpio_is_valid(lcd->gpio_backlight_on)) { |
---|
524 | | - lcd->gpio_backlight_cont_inverted = 1; |
---|
525 | | - gpio_direction_output(lcd->gpio_backlight_cont, 1); |
---|
526 | | - } else { |
---|
527 | | - lcd->gpio_backlight_cont_inverted = 0; |
---|
528 | | - gpio_direction_output(lcd->gpio_backlight_cont, 0); |
---|
529 | | - } |
---|
530 | | - } |
---|
531 | 489 | return 0; |
---|
532 | 490 | } |
---|
533 | 491 | |
---|