Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1883133imu; Thu, 17 Jan 2019 05:00:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN5XR3GOAq3QuRQZBKJb0ftiva/VlPkVClsDxq7pAmuc3qZC8qsqrip3OLRsF5udP9YZQWkS X-Received: by 2002:a62:c583:: with SMTP id j125mr14947348pfg.37.1547730033759; Thu, 17 Jan 2019 05:00:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547730033; cv=none; d=google.com; s=arc-20160816; b=T6EuR5D57BiJR9wtDBy54BLmUf8Y4OHCMvTnVNBMbl/Uw+FsaEOMsUAIADX3aM+s0Y Uy5SdAvwGzHP/YJNqLYRhRg4WmSeqHdSGtfJLEfJtWC7UUUv/69H+03w5LgXzpvsUPLf HJ8DZDdFEe2r5TSzg2Xf0Q5IW4ahvtOBlCXRkUGT22FVSLTm2JvjTyuvD2jDZkajnU1v hJ6MTk1n/Hg59jRqDPZhmoki3CxcV56r5EFfEMTT1OaG0oVYvjOSAlf9RSPJF0VAeo/u UL6I0GqBZ6KbaH4j02/QCjA/t7SdYlftIta+m/QuXTtFxaSZQPIgSpkWPBCnnDgRbSIt WeDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature; bh=4PVycBjPPbUxHUaYW/x0jPrQQ2cvtFkz8/zNOWlbkk4=; b=GZBCBDfc3d0/adKaGvW34fM3SMC9xB05adqLZuy+63oQW5Lv+8lFakMNdLUZG99Hms XFpohs2e6ex1+V1zijbqGc5R1SAZUw1KHp9Ko9wJH7GPsn945IcHWZElF4tEJDnIUFuw fxQJtzaz2PIaUSbeFfeyA6cN4xJ0EpNCg6Po/GAxrMWUjrAYjhDpAcQ/xfuxU0RwgiPs 6FKV+y2kSjyJYhN8Mnr7RURev/njTSQOHFMhP8XHWV2WrM178tPT+LismABBgKe2rzs3 dojToJr7wkUidvtj3kFyr3qrHhX1H6KZVjpFW/E1rkE7+Augqhql1frkQh5xn798AAiv ccXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=anchVuTi; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si1714861ple.185.2019.01.17.05.00.17; Thu, 17 Jan 2019 05:00:33 -0800 (PST) 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; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=anchVuTi; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727774AbfAQMkZ (ORCPT + 99 others); Thu, 17 Jan 2019 07:40:25 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:60488 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfAQMkV (ORCPT ); Thu, 17 Jan 2019 07:40:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=4PVycBjPPbUxHUaYW/x0jPrQQ2cvtFkz8/zNOWlbkk4=; b=anchVuTiD0RV +V4t/POmaVjFyi9L2Fymkuw5PhUNJVKJLvZzcgOsdN2h0ixEyHtXo8GUq4AsorfqOVG3MuXWkOUUm 4PyGMwdZZbE9oh3fpUhhzjbJDGvW3tid2iMn4i5kqiriNUrTC9DxsatXB0IwQu+tqt30hdmNfktwl nrLUs=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1gk6y2-0000ZL-QF; Thu, 17 Jan 2019 12:40:18 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 6B9621126FE2; Thu, 17 Jan 2019 12:40:18 +0000 (GMT) From: Mark Brown To: Alban Bedel Cc: Mark Brown , linux-kernel@vger.kernel.org, Mark Brown , linux-spi@vger.kernel.org, linux-spi@vger.kernel.org Subject: Applied "spi: ath79: Simplify ath79_spi_chipselect()" to the spi tree In-Reply-To: <20190116185549.23295-2-albeu@free.fr> X-Patchwork-Hint: ignore Message-Id: <20190117124018.6B9621126FE2@debutante.sirena.org.uk> Date: Thu, 17 Jan 2019 12:40:18 +0000 (GMT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch spi: ath79: Simplify ath79_spi_chipselect() has been applied to the spi tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 797622d7a3ab5192ff575288bdbec15c3a006280 Mon Sep 17 00:00:00 2001 From: Alban Bedel Date: Wed, 16 Jan 2019 19:55:45 +0100 Subject: [PATCH] spi: ath79: Simplify ath79_spi_chipselect() First of all this callback was slightly misused to setup the clock polarity at the beginning of a transfer. Beside being at the wrong place, it is also useless as only SPI mode 1 is supported. Instead just make sure the base value used for IOC is suitable to start a transfer by clearing the clock and data bits during the controller setup. This also remove the last direct usage of the GPIO API, so we can remove the direct dependency on GPIOLIB. Signed-off-by: Alban Bedel Signed-off-by: Mark Brown --- drivers/spi/Kconfig | 2 +- drivers/spi/spi-ath79.c | 40 +++++++++------------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index dc67eda1788a..128892c7e21e 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -63,7 +63,7 @@ config SPI_ALTERA config SPI_ATH79 tristate "Atheros AR71XX/AR724X/AR913X SPI controller driver" - depends on ATH79 && GPIOLIB + depends on ATH79 select SPI_BITBANG help This enables support for the SPI controller present on the diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index ed1068ac055f..edf695a359f4 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -67,38 +66,14 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active) { struct ath79_spi *sp = ath79_spidev_to_sp(spi); int cs_high = (spi->mode & SPI_CS_HIGH) ? is_active : !is_active; + u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select); - if (is_active) { - /* set initial clock polarity */ - if (spi->mode & SPI_CPOL) - sp->ioc_base |= AR71XX_SPI_IOC_CLK; - else - sp->ioc_base &= ~AR71XX_SPI_IOC_CLK; - - ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); - } - - if (spi->cs_gpiod) { - /* - * SPI chipselect is normally active-low, but - * inversion semantics are handled by gpiolib. - * - * FIXME: is this ever used? The driver doesn't - * set SPI_MASTER_GPIO_SS so this callback should not - * get called if a CS GPIO is found by the SPI core. - */ - gpiod_set_value_cansleep(spi->cs_gpiod, is_active); - } else { - u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select); - - if (cs_high) - sp->ioc_base |= cs_bit; - else - sp->ioc_base &= ~cs_bit; - - ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); - } + if (cs_high) + sp->ioc_base |= cs_bit; + else + sp->ioc_base &= ~cs_bit; + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); } static void ath79_spi_enable(struct ath79_spi *sp) @@ -110,6 +85,9 @@ static void ath79_spi_enable(struct ath79_spi *sp) sp->reg_ctrl = ath79_spi_rr(sp, AR71XX_SPI_REG_CTRL); sp->ioc_base = ath79_spi_rr(sp, AR71XX_SPI_REG_IOC); + /* clear clk and mosi in the base state */ + sp->ioc_base &= ~(AR71XX_SPI_IOC_DO | AR71XX_SPI_IOC_CLK); + /* TODO: setup speed? */ ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43); } -- 2.20.1