Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2826759pxv; Mon, 12 Jul 2021 02:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2m0uRxnW8b/qPTSd59pQzQsS2H8odMeuSjNizsxo+hdb++GYdxC8qzp7Z5MFgLwjudrgA X-Received: by 2002:a02:c7cc:: with SMTP id s12mr10400180jao.37.1626083717199; Mon, 12 Jul 2021 02:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083717; cv=none; d=google.com; s=arc-20160816; b=WUzT8ULCYF39B0+aNPjGAceoFNmmldWprJMVRGuZei+UkVbCNyP4tPwjNM6/tBDR2Y QWarN0wzcx1iLMdS6oW9+gT3oPv7LCtbhQmL8U4XxFZKJMKQq5MzKS7K2zNrnvS6nhNi UBcCz0aomsWQZWArytLV8wkZYmPiTkrf95FMX9XlQR+jSW69n3AoNAB9yb1jrTsvwOwy l7zU+hQ8s0f6zohyDPY7qrCgygAlpWYa4uKhtXigBrslm4cuyuz4ACMKy/ku04wmvXIJ GNGAu0nu+eZaI/saQqEUv180KrYRpyKC7nP2xz1RgrFAn4MUvt8XAGpzK/2RkKVI7Fwh b6Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+q0Euveys+yhNH8SRtf+l9gjZ+EoutNmTwSqnTSDIzY=; b=m00pHGUtz3PDmxNWffsx2VBn9nI80kcisSCkcOJCkU2mh8ob9S4mfe+z/3Jz9bi6ZV sogUoFk+zof4af6MYHvWVnw7rJ8V8WSkhaMDQ346qEa+c1zb6wTFYJA0T+6CYnjS5ZEJ EF7ne9L4fXbt/GK8xxx/nG3NjEwdlu73xEIZRRP0bazBMqgYBfYaYcwrDSFkU1iKYciA G2h9LLgiVgulmzkbHJItPRmSUObr36+ae3XwYZmTS50K/BG356l2+VYvzZ8u31aMdXyB +FdW1lT6dTxehF7ymBDiVb3Y4NyxcI6HxkPWhcMY/RRs1Ot4r/G6gwTGvVYVZ7ykO4Lo G80g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k+eKiyZs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d198si17168721jac.70.2021.07.12.02.55.05; Mon, 12 Jul 2021 02:55:17 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=k+eKiyZs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238654AbhGLG5I (ORCPT + 99 others); Mon, 12 Jul 2021 02:57:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:36804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234726AbhGLGlN (ORCPT ); Mon, 12 Jul 2021 02:41:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD75D61004; Mon, 12 Jul 2021 06:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071902; bh=cRihPaoRihsuA6DTjujpIiIJ2JBvDndLgo48WOan2BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+eKiyZs3r3zoXH2UdhGJUNQ1rSX9SgXpsuotVetwDEjZYaf4TL5Zb1L/VOyhDS5J U/w24/oapnsiw9suz/EdgWVfNDImJkxLrH4y8C56p2kdOPmnnWIf7HKn7GBRZCUF2A 6HxV2DupQA6+c8O3P/7U9NuN8FqEJN/q+mRXmdwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mirko Vogt , Ralf Schlatterbeck , Mark Brown , Sasha Levin Subject: [PATCH 5.10 269/593] spi: spi-sun6i: Fix chipselect/clock bug Date: Mon, 12 Jul 2021 08:07:09 +0200 Message-Id: <20210712060913.111592483@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mirko Vogt [ Upstream commit 0d7993b234c9fad8cb6bec6adfaa74694ba85ecb ] The current sun6i SPI implementation initializes the transfer too early, resulting in SCK going high before the transfer. When using an additional (gpio) chipselect with sun6i, the chipselect is asserted at a time when clock is high, making the SPI transfer fail. This is due to SUN6I_GBL_CTL_BUS_ENABLE being written into SUN6I_GBL_CTL_REG at an early stage. Moving that to the transfer function, hence, right before the transfer starts, mitigates that problem. Fixes: 3558fe900e8af (spi: sunxi: Add Allwinner A31 SPI controller driver) Signed-off-by: Mirko Vogt Signed-off-by: Ralf Schlatterbeck Link: https://lore.kernel.org/r/20210614144507.y3udezjfbko7eavv@runtux.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-sun6i.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index 19238e1b76b4..803d92f8d031 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -290,6 +290,10 @@ static int sun6i_spi_transfer_one(struct spi_master *master, } sun6i_spi_write(sspi, SUN6I_CLK_CTL_REG, reg); + /* Finally enable the bus - doing so before might raise SCK to HIGH */ + reg = sun6i_spi_read(sspi, SUN6I_GBL_CTL_REG); + reg |= SUN6I_GBL_CTL_BUS_ENABLE; + sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG, reg); /* Setup the transfer now... */ if (sspi->tx_buf) @@ -398,7 +402,7 @@ static int sun6i_spi_runtime_resume(struct device *dev) } sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG, - SUN6I_GBL_CTL_BUS_ENABLE | SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP); + SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP); return 0; -- 2.30.2