From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61018C64E7B for ; Tue, 1 Dec 2020 16:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA25F206B7 for ; Tue, 1 Dec 2020 16:50:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=goldelico.com header.i=@goldelico.com header.b="OaswZ6gS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728135AbgLAQuF (ORCPT ); Tue, 1 Dec 2020 11:50:05 -0500 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.51]:32891 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387395AbgLAQuE (ORCPT ); Tue, 1 Dec 2020 11:50:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1606841231; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Cc:Date:In-Reply-To:From:Subject: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=i0/Gp1dKaGGObGUNczkbh0vey3aIfMJXXWm7ukUxAog=; b=OaswZ6gSzPj+gLIYGDZTGASWdGSehtxH103RxVTOFqiWsVu74b2COo5tFAFQT38Fvx zgf88ye0SkoyO7TUdXie4pDCcUvyUIIKapfw+XEALaBl9yR2/VkMXdwW5fVYGUO3fM3g XYFdhJVFUUi62gbfvAz75bqEAdn2NiM2Z8PDNB2nhuqAcrFO8yOCQPN6wCbD1zmYUNOx XLt0fzBXCDQ93UZVdQqmmNOHuRCVjbe5SMdwWCiRyHN00YYBz6wRD40BOBn2EaW53+Tt NgdmUJVLdd7i6ndUscXKxZmcdjAZq+Mg0J4q1t1J8WjdeWa/Z1AXlPsgcEOlE15MCk7W z0Fg== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj7wpz8NMGH/vrwDuo6A==" X-RZG-CLASS-ID: mo00 Received: from imac.fritz.box by smtp.strato.de (RZmta 47.3.4 DYNA|AUTH) with ESMTPSA id N02faawB1GkuVXK (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Tue, 1 Dec 2020 17:46:56 +0100 (CET) Subject: Re: [BUG] SPI broken for SPI based panel drivers Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=us-ascii From: "H. Nikolaus Schaller" In-Reply-To: Date: Tue, 1 Dec 2020 17:46:56 +0100 Cc: Linus Walleij , Mark Brown , kernel list , Laurent Pinchart , Discussions about the Letux Kernel Content-Transfer-Encoding: quoted-printable Message-Id: References: <2D7916FA-678F-4236-B478-C953CADF2FFA@goldelico.com> <4AC29229-9542-4E77-B993-217E29C7E209@goldelico.com> <20201201121620.GB5239@sirena.org.uk> <6283C16F-549C-4463-BC08-E2C1A1D78B2F@goldelico.com> To: Sven Van Asbroeck X-Mailer: Apple Mail (2.3124) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 01.12.2020 um 16:52 schrieb Sven Van Asbroeck = : >=20 > Nikolaus, >=20 > On Tue, Dec 1, 2020 at 9:38 AM H. Nikolaus Schaller = wrote: >>=20 >> Let's work on a fix for the fix now. >=20 > 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. >=20 > 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=20 root@letux:~#=20 That is after the panel driver did send the commands. >=20 > Also, apply the following patch, and tell me > a) does this dev_err() get called on your system, and yes. Many times.=20 > 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 =3D 00000003 [ 14.599212] panel-tpo-td028ttec1 spi4.0: gpiod disable [ 14.817871] panel-tpo-td028ttec1 spi4.0: spi->mode =3D 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) >=20 > 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.