From patchwork Tue Jun 29 19:22:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Sneddon X-Patchwork-Id: 12350661 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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 14B2EC11F69 for ; Tue, 29 Jun 2021 19:24:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6C6861DE3 for ; Tue, 29 Jun 2021 19:24:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6C6861DE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DIJcrbou3S1NZwQXzaDo3/lSrM0mlQB8X3XMX04L9CQ=; b=BmRbJsTSFeppon +HWOfDkAue/iS5KgIOfrObmu8vO5c+465IzKI6eAA5TIkVygQ7G8kZ874hKBQBj76u4qIrFm94SG5 qTnUk6Afi4Nynek+yecQdf9IudVRYWuFIil06aaF3IOI+rrG7ICTQJkh/pOxcgV03PsYuwlunLHFd IeUoMFAp1DhqSahOA28EudG0pBjp3eyJDzj4M+EBm07NpDpJSJnYodJuhwyx8TFALqBHw41gySDj8 ITcWgBtCdRhz7hKMsHoJoD9MqkclsI+wUElTGrtipOpqbfA2UEUfw9H9QXtpICcvF6XP0InU1uwEx M4TceP686pbxcEQ32Kfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyJJV-00BvoK-Ni; Tue, 29 Jun 2021 19:22:29 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyJJS-00Bvo1-5C for linux-arm-kernel@lists.infradead.org; Tue, 29 Jun 2021 19:22:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1624994545; x=1656530545; h=from:to:cc:subject:date:message-id:mime-version; bh=011jMQzbysLea9YNOltRP7IGOoLMvt8FHdPjNFU4fE0=; b=necM85yp3rmGOTd8H9XWSZQlhlnhZ4ipQMmb3LckBqBxBoFIr1wY3sIg ETAYIKb4HoNGOkDbd8W8QamfVPysr8+4+pa1/gkVsjudDg46Xg4YOWBwS OX57VBe8SigqL0F5Og0YIFUxTtUdywFG3+4fgH0mbKZK0Nd612m0d8ic9 x6LBCBYiKpY+X1EQN6MMPHwAac6kJqt7mJ+cJzxHWdhA8IFYCMf7yD0UT gvrPjXEkXWFxcWgzSL8qRJwFznfAw9WGT+/RH2B6Y5xf/OtKh3MMmAxMO DHe7K0vWkXINjTcDsDgS+ZMOjNth3V70HjvCJREi/UhKjIdIX/+UaMIAl g==; IronPort-SDR: DBOpz7FXL6edMGxWnX9XPIlSA9yx5+/DHh0kcAZIAHgUW2vl9Z4Uh/gArsTQn3sV/iiFIhCvEF fIWiElgi/o9WDLusI+OJI6IHr6nYtj8C4zXfHh8iLunuSc8Jhzq5+HPjnyuT4MElGdpJVKllz/ tXZKmcVDfo6Ea/21d3bP9zSIXfYo9G1HyMo5TuhztsGmGeHWTDaZmTCJGByyIyoOWh80QkQOqa A8TNgjsfzCT0P+sx8H/lmI6dT4JdJiEMPm2GQSoQQX8z1B4kWuD2d1w8Ur1xbVQyr81BjzrQR3 Ors= X-IronPort-AV: E=Sophos;i="5.83,309,1616482800"; d="scan'208";a="133971297" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 29 Jun 2021 12:22:24 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 29 Jun 2021 12:22:24 -0700 Received: from dan-linux.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 29 Jun 2021 12:22:24 -0700 From: Dan Sneddon To: Dan Sneddon , Mark Brown , , , Subject: [PATCH v2] spi: atmel: Fix CS and initialization bug Date: Tue, 29 Jun 2021 12:22:18 -0700 Message-ID: <20210629192218.32125-1-dan.sneddon@microchip.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210629_122226_272947_4E39D5F3 X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Ludovic Desroches , Tudor Ambarus Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 5fa5e6dec762 ("spi: atmel: Switch to transfer_one transfer method") switched to using transfer_one and set_cs. The core doesn't call set_cs when the chip select lines are gpios. Add the SPI_MASTER_GPIO_SS flag to the driver to ensure the calls to set_cs happen since the driver programs configuration registers there. Fixes: 5fa5e6dec762 ("spi: atmel: Switch to transfer_one transfer method") Signed-off-by: Dan Sneddon --- Changes in v2: - Updated commit message - Dropped unnecessary change to enable variable in set_cs drivers/spi/spi-atmel.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 2ef74885ffa2..788dcdf25f00 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -352,8 +352,6 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) } mr = spi_readl(as, MR); - if (spi->cs_gpiod) - gpiod_set_value(spi->cs_gpiod, 1); } else { u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0; int i; @@ -369,8 +367,6 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) mr = spi_readl(as, MR); mr = SPI_BFINS(PCS, ~(1 << chip_select), mr); - if (spi->cs_gpiod) - gpiod_set_value(spi->cs_gpiod, 1); spi_writel(as, MR, mr); } @@ -400,8 +396,6 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) if (!spi->cs_gpiod) spi_writel(as, CR, SPI_BIT(LASTXFER)); - else - gpiod_set_value(spi->cs_gpiod, 0); } static void atmel_spi_lock(struct atmel_spi *as) __acquires(&as->lock) @@ -1483,7 +1477,8 @@ static int atmel_spi_probe(struct platform_device *pdev) master->bus_num = pdev->id; master->num_chipselect = 4; master->setup = atmel_spi_setup; - master->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX); + master->flags = (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX | + SPI_MASTER_GPIO_SS); master->transfer_one = atmel_spi_one_transfer; master->set_cs = atmel_spi_set_cs; master->cleanup = atmel_spi_cleanup;