Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4399334imu; Mon, 14 Jan 2019 22:26:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN7WWM6hxbBoMxKLPvL21xrn1m++2OEu80WP0YfgMxZCzFjBtJ3bRiicBuQgiugXWD3gTLPS X-Received: by 2002:a62:8a51:: with SMTP id y78mr2368590pfd.35.1547533612147; Mon, 14 Jan 2019 22:26:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547533612; cv=none; d=google.com; s=arc-20160816; b=jkDUZ4f8Jx4iBs2gUpvGPDdnDidus5erWT7p9d1gCXlnOiLMDugDkWIyi6l/50KxCe mfRsPGpp5JFzfk+HvgAsHqANVK06lx1PoB6XHPX5VRrJbBJlqJM1+zaz4OKXEjVNLgqL 9Jr+E3A+ondx3vCAojokQoQi6q0yQ7hlABF0H/Z2PZNeA3UpP32PTo4E8T6jKo9doI2l oh+OuHGjZMpvK/gay37MCRcVb0ZsN3AsL+O+mPzGpD1MfcigokUIuGp3oZKY9br2lQ7T bxjlSoFu+3TF+v+kffChtGziFsBpV7Oa55AT5z0VwVZ1wrBQVfDzsawQiUnomkWSg2MD KrNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=bIXMNxu87tt8my4EbfIVixbqmCEEAp2vED7MChWChTQ=; b=O/rhovpu1PMD0Sg2h4b9Z3shlSqUQvV2zF2wZBLEWSZcq9Cl03CsnH7wdGBXQ3bQIg nPdsVQTRd08SAGarBzh1PtF6qZrUlk5DHoAecuwA3Eb94mso0RDrMPnq7yUbZnaavbbo Eilkjle0E4ZjPXjgAsR7erLxJ9a9nTL49ThZfdGCUS3SBe0o/3lSsCUsk2b5LPwGzwQa XNbMgIhvi2VT6Bmpp8hR8Rfow7DxMTQ40ITQcfxHy9JbxRHJ9R9dAMnjzweCUI6Mnqmr CaI/urwj4VBNYkGQTs10sqI5vjuOEoDm0LQJPMveZ2xpXCaCwckxRM+fmS64hPazqp8D s8bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QtF5Opv+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m39si2444588plg.315.2019.01.14.22.26.29; Mon, 14 Jan 2019 22:26:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QtF5Opv+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbfAOErW (ORCPT + 99 others); Mon, 14 Jan 2019 23:47:22 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44856 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbfAOErW (ORCPT ); Mon, 14 Jan 2019 23:47:22 -0500 Received: by mail-pg1-f193.google.com with SMTP id t13so663771pgr.11; Mon, 14 Jan 2019 20:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=bIXMNxu87tt8my4EbfIVixbqmCEEAp2vED7MChWChTQ=; b=QtF5Opv+7N7tZpb8Bk7yoLERBZgrtXY9NnzSL++vU+B8YHVkv3FyiDuui7vJG5CCXY HL6eRwId7bil63Z23e8z8GpDdUk1UnY7V0sKHpmDqeDZLqi3Dd76VLnQSB1in6hBBuqM xxs93UgjTbAsQ08aZvmbJDR6L0AG8eXU3tb+3LCNYaZlngO80xOarnbZRaGROxL5cCef tUmxg1VCyjJ0KGGHgpgV2bdNyIhjPbrDQ//WcIHd7MMsze2Im9a4bV66ZPAviLjrXd3o HKanNy+IERCMP1uUEt7rCj0YO++TsMRCVMStiV2S1bbEKFS0TQd5li7936sTCoA/kHRm T5rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=bIXMNxu87tt8my4EbfIVixbqmCEEAp2vED7MChWChTQ=; b=XSA4oToIIEIuhkEiJg0wSh6+qcByyESUrWp1KFVXDvVJ6uOBrEJblzE3ierpcS/ai+ SFJEZSol9LJc6OS6zo409coUT7MetXSEHKsVBfseicCCrVVyzswXGlAd09O2kxUSRuVQ i1Wsy9tmpLgkrqH9FToe8P1U8Xno2kMqUr/xd6fixT9bxqclyjG/2DZKZ5Xoq1n2DNPd /2SpNwGfqfNR9U+mclxOcTkScXzwqOau5LkXoT1l8btICnrrSR6ZoQlFLxe5PjG8EEbf 44X7nhbr1UMVHy//xpanZoGfQWoCObAgPgn3KQd9f8wnfUtL/kZ7PQzbovXFdSJ5b/t8 p5zw== X-Gm-Message-State: AJcUukdIZgOOpY5i1EZ4Xm8qkTquAqMI0Sll5eP4BD/Wwce/+UImU52B mSB8VBTOoiGH6m7BfPd8Ows= X-Received: by 2002:a63:4342:: with SMTP id q63mr2066831pga.63.1547527639084; Mon, 14 Jan 2019 20:47:19 -0800 (PST) Received: from nishad ([106.51.25.107]) by smtp.gmail.com with ESMTPSA id h19sm2249653pfn.114.2019.01.14.20.47.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Jan 2019 20:47:18 -0800 (PST) Date: Tue, 15 Jan 2019 10:17:09 +0530 From: Nishad Kamdar To: Greg Kroah-Hartman Cc: Leonardo =?utf-8?B?QnLDoXM=?= , Tim Cofala , Felix Siegel , Matthias Wolf , Renato Soma , Daniel Vetter , Jani Nikula , Lee Jones , Mamta Shukla , YueHaibing , Radek =?utf-8?Q?Dost=C3=A1l?= , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nishad Kamdar Subject: [PATCH v2] Staging: fbtft: Switch to the gpio descriptor interface Message-ID: <20190115044704.GA20989@nishad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Nishad Kamdar Changes in v2: - Merge all patches in a single patch. This is because the first patch changes par->gpio from an int to a pointer so all the checks have to be updated in the same patch. Otherwie it breaks 'git bisect'. --- drivers/staging/fbtft/fb_agm1264k-fl.c | 52 ++-- drivers/staging/fbtft/fb_bd663474.c | 6 +- drivers/staging/fbtft/fb_ili9163.c | 6 +- drivers/staging/fbtft/fb_ili9320.c | 2 +- drivers/staging/fbtft/fb_ili9325.c | 6 +- drivers/staging/fbtft/fb_ili9340.c | 2 +- drivers/staging/fbtft/fb_pcd8544.c | 4 +- drivers/staging/fbtft/fb_ra8875.c | 4 +- drivers/staging/fbtft/fb_s6d1121.c | 6 +- drivers/staging/fbtft/fb_sh1106.c | 2 +- drivers/staging/fbtft/fb_ssd1289.c | 6 +- drivers/staging/fbtft/fb_ssd1305.c | 4 +- drivers/staging/fbtft/fb_ssd1306.c | 4 +- drivers/staging/fbtft/fb_ssd1325.c | 6 +- drivers/staging/fbtft/fb_ssd1331.c | 10 +- drivers/staging/fbtft/fb_ssd1351.c | 2 +- drivers/staging/fbtft/fb_tls8204.c | 6 +- drivers/staging/fbtft/fb_uc1611.c | 4 +- drivers/staging/fbtft/fb_uc1701.c | 6 +- drivers/staging/fbtft/fb_upd161704.c | 6 +- drivers/staging/fbtft/fb_watterott.c | 4 +- drivers/staging/fbtft/fbtft-bus.c | 6 +- drivers/staging/fbtft/fbtft-core.c | 173 +++---------- drivers/staging/fbtft/fbtft-io.c | 26 +- drivers/staging/fbtft/fbtft.h | 21 +- drivers/staging/fbtft/fbtft_device.c | 344 +------------------------ drivers/staging/fbtft/flexfb.c | 12 +- 27 files changed, 143 insertions(+), 587 deletions(-) diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c b/drivers/staging/fbtft/fb_agm1264k-fl.c index f6f30f5bf15a..8f27bd8da17d 100644 --- a/drivers/staging/fbtft/fb_agm1264k-fl.c +++ b/drivers/staging/fbtft/fb_agm1264k-fl.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include @@ -79,14 +79,14 @@ static int init_display(struct fbtft_par *par) static void reset(struct fbtft_par *par) { - if (par->gpio.reset == -1) + if (!par->gpio.reset) return; dev_dbg(par->info->device, "%s()\n", __func__); - gpio_set_value(par->gpio.reset, 0); + gpiod_set_value(par->gpio.reset, 0); udelay(20); - gpio_set_value(par->gpio.reset, 1); + gpiod_set_value(par->gpio.reset, 1); mdelay(120); } @@ -98,30 +98,30 @@ static int verify_gpios(struct fbtft_par *par) dev_dbg(par->info->device, "%s()\n", __func__); - if (par->EPIN < 0) { + if (!par->EPIN) { dev_err(par->info->device, "Missing info about 'wr' (aka E) gpio. Aborting.\n"); return -EINVAL; } for (i = 0; i < 8; ++i) { - if (par->gpio.db[i] < 0) { + if (!par->gpio.db[i]) { dev_err(par->info->device, "Missing info about 'db[%i]' gpio. Aborting.\n", i); return -EINVAL; } } - if (par->CS0 < 0) { + if (!par->CS0) { dev_err(par->info->device, "Missing info about 'cs0' gpio. Aborting.\n"); return -EINVAL; } - if (par->CS1 < 0) { + if (!par->CS1) { dev_err(par->info->device, "Missing info about 'cs1' gpio. Aborting.\n"); return -EINVAL; } - if (par->RW < 0) { + if (!par->RW) { dev_err(par->info->device, "Missing info about 'rw' gpio. Aborting.\n"); return -EINVAL; @@ -139,22 +139,22 @@ request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio) if (strcasecmp(gpio->name, "wr") == 0) { /* left ks0108 E pin */ par->EPIN = gpio->gpio; - return GPIOF_OUT_INIT_LOW; + return GPIOD_OUT_LOW; } else if (strcasecmp(gpio->name, "cs0") == 0) { /* left ks0108 controller pin */ par->CS0 = gpio->gpio; - return GPIOF_OUT_INIT_HIGH; + return GPIOD_OUT_HIGH; } else if (strcasecmp(gpio->name, "cs1") == 0) { /* right ks0108 controller pin */ par->CS1 = gpio->gpio; - return GPIOF_OUT_INIT_HIGH; + return GPIOD_OUT_HIGH; } /* if write (rw = 0) e(1->0) perform write */ /* if read (rw = 1) e(0->1) set data on D0-7*/ else if (strcasecmp(gpio->name, "rw") == 0) { par->RW = gpio->gpio; - return GPIOF_OUT_INIT_LOW; + return GPIOD_OUT_LOW; } return FBTFT_GPIO_NO_MATCH; @@ -194,15 +194,15 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) /* select chip */ if (*buf) { /* cs1 */ - gpio_set_value(par->CS0, 1); - gpio_set_value(par->CS1, 0); + gpiod_set_value(par->CS0, 1); + gpiod_set_value(par->CS1, 0); } else { /* cs0 */ - gpio_set_value(par->CS0, 0); - gpio_set_value(par->CS1, 1); + gpiod_set_value(par->CS0, 0); + 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--; if (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 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); if (ret < 0) dev_err(par->info->device, @@ -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 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); if (ret < 0) dev_err(par->info->device, @@ -397,8 +397,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) } kfree(convert_buf); - gpio_set_value(par->CS0, 1); - gpio_set_value(par->CS1, 1); + gpiod_set_value(par->CS0, 1); + gpiod_set_value(par->CS1, 1); return ret; } @@ -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, "%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--) { u8 i, data; @@ -417,12 +417,12 @@ static int write(struct fbtft_par *par, void *buf, size_t len) /* set data bus */ 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 */ - gpio_set_value(par->EPIN, 1); + gpiod_set_value(par->EPIN, 1); udelay(5); /* unset E - write */ - gpio_set_value(par->EPIN, 0); + gpiod_set_value(par->EPIN, 0); udelay(1); } diff --git a/drivers/staging/fbtft/fb_bd663474.c b/drivers/staging/fbtft/fb_bd663474.c index a58c514f4721..b6c6d66e4eb1 100644 --- a/drivers/staging/fbtft/fb_bd663474.c +++ b/drivers/staging/fbtft/fb_bd663474.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include "fbtft.h" @@ -24,8 +24,8 @@ static int init_display(struct fbtft_par *par) { - if (par->gpio.cs != -1) - gpio_set_value(par->gpio.cs, 0); /* Activate chip */ + if (!par->gpio.cs) + gpiod_set_value(par->gpio.cs, 0); /* Activate chip */ par->fbtftops.reset(par); diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c index 86e140244aab..d609a2b67db9 100644 --- a/drivers/staging/fbtft/fb_ili9163.c +++ b/drivers/staging/fbtft/fb_ili9163.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include