Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2836898pxv; Mon, 12 Jul 2021 03:09:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS46EmPTOW5K617vb3YeIfx9semnIWivOqgOE0QlMiWqgz8yMPguFhG4nsOPlJCAyvd44h X-Received: by 2002:a92:6509:: with SMTP id z9mr37624207ilb.184.1626084591067; Mon, 12 Jul 2021 03:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084591; cv=none; d=google.com; s=arc-20160816; b=ZNlpvosJPu42Y4do/H+Ky6CijvAdIvv/ud//7N0RuhK8+g1TGWNLKSVgIYyGv6RfHf gheOT81VXDhpcSXxoPAXJdyDBtdD36RBWnsYetFk4wybQb+8WtEMTp7ccSOJq0i0upf7 cyOUPix1Hnvi77zz/FNyYfTVHtwhpapVZSCGcQ8GTk8hnL2dnHXC3niPjeekYwotY0Gw mZ141okOP69gmEIUeJvBj1kio2e2MXv/ibrA291Zh802gyPJZ6wiWQPG2haLyuV3rKVJ wcNml6DcFA1ANP7op/qvtorEIROywi9/0BPUKscIttN5ZK48n2512IkIKqY6hOGj30pi XUfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pmLnEWc7ClzCXs7CKQ0+6S3YqUym8SFn9Jmwlr/apSE=; b=fU67EjuU/nqbiloc5gbZfIkcdwFjuNvtAVROBt72PEetNMtO/NBdutL1oL38puwXVg YGvI3EM8/kNg6aN6sN/Jn2tWOgb7vbfw/UxcUNU49xENA/nPi4RnkcnVvVpr1G07j5Pd E7r82TenPoCXozCbea2FD2XxC8g3mLkHHjBIgpmB3GizH2nEnvQItoWwMagWnoc7M57Z ZxQQGEuZDgF6usrCsEj9ny91+lT0XhoF8vHVFmI7Y34YCKd+zrFTFNO8Uh/4lbC6aAhC n/fbuFEvVpj3R7vEXr4RveSBFh0CgZJO+Xwn6+R3IGuARDsARRg2MfFqEQZX9/hG6StZ gSDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WncSubQ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si17948612iob.27.2021.07.12.03.09.39; Mon, 12 Jul 2021 03:09:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WncSubQ8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348391AbhGLH5q (ORCPT + 99 others); Mon, 12 Jul 2021 03:57:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:58358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344349AbhGLHUb (ORCPT ); Mon, 12 Jul 2021 03:20:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9965E60FF1; Mon, 12 Jul 2021 07:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074262; bh=ZT1pmyiARtub1V29N8TtizRxrXg/UNtxtP9XxSISmu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WncSubQ8lTicY/56NWFXaOLfSuGGBpFJ701Gi32+2G4nkwl1+m1ViYLHRFf7BSbpO U9yi9jHPpPR96f1tDdFzaNqLlrldxbwG1mDauh6g9g3bPL72MJP9Q/Er+xlUrBx5zm TN61JvxzzBMmjLBEGQYQ7Y6eNAHIz/kFyfT4+qlc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jan=20Sebastian=20G=C3=B6tte?= , Nishad Kamdar , Phil Reid , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 519/700] staging: fbtft: Rectify GPIO handling Date: Mon, 12 Jul 2021 08:10:02 +0200 Message-Id: <20210712061031.699362151@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit ec03c2104365ead0a33627c05e685093eed3eaef ] The infamous commit c440eee1a7a1 ("Staging: staging: fbtft: Switch to the GPIO descriptor interface") broke GPIO handling completely. It has already four commits to rectify and it seems not enough. In order to fix the mess here we: 1) Set default to "inactive" for all requested pins 2) Fix CS#, RD#, and WR# pins polarity since it's active low and GPIO descriptor interface takes it into consideration from the Device Tree or ACPI 3) Consolidate chip activation (CS# assertion) under default ->reset() callback To summarize the expectations about polarity for GPIOs: RD# Low WR# Low CS# Low RESET# Low DC or RS High RW High Data 0 .. 15 High See also Adafruit learning course [1] for the example of the schematics. While at it, drop unneeded NULL checks, since GPIO API is tolerant to that. [1]: https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2/downloads Fixes: 92e3e884887c ("Staging: fbtft: Fix GPIO handling") Fixes: b918d1c27066 ("Staging: fbtft: Fix reset assertion when using gpio descriptor") Fixes: dbc4f989c878 ("Staging: fbtft: Fix probing of gpio descriptor") Fixes: c440eee1a7a1 ("Staging: fbtft: Switch to the gpio descriptor interface") Cc: Jan Sebastian Götte Cc: Nishad Kamdar Reviewed-by: Phil Reid Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210503172114.27891-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/fbtft/fb_agm1264k-fl.c | 20 ++++++++++---------- drivers/staging/fbtft/fb_bd663474.c | 4 ---- drivers/staging/fbtft/fb_ili9163.c | 4 ---- drivers/staging/fbtft/fb_ili9320.c | 1 - drivers/staging/fbtft/fb_ili9325.c | 4 ---- drivers/staging/fbtft/fb_ili9340.c | 1 - drivers/staging/fbtft/fb_s6d1121.c | 4 ---- drivers/staging/fbtft/fb_sh1106.c | 1 - drivers/staging/fbtft/fb_ssd1289.c | 4 ---- drivers/staging/fbtft/fb_ssd1325.c | 2 -- drivers/staging/fbtft/fb_ssd1331.c | 6 ++---- drivers/staging/fbtft/fb_ssd1351.c | 1 - drivers/staging/fbtft/fb_upd161704.c | 4 ---- drivers/staging/fbtft/fb_watterott.c | 1 - drivers/staging/fbtft/fbtft-bus.c | 3 +-- drivers/staging/fbtft/fbtft-core.c | 13 ++++++------- drivers/staging/fbtft/fbtft-io.c | 12 ++++++------ 17 files changed, 25 insertions(+), 60 deletions(-) diff --git a/drivers/staging/fbtft/fb_agm1264k-fl.c b/drivers/staging/fbtft/fb_agm1264k-fl.c index eeeeec97ad27..b545c2ca80a4 100644 --- a/drivers/staging/fbtft/fb_agm1264k-fl.c +++ b/drivers/staging/fbtft/fb_agm1264k-fl.c @@ -84,9 +84,9 @@ static void reset(struct fbtft_par *par) dev_dbg(par->info->device, "%s()\n", __func__); - gpiod_set_value(par->gpio.reset, 0); - udelay(20); gpiod_set_value(par->gpio.reset, 1); + udelay(20); + gpiod_set_value(par->gpio.reset, 0); mdelay(120); } @@ -194,12 +194,12 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) /* select chip */ if (*buf) { /* cs1 */ - gpiod_set_value(par->CS0, 1); - gpiod_set_value(par->CS1, 0); - } else { - /* cs0 */ gpiod_set_value(par->CS0, 0); gpiod_set_value(par->CS1, 1); + } else { + /* cs0 */ + gpiod_set_value(par->CS0, 1); + gpiod_set_value(par->CS1, 0); } gpiod_set_value(par->RS, 0); /* RS->0 (command mode) */ @@ -397,8 +397,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) } kfree(convert_buf); - gpiod_set_value(par->CS0, 1); - gpiod_set_value(par->CS1, 1); + gpiod_set_value(par->CS0, 0); + gpiod_set_value(par->CS1, 0); return ret; } @@ -419,10 +419,10 @@ static int write(struct fbtft_par *par, void *buf, size_t len) for (i = 0; i < 8; ++i) gpiod_set_value(par->gpio.db[i], data & (1 << i)); /* set E */ - gpiod_set_value(par->EPIN, 1); + gpiod_set_value(par->EPIN, 0); udelay(5); /* unset E - write */ - gpiod_set_value(par->EPIN, 0); + gpiod_set_value(par->EPIN, 1); udelay(1); } diff --git a/drivers/staging/fbtft/fb_bd663474.c b/drivers/staging/fbtft/fb_bd663474.c index e2c7646588f8..1629c2c440a9 100644 --- a/drivers/staging/fbtft/fb_bd663474.c +++ b/drivers/staging/fbtft/fb_bd663474.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include "fbtft.h" @@ -24,9 +23,6 @@ static int init_display(struct fbtft_par *par) { - if (par->gpio.cs) - gpiod_set_value(par->gpio.cs, 0); /* Activate chip */ - par->fbtftops.reset(par); /* Initialization sequence from Lib_UTFT */ diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c index 05648c3ffe47..6582a2c90aaf 100644 --- a/drivers/staging/fbtft/fb_ili9163.c +++ b/drivers/staging/fbtft/fb_ili9163.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include