mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
backlight: hx8357: Convert to agnostic GPIO API
The of_gpio.h is going to be removed. In preparation of that convert
the driver to the agnostic API.
Fixes: fbbbcd177a
("gpiolib: of: add quirk for locating reset lines with legacy bindings")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20231207161513.3195509-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
769ff5283f
commit
7d84a63a39
2 changed files with 24 additions and 54 deletions
|
@ -184,7 +184,7 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
|
||||||
const char *propname;
|
const char *propname;
|
||||||
bool active_high;
|
bool active_high;
|
||||||
} gpios[] = {
|
} gpios[] = {
|
||||||
#if !IS_ENABLED(CONFIG_LCD_HX8357)
|
#if IS_ENABLED(CONFIG_LCD_HX8357)
|
||||||
/*
|
/*
|
||||||
* Himax LCD controllers used incorrectly named
|
* Himax LCD controllers used incorrectly named
|
||||||
* "gpios-reset" property and also specified wrong
|
* "gpios-reset" property and also specified wrong
|
||||||
|
@ -478,7 +478,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
|
||||||
*/
|
*/
|
||||||
const char *compatible;
|
const char *compatible;
|
||||||
} gpios[] = {
|
} gpios[] = {
|
||||||
#if !IS_ENABLED(CONFIG_LCD_HX8357)
|
#if IS_ENABLED(CONFIG_LCD_HX8357)
|
||||||
/* Himax LCD controllers used "gpios-reset" */
|
/* Himax LCD controllers used "gpios-reset" */
|
||||||
{ "reset", "gpios-reset", "himax,hx8357" },
|
{ "reset", "gpios-reset", "himax,hx8357" },
|
||||||
{ "reset", "gpios-reset", "himax,hx8369" },
|
{ "reset", "gpios-reset", "himax,hx8369" },
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/lcd.h>
|
#include <linux/lcd.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
|
|
||||||
#define HX8357_NUM_IM_PINS 3
|
#define HX8357_NUM_IM_PINS 3
|
||||||
|
@ -83,11 +83,10 @@
|
||||||
#define HX8369_SET_GAMMA_CURVE_RELATED 0xe0
|
#define HX8369_SET_GAMMA_CURVE_RELATED 0xe0
|
||||||
|
|
||||||
struct hx8357_data {
|
struct hx8357_data {
|
||||||
unsigned im_pins[HX8357_NUM_IM_PINS];
|
struct gpio_descs *im_pins;
|
||||||
unsigned reset;
|
struct gpio_desc *reset;
|
||||||
struct spi_device *spi;
|
struct spi_device *spi;
|
||||||
int state;
|
int state;
|
||||||
bool use_im_pins;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static u8 hx8357_seq_power[] = {
|
static u8 hx8357_seq_power[] = {
|
||||||
|
@ -321,11 +320,11 @@ static void hx8357_lcd_reset(struct lcd_device *lcdev)
|
||||||
struct hx8357_data *lcd = lcd_get_data(lcdev);
|
struct hx8357_data *lcd = lcd_get_data(lcdev);
|
||||||
|
|
||||||
/* Reset the screen */
|
/* Reset the screen */
|
||||||
gpio_set_value(lcd->reset, 1);
|
gpiod_set_value(lcd->reset, 0);
|
||||||
usleep_range(10000, 12000);
|
usleep_range(10000, 12000);
|
||||||
gpio_set_value(lcd->reset, 0);
|
gpiod_set_value(lcd->reset, 1);
|
||||||
usleep_range(10000, 12000);
|
usleep_range(10000, 12000);
|
||||||
gpio_set_value(lcd->reset, 1);
|
gpiod_set_value(lcd->reset, 0);
|
||||||
|
|
||||||
/* The controller needs 120ms to recover from reset */
|
/* The controller needs 120ms to recover from reset */
|
||||||
msleep(120);
|
msleep(120);
|
||||||
|
@ -340,10 +339,10 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
|
||||||
* Set the interface selection pins to SPI mode, with three
|
* Set the interface selection pins to SPI mode, with three
|
||||||
* wires
|
* wires
|
||||||
*/
|
*/
|
||||||
if (lcd->use_im_pins) {
|
if (lcd->im_pins) {
|
||||||
gpio_set_value_cansleep(lcd->im_pins[0], 1);
|
gpiod_set_value_cansleep(lcd->im_pins->desc[0], 1);
|
||||||
gpio_set_value_cansleep(lcd->im_pins[1], 0);
|
gpiod_set_value_cansleep(lcd->im_pins->desc[1], 0);
|
||||||
gpio_set_value_cansleep(lcd->im_pins[2], 1);
|
gpiod_set_value_cansleep(lcd->im_pins->desc[2], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
|
ret = hx8357_spi_write_array(lcdev, hx8357_seq_power,
|
||||||
|
@ -580,6 +579,7 @@ MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
|
||||||
|
|
||||||
static int hx8357_probe(struct spi_device *spi)
|
static int hx8357_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
|
struct device *dev = &spi->dev;
|
||||||
struct lcd_device *lcdev;
|
struct lcd_device *lcdev;
|
||||||
struct hx8357_data *lcd;
|
struct hx8357_data *lcd;
|
||||||
const struct of_device_id *match;
|
const struct of_device_id *match;
|
||||||
|
@ -601,49 +601,19 @@ static int hx8357_probe(struct spi_device *spi)
|
||||||
if (!match || !match->data)
|
if (!match || !match->data)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
lcd->reset = of_get_named_gpio(spi->dev.of_node, "gpios-reset", 0);
|
lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
|
||||||
if (!gpio_is_valid(lcd->reset)) {
|
if (IS_ERR(lcd->reset))
|
||||||
dev_err(&spi->dev, "Missing dt property: gpios-reset\n");
|
return dev_err_probe(dev, PTR_ERR(lcd->reset), "failed to request reset GPIO\n");
|
||||||
return -EINVAL;
|
gpiod_set_consumer_name(lcd->reset, "hx8357-reset");
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_gpio_request_one(&spi->dev, lcd->reset,
|
lcd->im_pins = devm_gpiod_get_array_optional(dev, "im", GPIOD_OUT_LOW);
|
||||||
GPIOF_OUT_INIT_HIGH,
|
if (IS_ERR(lcd->im_pins))
|
||||||
"hx8357-reset");
|
return dev_err_probe(dev, PTR_ERR(lcd->im_pins), "failed to request im GPIOs\n");
|
||||||
if (ret) {
|
if (lcd->im_pins->ndescs < HX8357_NUM_IM_PINS)
|
||||||
dev_err(&spi->dev,
|
return dev_err_probe(dev, -EINVAL, "not enough im GPIOs\n");
|
||||||
"failed to request gpio %d: %d\n",
|
|
||||||
lcd->reset, ret);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (of_property_present(spi->dev.of_node, "im-gpios")) {
|
for (i = 0; i < HX8357_NUM_IM_PINS; i++)
|
||||||
lcd->use_im_pins = 1;
|
gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
|
||||||
|
|
||||||
for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
|
|
||||||
lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node,
|
|
||||||
"im-gpios", i);
|
|
||||||
if (lcd->im_pins[i] == -EPROBE_DEFER) {
|
|
||||||
dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
|
|
||||||
return -EPROBE_DEFER;
|
|
||||||
}
|
|
||||||
if (!gpio_is_valid(lcd->im_pins[i])) {
|
|
||||||
dev_err(&spi->dev, "Missing dt property: im-gpios\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i],
|
|
||||||
GPIOF_OUT_INIT_LOW,
|
|
||||||
"im_pins");
|
|
||||||
if (ret) {
|
|
||||||
dev_err(&spi->dev, "failed to request gpio %d: %d\n",
|
|
||||||
lcd->im_pins[i], ret);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lcd->use_im_pins = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
|
lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
|
||||||
&hx8357_ops);
|
&hx8357_ops);
|
||||||
|
|
Loading…
Reference in a new issue