Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3753445pxv; Mon, 19 Jul 2021 08:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTR/7Tf0xxIkA+5+Nn1fxagvhl9NIz6FIvHlprYJ0uBp8fs7nDIDPaykA9fwRFabTSIi7F X-Received: by 2002:a17:906:fa0b:: with SMTP id lo11mr27057134ejb.508.1626706838139; Mon, 19 Jul 2021 08:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626706838; cv=none; d=google.com; s=arc-20160816; b=x8qmSxwrrlwb34GFLjHQnbiI1qMNSzm36ZQ+dGs+fxvcF6pT69/mk2XUsCFurZjY0J BQ72CcJu84aaXVHEPnf+JRxe6QpvSlVXLINinFBse2r4+Ykak6TbVR0L/4cfF9RHcbTK 8TYmnBbjXX1ibrAU0g6gaOih3oIdS3CYgO1Qg+GgXszjXG4z0MErNi/Pe7feQcvGmRdq RH9NCfrf9kygQRWGLo2/pil6nTLzApQ53MApzAqA5g3UVS9YYOTktBN5KdZ6C+sa9AS7 m+maCFQXGXZYs+C4E3CxH4WVEXqYspZD5SaD/WjQ3cLV+6WaUh3dZm15l7DnYCE8+21K D5iw== 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=uqs4acKLIeK7VfRBFAmzieCJvlx44KywY+qjW1ZlZsI=; b=ySrZifmPuDZBuIgcLq+57XOkR1iLr4NLErDc3yEj14SjF3HuNqaVTowpX6Avqdletd D2fiDQw/tlRCfTSGqdMjXzDslWG14b2ehASyqX9Y6B4P2HGrCQ3yGeRdaLaTsMQ0BovV /dw2ecLtYj/c30JYieFq3OBIhuEtO668q8rjtZvmI1usuzuUnQ9QHCFdqtW/MQZstxzg 1JUZtck2wmxOYx5NUkChdIeq6zWFBC9y/eaVRS7QoOQwB9GvmTdvaBCHe76xVetO/rk1 /C1B5ad7+YcMfXJcp6K7Al3mIAarDECylProkWeLc7ay6q1/Lujq7PWPrKH18aU0X258 0WYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jEUTK4sZ; 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 a5si21408908edv.295.2021.07.19.08.00.15; Mon, 19 Jul 2021 08:00:38 -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=jEUTK4sZ; 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 S241706AbhGSOSp (ORCPT + 99 others); Mon, 19 Jul 2021 10:18:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:52082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242027AbhGSORn (ORCPT ); Mon, 19 Jul 2021 10:17:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1906661165; Mon, 19 Jul 2021 14:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626706698; bh=2g3riF2PmjxQI7FI8+iGWs2y6j5QXFcVpKB+p3oo9ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jEUTK4sZCcNr7zHHirDxPSj/vxV+azrYMLkVoDjav0lY5E+3FzKX8h/NCymSrl1S3 e+DKXjouYQX3ligmqAQaqUPnU0ygrTRXknsAR2nmmWXmYeFU11Yt6dFiaE4wFsPvE4 TCiZZSqhKhudwEw0KnJifdsiEA08MqDXgQsOhKkg= 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 4.4 059/188] spi: spi-sun6i: Fix chipselect/clock bug Date: Mon, 19 Jul 2021 16:50:43 +0200 Message-Id: <20210719144926.783184650@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144913.076563739@linuxfoundation.org> References: <20210719144913.076563739@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 48888ab630c2..079bdc4e65ff 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -249,6 +249,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) @@ -332,7 +336,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