Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp412573pxu; Tue, 1 Dec 2020 14:39:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSRq601CFOUuuv5RCQ2aqS/itkeIE8NKN5gJUsYD19NYP8QaaoEUTPwnlU/hW1astzKVEu X-Received: by 2002:a17:906:ae55:: with SMTP id lf21mr5345607ejb.101.1606862368219; Tue, 01 Dec 2020 14:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862368; cv=none; d=google.com; s=arc-20160816; b=emaKnqAWgQ9bT3Ye9z2B38E+RrX7FP/P39uJN0aPSbGnh+5/6moFOnv8n5qtRznsX4 xQdVfjKXYn31ttWpVdhqSHzqMX+5Yxy6Cbb+joo1xsu1tQK/Lt28tuZqgy0ivKgTox4r Ty/cwXWsNTHJbgMIDHONBF6ks6OHEERaKzTLGgp6dJv/gtsg/okyVfp3h8GzWfXlUBUj JvPlVfnolW6o/kPy2RviPc8FDiZwq6ADKe8ZbDXJOOmlqv/QrOQRw02dLO1HTOMcKaux zqlur3z2XDRy3qepvB9XGbziKq7FQEIHk5CRuO3+OvTyaZkCaXcnmaWq2rAYe1pVyc6e tbNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:mime-version :subject:dkim-signature; bh=i0/Gp1dKaGGObGUNczkbh0vey3aIfMJXXWm7ukUxAog=; b=GmkQ/xekzanqoH+I7BnwklwLvY4HUpFWVNmWOS/MkLUslEC44H3iJaiNSQ1UbBaS9J 8Cy6RMy9wWuFqV+xynL0XvJMnXduh+1XddiILd3fTO0qd7XdA6eTv4cyWDarMX7/q17o +6tyDRHKvObIdi1EEF5zY+nbFnpBGT4nS/HGjUW1KJdgapuwKsM9b54F0DRCFNXQNEB0 FdCgJnnmLNrB+pbNxUF9I7z30qkks1jah0UX4wIwuIrgaVyAyG0XPq8sV7wF/mjUnTq2 eRf9La7RqzRGO4alCs6IKeNvjOfddXDb0OzhXJA059DM0EvFUjgWL0taaUqgMB/fz9CU ROwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=OaswZ6gS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si752986ejj.159.2020.12.01.14.39.05; Tue, 01 Dec 2020 14:39:28 -0800 (PST) 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=@goldelico.com header.s=strato-dkim-0002 header.b=OaswZ6gS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727381AbgLAQuF (ORCPT + 99 others); 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.