linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "H. Nikolaus Schaller" <hns@goldelico.com>
To: Sven Van Asbroeck <thesven73@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Mark Brown <broonie@kernel.org>,
	kernel list <linux-kernel@vger.kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Discussions about the Letux Kernel 
	<letux-kernel@openphoenux.org>
Subject: Re: [BUG] SPI broken for SPI based panel drivers
Date: Tue, 1 Dec 2020 17:46:56 +0100	[thread overview]
Message-ID: <FF708A45-7325-49D5-B41E-7D54942F5E23@goldelico.com> (raw)
In-Reply-To: <CAGngYiVd6d2pb3eOd5ZiCvTBOzZK6+dudRUVWj8neBRK0S42Pg@mail.gmail.com>


> Am 01.12.2020 um 16:52 schrieb Sven Van Asbroeck <thesven73@gmail.com>:
> 
> Nikolaus,
> 
> On Tue, Dec 1, 2020 at 9:38 AM H. Nikolaus Schaller <hns@goldelico.com> wrote:
>> 
>> Let's work on a fix for the fix now.
> 
> I tested spi-gpio on my system, by converting a built-in or hardware spi,
> to a spi-gpio. Interestingly, the patch has the opposite effect on my system:
> before the patch, spi-gpio did not work, but after it's applied, it does work.
> 
> Can you tell me the idle status of your chip-select gpio in debugfs?
> # mount -t debugfs none /sys/kernel/debug
> # cat /sys/kernel/debug/gpio
> Look for something like this:
> gpiochip0: GPIOs 0-31, parent: platform/209c000.gpio, 209c000.gpio:
> gpio-17  (                    |spi5 CS0            ) out hi ACTIVE LOW

root@letux:~# mount -t debugfs none /sys/kernel/debug
root@letux:~# cat /sys/kernel/debug/gpio|fgrep spi
 gpio-179 (                    |spi4 CS0            ) out lo 
root@letux:~# 

That is after the panel driver did send the commands.

> 
> Also, apply the following patch, and tell me
> a) does this dev_err() get called on your system, and

yes. Many times. 

> b) what is the value when your chip is de-selected

root@letux:~# dmesg|fgrep td028
[   14.530456] panel-tpo-td028ttec1 spi4.0: spi->mode = 00000003
[   14.599212] panel-tpo-td028ttec1 spi4.0: gpiod disable
[   14.817871] panel-tpo-td028ttec1 spi4.0: spi->mode = 00000003
[   14.817871] panel-tpo-td028ttec1 spi4.0: gpiod enable

So it is disabled first and then enabled. Which appears to be the opposite
of what it should be.

BTW: I have added another dev_err to print the spi->mode and like
you describe it is (overwritten? by SPI_MODE_3.

I can check what value it has in the driver before it is set to SPI_MODE_3.

Maybe, there the spi-cs-high gets lost?

BR and thanks,
Nikolaus


> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 7e8804b02be9..b2f4cf5c9ffb 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -813,11 +813,12 @@ static void spi_set_cs(struct spi_device *spi,
> bool enable)
> 
>        if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio)) {
>                if (!(spi->mode & SPI_NO_CS)) {
> -                       if (spi->cs_gpiod)
> +                       if (spi->cs_gpiod) {
> +                               dev_err(&spi->dev, "gpiod %s", enable1
> ? "enable" : "disable");
>                                /* polarity handled by gpiolib */
>                                gpiod_set_value_cansleep(spi->cs_gpiod,
>                                                         enable1);
> -                       else
> +                       } else
>                                /*
>                                 * invert the enable line, as active low is
>                                 * default for SPI.


  reply	other threads:[~2020-12-01 16:50 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 19:03 [BUG] SPI broken for SPI based panel drivers H. Nikolaus Schaller
2020-11-30 20:13 ` Sven Van Asbroeck
2020-11-30 20:22   ` Sven Van Asbroeck
2020-12-01  8:59   ` H. Nikolaus Schaller
2020-12-01 12:16     ` Mark Brown
2020-12-01 14:05       ` H. Nikolaus Schaller
2020-12-01 14:20         ` Linus Walleij
2020-12-01 14:34           ` Sven Van Asbroeck
2020-12-01 14:35           ` H. Nikolaus Schaller
2020-12-01 15:52             ` Sven Van Asbroeck
2020-12-01 16:46               ` H. Nikolaus Schaller [this message]
2020-12-01 16:10             ` Sven Van Asbroeck
2020-12-01 16:39               ` H. Nikolaus Schaller
2020-12-01 16:53                 ` Sven Van Asbroeck
2020-12-01 17:10                   ` H. Nikolaus Schaller
2020-12-01 18:43                     ` Sven Van Asbroeck
2020-12-02 12:19                       ` Mark Brown
2020-12-04 10:08                       ` H. Nikolaus Schaller
2020-12-04 13:46                         ` Sven Van Asbroeck
2020-12-04 16:49                           ` H. Nikolaus Schaller
2020-12-04 19:19                             ` Sven Van Asbroeck
2020-12-04 21:31                               ` H. Nikolaus Schaller
2020-12-05  0:25                             ` Linus Walleij
2020-12-05  7:04                               ` H. Nikolaus Schaller
2020-12-09  8:04                                 ` Andreas Kemnade
2020-12-09  8:40                                   ` H. Nikolaus Schaller
2020-12-09  8:38                                 ` Linus Walleij
2020-12-09  8:45                                   ` H. Nikolaus Schaller
2020-12-01 22:51                     ` Linus Walleij
2020-12-01 16:44               ` [Letux-kernel] " Andreas Kemnade
2020-12-01 16:51                 ` H. Nikolaus Schaller
2020-12-01 16:52                 ` H. Nikolaus Schaller
2020-12-01 16:55                 ` Sven Van Asbroeck
2020-12-01 16:20           ` Mark Brown
2020-12-01 16:41             ` H. Nikolaus Schaller
2020-12-01 17:11               ` Mark Brown
2020-12-01 12:41     ` Sven Van Asbroeck
2020-12-01 13:32       ` H. Nikolaus Schaller
2020-12-01 14:08         ` Sven Van Asbroeck
2020-12-01 15:33           ` Mark Brown
2020-12-05 20:57   ` Pavel Machek
2020-12-07 13:43     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FF708A45-7325-49D5-B41E-7D54942F5E23@goldelico.com \
    --to=hns@goldelico.com \
    --cc=broonie@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=letux-kernel@openphoenux.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thesven73@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).