Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1743384ybg; Sat, 19 Oct 2019 01:32:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6c5djl5262W7ThKnjI+CMIkKxcwXpoEs0WBLRQuZtWHbr3812y0/sxDzbZBLDZwgDt1s0 X-Received: by 2002:a05:6402:1511:: with SMTP id f17mr14015671edw.232.1571473978854; Sat, 19 Oct 2019 01:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473978; cv=none; d=google.com; s=arc-20160816; b=PjvQl2yoA43DabIz0aGQGIIyk0yqEcJA83hkkyKnOEyU+sHIstQoKCWOA6ub2WE158 6h5wOlTR+yb0Z+xcVfLJ1ctEPnHRz+uXcL4UunXJW0VZUbE0RYGagKBJj0V9euS4iuJy 2/4DYqK479HAMSJQ8PKPYjTl5pUe7XQzUUR5ilAuTBlZCoA67Tsv1Bdf0MQPPOHko1mD 0n6KgSLmIpMDX/skf2vBRxUOV711ylUCXPBHoxtPeK5hbMTRr9pXhDGSnJoRfK+25jU+ MZ971Lwg6+rg1n70rqeaLu3ICnyUZqBjmfY5HP5/xhFYC/lzubkI3BnTTBie6k9EPrCx t8og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FJNmBA//igWlJ+Rx0HV8T+459uh4eRTfE1opOsV+yYY=; b=v8FToolAOwjWhtey2b6x/NCNsk8LhfLx5ISPCikSHeOLxIiZAZoY4EDpCHghDKvz5q s3JwUhqmxdXbwvUEZG2r+TvSXrLh3QQ1Qo6ojWcXLPLBMwpo3ehshBQQlrNMLOC29trC WcUd23ZMZDcMq80utVO/CLIa3QmUbzDsihGl7aHsNjDaq3++fiPz9+PXXctaMUDm7n+e /jOpW6PUQRKFzRfVNbSpRH5MljLjHtmGqyZbKWedT+XsdqieAooaRzOvY49GhLMX7OKo Ib3jXmFJ7JRC+YsXEj3jVBIQRX651bZe2i3+QLhd+bkZaXpMewTZcZNPNimgAs03WnYZ CpMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck24si4803818ejb.400.2019.10.19.01.32.36; Sat, 19 Oct 2019 01:32:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408733AbfJRP3h (ORCPT + 99 others); Fri, 18 Oct 2019 11:29:37 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:48873 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393138AbfJRP3h (ORCPT ); Fri, 18 Oct 2019 11:29:37 -0400 Received: from localhost (aclermont-ferrand-651-1-259-53.w86-207.abo.wanadoo.fr [86.207.98.53]) (Authenticated sender: gregory.clement@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id A7A76200004; Fri, 18 Oct 2019 15:29:33 +0000 (UTC) From: Gregory CLEMENT To: Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , Gregory CLEMENT , stable@vger.kernel.org Subject: [PATCH] spi: Fix SPI_CS_HIGH setting when using native and GPIO CS Date: Fri, 18 Oct 2019 17:29:29 +0200 Message-Id: <20191018152929.3287-1-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When improving the CS GPIO support at core level, the SPI_CS_HIGH has been enabled for all the CS lines used for a given SPI controller. However, the SPI framework allows to have on the same controller native CS and GPIO CS. The native CS may not support the SPI_CS_HIGH, so they should not be setup automatically. With this patch the setting is done only for the CS that will use a GPIO as CS Fixes: f3186dd87669 ("spi: Optionally use GPIO descriptors for CS GPIOs") Cc: Signed-off-by: Gregory CLEMENT --- drivers/spi/spi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 5414a10afd65..1b68acc28c8f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1880,15 +1880,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, spi->mode |= SPI_3WIRE; if (of_property_read_bool(nc, "spi-lsb-first")) spi->mode |= SPI_LSB_FIRST; - - /* - * For descriptors associated with the device, polarity inversion is - * handled in the gpiolib, so all chip selects are "active high" in - * the logical sense, the gpiolib will invert the line if need be. - */ - if (ctlr->use_gpio_descriptors) - spi->mode |= SPI_CS_HIGH; - else if (of_property_read_bool(nc, "spi-cs-high")) + if (of_property_read_bool(nc, "spi-cs-high")) spi->mode |= SPI_CS_HIGH; /* Device DUAL/QUAD mode */ @@ -1952,6 +1944,14 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, } spi->chip_select = value; + /* + * For descriptors associated with the device, polarity inversion is + * handled in the gpiolib, so all gpio chip selects are "active high" + * in the logical sense, the gpiolib will invert the line if need be. + */ + if ((ctlr->use_gpio_descriptors) && ctlr->cs_gpiods[spi->chip_select]) + spi->mode |= SPI_CS_HIGH; + /* Device speed */ rc = of_property_read_u32(nc, "spi-max-frequency", &value); if (rc) { -- 2.23.0