Commit c440eee1 authored by Nishad Kamdar's avatar Nishad Kamdar Committed by Greg Kroah-Hartman

Staging: fbtft: Switch to the gpio descriptor interface

This switches the fbtft driver to use GPIO descriptors
rather than numerical gpios:

Utilize the GPIO library's intrinsic handling of OF GPIOs
and polarity. If the line is flagged active low, gpiolib
will deal with this.

Remove gpios from platform device structure. Neither assign
statically numbers to gpios in platform device nor allow
gpios to be parsed as module parameters.
Signed-off-by: default avatarNishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 032ecb59
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -79,14 +79,14 @@ static int init_display(struct fbtft_par *par) ...@@ -79,14 +79,14 @@ static int init_display(struct fbtft_par *par)
static void reset(struct fbtft_par *par) static void reset(struct fbtft_par *par)
{ {
if (par->gpio.reset == -1) if (!par->gpio.reset)
return; return;
dev_dbg(par->info->device, "%s()\n", __func__); dev_dbg(par->info->device, "%s()\n", __func__);
gpio_set_value(par->gpio.reset, 0); gpiod_set_value(par->gpio.reset, 0);
udelay(20); udelay(20);
gpio_set_value(par->gpio.reset, 1); gpiod_set_value(par->gpio.reset, 1);
mdelay(120); mdelay(120);
} }
...@@ -98,30 +98,30 @@ static int verify_gpios(struct fbtft_par *par) ...@@ -98,30 +98,30 @@ static int verify_gpios(struct fbtft_par *par)
dev_dbg(par->info->device, dev_dbg(par->info->device,
"%s()\n", __func__); "%s()\n", __func__);
if (par->EPIN < 0) { if (!par->EPIN) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'wr' (aka E) gpio. Aborting.\n"); "Missing info about 'wr' (aka E) gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
if (par->gpio.db[i] < 0) { if (!par->gpio.db[i]) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'db[%i]' gpio. Aborting.\n", "Missing info about 'db[%i]' gpio. Aborting.\n",
i); i);
return -EINVAL; return -EINVAL;
} }
} }
if (par->CS0 < 0) { if (!par->CS0) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'cs0' gpio. Aborting.\n"); "Missing info about 'cs0' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (par->CS1 < 0) { if (!par->CS1) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'cs1' gpio. Aborting.\n"); "Missing info about 'cs1' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (par->RW < 0) { if (!par->RW) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'rw' gpio. Aborting.\n"); "Missing info about 'rw' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
...@@ -139,22 +139,22 @@ request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio) ...@@ -139,22 +139,22 @@ request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio)
if (strcasecmp(gpio->name, "wr") == 0) { if (strcasecmp(gpio->name, "wr") == 0) {
/* left ks0108 E pin */ /* left ks0108 E pin */
par->EPIN = gpio->gpio; par->EPIN = gpio->gpio;
return GPIOF_OUT_INIT_LOW; return GPIOD_OUT_LOW;
} else if (strcasecmp(gpio->name, "cs0") == 0) { } else if (strcasecmp(gpio->name, "cs0") == 0) {
/* left ks0108 controller pin */ /* left ks0108 controller pin */
par->CS0 = gpio->gpio; par->CS0 = gpio->gpio;
return GPIOF_OUT_INIT_HIGH; return GPIOD_OUT_HIGH;
} else if (strcasecmp(gpio->name, "cs1") == 0) { } else if (strcasecmp(gpio->name, "cs1") == 0) {
/* right ks0108 controller pin */ /* right ks0108 controller pin */
par->CS1 = gpio->gpio; par->CS1 = gpio->gpio;
return GPIOF_OUT_INIT_HIGH; return GPIOD_OUT_HIGH;
} }
/* if write (rw = 0) e(1->0) perform write */ /* if write (rw = 0) e(1->0) perform write */
/* if read (rw = 1) e(0->1) set data on D0-7*/ /* if read (rw = 1) e(0->1) set data on D0-7*/
else if (strcasecmp(gpio->name, "rw") == 0) { else if (strcasecmp(gpio->name, "rw") == 0) {
par->RW = gpio->gpio; par->RW = gpio->gpio;
return GPIOF_OUT_INIT_LOW; return GPIOD_OUT_LOW;
} }
return FBTFT_GPIO_NO_MATCH; return FBTFT_GPIO_NO_MATCH;
...@@ -194,15 +194,15 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) ...@@ -194,15 +194,15 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
/* select chip */ /* select chip */
if (*buf) { if (*buf) {
/* cs1 */ /* cs1 */
gpio_set_value(par->CS0, 1); gpiod_set_value(par->CS0, 1);
gpio_set_value(par->CS1, 0); gpiod_set_value(par->CS1, 0);
} else { } else {
/* cs0 */ /* cs0 */
gpio_set_value(par->CS0, 0); gpiod_set_value(par->CS0, 0);
gpio_set_value(par->CS1, 1); gpiod_set_value(par->CS1, 1);
} }
gpio_set_value(par->RS, 0); /* RS->0 (command mode) */ gpiod_set_value(par->RS, 0); /* RS->0 (command mode) */
len--; len--;
if (len) { if (len) {
...@@ -364,7 +364,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -364,7 +364,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
write_reg(par, 0x00, (0x17 << 3) | (u8)y); write_reg(par, 0x00, (0x17 << 3) | (u8)y);
/* write bitmap */ /* write bitmap */
gpio_set_value(par->RS, 1); /* RS->1 (data mode) */ gpiod_set_value(par->RS, 1); /* RS->1 (data mode) */
ret = par->fbtftops.write(par, buf, len); ret = par->fbtftops.write(par, buf, len);
if (ret < 0) if (ret < 0)
dev_err(par->info->device, dev_err(par->info->device,
...@@ -387,7 +387,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -387,7 +387,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
write_reg(par, 0x01, (0x17 << 3) | (u8)y); write_reg(par, 0x01, (0x17 << 3) | (u8)y);
/* write bitmap */ /* write bitmap */
gpio_set_value(par->RS, 1); /* RS->1 (data mode) */ gpiod_set_value(par->RS, 1); /* RS->1 (data mode) */
par->fbtftops.write(par, buf, len); par->fbtftops.write(par, buf, len);
if (ret < 0) if (ret < 0)
dev_err(par->info->device, dev_err(par->info->device,
...@@ -397,8 +397,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -397,8 +397,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
kfree(convert_buf); kfree(convert_buf);
gpio_set_value(par->CS0, 1); gpiod_set_value(par->CS0, 1);
gpio_set_value(par->CS1, 1); gpiod_set_value(par->CS1, 1);
return ret; return ret;
} }
...@@ -408,7 +408,7 @@ static int write(struct fbtft_par *par, void *buf, size_t len) ...@@ -408,7 +408,7 @@ static int write(struct fbtft_par *par, void *buf, size_t len)
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len, fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
"%s(len=%d): ", __func__, len); "%s(len=%d): ", __func__, len);
gpio_set_value(par->RW, 0); /* set write mode */ gpiod_set_value(par->RW, 0); /* set write mode */
while (len--) { while (len--) {
u8 i, data; u8 i, data;
...@@ -417,12 +417,12 @@ static int write(struct fbtft_par *par, void *buf, size_t len) ...@@ -417,12 +417,12 @@ static int write(struct fbtft_par *par, void *buf, size_t len)
/* set data bus */ /* set data bus */
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
gpio_set_value(par->gpio.db[i], data & (1 << i)); gpiod_set_value(par->gpio.db[i], data & (1 << i));
/* set E */ /* set E */
gpio_set_value(par->EPIN, 1); gpiod_set_value(par->EPIN, 1);
udelay(5); udelay(5);
/* unset E - write */ /* unset E - write */
gpio_set_value(par->EPIN, 0); gpiod_set_value(par->EPIN, 0);
udelay(1); udelay(1);
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
static int init_display(struct fbtft_par *par) static int init_display(struct fbtft_par *par)
{ {
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
par->fbtftops.reset(par); par->fbtftops.reset(par);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
...@@ -77,8 +77,8 @@ static int init_display(struct fbtft_par *par) ...@@ -77,8 +77,8 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */ write_reg(par, MIPI_DCS_SOFT_RESET); /* software reset */
mdelay(500); mdelay(500);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -85,8 +85,8 @@ static int init_display(struct fbtft_par *par) ...@@ -85,8 +85,8 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
bt &= 0x07; bt &= 0x07;
vc &= 0x07; vc &= 0x07;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -119,7 +119,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -119,7 +119,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
/* Write data */ /* Write data */
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, 6 * 84); ret = par->fbtftops.write(par, par->txbuf.buf, 6 * 84);
if (ret < 0) if (ret < 0)
dev_err(par->info->device, "write failed and returned: %d\n", dev_err(par->info->device, "write failed and returned: %d\n",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include "fbtft.h" #include "fbtft.h"
#define DRVNAME "fb_ra8875" #define DRVNAME "fb_ra8875"
...@@ -39,7 +39,7 @@ static int write_spi(struct fbtft_par *par, void *buf, size_t len) ...@@ -39,7 +39,7 @@ static int write_spi(struct fbtft_par *par, void *buf, size_t len)
static int init_display(struct fbtft_par *par) static int init_display(struct fbtft_par *par)
{ {
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, fbtft_par_dbg(DEBUG_INIT_DISPLAY, par,
"%s()\n", __func__); "%s()\n", __func__);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -29,8 +29,8 @@ static int init_display(struct fbtft_par *par) ...@@ -29,8 +29,8 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
/* Initialization sequence from Lib_UTFT */ /* Initialization sequence from Lib_UTFT */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -28,8 +28,8 @@ static int init_display(struct fbtft_par *par) ...@@ -28,8 +28,8 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
write_reg(par, 0x00, 0x0001); write_reg(par, 0x00, 0x0001);
write_reg(par, 0x03, 0xA8A4); write_reg(par, 0x03, 0xA8A4);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -168,7 +168,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -168,7 +168,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
/* Write data */ /* Write data */
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, ret = par->fbtftops.write(par, par->txbuf.buf,
par->info->var.xres * par->info->var.yres / par->info->var.xres * par->info->var.yres /
8); 8);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -190,7 +190,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -190,7 +190,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
/* Write data */ /* Write data */
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, xres * yres / 8); ret = par->fbtftops.write(par, par->txbuf.buf, xres * yres / 8);
if (ret < 0) if (ret < 0)
dev_err(par->info->device, "write failed and returned: %d\n", dev_err(par->info->device, "write failed and returned: %d\n",
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -35,7 +35,7 @@ static int init_display(struct fbtft_par *par) ...@@ -35,7 +35,7 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
gpio_set_value(par->gpio.cs, 0); gpiod_set_value(par->gpio.cs, 0);
write_reg(par, 0xb3); write_reg(par, 0xb3);
write_reg(par, 0xf0); write_reg(par, 0xf0);
...@@ -155,7 +155,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -155,7 +155,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
} }
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
/* Write data */ /* Write data */
ret = par->fbtftops.write(par, par->txbuf.buf, ret = par->fbtftops.write(par, par->txbuf.buf,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -80,8 +80,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) ...@@ -80,8 +80,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
va_start(args, len); va_start(args, len);
*buf = (u8)va_arg(args, unsigned int); *buf = (u8)va_arg(args, unsigned int);
if (par->gpio.dc != -1) if (!par->gpio.dc)
gpio_set_value(par->gpio.dc, 0); gpiod_set_value(par->gpio.dc, 0);
ret = par->fbtftops.write(par, par->buf, sizeof(u8)); ret = par->fbtftops.write(par, par->buf, sizeof(u8));
if (ret < 0) { if (ret < 0) {
va_end(args); va_end(args);
...@@ -103,8 +103,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) ...@@ -103,8 +103,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
return; return;
} }
} }
if (par->gpio.dc != -1) if (!par->gpio.dc)
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
va_end(args); va_end(args);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -94,7 +94,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -94,7 +94,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
/* The display is 102x68 but the LCD is 84x48. /* The display is 102x68 but the LCD is 84x48.
* Set the write pointer at the start of each row. * Set the write pointer at the start of each row.
*/ */
gpio_set_value(par->gpio.dc, 0); gpiod_set_value(par->gpio.dc, 0);
write_reg(par, 0x80 | 0); write_reg(par, 0x80 | 0);
write_reg(par, 0x40 | y); write_reg(par, 0x40 | y);
...@@ -109,7 +109,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -109,7 +109,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
*buf++ = ch; *buf++ = ch;
} }
/* Write the row */ /* Write the row */
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH); ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH);
if (ret < 0) { if (ret < 0) {
dev_err(par->info->device, dev_err(par->info->device,
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -251,7 +251,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -251,7 +251,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
} }
break; break;
} }
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
/* Write data */ /* Write data */
ret = par->fbtftops.write(par, par->txbuf.buf, len / 2); ret = par->fbtftops.write(par, par->txbuf.buf, len / 2);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -136,9 +136,9 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -136,9 +136,9 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
write_reg(par, LCD_PAGE_ADDRESS | (u8)y); write_reg(par, LCD_PAGE_ADDRESS | (u8)y);
write_reg(par, 0x00); write_reg(par, 0x00);
write_reg(par, LCD_COL_ADDRESS); write_reg(par, LCD_COL_ADDRESS);
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH); ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH);
gpio_set_value(par->gpio.dc, 0); gpiod_set_value(par->gpio.dc, 0);
} }
if (ret < 0) if (ret < 0)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -26,8 +26,8 @@ static int init_display(struct fbtft_par *par) ...@@ -26,8 +26,8 @@ static int init_display(struct fbtft_par *par)
{ {
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
/* Initialization sequence from Lib_UTFT */ /* Initialization sequence from Lib_UTFT */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -213,7 +213,7 @@ static int set_var(struct fbtft_par *par) ...@@ -213,7 +213,7 @@ static int set_var(struct fbtft_par *par)
static int verify_gpios(struct fbtft_par *par) static int verify_gpios(struct fbtft_par *par)
{ {
if (par->gpio.reset < 0) { if (!par->gpio.reset) {
dev_err(par->info->device, "Missing 'reset' gpio. Aborting.\n"); dev_err(par->info->device, "Missing 'reset' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <linux/export.h> #include <linux/export.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -135,8 +135,8 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) ...@@ -135,8 +135,8 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
remain = len / 2; remain = len / 2;
vmem16 = (u16 *)(par->info->screen_buffer + offset); vmem16 = (u16 *)(par->info->screen_buffer + offset);
if (par->gpio.dc != -1) if (!par->gpio.dc)
gpio_set_value(par->gpio.dc, 1); gpiod_set_value(par->gpio.dc, 1);
/* non buffered write */ /* non buffered write */
if (!par->txbuf.buf) if (!par->txbuf.buf)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -38,8 +37,8 @@ int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc) ...@@ -38,8 +37,8 @@ int fbtft_write_buf_dc(struct fbtft_par *par, void *buf, size_t len, int dc)
{ {
int ret; int ret;
if (gpio_is_valid(par->gpio.dc)) if (par->gpio.dc)
gpio_set_value(par->gpio.dc, dc); gpiod_set_value(par->gpio.dc, dc);
ret = par->fbtftops.write(par, buf, len); ret = par->fbtftops.write(par, buf, len);
if (ret < 0) if (ret < 0)
...@@ -71,127 +70,27 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize, ...@@ -71,127 +70,27 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize,
} }
EXPORT_SYMBOL(fbtft_dbg_hex); EXPORT_SYMBOL(fbtft_dbg_hex);
static unsigned long fbtft_request_gpios_match(struct fbtft_par *par,
const struct fbtft_gpio *gpio)
{
int ret;
unsigned int val;
fbtft_par_dbg(DEBUG_REQUEST_GPIOS_MATCH, par, "%s('%s')\n",
__func__, gpio->name);
if (strcasecmp(gpio->name, "reset") == 0) {
par->gpio.reset = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
} else if (strcasecmp(gpio->name, "dc") == 0) {
par->gpio.dc = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
} else if (strcasecmp(gpio->name, "cs") == 0) {
par->gpio.cs = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
} else if (strcasecmp(gpio->name, "wr") == 0) {
par->gpio.wr = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
} else if (strcasecmp(gpio->name, "rd") == 0) {
par->gpio.rd = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
} else if (strcasecmp(gpio->name, "latch") == 0) {
par->gpio.latch = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
} else if (gpio->name[0] == 'd' && gpio->name[1] == 'b') {
ret = kstrtouint(&gpio->name[2], 10, &val);
if (ret == 0 && val < 16) {
par->gpio.db[val] = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
}
} else if (strcasecmp(gpio->name, "led") == 0) {
par->gpio.led[0] = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
} else if (strcasecmp(gpio->name, "led_") == 0) {
par->gpio.led[0] = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
}
return FBTFT_GPIO_NO_MATCH;
}
static int fbtft_request_gpios(struct fbtft_par *par)
{
struct fbtft_platform_data *pdata = par->pdata;
const struct fbtft_gpio *gpio;
unsigned long flags;
int ret;
if (!(pdata && pdata->gpios))
return 0;
gpio = pdata->gpios;
while (gpio->name[0]) {
flags = FBTFT_GPIO_NO_MATCH;
/* if driver provides match function, try it first,
* if no match use our own
*/
if (par->fbtftops.request_gpios_match)
flags = par->fbtftops.request_gpios_match(par, gpio);
if (flags == FBTFT_GPIO_NO_MATCH)
flags = fbtft_request_gpios_match(par, gpio);
if (flags != FBTFT_GPIO_NO_MATCH) {
ret = devm_gpio_request_one(par->info->device,
gpio->gpio, flags,
par->info->device->driver->name);
if (ret < 0) {
dev_err(par->info->device,
"%s: gpio_request_one('%s'=%d) failed with %d\n",
__func__, gpio->name,
gpio->gpio, ret);
return ret;
}
fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par,
"%s: '%s' = GPIO%d\n",
__func__, gpio->name, gpio->gpio);
}
gpio++;
}
return 0;
}
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int fbtft_request_one_gpio(struct fbtft_par *par, static int fbtft_request_one_gpio(struct fbtft_par *par,
const char *name, int index, int *gpiop) const char *name, int index,
struct gpio_desc **gpiop)
{ {
struct device *dev = par->info->device; struct device *dev = par->info->device;
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
int gpio, flags, ret = 0; int ret = 0;
enum of_gpio_flags of_flags;
if (of_find_property(node, name, NULL)) { if (of_find_property(node, name, NULL)) {
gpio = of_get_named_gpio_flags(node, name, index, &of_flags); *gpiop = devm_gpiod_get_index(dev, dev->driver->name, index,
if (gpio == -ENOENT) GPIOD_OUT_HIGH);
return 0; if (IS_ERR(*gpiop)) {
if (gpio == -EPROBE_DEFER) ret = PTR_ERR(*gpiop);
return gpio;
if (gpio < 0) {
dev_err(dev, dev_err(dev,
"failed to get '%s' from DT\n", name); "Failed to request %s GPIO:%d\n", name, ret);
return gpio;
}
/* active low translates to initially low */
flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
GPIOF_OUT_INIT_HIGH;
ret = devm_gpio_request_one(dev, gpio, flags,
dev->driver->name);
if (ret) {
dev_err(dev,
"gpio_request_one('%s'=%d) failed with %d\n",
name, gpio, ret);
return ret; return ret;
} }
if (gpiop) fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
*gpiop = gpio; __func__, name);
fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
__func__, name, gpio);
} }
return ret; return ret;
...@@ -254,9 +153,9 @@ static int fbtft_backlight_update_status(struct backlight_device *bd) ...@@ -254,9 +153,9 @@ static int fbtft_backlight_update_status(struct backlight_device *bd)
if ((bd->props.power == FB_BLANK_UNBLANK) && if ((bd->props.power == FB_BLANK_UNBLANK) &&
(bd->props.fb_blank == FB_BLANK_UNBLANK)) (bd->props.fb_blank == FB_BLANK_UNBLANK))
gpio_set_value(par->gpio.led[0], polarity); gpiod_set_value(par->gpio.led[0], polarity);
else else
gpio_set_value(par->gpio.led[0], !polarity); gpiod_set_value(par->gpio.led[0], !polarity);
return 0; return 0;
} }
...@@ -286,7 +185,7 @@ void fbtft_register_backlight(struct fbtft_par *par) ...@@ -286,7 +185,7 @@ void fbtft_register_backlight(struct fbtft_par *par)
struct backlight_device *bd; struct backlight_device *bd;
struct backlight_properties bl_props = { 0, }; struct backlight_properties bl_props = { 0, };
if (par->gpio.led[0] == -1) { if (!par->gpio.led[0]) {
fbtft_par_dbg(DEBUG_BACKLIGHT, par, fbtft_par_dbg(DEBUG_BACKLIGHT, par,
"%s(): led pin not set, exiting.\n", __func__); "%s(): led pin not set, exiting.\n", __func__);
return; return;
...@@ -295,7 +194,7 @@ void fbtft_register_backlight(struct fbtft_par *par) ...@@ -295,7 +194,7 @@ void fbtft_register_backlight(struct fbtft_par *par)
bl_props.type = BACKLIGHT_RAW; bl_props.type = BACKLIGHT_RAW;
/* Assume backlight is off, get polarity from current state of pin */ /* Assume backlight is off, get polarity from current state of pin */
bl_props.power = FB_BLANK_POWERDOWN; bl_props.power = FB_BLANK_POWERDOWN;
if (!gpio_get_value(par->gpio.led[0])) if (!gpiod_get_value(par->gpio.led[0]))
par->polarity = true; par->polarity = true;
bd = backlight_device_register(dev_driver_string(par->info->device), bd = backlight_device_register(dev_driver_string(par->info->device),
...@@ -333,12 +232,12 @@ static void fbtft_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, ...@@ -333,12 +232,12 @@ static void fbtft_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe,
static void fbtft_reset(struct fbtft_par *par) static void fbtft_reset(struct fbtft_par *par)
{ {
if (par->gpio.reset == -1) if (!par->gpio.reset)
return; return;
fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__); fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
gpio_set_value_cansleep(par->gpio.reset, 0); gpiod_set_value_cansleep(par->gpio.reset, 0);
usleep_range(20, 40); usleep_range(20, 40);
gpio_set_value_cansleep(par->gpio.reset, 1); gpiod_set_value_cansleep(par->gpio.reset, 1);
msleep(120); msleep(120);
} }
...@@ -663,7 +562,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, ...@@ -663,7 +562,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
int txbuflen = display->txbuflen; int txbuflen = display->txbuflen;
unsigned int bpp = display->bpp; unsigned int bpp = display->bpp;
unsigned int fps = display->fps; unsigned int fps = display->fps;
int vmem_size, i; int vmem_size;
const s16 *init_sequence = display->init_sequence; const s16 *init_sequence = display->init_sequence;
char *gamma = display->gamma; char *gamma = display->gamma;
u32 *gamma_curves = NULL; u32 *gamma_curves = NULL;
...@@ -841,19 +740,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, ...@@ -841,19 +740,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
par->txbuf.len = txbuflen; par->txbuf.len = txbuflen;
} }
/* Initialize gpios to disabled */
par->gpio.reset = -1;
par->gpio.dc = -1;
par->gpio.rd = -1;
par->gpio.wr = -1;
par->gpio.cs = -1;
par->gpio.latch = -1;
for (i = 0; i < 16; i++) {
par->gpio.db[i] = -1;
par->gpio.led[i] = -1;
par->gpio.aux[i] = -1;
}
/* default fbtft operations */ /* default fbtft operations */
par->fbtftops.write = fbtft_write_spi; par->fbtftops.write = fbtft_write_spi;
par->fbtftops.read = fbtft_read_spi; par->fbtftops.read = fbtft_read_spi;
...@@ -863,7 +749,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, ...@@ -863,7 +749,6 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
par->fbtftops.reset = fbtft_reset; par->fbtftops.reset = fbtft_reset;
par->fbtftops.mkdirty = fbtft_mkdirty; par->fbtftops.mkdirty = fbtft_mkdirty;
par->fbtftops.update_display = fbtft_update_display; par->fbtftops.update_display = fbtft_update_display;
par->fbtftops.request_gpios = fbtft_request_gpios;
if (display->backlight) if (display->backlight)
par->fbtftops.register_backlight = fbtft_register_backlight; par->fbtftops.register_backlight = fbtft_register_backlight;
...@@ -1035,8 +920,8 @@ static int fbtft_init_display_dt(struct fbtft_par *par) ...@@ -1035,8 +920,8 @@ static int fbtft_init_display_dt(struct fbtft_par *par)
return -EINVAL; return -EINVAL;
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
while (p) { while (p) {
if (val & FBTFT_OF_INIT_CMD) { if (val & FBTFT_OF_INIT_CMD) {
...@@ -1126,8 +1011,8 @@ int fbtft_init_display(struct fbtft_par *par) ...@@ -1126,8 +1011,8 @@ int fbtft_init_display(struct fbtft_par *par)
} }
par->fbtftops.reset(par); par->fbtftops.reset(par);
if (par->gpio.cs != -1) if (!par->gpio.cs)
gpio_set_value(par->gpio.cs, 0); /* Activate chip */ gpiod_set_value(par->gpio.cs, 0); /* Activate chip */
i = 0; i = 0;
while (i < FBTFT_MAX_INIT_SEQUENCE) { while (i < FBTFT_MAX_INIT_SEQUENCE) {
...@@ -1227,7 +1112,7 @@ static int fbtft_verify_gpios(struct fbtft_par *par) ...@@ -1227,7 +1112,7 @@ static int fbtft_verify_gpios(struct fbtft_par *par)
fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__);
if (pdata->display.buswidth != 9 && par->startbyte == 0 && if (pdata->display.buswidth != 9 && par->startbyte == 0 &&
par->gpio.dc < 0) { !par->gpio.dc) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'dc' gpio. Aborting.\n"); "Missing info about 'dc' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
...@@ -1236,12 +1121,12 @@ static int fbtft_verify_gpios(struct fbtft_par *par) ...@@ -1236,12 +1121,12 @@ static int fbtft_verify_gpios(struct fbtft_par *par)
if (!par->pdev) if (!par->pdev)
return 0; return 0;
if (par->gpio.wr < 0) { if (!par->gpio.wr) {
dev_err(par->info->device, "Missing 'wr' gpio. Aborting.\n"); dev_err(par->info->device, "Missing 'wr' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < pdata->display.buswidth; i++) { for (i = 0; i < pdata->display.buswidth; i++) {
if (par->gpio.db[i] < 0) { if (!par->gpio.db[i]) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing 'db%02d' gpio. Aborting.\n", i); "Missing 'db%02d' gpio. Aborting.\n", i);
return -EINVAL; return -EINVAL;
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <linux/export.h> #include <linux/export.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include "fbtft.h" #include "fbtft.h"
...@@ -142,30 +142,30 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len) ...@@ -142,30 +142,30 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
data = *(u8 *)buf; data = *(u8 *)buf;
/* Start writing by pulling down /WR */ /* Start writing by pulling down /WR */
gpio_set_value(par->gpio.wr, 0); gpiod_set_value(par->gpio.wr, 0);
/* Set data */ /* Set data */
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
if (data == prev_data) { if (data == prev_data) {
gpio_set_value(par->gpio.wr, 0); /* used as delay */ gpiod_set_value(par->gpio.wr, 0); /* used as delay */
} else { } else {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
if ((data & 1) != (prev_data & 1)) if ((data & 1) != (prev_data & 1))
gpio_set_value(par->gpio.db[i], gpiod_set_value(par->gpio.db[i],
data & 1); data & 1);
data >>= 1; data >>= 1;
prev_data >>= 1; prev_data >>= 1;
} }
} }
#else #else
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
gpio_set_value(par->gpio.db[i], data & 1); gpiod_set_value(par->gpio.db[i], data & 1);
data >>= 1; data >>= 1;
} }
#endif #endif
/* Pullup /WR */ /* Pullup /WR */
gpio_set_value(par->gpio.wr, 1); gpiod_set_value(par->gpio.wr, 1);
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
prev_data = *(u8 *)buf; prev_data = *(u8 *)buf;
...@@ -192,30 +192,30 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len) ...@@ -192,30 +192,30 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
data = *(u16 *)buf; data = *(u16 *)buf;
/* Start writing by pulling down /WR */ /* Start writing by pulling down /WR */
gpio_set_value(par->gpio.wr, 0); gpiod_set_value(par->gpio.wr, 0);
/* Set data */ /* Set data */
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
if (data == prev_data) { if (data == prev_data) {
gpio_set_value(par->gpio.wr, 0); /* used as delay */ gpiod_set_value(par->gpio.wr, 0); /* used as delay */
} else { } else {
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if ((data & 1) != (prev_data & 1)) if ((data & 1) != (prev_data & 1))
gpio_set_value(par->gpio.db[i], gpiod_set_value(par->gpio.db[i],
data & 1); data & 1);
data >>= 1; data >>= 1;
prev_data >>= 1; prev_data >>= 1;
} }
} }
#else #else
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
gpio_set_value(par->gpio.db[i], data & 1); gpiod_set_value(par->gpio.db[i], data & 1);
data >>= 1; data >>= 1;
} }
#endif #endif
/* Pullup /WR */ /* Pullup /WR */
gpio_set_value(par->gpio.wr, 1); gpiod_set_value(par->gpio.wr, 1);
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO #ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
prev_data = *(u16 *)buf; prev_data = *(u16 *)buf;
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
struct fbtft_gpio { struct fbtft_gpio {
char name[FBTFT_GPIO_NAME_SIZE]; char name[FBTFT_GPIO_NAME_SIZE];
unsigned int gpio; struct gpio_desc *gpio;
}; };
struct fbtft_par; struct fbtft_par;
...@@ -134,7 +134,6 @@ struct fbtft_display { ...@@ -134,7 +134,6 @@ struct fbtft_display {
*/ */
struct fbtft_platform_data { struct fbtft_platform_data {
struct fbtft_display display; struct fbtft_display display;
const struct fbtft_gpio *gpios;
unsigned int rotate; unsigned int rotate;
bool bgr; bool bgr;
unsigned int fps; unsigned int fps;
...@@ -207,15 +206,15 @@ struct fbtft_par { ...@@ -207,15 +206,15 @@ struct fbtft_par {
unsigned int dirty_lines_start; unsigned int dirty_lines_start;
unsigned int dirty_lines_end; unsigned int dirty_lines_end;
struct { struct {
int reset; struct gpio_desc *reset;
int dc; struct gpio_desc *dc;
int rd; struct gpio_desc *rd;
int wr; struct gpio_desc *wr;
int latch; struct gpio_desc *latch;
int cs; struct gpio_desc *cs;
int db[16]; struct gpio_desc *db[16];
int led[16]; struct gpio_desc *led[16];
int aux[16]; struct gpio_desc *aux[16];
} gpio; } gpio;
const s16 *init_sequence; const s16 *init_sequence;
struct { struct {
......
This diff is collapsed.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -521,7 +521,7 @@ static int flexfb_verify_gpios_dc(struct fbtft_par *par) ...@@ -521,7 +521,7 @@ static int flexfb_verify_gpios_dc(struct fbtft_par *par)
{ {
fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__);
if (par->gpio.dc < 0) { if (!par->gpio.dc) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'dc' gpio. Aborting.\n"); "Missing info about 'dc' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
...@@ -537,22 +537,22 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par) ...@@ -537,22 +537,22 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par)
fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__); fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__);
if (par->gpio.dc < 0) { if (!par->gpio.dc) {
dev_err(par->info->device, "Missing info about 'dc' gpio. Aborting.\n"); dev_err(par->info->device, "Missing info about 'dc' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (par->gpio.wr < 0) { if (!par->gpio.wr) {
dev_err(par->info->device, "Missing info about 'wr' gpio. Aborting.\n"); dev_err(par->info->device, "Missing info about 'wr' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (latched && (par->gpio.latch < 0)) { if (latched && !par->gpio.latch) {
dev_err(par->info->device, "Missing info about 'latch' gpio. Aborting.\n"); dev_err(par->info->device, "Missing info about 'latch' gpio. Aborting.\n");
return -EINVAL; return -EINVAL;
} }
if (latched) if (latched)
num_db = buswidth / 2; num_db = buswidth / 2;
for (i = 0; i < num_db; i++) { for (i = 0; i < num_db; i++) {
if (par->gpio.db[i] < 0) { if (!par->gpio.db[i]) {
dev_err(par->info->device, dev_err(par->info->device,
"Missing info about 'db%02d' gpio. Aborting.\n", "Missing info about 'db%02d' gpio. Aborting.\n",
i); i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment