diff mbox series

[v4,1/4] Input: ads7846 - Convert to use software nodes

Message ID 20230430-nokia770-regression-v4-1-9b6dc5536b17@linaro.org (mailing list archive)
State New, archived
Headers show
Series Fix up Nokia 770 regression | expand

Commit Message

Linus Walleij May 8, 2023, 9:20 p.m. UTC
The Nokia 770 is using GPIOs from the global numberspace on the
CBUS node to pass down to the LCD controller. This regresses when we
let the OMAP GPIO driver use dynamic GPIO base.

The Nokia 770 now has dynamic allocation of IRQ numbers, so this
needs to be fixed for it to work.

As this is the only user of LCD MIPID we can easily augment the
driver to use a GPIO descriptor instead and resolve the issue.

The platform data .shutdown() callback wasn't even used in the
code, but we encode a shutdown asserting RESET in the remove()
callback for completeness sake.

The CBUS also has the ADS7846 touchscreen attached.

Populate the devices on the Nokia 770 CBUS I2C using software
nodes instead of platform data quirks. This includes the LCD
and the ADS7846 touchscreen so the conversion just brings the LCD
along with it as software nodes is an all-or-nothing design
pattern.

The ADS7846 has some limited support for using GPIO descriptors,
let's convert it over completely to using device properties and then
fix all remaining boardfile users to provide all platform data using
software nodes.

Dump the of includes and of_match_ptr() in the ADS7846 driver as part
of the job.

Since we have to move ADS7846 over to obtaining the GPIOs it is
using exclusively from descriptors, we provide descriptor tables
for the two remaining in-kernel boardfiles using ADS7846:

- PXA Spitz
- MIPS Alchemy DB1000 development board

It was too hard for me to include software node conversion of
these two remaining users at this time: the spitz is using a
hscync callback in the platform data that would require further
GPIO descriptor conversion of the Spitz, and moving the hsync
callback down into the driver: it will just become too big of
a job, but it can be done separately.

The MIPS Alchemy DB1000 is simply something I cannot test, so take
the easier approach of just providing some GPIO descriptors in
this case as I don't want the patch to grow too intrusive.

As we see that several device trees have incorrect polarity flags
and just expect to bypass the gpiolib polarity handling, fix up
all device trees too, in a separate patch.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v3->v4:
- Fix all board file polarity flags to be active low, because
  this pendown signal is active low.
- Fix all erroneous device trees too.
- Drop some unnecessary commas.
ChangeLog v2->v3:
- Drop leftover OF ifdefs no longer needed and causing compile
  errors.
---
 arch/arm/mach-omap1/board-nokia770.c    |  98 +++++++++++++++++----------
 arch/arm/mach-pxa/spitz.c               |  11 +++-
 arch/mips/alchemy/devboards/db1000.c    |  11 +++-
 drivers/input/touchscreen/ads7846.c     | 113 ++++++++++++--------------------
 drivers/video/fbdev/omap/lcd_mipid.c    |  10 +++
 include/linux/platform_data/lcd-mipid.h |   2 -
 include/linux/spi/ads7846.h             |   2 -
 7 files changed, 135 insertions(+), 112 deletions(-)

Comments

Dmitry Torokhov May 8, 2023, 9:24 p.m. UTC | #1
On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> The Nokia 770 is using GPIOs from the global numberspace on the
> CBUS node to pass down to the LCD controller. This regresses when we
> let the OMAP GPIO driver use dynamic GPIO base.
> 
> The Nokia 770 now has dynamic allocation of IRQ numbers, so this
> needs to be fixed for it to work.
> 
> As this is the only user of LCD MIPID we can easily augment the
> driver to use a GPIO descriptor instead and resolve the issue.
> 
> The platform data .shutdown() callback wasn't even used in the
> code, but we encode a shutdown asserting RESET in the remove()
> callback for completeness sake.
> 
> The CBUS also has the ADS7846 touchscreen attached.
> 
> Populate the devices on the Nokia 770 CBUS I2C using software
> nodes instead of platform data quirks. This includes the LCD
> and the ADS7846 touchscreen so the conversion just brings the LCD
> along with it as software nodes is an all-or-nothing design
> pattern.
> 
> The ADS7846 has some limited support for using GPIO descriptors,
> let's convert it over completely to using device properties and then
> fix all remaining boardfile users to provide all platform data using
> software nodes.
> 
> Dump the of includes and of_match_ptr() in the ADS7846 driver as part
> of the job.
> 
> Since we have to move ADS7846 over to obtaining the GPIOs it is
> using exclusively from descriptors, we provide descriptor tables
> for the two remaining in-kernel boardfiles using ADS7846:
> 
> - PXA Spitz
> - MIPS Alchemy DB1000 development board
> 
> It was too hard for me to include software node conversion of
> these two remaining users at this time: the spitz is using a
> hscync callback in the platform data that would require further
> GPIO descriptor conversion of the Spitz, and moving the hsync
> callback down into the driver: it will just become too big of
> a job, but it can be done separately.
> 
> The MIPS Alchemy DB1000 is simply something I cannot test, so take
> the easier approach of just providing some GPIO descriptors in
> this case as I don't want the patch to grow too intrusive.
> 
> As we see that several device trees have incorrect polarity flags
> and just expect to bypass the gpiolib polarity handling, fix up
> all device trees too, in a separate patch.
> 
> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Fix all board file polarity flags to be active low, because
>   this pendown signal is active low.
> - Fix all erroneous device trees too.
> - Drop some unnecessary commas.
> ChangeLog v2->v3:
> - Drop leftover OF ifdefs no longer needed and causing compile
>   errors.
> ---
>  arch/arm/mach-omap1/board-nokia770.c    |  98 +++++++++++++++++----------
>  arch/arm/mach-pxa/spitz.c               |  11 +++-
>  arch/mips/alchemy/devboards/db1000.c    |  11 +++-
>  drivers/input/touchscreen/ads7846.c     | 113 ++++++++++++--------------------

For input:

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

In general:

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.
Aaro Koskinen May 17, 2023, 7:59 p.m. UTC | #2
Hi,

This does not compile as nokia770_ads7846_props is declared twice,
and nokia770_cbus_props and nokia770_mpuio_gpiochip_swnode are missing.

On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> +static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
> +	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 9, 0),
> +	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 10, 0),
> +	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 11, 0),
> +};

These should be nokia770_mpuio_gpiochip_node.

> +static const struct property_entry nokia770_ads7846_props[] = {
> +	PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
> +	{ }
>  };

This should be nokia770_cbus_props.

A.
Aaro Koskinen May 17, 2023, 8:39 p.m. UTC | #3
Hi,

On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> The CBUS also has the ADS7846 touchscreen attached.

Not sure what this comment means. CBUS is for Retu/Tahvo, and touchscreen
is SPI.

When tested w/gpio-descriptors-omap branch, the touchscreen probe fails:

[    2.378540] SPI driver ads7846 has no spi_device_id for ti,tsc2046
[    2.391906] SPI driver ads7846 has no spi_device_id for ti,ads7843
[    2.405029] SPI driver ads7846 has no spi_device_id for ti,ads7845
[    2.418151] SPI driver ads7846 has no spi_device_id for ti,ads7873
[    2.432556] ads7846 spi2.0: Unknown device model
[    2.443817] ads7846: probe of spi2.0 failed with error -22

I don't know if that's caused by any the patches in the branch or some
other regression. With v6.2 it probes OK.

A.
Linus Walleij May 17, 2023, 9:11 p.m. UTC | #4
On Wed, May 17, 2023 at 9:59 PM Aaro Koskinen <aaro.koskinen@iki.fi> wrote:

> This does not compile as nokia770_ads7846_props is declared twice,
> and nokia770_cbus_props and nokia770_mpuio_gpiochip_swnode are missing.

Hmmmm I think we should probably update omap1_defconfig to enable
all the OMAP1 drivers so we have good compile coverage. It's the
ifdefs that fool me into believeing the code actually compiles ...

> On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> > +static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
> > +     SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 9, 0),
> > +     SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 10, 0),
> > +     SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 11, 0),
> > +};
>
> These should be nokia770_mpuio_gpiochip_node.

Fixed it.

> > +static const struct property_entry nokia770_ads7846_props[] = {
> > +     PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
> > +     { }
> >  };
>
> This should be nokia770_cbus_props.

Fixed it.

Also enabled CONFIG_I2C_CBUS_GPIO and recompiled.

Yours,
Linus Walleij

Yours,
Linus Walleij
Linus Walleij May 17, 2023, 9:20 p.m. UTC | #5
On Wed, May 17, 2023 at 10:39 PM Aaro Koskinen <aaro.koskinen@iki.fi> wrote:

> When tested w/gpio-descriptors-omap branch, the touchscreen probe fails:
>
> [    2.378540] SPI driver ads7846 has no spi_device_id for ti,tsc2046
> [    2.391906] SPI driver ads7846 has no spi_device_id for ti,ads7843
> [    2.405029] SPI driver ads7846 has no spi_device_id for ti,ads7845
> [    2.418151] SPI driver ads7846 has no spi_device_id for ti,ads7873

This is just regular noise from SPI device drivers that are missing
spi_device_id.

> [    2.432556] ads7846 spi2.0: Unknown device model
> [    2.443817] ads7846: probe of spi2.0 failed with error -22
>
> I don't know if that's caused by any the patches in the branch or some
> other regression. With v6.2 it probes OK.

The device is missing compatible. I fixed it.

Will push the branch after looking at the rest of the comments.

Yours,
Linus Walleij
Christophe JAILLET June 4, 2023, 3:44 p.m. UTC | #6
Le 08/05/2023 à 23:20, Linus Walleij a écrit :
> The Nokia 770 is using GPIOs from the global numberspace on the
> CBUS node to pass down to the LCD controller. This regresses when we
> let the OMAP GPIO driver use dynamic GPIO base.
> 
> The Nokia 770 now has dynamic allocation of IRQ numbers, so this
> needs to be fixed for it to work.
> 
> As this is the only user of LCD MIPID we can easily augment the
> driver to use a GPIO descriptor instead and resolve the issue.
> 
> The platform data .shutdown() callback wasn't even used in the
> code, but we encode a shutdown asserting RESET in the remove()
> callback for completeness sake.
> 
> The CBUS also has the ADS7846 touchscreen attached.
> 
> Populate the devices on the Nokia 770 CBUS I2C using software
> nodes instead of platform data quirks. This includes the LCD
> and the ADS7846 touchscreen so the conversion just brings the LCD
> along with it as software nodes is an all-or-nothing design
> pattern.
> 
> The ADS7846 has some limited support for using GPIO descriptors,
> let's convert it over completely to using device properties and then
> fix all remaining boardfile users to provide all platform data using
> software nodes.
> 
> Dump the of includes and of_match_ptr() in the ADS7846 driver as part
> of the job.
> 
> Since we have to move ADS7846 over to obtaining the GPIOs it is
> using exclusively from descriptors, we provide descriptor tables
> for the two remaining in-kernel boardfiles using ADS7846:
> 
> - PXA Spitz
> - MIPS Alchemy DB1000 development board
> 
> It was too hard for me to include software node conversion of
> these two remaining users at this time: the spitz is using a
> hscync callback in the platform data that would require further
> GPIO descriptor conversion of the Spitz, and moving the hsync
> callback down into the driver: it will just become too big of
> a job, but it can be done separately.
> 
> The MIPS Alchemy DB1000 is simply something I cannot test, so take
> the easier approach of just providing some GPIO descriptors in
> this case as I don't want the patch to grow too intrusive.
> 
> As we see that several device trees have incorrect polarity flags
> and just expect to bypass the gpiolib polarity handling, fix up
> all device trees too, in a separate patch.
> 
> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

[...]

> diff --git a/drivers/video/fbdev/omap/lcd_mipid.c b/drivers/video/fbdev/omap/lcd_mipid.c
> index 03cff39d392d..e4a7f0b824ff 100644
> --- a/drivers/video/fbdev/omap/lcd_mipid.c
> +++ b/drivers/video/fbdev/omap/lcd_mipid.c
> @@ -7,6 +7,7 @@
>    */
>   #include <linux/device.h>
>   #include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
>   #include <linux/slab.h>
>   #include <linux/workqueue.h>
>   #include <linux/spi/spi.h>
> @@ -41,6 +42,7 @@ struct mipid_device {
>   						   when we can issue the
>   						   next sleep in/out command */
>   	unsigned long	hw_guard_wait;		/* max guard time in jiffies */
> +	struct gpio_desc	*reset;
>   
>   	struct omapfb_device	*fbdev;
>   	struct spi_device	*spi;
> @@ -556,6 +558,12 @@ static int mipid_spi_probe(struct spi_device *spi)
>   		return -ENOMEM;
>   	}
>   
> +	/* This will de-assert RESET if active */
> +	md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
> +	if (IS_ERR(md->reset))
> +		return dev_err_probe(&spi->dev, PTR_ERR(md->reset),
> +				     "no reset GPIO line\n");
> +
>   	spi->mode = SPI_MODE_0;
>   	md->spi = spi;
>   	dev_set_drvdata(&spi->dev, md);
> @@ -574,6 +582,8 @@ static void mipid_spi_remove(struct spi_device *spi)
>   {
>   	struct mipid_device *md = dev_get_drvdata(&spi->dev);
>   
> +	/* Asserts RESET */
> +	gpiod_set_value(md->reset, 1);

Hi,

should this also be done in the probe if mipid_detect() fails?

If yes, please also look at [1], that I've just sent, which introduces 
an error handling path in the probe.

CJ

[1]: 
https://lore.kernel.org/all/8b82e34724755b69f34f15dddb288cd373080390.1620505229.git.christophe.jaillet@wanadoo.fr/

>   	mipid_disable(&md->panel);
>   	kfree(md);
>   }

[...]
Guenter Roeck June 5, 2023, 6:33 p.m. UTC | #7
Hi,

On Mon, May 08, 2023 at 11:20:06PM +0200, Linus Walleij wrote:
> The Nokia 770 is using GPIOs from the global numberspace on the
> CBUS node to pass down to the LCD controller. This regresses when we
> let the OMAP GPIO driver use dynamic GPIO base.
> 
...
> 
> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Fixes: 92bf78b33b0b ("gpio: omap: use dynamic allocation of base")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

This patch causes a crash with the mcimx7d-sabre qemu emulation.
Backtrace and bisect results below.

Source:

        pdev_id = device_get_match_data(dev);
        if (!pdev_id) {
                dev_err(dev, "Unknown device model\n");
                return ERR_PTR(-EINVAL);
        }

        pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return ERR_PTR(-ENOMEM);

        pdata->model = (unsigned long)pdev_id->driver_data;	<--- crash

It appears that device_get_match_data() already returns driver_data.
A little debugging shows that pdev_id is indeed 0x1EA6 or 7846.

Guenter

---
Stack backtrace:

[    7.254561] wm8960 3-001a: Failed to issue reset
[    7.257313] wm8960: probe of 3-001a failed with error -110
[    7.258170] i2c i2c-3: IMX I2C adapter registered
[    7.265584] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available
[    7.280312] stmp_reset_block((ptrval)): module reset timeout
[    7.280573] mxs-dma: probe of 33000000.dma-controller failed with error -110
[    7.309572] 8<--- cut here ---
[    7.309785] Unhandled fault: page domain fault (0x01b) at 0x00001eba
[    7.309916] [00001eba] *pgd=00000000
[    7.310327] Internal error: : 1b [#1] SMP ARM
[    7.310504] Modules linked in:
[    7.310701] CPU: 0 PID: 29 Comm: kworker/u4:2 Tainted: G                 N 6.4.0-rc5-next-20230605 #1
[    7.310868] Hardware name: Freescale i.MX7 Dual (Device Tree)
[    7.311058] Workqueue: events_unbound deferred_probe_work_func
[    7.311482] PC is at ads7846_probe+0x9f0/0xfa0
[    7.311576] LR is at _raw_spin_unlock_irqrestore+0x50/0x64
[    7.311659] pc : [<c0cf2ab0>]    lr : [<c1128bf4>]    psr: a0000013
[    7.311742] sp : d0949bf0  ip : 00000001  fp : 00000000
[    7.311814] r10: c1b96954  r9 : cbdcd208  r8 : c499aec0
[    7.311889] r7 : c4b64400  r6 : c4b4d040  r5 : c4b64400  r4 : 00001ea6
[    7.311978] r3 : 00000000  r2 : c41dd000  r1 : 0a3d1000  r0 : c499aec0
[    7.312102] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[    7.312211] Control: 10c5387d  Table: 848c406a  DAC: 00000051
[    7.312305] Register r0 information: slab kmalloc-128 start c499ae80 pointer offset 64 size 128
[    7.312688] Register r1 information: non-paged memory
[    7.312832] Register r2 information: slab kmalloc-4k start c41dd000 pointer offset 0 size 4096
[    7.312973] Register r3 information: NULL pointer
[    7.313045] Register r4 information: non-paged memory
[    7.313116] Register r5 information: slab kmalloc-1k start c4b64400 pointer offset 0 size 1024
[    7.313247] Register r6 information: slab kmalloc-4k start c4b4d000 pointer offset 64 size 4096
[    7.313379] Register r7 information: slab kmalloc-1k start c4b64400 pointer offset 0 size 1024
[    7.313509] Register r8 information: slab kmalloc-128 start c499ae80 pointer offset 64 size 128
[    7.313640] Register r9 information: non-slab/vmalloc memory
[    7.313751] Register r10 information: non-slab/vmalloc memory
[    7.313836] Register r11 information: NULL pointer
[    7.313908] Register r12 information: non-paged memory
[    7.313992] Process kworker/u4:2 (pid: 29, stack limit = 0x(ptrval))
[    7.314107] Stack: (0xd0949bf0 to 0xd094a000)
[    7.314223] 9be0:                                     00000000 c4b64400 c4b64400 c1bc0a9c
[    7.314337] 9c00: c4b69000 c234b3f4 cbdcd208 c0e01338 ffffffff 00000000 00000000 00000000
[    7.314441] 9c20: 00000000 00000000 00000000 d0b2c62c 00000000 00000000 c4b64400 c1bc0a9c
[    7.314543] 9c40: 00000000 c234b3f4 cbdcd208 c1b96954 00000000 c0b73a98 c4b64400 00000000
[    7.314650] 9c60: c1bc0aac c0a4a434 c4b64400 c1bc0aac c4b64400 00000016 c234b3f4 c0a4a6d4
[    7.314754] 9c80: c134db68 3fffffff c234b44c c1bc0aac c4b64400 00000016 c234b3f4 c0a4a81c
[    7.314856] 9ca0: 00000001 c1bc0aac d0949cfc c4b64400 c234b3f4 c0a4a948 00000000 c41ea600
[    7.314957] 9cc0: d0949cfc c0a4a8b4 c234b3f4 c0a4849c c4b688bc c41ea6e4 c461d3d8 d0b2c62c
[    7.315059] 9ce0: c4b688bc c4b64400 00000001 c4b64444 c41ea600 c0a4aca8 c413ac88 c4b64400
[    7.315161] 9d00: 00000001 d0b2c62c c4b64400 c4b64400 00000000 c0a49590 c4b64400 00000000
[    7.315263] 9d20: 00000000 c4b68800 c234b3f4 c0a47164 c41dd000 c4b64400 00000000 c422f810
[    7.315365] 9d40: c422f810 d0b2c62c 00000000 c4b64400 c4b68800 c422f810 cbdcd260 c170bd30
[    7.315471] 9d60: c170bd24 c0b77d4c c4b68b1c c4b64400 c4b64400 00000000 cbdcd260 c0b77e34
[    7.315574] 9d80: c4b68800 cbdcd1fc c4b64400 c0b786e4 00000000 c1b7dac4 c4020000 c422f810
[    7.315675] 9da0: d0949d9c 000f4240 00000000 d0b2c62c 00000000 c4b68800 ffffffed c422f800
[    7.315777] 9dc0: c422f810 c4b68d40 c4b68800 00000000 c4020000 c0b8102c 00000000 c423c080
[    7.315878] 9de0: c4b68d40 00000000 c423c040 00000000 00000000 d0b2c62c 00000000 c422f810
[    7.315980] 9e00: c1baff90 00000000 c1b96f6c 00000000 c1c20420 c0a4cd34 c422f810 00000000
[    7.316080] 9e20: c1baff90 00000000 c1b96f6c c0a4a434 c422f810 c1baff90 c422f810 00000016
[    7.316182] 9e40: c1b96f6c c0a4a6d4 c1330f38 3ffffffb c234b44c c1baff90 c422f810 00000016
[    7.316283] 9e60: c1b96f6c c0a4a81c 00000001 c1baff90 d0949ec4 c422f810 c1b96f6c c0a4a948
[    7.316384] 9e80: 00000000 c40dec00 d0949ec4 c0a4a8b4 c1b96f6c c0a4849c c422e0cc c40dece4
[    7.316486] 9ea0: c4603a58 d0b2c62c c422e0cc c422f810 00000001 c422f854 c40dec00 c0a4aca8
[    7.316587] 9ec0: c413ac88 c422f810 00000001 d0b2c62c c423a434 c422f810 c1b96e8c c0a49590
[    7.316689] 9ee0: c423a434 c422f810 c1b96e8c c1b96e90 c1b96f6c c0a4a1d8 c1b96f00 c429f680
[    7.316791] 9f00: c400ce00 c4020000 c1a093d4 c400ce15 c1c20420 c0149e40 00000001 00000000
[    7.316893] 9f20: c0149d78 c4020000 c1b96f00 c209b3cc 00000000 c16e587c 00000000 d0b2c62c
[    7.316996] 9f40: c4020000 c429f680 c4020000 c429f6ac c4020040 c1a05d40 00000088 c41dd000
[    7.317099] 9f60: c4020000 c014a294 00000000 c429c780 c41dd000 c014a268 c429f680 c429f780
[    7.317201] 9f80: d0889ec4 00000000 00000000 c0154358 c429c780 c015425c 00000000 00000000
[    7.317303] 9fa0: 00000000 00000000 00000000 c010012c 00000000 00000000 00000000 00000000
[    7.317404] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    7.317506] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[    7.317682]  ads7846_probe from spi_probe+0x84/0xa8
[    7.317785]  spi_probe from really_probe+0xc4/0x2e0
[    7.317862]  really_probe from __driver_probe_device+0x84/0x1a0
[    7.317948]  __driver_probe_device from driver_probe_device+0x2c/0xc4
[    7.318037]  driver_probe_device from __device_attach_driver+0x94/0xc4
[    7.318125]  __device_attach_driver from bus_for_each_drv+0x84/0xdc
[    7.318214]  bus_for_each_drv from __device_attach+0xac/0x1d8
[    7.318296]  __device_attach from bus_probe_device+0x8c/0x90
[    7.318377]  bus_probe_device from device_add+0x560/0x774
[    7.318455]  device_add from __spi_add_device+0x58/0xe8
[    7.318533]  __spi_add_device from spi_add_device+0x58/0x8c
[    7.318613]  spi_add_device from spi_register_controller+0x784/0xbfc
[    7.318705]  spi_register_controller from spi_imx_probe+0x390/0x604
[    7.318795]  spi_imx_probe from platform_probe+0x58/0xbc
[    7.318872]  platform_probe from really_probe+0xc4/0x2e0
[    7.318947]  really_probe from __driver_probe_device+0x84/0x1a0
[    7.319029]  __driver_probe_device from driver_probe_device+0x2c/0xc4
[    7.319116]  driver_probe_device from __device_attach_driver+0x94/0xc4
[    7.319205]  __device_attach_driver from bus_for_each_drv+0x84/0xdc
[    7.319291]  bus_for_each_drv from __device_attach+0xac/0x1d8
[    7.319372]  __device_attach from bus_probe_device+0x8c/0x90
[    7.319454]  bus_probe_device from deferred_probe_work_func+0x8c/0xc0
[    7.319542]  deferred_probe_work_func from process_one_work+0x288/0x6b0
[    7.319635]  process_one_work from worker_thread+0x2c/0x480
[    7.319715]  worker_thread from kthread+0xfc/0x120
[    7.319788]  kthread from ret_from_fork+0x14/0x28

Bisect result:

# bad: [9ca10bfb8aa8fbf19ee22e702c8cf9b66ea73a54] Add linux-next specific files for 20230605
# good: [9561de3a55bed6bdd44a12820ba81ec416e705a7] Linux 6.4-rc5
git bisect start 'HEAD' 'v6.4-rc5'
# bad: [8e3a5ba24fdd336ddd8096257588f5ad5a934ffa] Merge branch 'drm-next' of git://git.freedesktop.org/git/drm/drm.git
git bisect bad 8e3a5ba24fdd336ddd8096257588f5ad5a934ffa
# bad: [376395b3a956c450a8f52a02acf0e9d7cbb77ac9] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git
git bisect bad 376395b3a956c450a8f52a02acf0e9d7cbb77ac9
# bad: [332f472c4163f902f588816c8b28a00a461ed325] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git
git bisect bad 332f472c4163f902f588816c8b28a00a461ed325
# good: [159f9e8420bb86f7b154acec72d93528a3f9b0f7] Merge branch 'mm-everything' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good 159f9e8420bb86f7b154acec72d93528a3f9b0f7
# good: [dc7fd8b3a8838ce715fed6c58a90187380084582] Merge branch 'for-next/core' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
git bisect good dc7fd8b3a8838ce715fed6c58a90187380084582
# bad: [de6a558f810c3de395eaa58bce1063e24d8a78b8] Merge branch 'at91-next' of git://git.kernel.org/pub/scm/linux/kernel/git/at91/linux.git
git bisect bad de6a558f810c3de395eaa58bce1063e24d8a78b8
# good: [3ea093976845afd968dfc9cf36eb8d5ba63b7c0e] Merge branch 'soc/dt' into for-next
git bisect good 3ea093976845afd968dfc9cf36eb8d5ba63b7c0e
# bad: [b26078a2b9df1dfd725a0e171d2b0ad0259cfef1] Merge branch 'arm/fixes' into for-next
git bisect bad b26078a2b9df1dfd725a0e171d2b0ad0259cfef1
# bad: [8e0285ab95a9baf374f2c13eb152221c8ecb3f28] ARM/musb: omap2: Remove global GPIO numbers from TUSB6010
git bisect bad 8e0285ab95a9baf374f2c13eb152221c8ecb3f28
# bad: [e519f0bb64efc2c9c8b67bb2d114dda458bdc34d] ARM/mmc: Convert old mmci-omap to GPIO descriptors
git bisect bad e519f0bb64efc2c9c8b67bb2d114dda458bdc34d
# good: [4c40db6249ff1da335b276bdd6c3c3462efbc2ab] ARM: omap1: Remove reliance on GPIO numbers from PalmTE
git bisect good 4c40db6249ff1da335b276bdd6c3c3462efbc2ab
# bad: [767d83361aaa6a1ecb4d5b89eeb38a267239917a] Input: ads7846 - Convert to use software nodes
git bisect bad 767d83361aaa6a1ecb4d5b89eeb38a267239917a
# good: [480c82daa3e41873421dc2c9e2918ad7e21d7a0b] ARM: omap1: Remove reliance on GPIO numbers from SX1
git bisect good 480c82daa3e41873421dc2c9e2918ad7e21d7a0b
# first bad commit: [767d83361aaa6a1ecb4d5b89eeb38a267239917a] Input: ads7846 - Convert to use software nodes
Linus Walleij June 6, 2023, 7:15 p.m. UTC | #8
On Sun, Jun 4, 2023 at 5:44 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:

> > +     /* Asserts RESET */
> > +     gpiod_set_value(md->reset, 1);
>
> Hi,
>
> should this also be done in the probe if mipid_detect() fails?

It's a nice bonus but surely not urgent or necessary.

> If yes, please also look at [1], that I've just sent, which introduces
> an error handling path in the probe.

Looks good to me.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index a501a473ffd6..8a1f2572deea 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -8,15 +8,16 @@ 
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/input.h>
 #include <linux/omapfb.h>
 
 #include <linux/spi/spi.h>
-#include <linux/spi/ads7846.h>
 #include <linux/workqueue.h>
 #include <linux/delay.h>
 
@@ -35,6 +36,25 @@ 
 #include "clock.h"
 #include "mmc.h"
 
+static const struct software_node nokia770_mpuio_gpiochip_node = {
+	.name = "mpuio",
+};
+
+static const struct software_node nokia770_gpiochip1_node = {
+	.name = "gpio-0-15",
+};
+
+static const struct software_node nokia770_gpiochip2_node = {
+	.name = "gpio-16-31",
+};
+
+static const struct software_node *nokia770_gpiochip_nodes[] = {
+	&nokia770_mpuio_gpiochip_node,
+	&nokia770_gpiochip1_node,
+	&nokia770_gpiochip2_node,
+	NULL
+};
+
 #define ADS7846_PENDOWN_GPIO	15
 
 static const unsigned int nokia770_keymap[] = {
@@ -85,40 +105,46 @@  static struct platform_device *nokia770_devices[] __initdata = {
 	&nokia770_kp_device,
 };
 
-static void mipid_shutdown(struct mipid_platform_data *pdata)
-{
-	if (pdata->nreset_gpio != -1) {
-		printk(KERN_INFO "shutdown LCD\n");
-		gpio_set_value(pdata->nreset_gpio, 0);
-		msleep(120);
-	}
-}
-
-static struct mipid_platform_data nokia770_mipid_platform_data = {
-	.shutdown = mipid_shutdown,
-};
+static struct mipid_platform_data nokia770_mipid_platform_data = { };
 
 static const struct omap_lcd_config nokia770_lcd_config __initconst = {
 	.ctrl_name	= "hwa742",
 };
 
+static const struct property_entry nokia770_mipid_props[] = {
+	PROPERTY_ENTRY_GPIO("reset-gpios", &nokia770_gpiochip1_node,
+			    13, GPIO_ACTIVE_LOW),
+	{ }
+};
+
+static const struct software_node nokia770_mipid_swnode = {
+	.name = "lcd_mipid",
+	.properties = nokia770_mipid_props,
+};
+
 static void __init mipid_dev_init(void)
 {
-	nokia770_mipid_platform_data.nreset_gpio = 13;
 	nokia770_mipid_platform_data.data_lines = 16;
 
 	omapfb_set_lcd_config(&nokia770_lcd_config);
 }
 
-static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = {
-	.x_max		= 0x0fff,
-	.y_max		= 0x0fff,
-	.x_plate_ohms	= 180,
-	.pressure_max	= 255,
-	.debounce_max	= 10,
-	.debounce_tol	= 3,
-	.debounce_rep	= 1,
-	.gpio_pendown	= ADS7846_PENDOWN_GPIO,
+static const struct property_entry nokia770_ads7846_props[] = {
+	PROPERTY_ENTRY_U32("touchscreen-size-x", 4096),
+	PROPERTY_ENTRY_U32("touchscreen-size-y", 4096),
+	PROPERTY_ENTRY_U32("touchscreen-max-pressure", 256),
+	PROPERTY_ENTRY_U32("touchscreen-average-samples", 10),
+	PROPERTY_ENTRY_U16("ti,x-plate-ohms", 180),
+	PROPERTY_ENTRY_U16("ti,debounce-tol", 3),
+	PROPERTY_ENTRY_U16("ti,debounce-rep", 1),
+	PROPERTY_ENTRY_GPIO("pendown-gpios", &nokia770_gpiochip1_node,
+			    ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW),
+	{ }
+};
+
+static const struct software_node nokia770_ads7846_swnode = {
+	.name = "ads7846",
+	.properties = nokia770_ads7846_props,
 };
 
 static struct spi_board_info nokia770_spi_board_info[] __initdata = {
@@ -128,13 +154,14 @@  static struct spi_board_info nokia770_spi_board_info[] __initdata = {
 		.chip_select    = 3,
 		.max_speed_hz   = 12000000,
 		.platform_data	= &nokia770_mipid_platform_data,
+		.swnode         = &nokia770_mipid_swnode,
 	},
 	[1] = {
 		.modalias       = "ads7846",
 		.bus_num        = 2,
 		.chip_select    = 0,
 		.max_speed_hz   = 2500000,
-		.platform_data	= &nokia770_ads7846_platform_data,
+		.swnode         = &nokia770_ads7846_swnode,
 	},
 };
 
@@ -212,14 +239,16 @@  static inline void nokia770_mmc_init(void)
 #endif
 
 #if IS_ENABLED(CONFIG_I2C_CBUS_GPIO)
-static struct gpiod_lookup_table nokia770_cbus_gpio_table = {
-	.dev_id = "i2c-cbus-gpio.2",
-	.table = {
-		GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */
-		GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */
-		GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */
-		{ },
-	},
+
+static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 9, 0),
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 10, 0),
+	SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_swnode, 11, 0),
+};
+
+static const struct property_entry nokia770_ads7846_props[] = {
+	PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
+	{ }
 };
 
 static struct platform_device nokia770_cbus_device = {
@@ -253,7 +282,8 @@  static void __init nokia770_cbus_init(void)
 	nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
 	i2c_register_board_info(2, nokia770_i2c_board_info_2,
 				ARRAY_SIZE(nokia770_i2c_board_info_2));
-	gpiod_add_lookup_table(&nokia770_cbus_gpio_table);
+	device_create_managed_software_node(&nokia770_cbus_device.dev,
+					    nokia770_cbus_props, NULL);
 	platform_device_register(&nokia770_cbus_device);
 }
 #else /* CONFIG_I2C_CBUS_GPIO */
@@ -273,8 +303,8 @@  static void __init omap_nokia770_init(void)
 	/* Unmask SleepX signal */
 	omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
 
+	software_node_register_node_group(nokia770_gpiochip_nodes);
 	platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
-	nokia770_spi_board_info[1].irq = gpio_to_irq(15);
 	spi_register_board_info(nokia770_spi_board_info,
 				ARRAY_SIZE(nokia770_spi_board_info));
 	omap_serial_init();
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 4325bdc2b9ff..28e376e06fdc 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -506,10 +506,18 @@  static struct ads7846_platform_data spitz_ads7846_info = {
 	.x_plate_ohms		= 419,
 	.y_plate_ohms		= 486,
 	.pressure_max		= 1024,
-	.gpio_pendown		= SPITZ_GPIO_TP_INT,
 	.wait_for_sync		= spitz_ads7846_wait_for_hsync,
 };
 
+static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
+	.dev_id = "spi2.0",
+	.table = {
+		GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
+			    "pendown", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static void spitz_bl_kick_battery(void)
 {
 	void (*kick_batt)(void);
@@ -594,6 +602,7 @@  static void __init spitz_spi_init(void)
 	else
 		gpiod_add_lookup_table(&spitz_lcdcon_gpio_table);
 
+	gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
 	gpiod_add_lookup_table(&spitz_spi_gpio_table);
 	pxa2xx_set_spi_info(2, &spitz_spi_info);
 	spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c
index 2c52ee27b4f2..79d66faa8482 100644
--- a/arch/mips/alchemy/devboards/db1000.c
+++ b/arch/mips/alchemy/devboards/db1000.c
@@ -381,13 +381,21 @@  static struct platform_device db1100_mmc1_dev = {
 static struct ads7846_platform_data db1100_touch_pd = {
 	.model		= 7846,
 	.vref_mv	= 3300,
-	.gpio_pendown	= 21,
 };
 
 static struct spi_gpio_platform_data db1100_spictl_pd = {
 	.num_chipselect = 1,
 };
 
+static struct gpiod_lookup_table db1100_touch_gpio_table = {
+	.dev_id = "spi0.0",
+	.table = {
+		GPIO_LOOKUP("alchemy-gpio2", 21,
+			    "pendown", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static struct spi_board_info db1100_spi_info[] __initdata = {
 	[0] = {
 		.modalias	 = "ads7846",
@@ -474,6 +482,7 @@  int __init db1000_dev_setup(void)
 		pfc |= (1 << 0);	/* SSI0 pins as GPIOs */
 		alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
 
+		gpiod_add_lookup_table(&db1100_touch_gpio_table);
 		spi_register_board_info(db1100_spi_info,
 					ARRAY_SIZE(db1100_spi_info));
 
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index bb1058b1e7fd..40eb27f1b23f 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -24,11 +24,8 @@ 
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/pm.h>
-#include <linux/of.h>
-#include <linux/of_gpio.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 #include <linux/gpio/consumer.h>
-#include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/regulator/consumer.h>
@@ -140,7 +137,7 @@  struct ads7846 {
 	int			(*filter)(void *data, int data_idx, int *val);
 	void			*filter_data;
 	int			(*get_pendown_state)(void);
-	int			gpio_pendown;
+	struct gpio_desc	*gpio_pendown;
 
 	void			(*wait_for_sync)(void);
 };
@@ -223,7 +220,7 @@  static int get_pendown_state(struct ads7846 *ts)
 	if (ts->get_pendown_state)
 		return ts->get_pendown_state();
 
-	return !gpio_get_value(ts->gpio_pendown);
+	return gpiod_get_value(ts->gpio_pendown);
 }
 
 static void ads7846_report_pen_up(struct ads7846 *ts)
@@ -989,8 +986,6 @@  static int ads7846_setup_pendown(struct spi_device *spi,
 				 struct ads7846 *ts,
 				 const struct ads7846_platform_data *pdata)
 {
-	int err;
-
 	/*
 	 * REVISIT when the irq can be triggered active-low, or if for some
 	 * reason the touchscreen isn't hooked up, we don't need to access
@@ -999,25 +994,15 @@  static int ads7846_setup_pendown(struct spi_device *spi,
 
 	if (pdata->get_pendown_state) {
 		ts->get_pendown_state = pdata->get_pendown_state;
-	} else if (gpio_is_valid(pdata->gpio_pendown)) {
-
-		err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown,
-					    GPIOF_IN, "ads7846_pendown");
-		if (err) {
-			dev_err(&spi->dev,
-				"failed to request/setup pendown GPIO%d: %d\n",
-				pdata->gpio_pendown, err);
-			return err;
+	} else {
+		ts->gpio_pendown = gpiod_get(&spi->dev, "pendown", GPIOD_IN);
+		if (IS_ERR(ts->gpio_pendown)) {
+			dev_err(&spi->dev, "failed to request pendown GPIO\n");
+			return PTR_ERR(ts->gpio_pendown);
 		}
-
-		ts->gpio_pendown = pdata->gpio_pendown;
-
 		if (pdata->gpio_pendown_debounce)
-			gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown),
+			gpiod_set_debounce(ts->gpio_pendown,
 					   pdata->gpio_pendown_debounce);
-	} else {
-		dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
-		return -EINVAL;
 	}
 
 	return 0;
@@ -1119,7 +1104,6 @@  static int ads7846_setup_spi_msg(struct ads7846 *ts,
 	return 0;
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id ads7846_dt_ids[] = {
 	{ .compatible = "ti,tsc2046",	.data = (void *) 7846 },
 	{ .compatible = "ti,ads7843",	.data = (void *) 7843 },
@@ -1130,20 +1114,14 @@  static const struct of_device_id ads7846_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, ads7846_dt_ids);
 
-static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
+static const struct ads7846_platform_data *ads7846_get_props(struct device *dev)
 {
 	struct ads7846_platform_data *pdata;
-	struct device_node *node = dev->of_node;
-	const struct of_device_id *match;
+	const struct platform_device_id *pdev_id;
 	u32 value;
 
-	if (!node) {
-		dev_err(dev, "Device does not have associated DT data\n");
-		return ERR_PTR(-EINVAL);
-	}
-
-	match = of_match_device(ads7846_dt_ids, dev);
-	if (!match) {
+	pdev_id = device_get_match_data(dev);
+	if (!pdev_id) {
 		dev_err(dev, "Unknown device model\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -1152,60 +1130,51 @@  static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
 	if (!pdata)
 		return ERR_PTR(-ENOMEM);
 
-	pdata->model = (unsigned long)match->data;
+	pdata->model = (unsigned long)pdev_id->driver_data;
 
-	of_property_read_u16(node, "ti,vref-delay-usecs",
-			     &pdata->vref_delay_usecs);
-	of_property_read_u16(node, "ti,vref-mv", &pdata->vref_mv);
-	pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on");
+	device_property_read_u16(dev, "ti,vref-delay-usecs",
+				 &pdata->vref_delay_usecs);
+	device_property_read_u16(dev, "ti,vref-mv", &pdata->vref_mv);
+	pdata->keep_vref_on = device_property_read_bool(dev, "ti,keep-vref-on");
 
-	pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy");
+	pdata->swap_xy = device_property_read_bool(dev, "ti,swap-xy");
 
-	of_property_read_u16(node, "ti,settle-delay-usec",
-			     &pdata->settle_delay_usecs);
-	of_property_read_u16(node, "ti,penirq-recheck-delay-usecs",
-			     &pdata->penirq_recheck_delay_usecs);
+	device_property_read_u16(dev, "ti,settle-delay-usec",
+				 &pdata->settle_delay_usecs);
+	device_property_read_u16(dev, "ti,penirq-recheck-delay-usecs",
+				 &pdata->penirq_recheck_delay_usecs);
 
-	of_property_read_u16(node, "ti,x-plate-ohms", &pdata->x_plate_ohms);
-	of_property_read_u16(node, "ti,y-plate-ohms", &pdata->y_plate_ohms);
+	device_property_read_u16(dev, "ti,x-plate-ohms", &pdata->x_plate_ohms);
+	device_property_read_u16(dev, "ti,y-plate-ohms", &pdata->y_plate_ohms);
 
-	of_property_read_u16(node, "ti,x-min", &pdata->x_min);
-	of_property_read_u16(node, "ti,y-min", &pdata->y_min);
-	of_property_read_u16(node, "ti,x-max", &pdata->x_max);
-	of_property_read_u16(node, "ti,y-max", &pdata->y_max);
+	device_property_read_u16(dev, "ti,x-min", &pdata->x_min);
+	device_property_read_u16(dev, "ti,y-min", &pdata->y_min);
+	device_property_read_u16(dev, "ti,x-max", &pdata->x_max);
+	device_property_read_u16(dev, "ti,y-max", &pdata->y_max);
 
 	/*
 	 * touchscreen-max-pressure gets parsed during
 	 * touchscreen_parse_properties()
 	 */
-	of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min);
-	if (!of_property_read_u32(node, "touchscreen-min-pressure", &value))
+	device_property_read_u16(dev, "ti,pressure-min", &pdata->pressure_min);
+	if (!device_property_read_u32(dev, "touchscreen-min-pressure", &value))
 		pdata->pressure_min = (u16) value;
-	of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max);
+	device_property_read_u16(dev, "ti,pressure-max", &pdata->pressure_max);
 
-	of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max);
-	if (!of_property_read_u32(node, "touchscreen-average-samples", &value))
+	device_property_read_u16(dev, "ti,debounce-max", &pdata->debounce_max);
+	if (!device_property_read_u32(dev, "touchscreen-average-samples", &value))
 		pdata->debounce_max = (u16) value;
-	of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol);
-	of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep);
+	device_property_read_u16(dev, "ti,debounce-tol", &pdata->debounce_tol);
+	device_property_read_u16(dev, "ti,debounce-rep", &pdata->debounce_rep);
 
-	of_property_read_u32(node, "ti,pendown-gpio-debounce",
+	device_property_read_u32(dev, "ti,pendown-gpio-debounce",
 			     &pdata->gpio_pendown_debounce);
 
-	pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
-			of_property_read_bool(node, "linux,wakeup");
-
-	pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
+	pdata->wakeup = device_property_read_bool(dev, "wakeup-source") ||
+			device_property_read_bool(dev, "linux,wakeup");
 
 	return pdata;
 }
-#else
-static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
-{
-	dev_err(dev, "no platform data defined\n");
-	return ERR_PTR(-EINVAL);
-}
-#endif
 
 static void ads7846_regulator_disable(void *regulator)
 {
@@ -1269,7 +1238,7 @@  static int ads7846_probe(struct spi_device *spi)
 
 	pdata = dev_get_platdata(dev);
 	if (!pdata) {
-		pdata = ads7846_probe_dt(dev);
+		pdata = ads7846_get_props(dev);
 		if (IS_ERR(pdata))
 			return PTR_ERR(pdata);
 	}
@@ -1426,7 +1395,7 @@  static struct spi_driver ads7846_driver = {
 	.driver = {
 		.name	= "ads7846",
 		.pm	= pm_sleep_ptr(&ads7846_pm),
-		.of_match_table = of_match_ptr(ads7846_dt_ids),
+		.of_match_table = ads7846_dt_ids,
 	},
 	.probe		= ads7846_probe,
 	.remove		= ads7846_remove,
diff --git a/drivers/video/fbdev/omap/lcd_mipid.c b/drivers/video/fbdev/omap/lcd_mipid.c
index 03cff39d392d..e4a7f0b824ff 100644
--- a/drivers/video/fbdev/omap/lcd_mipid.c
+++ b/drivers/video/fbdev/omap/lcd_mipid.c
@@ -7,6 +7,7 @@ 
  */
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
@@ -41,6 +42,7 @@  struct mipid_device {
 						   when we can issue the
 						   next sleep in/out command */
 	unsigned long	hw_guard_wait;		/* max guard time in jiffies */
+	struct gpio_desc	*reset;
 
 	struct omapfb_device	*fbdev;
 	struct spi_device	*spi;
@@ -556,6 +558,12 @@  static int mipid_spi_probe(struct spi_device *spi)
 		return -ENOMEM;
 	}
 
+	/* This will de-assert RESET if active */
+	md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(md->reset))
+		return dev_err_probe(&spi->dev, PTR_ERR(md->reset),
+				     "no reset GPIO line\n");
+
 	spi->mode = SPI_MODE_0;
 	md->spi = spi;
 	dev_set_drvdata(&spi->dev, md);
@@ -574,6 +582,8 @@  static void mipid_spi_remove(struct spi_device *spi)
 {
 	struct mipid_device *md = dev_get_drvdata(&spi->dev);
 
+	/* Asserts RESET */
+	gpiod_set_value(md->reset, 1);
 	mipid_disable(&md->panel);
 	kfree(md);
 }
diff --git a/include/linux/platform_data/lcd-mipid.h b/include/linux/platform_data/lcd-mipid.h
index 63f05eb23827..4927cfc5158c 100644
--- a/include/linux/platform_data/lcd-mipid.h
+++ b/include/linux/platform_data/lcd-mipid.h
@@ -15,10 +15,8 @@  enum mipid_test_result {
 #ifdef __KERNEL__
 
 struct mipid_platform_data {
-	int	nreset_gpio;
 	int	data_lines;
 
-	void	(*shutdown)(struct mipid_platform_data *pdata);
 	void	(*set_bklight_level)(struct mipid_platform_data *pdata,
 				     int level);
 	int	(*get_bklight_level)(struct mipid_platform_data *pdata);
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index d424c1aadf38..a04c1c34c344 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -35,8 +35,6 @@  struct ads7846_platform_data {
 	u16	debounce_tol;		/* tolerance used for filtering */
 	u16	debounce_rep;		/* additional consecutive good readings
 					 * required after the first two */
-	int	gpio_pendown;		/* the GPIO used to decide the pendown
-					 * state if get_pendown_state == NULL */
 	int	gpio_pendown_debounce;	/* platform specific debounce time for
 					 * the gpio_pendown */
 	int	(*get_pendown_state)(void);