| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * l4f00242t03.c -- support for Epson L4F00242T03 LCD |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> |
|---|
| 7 | 8 | * Inspired by Marek Vasut work in l4f00242t03.c |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | 9 | */ |
|---|
| 13 | 10 | |
|---|
| 14 | 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 17 | 14 | #include <linux/kernel.h> |
|---|
| 18 | 15 | #include <linux/delay.h> |
|---|
| 19 | 16 | #include <linux/module.h> |
|---|
| 20 | | -#include <linux/gpio.h> |
|---|
| 17 | +#include <linux/gpio/consumer.h> |
|---|
| 21 | 18 | #include <linux/lcd.h> |
|---|
| 22 | 19 | #include <linux/slab.h> |
|---|
| 23 | 20 | #include <linux/regulator/consumer.h> |
|---|
| 24 | | - |
|---|
| 25 | 21 | #include <linux/spi/spi.h> |
|---|
| 26 | | -#include <linux/spi/l4f00242t03.h> |
|---|
| 27 | 22 | |
|---|
| 28 | 23 | struct l4f00242t03_priv { |
|---|
| 29 | 24 | struct spi_device *spi; |
|---|
| .. | .. |
|---|
| 31 | 26 | int lcd_state; |
|---|
| 32 | 27 | struct regulator *io_reg; |
|---|
| 33 | 28 | struct regulator *core_reg; |
|---|
| 29 | + struct gpio_desc *reset; |
|---|
| 30 | + struct gpio_desc *enable; |
|---|
| 34 | 31 | }; |
|---|
| 35 | 32 | |
|---|
| 36 | | -static void l4f00242t03_reset(unsigned int gpio) |
|---|
| 33 | +static void l4f00242t03_reset(struct gpio_desc *gpiod) |
|---|
| 37 | 34 | { |
|---|
| 38 | 35 | pr_debug("l4f00242t03_reset.\n"); |
|---|
| 39 | | - gpio_set_value(gpio, 1); |
|---|
| 36 | + gpiod_set_value(gpiod, 1); |
|---|
| 40 | 37 | mdelay(100); |
|---|
| 41 | | - gpio_set_value(gpio, 0); |
|---|
| 38 | + gpiod_set_value(gpiod, 0); |
|---|
| 42 | 39 | mdelay(10); /* tRES >= 100us */ |
|---|
| 43 | | - gpio_set_value(gpio, 1); |
|---|
| 40 | + gpiod_set_value(gpiod, 1); |
|---|
| 44 | 41 | mdelay(20); |
|---|
| 45 | 42 | } |
|---|
| 46 | 43 | |
|---|
| .. | .. |
|---|
| 48 | 45 | |
|---|
| 49 | 46 | static void l4f00242t03_lcd_init(struct spi_device *spi) |
|---|
| 50 | 47 | { |
|---|
| 51 | | - struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); |
|---|
| 52 | 48 | struct l4f00242t03_priv *priv = spi_get_drvdata(spi); |
|---|
| 53 | 49 | const u16 cmd[] = { 0x36, param(0), 0x3A, param(0x60) }; |
|---|
| 54 | 50 | int ret; |
|---|
| .. | .. |
|---|
| 79 | 75 | return; |
|---|
| 80 | 76 | } |
|---|
| 81 | 77 | |
|---|
| 82 | | - l4f00242t03_reset(pdata->reset_gpio); |
|---|
| 78 | + l4f00242t03_reset(priv->reset); |
|---|
| 83 | 79 | |
|---|
| 84 | | - gpio_set_value(pdata->data_enable_gpio, 1); |
|---|
| 80 | + gpiod_set_value(priv->enable, 1); |
|---|
| 85 | 81 | msleep(60); |
|---|
| 86 | 82 | spi_write(spi, (const u8 *)cmd, ARRAY_SIZE(cmd) * sizeof(u16)); |
|---|
| 87 | 83 | } |
|---|
| 88 | 84 | |
|---|
| 89 | 85 | static void l4f00242t03_lcd_powerdown(struct spi_device *spi) |
|---|
| 90 | 86 | { |
|---|
| 91 | | - struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); |
|---|
| 92 | 87 | struct l4f00242t03_priv *priv = spi_get_drvdata(spi); |
|---|
| 93 | 88 | |
|---|
| 94 | 89 | dev_dbg(&spi->dev, "Powering down LCD\n"); |
|---|
| 95 | 90 | |
|---|
| 96 | | - gpio_set_value(pdata->data_enable_gpio, 0); |
|---|
| 91 | + gpiod_set_value(priv->enable, 0); |
|---|
| 97 | 92 | |
|---|
| 98 | 93 | regulator_disable(priv->io_reg); |
|---|
| 99 | 94 | regulator_disable(priv->core_reg); |
|---|
| .. | .. |
|---|
| 171 | 166 | static int l4f00242t03_probe(struct spi_device *spi) |
|---|
| 172 | 167 | { |
|---|
| 173 | 168 | struct l4f00242t03_priv *priv; |
|---|
| 174 | | - struct l4f00242t03_pdata *pdata = dev_get_platdata(&spi->dev); |
|---|
| 175 | | - int ret; |
|---|
| 176 | | - |
|---|
| 177 | | - if (pdata == NULL) { |
|---|
| 178 | | - dev_err(&spi->dev, "Uninitialized platform data.\n"); |
|---|
| 179 | | - return -EINVAL; |
|---|
| 180 | | - } |
|---|
| 181 | 169 | |
|---|
| 182 | 170 | priv = devm_kzalloc(&spi->dev, sizeof(struct l4f00242t03_priv), |
|---|
| 183 | 171 | GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 190 | 178 | |
|---|
| 191 | 179 | priv->spi = spi; |
|---|
| 192 | 180 | |
|---|
| 193 | | - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, |
|---|
| 194 | | - GPIOF_OUT_INIT_HIGH, "lcd l4f00242t03 reset"); |
|---|
| 195 | | - if (ret) { |
|---|
| 181 | + priv->reset = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); |
|---|
| 182 | + if (IS_ERR(priv->reset)) { |
|---|
| 196 | 183 | dev_err(&spi->dev, |
|---|
| 197 | 184 | "Unable to get the lcd l4f00242t03 reset gpio.\n"); |
|---|
| 198 | | - return ret; |
|---|
| 185 | + return PTR_ERR(priv->reset); |
|---|
| 199 | 186 | } |
|---|
| 187 | + gpiod_set_consumer_name(priv->reset, "lcd l4f00242t03 reset"); |
|---|
| 200 | 188 | |
|---|
| 201 | | - ret = devm_gpio_request_one(&spi->dev, pdata->data_enable_gpio, |
|---|
| 202 | | - GPIOF_OUT_INIT_LOW, "lcd l4f00242t03 data enable"); |
|---|
| 203 | | - if (ret) { |
|---|
| 189 | + priv->enable = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); |
|---|
| 190 | + if (IS_ERR(priv->enable)) { |
|---|
| 204 | 191 | dev_err(&spi->dev, |
|---|
| 205 | 192 | "Unable to get the lcd l4f00242t03 data en gpio.\n"); |
|---|
| 206 | | - return ret; |
|---|
| 193 | + return PTR_ERR(priv->enable); |
|---|
| 207 | 194 | } |
|---|
| 195 | + gpiod_set_consumer_name(priv->enable, "lcd l4f00242t03 data enable"); |
|---|
| 208 | 196 | |
|---|
| 209 | 197 | priv->io_reg = devm_regulator_get(&spi->dev, "vdd"); |
|---|
| 210 | 198 | if (IS_ERR(priv->io_reg)) { |
|---|