staging: fbtft: Rectify GPIO handling
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 3 May 2021 17:21:10 +0000 (20:21 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:56:32 +0000 (16:56 +0200)
commit7a42f3c30dfe3d51fa7d1a70b669243d9b34a38d
treee0ffc75059a269ba17558f31f01ecbcb58793b78
parentd8c1504cf1a0cd71b0619aaf3176c6f81ca3af60
staging: fbtft: Rectify GPIO handling

[ 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 <linux@jaseg.net>
Cc: Nishad Kamdar <nishadkamdar@gmail.com>
Reviewed-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210503172114.27891-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
17 files changed:
drivers/staging/fbtft/fb_agm1264k-fl.c
drivers/staging/fbtft/fb_bd663474.c
drivers/staging/fbtft/fb_ili9163.c
drivers/staging/fbtft/fb_ili9320.c
drivers/staging/fbtft/fb_ili9325.c
drivers/staging/fbtft/fb_ili9340.c
drivers/staging/fbtft/fb_s6d1121.c
drivers/staging/fbtft/fb_sh1106.c
drivers/staging/fbtft/fb_ssd1289.c
drivers/staging/fbtft/fb_ssd1325.c
drivers/staging/fbtft/fb_ssd1331.c
drivers/staging/fbtft/fb_ssd1351.c
drivers/staging/fbtft/fb_upd161704.c
drivers/staging/fbtft/fb_watterott.c
drivers/staging/fbtft/fbtft-bus.c
drivers/staging/fbtft/fbtft-core.c
drivers/staging/fbtft/fbtft-io.c