From patchwork Mon Jan 7 15:51:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="N/t1dhVw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKky1FHjz9sDP for ; Tue, 8 Jan 2019 02:56:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfAGP4l (ORCPT ); Mon, 7 Jan 2019 10:56:41 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33022 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfAGP4k (ORCPT ); Mon, 7 Jan 2019 10:56:40 -0500 Received: by mail-lj1-f193.google.com with SMTP id v1-v6so778012ljd.0 for ; Mon, 07 Jan 2019 07:56:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ra+zLtqtNCVMe3JGWM08Eu1AX9L0cpRs8XQnZXyXhCc=; b=N/t1dhVw7Sr02CG+WTYkYYGbG4UJ8O8XWjBokNJ+t+8rJEr1lwfONA3fBDn0VDrtys DUdkDuvux/0yyeUk5wsesPUrSRj/b0fyaM6vrJV5Y6HvW6QOI6LK36luSqiPAfBI2JC+ n6ULOwSU+ScseMbNX6cg8SVM+09ssNskz4oKA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ra+zLtqtNCVMe3JGWM08Eu1AX9L0cpRs8XQnZXyXhCc=; b=Hj3D6dWxtdUmEcqpUrdZljkWlNFubnQdl+fYazvu+rHCV+7oZi6Wb6SdtqbRnWszQf A4Qsnzunk8xDa1Kjtusyi4VGeGPYsRaKC2USzJxhl+cOghw3TeS1Ddd91pKB2qlbEdC0 Gu+f/JzAjsy4+ei+TpISgDI4dA4aeqjT+2f+1ySvSguUJ5wYPWE+ic7hAGhBoj8OmSkA ZdCrmmKFsjyupA6hPgf0Kx7dVXvn8n5bfQZBHYL3XLDZ14oLWXOAN9uRinaz+Fv0WlEe SIFobteR76Vw7NSSqYT6R9xNUZirYHyehVP8I4zv0rXturmFlMIPPqSyJV9rdopXvSo/ JzlA== X-Gm-Message-State: AA+aEWYrxoOTkL9pJA8rLM3MMEJ3TH9WxpSoRak17RlKeppfBgZYid6h zwo3gElWbFqxo92oHoCMbsZFCQ== X-Google-Smtp-Source: ALg8bN7HEP2GmTdZqK1QwwVpF+2yDx2Zwi18cSG4Ggd400snbOKwtlvZ0tPX2xZL6/ZPJR1+wB8WeA== X-Received: by 2002:a2e:974a:: with SMTP id f10-v6mr38524207ljj.61.1546876597481; Mon, 07 Jan 2019 07:56:37 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:36 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij Subject: [PATCH 1/7 v2] spi: Optionally use GPIO descriptors for CS GPIOs Date: Mon, 7 Jan 2019 16:51:50 +0100 Message-Id: <20190107155156.3738-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This augments the SPI core to optionally use GPIO descriptors for chip select on a per-master-driver opt-in basis. Drivers using this will rely on the SPI core to look up GPIO descriptors associated with the device, such as when using device tree or board files with GPIO descriptor tables. When getting descriptors from the device tree, this will in turn activate the code in gpiolib that was added in commit 6953c57ab172 ("gpio: of: Handle SPI chipselect legacy bindings") which means that these descriptors are aware of the active low semantics that is the default for SPI CS GPIO lines and we can assume that all of these are "active high" and thus assign SPI_CS_HIGH to all CS lines on the DT path. The previously used gpio_set_value() would call down into gpiod_set_raw_value() and ignore the polarity inversion semantics. It seems like many drivers go to great lengths to set up the CS GPIO line as non-asserted, respecting SPI_CS_HIGH. We pull this out of the SPI drivers and into the core, and by simply requesting the line as GPIOD_OUT_LOW when retrieveing it from the device and relying on the gpiolib to handle any inversion semantics. This way a lot of code can be simplified and removed in each converted driver. The end goal after dealing with each driver in turn, is to delete the non-descriptor path (of_spi_register_master() for example) and let the core deal with only descriptors. The different SPI drivers have complex interactions with the core so we cannot simply change them all over, we need to use a stepwise, bisectable approach so that each driver can be converted and fixed in isolation. This patch has the intended side effect of adding support for ACPI GPIOs as it starts relying on gpiod_get_*() to get the GPIO handle associated with the device. Cc: Linuxarm Acked-by: Jonathan Cameron Tested-by: Fangjian (Turing) Signed-off-by: Linus Walleij --- ChangeLog v1-v2: - Do not initialize gpiod to NULL - Record Jonathans ACK - Record Fangjian's Tested-by - Rebase on v5.0-rc1 --- drivers/spi/spi.c | 104 ++++++++++++++++++++++++++++++++++++---- include/linux/spi/spi.h | 23 +++++++-- 2 files changed, 113 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9a7def7c3237..13f447a67d67 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -578,7 +579,10 @@ int spi_add_device(struct spi_device *spi) goto done; } - if (ctlr->cs_gpios) + /* Descriptors take precedence */ + if (ctlr->cs_gpiods) + spi->cs_gpiod = ctlr->cs_gpiods[spi->chip_select]; + else if (ctlr->cs_gpios) spi->cs_gpio = ctlr->cs_gpios[spi->chip_select]; /* Drivers may modify this initial i/o setup, but will @@ -772,10 +776,20 @@ static void spi_set_cs(struct spi_device *spi, bool enable) if (spi->mode & SPI_CS_HIGH) enable = !enable; - if (gpio_is_valid(spi->cs_gpio)) { - /* Honour the SPI_NO_CS flag */ - if (!(spi->mode & SPI_NO_CS)) - gpio_set_value(spi->cs_gpio, !enable); + if (spi->cs_gpiod || gpio_is_valid(spi->cs_gpio)) { + /* + * Honour the SPI_NO_CS flag and invert the enable line, as + * active low is default for SPI. Execution paths that handle + * polarity inversion in gpiolib (such as device tree) will + * enforce active high using the SPI_CS_HIGH resulting in a + * double inversion through the code above. + */ + if (!(spi->mode & SPI_NO_CS)) { + if (spi->cs_gpiod) + gpiod_set_value(spi->cs_gpiod, !enable); + else + gpio_set_value(spi->cs_gpio, !enable); + } /* Some SPI masters need both GPIO CS & slave_select */ if ((spi->controller->flags & SPI_MASTER_GPIO_SS) && spi->controller->set_cs) @@ -1615,13 +1629,21 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, spi->mode |= SPI_CPHA; if (of_property_read_bool(nc, "spi-cpol")) spi->mode |= SPI_CPOL; - if (of_property_read_bool(nc, "spi-cs-high")) - spi->mode |= SPI_CS_HIGH; if (of_property_read_bool(nc, "spi-3wire")) 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")) + spi->mode |= SPI_CS_HIGH; + /* Device DUAL/QUAD mode */ if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) { switch (value) { @@ -2137,6 +2159,60 @@ static int of_spi_register_master(struct spi_controller *ctlr) } #endif +/** + * spi_get_gpio_descs() - grab chip select GPIOs for the master + * @ctlr: The SPI master to grab GPIO descriptors for + */ +static int spi_get_gpio_descs(struct spi_controller *ctlr) +{ + int nb, i; + struct gpio_desc **cs; + struct device *dev = &ctlr->dev; + + nb = gpiod_count(dev, "cs"); + ctlr->num_chipselect = max_t(int, nb, ctlr->num_chipselect); + + /* No GPIOs at all is fine, else return the error */ + if (nb == 0 || nb == -ENOENT) + return 0; + else if (nb < 0) + return nb; + + cs = devm_kcalloc(dev, ctlr->num_chipselect, sizeof(*cs), + GFP_KERNEL); + if (!cs) + return -ENOMEM; + ctlr->cs_gpiods = cs; + + for (i = 0; i < nb; i++) { + /* + * Most chipselects are active low, the inverted + * semantics are handled by special quirks in gpiolib, + * so initializing them GPIOD_OUT_LOW here means + * "unasserted", in most cases this will drive the physical + * line high. + */ + cs[i] = devm_gpiod_get_index_optional(dev, "cs", i, + GPIOD_OUT_LOW); + + if (cs[i]) { + /* + * If we find a CS GPIO, name it after the device and + * chip select line. + */ + char *gpioname; + + gpioname = devm_kasprintf(dev, GFP_KERNEL, "%s CS%d", + dev_name(dev), i); + if (!gpioname) + return -ENOMEM; + gpiod_set_consumer_name(cs[i], gpioname); + } + } + + return 0; +} + static int spi_controller_check_ops(struct spi_controller *ctlr) { /* @@ -2199,9 +2275,16 @@ int spi_register_controller(struct spi_controller *ctlr) return status; if (!spi_controller_is_slave(ctlr)) { - status = of_spi_register_master(ctlr); - if (status) - return status; + if (ctlr->use_gpio_descriptors) { + status = spi_get_gpio_descs(ctlr); + if (status) + return status; + } else { + /* Legacy code path for GPIOs from DT */ + status = of_spi_register_master(ctlr); + if (status) + return status; + } } /* even if it's just one always-selected device, there must @@ -2915,6 +2998,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) * cs_change is set for each transfer. */ if ((spi->mode & SPI_CS_WORD) && (!(ctlr->mode_bits & SPI_CS_WORD) || + spi->cs_gpiod || gpio_is_valid(spi->cs_gpio))) { size_t maxsize; int ret; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 314d922ca607..916bba47d156 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -12,6 +12,7 @@ #include #include #include +#include struct dma_chan; struct property_entry; @@ -116,7 +117,10 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats, * @modalias: Name of the driver to use with this device, or an alias * for that name. This appears in the sysfs "modalias" attribute * for driver coldplugging, and in uevents used for hotplugging - * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when + * @cs_gpio: LEGACY: gpio number of the chipselect line (optional, -ENOENT when + * not using a GPIO line) use cs_gpiod in new drivers by opting in on + * the spi_master. + * @cs_gpiod: gpio descriptor of the chipselect line (optional, NULL when * not using a GPIO line) * * @statistics: statistics for the spi_device @@ -163,7 +167,8 @@ struct spi_device { void *controller_data; char modalias[SPI_NAME_SIZE]; const char *driver_override; - int cs_gpio; /* chip select gpio */ + int cs_gpio; /* LEGACY: chip select gpio */ + struct gpio_desc *cs_gpiod; /* chip select gpio desc */ /* the statistics */ struct spi_statistics statistics; @@ -376,9 +381,17 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * controller has native support for memory like operations. * @unprepare_message: undo any work done by prepare_message(). * @slave_abort: abort the ongoing transfer request on an SPI slave controller - * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS - * number. Any individual value may be -ENOENT for CS lines that + * @cs_gpios: LEGACY: array of GPIO descs to use as chip select lines; one per + * CS number. Any individual value may be -ENOENT for CS lines that + * are not GPIOs (driven by the SPI controller itself). Use the cs_gpiods + * in new drivers. + * @cs_gpiods: Array of GPIO descs to use as chip select lines; one per CS + * number. Any individual value may be NULL for CS lines that * are not GPIOs (driven by the SPI controller itself). + * @use_gpio_descriptors: Turns on the code in the SPI core to parse and grab + * GPIO descriptors rather than using global GPIO numbers grabbed by the + * driver. This will fill in @cs_gpiods and @cs_gpios should not be used, + * and SPI devices will have the cs_gpiod assigned rather than cs_gpio. * @statistics: statistics for the spi_controller * @dma_tx: DMA transmit channel * @dma_rx: DMA receive channel @@ -557,6 +570,8 @@ struct spi_controller { /* gpio chip select */ int *cs_gpios; + struct gpio_desc **cs_gpiods; + bool use_gpio_descriptors; /* statistics */ struct spi_statistics statistics; From patchwork Mon Jan 7 15:51:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gN+y+595"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKl03kxwz9sDn for ; Tue, 8 Jan 2019 02:56:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727316AbfAGP4n (ORCPT ); Mon, 7 Jan 2019 10:56:43 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41299 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbfAGP4m (ORCPT ); Mon, 7 Jan 2019 10:56:42 -0500 Received: by mail-lj1-f193.google.com with SMTP id k15-v6so738141ljc.8 for ; Mon, 07 Jan 2019 07:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=329rMIw7dk8N5WV5b3QguRojP7Xyn99GAFQEKXGZQEs=; b=gN+y+595Yove8MadqCNy4hJYDphMRQorwd3AT4DqAFybqXz9B3OTmVHv3faKVeokKW SX/fZfKgigizvQTgwmAGNVeaLTz37oSVF31sKhb1na/oe10Uc2pL+sh/VDzr5Yw+iQzp qKC0qCVwEIv4Ash7Ktxpaxqp9ei0Dzjyg/NHM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=329rMIw7dk8N5WV5b3QguRojP7Xyn99GAFQEKXGZQEs=; b=h9R1xucOi0gj+3fCbhnLf4LDGNCk0wRWZd/8g0BI79FfEl2Yb+x/un90fzlo6bac0I 5IBRKD3LML1/w+PItpmW1Ujw46CDkFPNWQW/SX12Oz881vqwO7trNA06ClBPVzPkRPYZ RPkHhtRdnjDO3I09VJrxepgHwUu2g3tKI1CA/qBvPsephk2ozRHibyVl/8kkCKMEsPw8 IZNRnSQEiDhL3h8g7uMwlqKkNuWFTshxpSQNQFxkIdEemaAliFq6DdwKg+e9Lem/dv58 fonGHFkGJQE8p/A3EVcUuqlVVq1CSYQIO6LnjfJf6bYrDUVzXtPFlvbDPH5bdP9BKfZw adwg== X-Gm-Message-State: AJcUukdyhrNdh+yT5qUtU7oKHCDtMwuivmAak333QGg6ZtEkTQhOvimc N/qrhVVi+9NGu6d0N8r2u6Hqng== X-Google-Smtp-Source: ALg8bN7zi8Gi0X7ryrNOXeHsiwkph7LgcSPhqlebdvp9ahGJo9thvoA+jyf5MvnQFoPtA6GCvzKGug== X-Received: by 2002:a2e:9bc3:: with SMTP id w3-v6mr33347697ljj.70.1546876599911; Mon, 07 Jan 2019 07:56:39 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:38 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , Felix Fietkau , Alban Bedel Subject: [PATCH 2/7 v2] spi: ath79: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:51 +0100 Message-Id: <20190107155156.3738-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the ATH79 SPI master driver to use GPIO descriptors for chip select handling. The ATH79 driver was requesting the GPIO and driving it from the bitbang .chipselect callback. Do not request it anymore as the SPI core will request it, remove the line inversion semantics for the GPIO case (handled by gpiolib) and let the SPI core deal with requesting the GPIO line from the device tree node of the controller. This driver can be instantiated from a board file (no device tree) but the board files only use native CS (no GPIO lines) so we should be fine just letting the SPI core grab the GPIO from the device. The fact that the driver is actively driving the GPIO in the ath79_spi_chipselect() callback is confusing since the host does not set SPI_MASTER_GPIO_SS so this should not ever get called when using GPIO CS. I put in a comment about this. Cc: Felix Fietkau Cc: Alban Bedel Cc: Linuxarm Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-ath79.c | 42 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 3f6b657394de..ed1068ac055f 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -78,9 +78,16 @@ static void ath79_spi_chipselect(struct spi_device *spi, int is_active) ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); } - if (gpio_is_valid(spi->cs_gpio)) { - /* SPI is normally active-low */ - gpio_set_value_cansleep(spi->cs_gpio, cs_high); + 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); @@ -118,21 +125,8 @@ static void ath79_spi_disable(struct ath79_spi *sp) static int ath79_spi_setup_cs(struct spi_device *spi) { struct ath79_spi *sp = ath79_spidev_to_sp(spi); - int status; - status = 0; - if (gpio_is_valid(spi->cs_gpio)) { - unsigned long flags; - - flags = GPIOF_DIR_OUT; - if (spi->mode & SPI_CS_HIGH) - flags |= GPIOF_INIT_LOW; - else - flags |= GPIOF_INIT_HIGH; - - status = gpio_request_one(spi->cs_gpio, flags, - dev_name(&spi->dev)); - } else { + if (!spi->cs_gpiod) { u32 cs_bit = AR71XX_SPI_IOC_CS(spi->chip_select); if (spi->mode & SPI_CS_HIGH) @@ -143,13 +137,7 @@ static int ath79_spi_setup_cs(struct spi_device *spi) ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base); } - return status; -} - -static void ath79_spi_cleanup_cs(struct spi_device *spi) -{ - if (gpio_is_valid(spi->cs_gpio)) - gpio_free(spi->cs_gpio); + return 0; } static int ath79_spi_setup(struct spi_device *spi) @@ -163,15 +151,12 @@ static int ath79_spi_setup(struct spi_device *spi) } status = spi_bitbang_setup(spi); - if (status && !spi->controller_state) - ath79_spi_cleanup_cs(spi); return status; } static void ath79_spi_cleanup(struct spi_device *spi) { - ath79_spi_cleanup_cs(spi); spi_bitbang_cleanup(spi); } @@ -225,6 +210,7 @@ static int ath79_spi_probe(struct platform_device *pdev) pdata = dev_get_platdata(&pdev->dev); + master->use_gpio_descriptors = true; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); master->setup = ath79_spi_setup; master->cleanup = ath79_spi_cleanup; From patchwork Mon Jan 7 15:51:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NdPCVyWG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKl36mQmz9sDn for ; Tue, 8 Jan 2019 02:56:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726907AbfAGP4r (ORCPT ); Mon, 7 Jan 2019 10:56:47 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39668 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726858AbfAGP4p (ORCPT ); Mon, 7 Jan 2019 10:56:45 -0500 Received: by mail-lj1-f195.google.com with SMTP id t9-v6so752891ljh.6 for ; Mon, 07 Jan 2019 07:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4QthtHvNQMLswNSpCzO3VdhVLwJQ3jKsqPb84qyLfbY=; b=NdPCVyWGmF70d+mmcxyrBnl/agXelhLSke9TSqVm027cfhgaYKLQIrPTO42DRKYNDI hmkMO1QjiLaI6m5OHaCPEAyRR7/BTa/bXZxg41/xmi2WSF9CDXQIR/4x112bixsAu3sZ XEIjv2nCnKk0fmxX5M68QSCUpf5CgxkPjsZU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4QthtHvNQMLswNSpCzO3VdhVLwJQ3jKsqPb84qyLfbY=; b=NnPx1qm3mbLouU3QMewywmX3Xu/WoaIfL1N2Zq72uriA4v6j8JRvnc3u99rNC/rbcc o6P5SVwFyAi5i4zMZ2bTTFoUa2UebVu/K1TRZAzAwMIJTGJBH2F4DjNerUOlQQ8D98kD 4VKhf93C68/moc7NsMmxHAYh9z4HTE2RiBY8ZDo2anHz4D9Ap3ZKgUj0aIx+FyPfKNVR JjHncnTE081XoU9PuTecculoaoVtIkP+kYRktnFPNJDlIONl5F8TcH2c/GLTygO6t8bZ NtvrGMan1Lek16rFZLFDqRFprbeAgU7tsD2AxCu1kSe9zEcXykez1r08/cIN00kyp7O2 /BEg== X-Gm-Message-State: AJcUukePSkYW8jxkfF6+G9k1y4vgo0AFixfuMmL0aw/dOm8IqvMNGdaa ylwUZPK/nFbDwfN1ohkRhYpK9A== X-Google-Smtp-Source: ALg8bN5Zy7QcmTry+4PnR6U4W1rBHxlKQ3vqgvDhraTZDVpovEObeSzK2vJG0MS+rUiT4Xnaa8lgHg== X-Received: by 2002:a2e:2416:: with SMTP id k22-v6mr11620995ljk.80.1546876602746; Mon, 07 Jan 2019 07:56:42 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:41 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , Eugen Hristev , Nicolas Ferre , Radu Pirea Subject: [PATCH 3/7 v2] spi: atmel: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:52 +0100 Message-Id: <20190107155156.3738-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the Atmel SPI master driver to use GPIO descriptors for chip select handling. The Atmel driver has duplicate code to look up and initialize CS GPIOs from the device tree, so this is removed. It further has code to retrieve a CS GPIO from .controller_data but this seems to be completely unused in the kernel (legacy codepath?) so I deleted this support. It keeps track of polarity when switching the CS, but this is not needed anymore since we moved this over to the gpiolib. The local handling of the "npcs_pin" (I guess this might mean "negative polarity chip select pin") is preserved, but I strongly suspect this can be switched over to handling by the core and using the SPI_MASTER_GPIO_SS flag on the master to assure that the additional CS handling in the driver is also done. Cc: Eugen Hristev Cc: Nicolas Ferre Cc: Radu Pirea Cc: Linuxarm Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-atmel.c | 93 ++++++++++++----------------------------- 1 file changed, 27 insertions(+), 66 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 74fddcd3282b..f53f0c5e63da 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -23,8 +23,7 @@ #include #include -#include -#include +#include #include #include @@ -312,7 +311,7 @@ struct atmel_spi { /* Controller-specific per-slave state */ struct atmel_spi_device { - unsigned int npcs_pin; + struct gpio_desc *npcs_pin; u32 csr; }; @@ -355,7 +354,6 @@ static bool atmel_spi_is_v2(struct atmel_spi *as) static void cs_activate(struct atmel_spi *as, struct spi_device *spi) { struct atmel_spi_device *asd = spi->controller_state; - unsigned active = spi->mode & SPI_CS_HIGH; u32 mr; if (atmel_spi_is_v2(as)) { @@ -379,7 +377,7 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) mr = spi_readl(as, MR); if (as->use_cs_gpios) - gpio_set_value(asd->npcs_pin, active); + gpiod_set_value(asd->npcs_pin, 1); } else { u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0; int i; @@ -396,19 +394,16 @@ static void cs_activate(struct atmel_spi *as, struct spi_device *spi) mr = spi_readl(as, MR); mr = SPI_BFINS(PCS, ~(1 << spi->chip_select), mr); if (as->use_cs_gpios && spi->chip_select != 0) - gpio_set_value(asd->npcs_pin, active); + gpiod_set_value(asd->npcs_pin, 1); spi_writel(as, MR, mr); } - dev_dbg(&spi->dev, "activate %u%s, mr %08x\n", - asd->npcs_pin, active ? " (high)" : "", - mr); + dev_dbg(&spi->dev, "activate NPCS, mr %08x\n", mr); } static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) { struct atmel_spi_device *asd = spi->controller_state; - unsigned active = spi->mode & SPI_CS_HIGH; u32 mr; /* only deactivate *this* device; sometimes transfers to @@ -420,14 +415,12 @@ static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) spi_writel(as, MR, mr); } - dev_dbg(&spi->dev, "DEactivate %u%s, mr %08x\n", - asd->npcs_pin, active ? " (low)" : "", - mr); + dev_dbg(&spi->dev, "DEactivate NPCS, mr %08x\n", mr); if (!as->use_cs_gpios) spi_writel(as, CR, SPI_BIT(LASTXFER)); else if (atmel_spi_is_v2(as) || spi->chip_select != 0) - gpio_set_value(asd->npcs_pin, !active); + gpiod_set_value(asd->npcs_pin, 0); } static void atmel_spi_lock(struct atmel_spi *as) __acquires(&as->lock) @@ -1188,7 +1181,6 @@ static int atmel_spi_setup(struct spi_device *spi) struct atmel_spi_device *asd; u32 csr; unsigned int bits = spi->bits_per_word; - unsigned int npcs_pin; as = spi_master_get_devdata(spi->master); @@ -1217,25 +1209,27 @@ static int atmel_spi_setup(struct spi_device *spi) csr |= SPI_BF(DLYBS, 0); csr |= SPI_BF(DLYBCT, 0); - /* chipselect must have been muxed as GPIO (e.g. in board setup) */ - npcs_pin = (unsigned long)spi->controller_data; - - if (!as->use_cs_gpios) - npcs_pin = spi->chip_select; - else if (gpio_is_valid(spi->cs_gpio)) - npcs_pin = spi->cs_gpio; - asd = spi->controller_state; if (!asd) { asd = kzalloc(sizeof(struct atmel_spi_device), GFP_KERNEL); if (!asd) return -ENOMEM; - if (as->use_cs_gpios) - gpio_direction_output(npcs_pin, - !(spi->mode & SPI_CS_HIGH)); + /* + * If use_cs_gpios is true this means that we have "cs-gpios" + * defined in the device tree node so we should have + * gotten the GPIO lines from the device tree inside the + * SPI core. Warn if this is not the case but continue since + * CS GPIOs are after all optional. + */ + if (as->use_cs_gpios) { + if (!spi->cs_gpiod) { + dev_err(&spi->dev, + "host claims to use CS GPIOs but no CS found in DT by the SPI core\n"); + } + asd->npcs_pin = spi->cs_gpiod; + } - asd->npcs_pin = npcs_pin; spi->controller_state = asd; } @@ -1473,41 +1467,6 @@ static void atmel_get_caps(struct atmel_spi *as) as->caps.has_pdc_support = version < 0x212; } -/*-------------------------------------------------------------------------*/ -static int atmel_spi_gpio_cs(struct platform_device *pdev) -{ - struct spi_master *master = platform_get_drvdata(pdev); - struct atmel_spi *as = spi_master_get_devdata(master); - struct device_node *np = master->dev.of_node; - int i; - int ret = 0; - int nb = 0; - - if (!as->use_cs_gpios) - return 0; - - if (!np) - return 0; - - nb = of_gpio_named_count(np, "cs-gpios"); - for (i = 0; i < nb; i++) { - int cs_gpio = of_get_named_gpio(pdev->dev.of_node, - "cs-gpios", i); - - if (cs_gpio == -EPROBE_DEFER) - return cs_gpio; - - if (gpio_is_valid(cs_gpio)) { - ret = devm_gpio_request(&pdev->dev, cs_gpio, - dev_name(&pdev->dev)); - if (ret) - return ret; - } - } - - return 0; -} - static void atmel_spi_init(struct atmel_spi *as) { spi_writel(as, CR, SPI_BIT(SWRST)); @@ -1560,6 +1519,7 @@ static int atmel_spi_probe(struct platform_device *pdev) goto out_free; /* the spi->mode bits understood by this driver: */ + master->use_gpio_descriptors = true; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 16); master->dev.of_node = pdev->dev.of_node; @@ -1592,6 +1552,11 @@ static int atmel_spi_probe(struct platform_device *pdev) atmel_get_caps(as); + /* + * If there are chip selects in the device tree, those will be + * discovered by the SPI core when registering the SPI master + * and assigned to each SPI device. + */ as->use_cs_gpios = true; if (atmel_spi_is_v2(as) && pdev->dev.of_node && @@ -1600,10 +1565,6 @@ static int atmel_spi_probe(struct platform_device *pdev) master->num_chipselect = 4; } - ret = atmel_spi_gpio_cs(pdev); - if (ret) - goto out_unmap_regs; - as->use_dma = false; as->use_pdc = false; if (as->caps.has_dma_support) { From patchwork Mon Jan 7 15:51:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FhXDTNWD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKl53dqSz9sDn for ; Tue, 8 Jan 2019 02:56:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbfAGP4s (ORCPT ); Mon, 7 Jan 2019 10:56:48 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39990 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfAGP4s (ORCPT ); Mon, 7 Jan 2019 10:56:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id n18-v6so750836lji.7 for ; Mon, 07 Jan 2019 07:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dyc209MkU26DsHhcTstxC4XkO3ZgBkaOKbCSbkZ/s8Y=; b=FhXDTNWDW2kYR1E0Ka0ictK08cm07X1LltpJXFWMPJD7eoPuDMyzaqbdRn807FwFZr vu//JB4C3xrxT7Xfj9tSxy7jL10GWw1r6K1z4I+JHqxkdoevhoiXsGlA4K5FxnYglK2y Suw78IhkvW38UeAyxcHWXFRoL/4AoCofL09m4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dyc209MkU26DsHhcTstxC4XkO3ZgBkaOKbCSbkZ/s8Y=; b=OV1jO5BpvdMKpjlSXoYpiihHOugVG99tHdS29mSn/B5jpNSWDb2yJtsfvFQTO/nAbU oSpSd2L90RzTXvOgYbKVi4vuRX7Kdm8qX4hNvZj03E/ats+2umYO9Le3b17Sk3nzPBlQ vXFLIXOq2ekWtViOgiAYd16jRjqqZrsroec0BtkCtjbrr9F+IKbM/MNmM27iUO/oh5tz XiucGEF1TsotBXgtWPVpoiMfaQ6zKxJJuBa+LYmt+YfbFDxwHMwFx44cYioD4XquwGnj WS1ovLAr1SJ9JVL1Ihm4nlb9tQf5nFhnkGZh8I/t9RLPAO2PGBD27nfudeM9SoA86RwJ 811g== X-Gm-Message-State: AJcUukc2ouVCPKheZNlFGN7KRZMDa4US3yEF9KSggT+rFyOeaz+yaO+D wHWe/yhOA24nj0wv4wa8qmL/EQ== X-Google-Smtp-Source: ALg8bN5X/dphTZq40O6tRq7WSQSm6+eVTquMok35iI2QplBSgTyMce9Z9lFvNEWGRO3TWF28nBAosQ== X-Received: by 2002:a2e:9a16:: with SMTP id o22-v6mr34479934lji.112.1546876605297; Mon, 07 Jan 2019 07:56:45 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:44 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , Wei Yongjun , Janek Kotas Subject: [PATCH 4/7 v2] spi: cadence: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:53 +0100 Message-Id: <20190107155156.3738-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the Cadence SPI master driver to use GPIO descriptors for chip select handling. The Cadence driver was allocating a state container just to hold the requested GPIO line and contained lots of polarity inversion code. As this is all handled by gpiolib and a simple devm_* request in the core, and as the driver is fully device tree only, most of this code chunk goes away in favour of central handling. The setup/cleanup callbacks goes away. This driver does NOT drive the CS line by setting the value of the GPIO so it relies on the SPI core to do this, which should work just fine with the descriptors. Cc: Wei Yongjun Cc: Janek Kotas Cc: Linuxarm Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-cadence.c | 67 ++------------------------------------- 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index 7c88f74f7f47..e332d173dbf9 100644 --- a/drivers/spi/spi-cadence.c +++ b/drivers/spi/spi-cadence.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -128,10 +128,6 @@ struct cdns_spi { u32 is_decoded_cs; }; -struct cdns_spi_device_data { - bool gpio_requested; -}; - /* Macros for the SPI controller read/write */ static inline u32 cdns_spi_read(struct cdns_spi *xspi, u32 offset) { @@ -469,64 +465,6 @@ static int cdns_unprepare_transfer_hardware(struct spi_master *master) return 0; } -static int cdns_spi_setup(struct spi_device *spi) -{ - - int ret = -EINVAL; - struct cdns_spi_device_data *cdns_spi_data = spi_get_ctldata(spi); - - /* this is a pin managed by the controller, leave it alone */ - if (spi->cs_gpio == -ENOENT) - return 0; - - /* this seems to be the first time we're here */ - if (!cdns_spi_data) { - cdns_spi_data = kzalloc(sizeof(*cdns_spi_data), GFP_KERNEL); - if (!cdns_spi_data) - return -ENOMEM; - cdns_spi_data->gpio_requested = false; - spi_set_ctldata(spi, cdns_spi_data); - } - - /* if we haven't done so, grab the gpio */ - if (!cdns_spi_data->gpio_requested && gpio_is_valid(spi->cs_gpio)) { - ret = gpio_request_one(spi->cs_gpio, - (spi->mode & SPI_CS_HIGH) ? - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, - dev_name(&spi->dev)); - if (ret) - dev_err(&spi->dev, "can't request chipselect gpio %d\n", - spi->cs_gpio); - else - cdns_spi_data->gpio_requested = true; - } else { - if (gpio_is_valid(spi->cs_gpio)) { - int mode = ((spi->mode & SPI_CS_HIGH) ? - GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH); - - ret = gpio_direction_output(spi->cs_gpio, mode); - if (ret) - dev_err(&spi->dev, "chipselect gpio %d setup failed (%d)\n", - spi->cs_gpio, ret); - } - } - - return ret; -} - -static void cdns_spi_cleanup(struct spi_device *spi) -{ - struct cdns_spi_device_data *cdns_spi_data = spi_get_ctldata(spi); - - if (cdns_spi_data) { - if (cdns_spi_data->gpio_requested) - gpio_free(spi->cs_gpio); - kfree(cdns_spi_data); - spi_set_ctldata(spi, NULL); - } - -} - /** * cdns_spi_probe - Probe method for the SPI driver * @pdev: Pointer to the platform_device structure @@ -621,13 +559,12 @@ static int cdns_spi_probe(struct platform_device *pdev) goto clk_dis_all; } + master->use_gpio_descriptors = true; master->prepare_transfer_hardware = cdns_prepare_transfer_hardware; master->prepare_message = cdns_prepare_message; master->transfer_one = cdns_transfer_one; master->unprepare_transfer_hardware = cdns_unprepare_transfer_hardware; master->set_cs = cdns_spi_chipselect; - master->setup = cdns_spi_setup; - master->cleanup = cdns_spi_cleanup; master->auto_runtime_pm = true; master->mode_bits = SPI_CPOL | SPI_CPHA; From patchwork Mon Jan 7 15:51:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="UM1SFyu6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKl70gfRz9sDP for ; Tue, 8 Jan 2019 02:56:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727788AbfAGP4u (ORCPT ); Mon, 7 Jan 2019 10:56:50 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36695 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727469AbfAGP4u (ORCPT ); Mon, 7 Jan 2019 10:56:50 -0500 Received: by mail-lj1-f193.google.com with SMTP id g11-v6so765461ljk.3 for ; Mon, 07 Jan 2019 07:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U/f3ju9GAcQU2D9t1vnukcnrS930aDOZrrMHtBThSv0=; b=UM1SFyu6VOe2ezjzpBKx2/3g5foqiuj7bAQfTVVs0kJrk4kxE8ncStmKououjitABI WRFxaPdPwpboTTWpkTwzKlZYzOyK2UyHXWuPD9S1pZo21S+zFN0W6hsBqimIxxHVlq5a ZGK2a97sSe5eEurZhIJVfN1qSTWeZw0idYB14= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U/f3ju9GAcQU2D9t1vnukcnrS930aDOZrrMHtBThSv0=; b=kMPSIWUQ9NPW2VPCC2hppv+ZjusERuSsZriCwaU+gvss14FDi+h2uezwSiZKeF95Xu su6DXj0unynu/4T8nqW7nFKCJQUqZC0JQGh7aBVXl/rOWu0sARyWwOaO8+D45a78ngkN 0CXvdrVNV4HRFeNQfICkRM0X9cvCbwpaHtQavNtxc21tSUlOlbXybAVqL/WA6SolFs0U pJOH9S++iLHXZjkO/5fjkfquAzk2ap7cHfqkFXGNthsvMatMV474W68UeTGSkvn6OcoZ bTmBMMton18qOG0Yu6zuyqqIjCyTu2CJGz0FNYGvtd6sbUc6ox4nkB/G9oy6GAOchZoh yh1w== X-Gm-Message-State: AJcUukf8mN+mdoIgO1+k6iG1Q1T6zRcjXmMHUXtxNgU8F3SKnmNYC0n7 Bfn6BbRr3/L32XYQGy3upaX+ng== X-Google-Smtp-Source: ALg8bN4bDohuTnjf2rtS9BCemh6PA09Z1Rdgjk8D0FdOC6EyE9pxJFuNRAVPGmcaKWAX0Pi24opzLQ== X-Received: by 2002:a2e:2d11:: with SMTP id t17-v6mr33714989ljt.159.1546876608141; Mon, 07 Jan 2019 07:56:48 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:47 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , Alexander Shiyan Subject: [PATCH 5/7 v2] spi: clps711x: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:54 +0100 Message-Id: <20190107155156.3738-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the CLPS711x SPI master driver to use GPIO descriptors for chip select handling. The CLPS711x driver was merely requesting the GPIO and setting the CS line non-asserted so this was a pretty straight-forward conversion. The setup callback goes away. Cc: Alexander Shiyan Cc: Linuxarm Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-clps711x.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index 18193df2eba8..8c03c409fc07 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -36,25 +36,6 @@ struct spi_clps711x_data { int len; }; -static int spi_clps711x_setup(struct spi_device *spi) -{ - if (!spi->controller_state) { - int ret; - - ret = devm_gpio_request(&spi->master->dev, spi->cs_gpio, - dev_name(&spi->master->dev)); - if (ret) - return ret; - - spi->controller_state = spi; - } - - /* We are expect that SPI-device is not selected */ - gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); - - return 0; -} - static int spi_clps711x_prepare_message(struct spi_master *master, struct spi_message *msg) { @@ -125,11 +106,11 @@ static int spi_clps711x_probe(struct platform_device *pdev) if (!master) return -ENOMEM; + master->use_gpio_descriptors = true; master->bus_num = -1; master->mode_bits = SPI_CPHA | SPI_CS_HIGH; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8); master->dev.of_node = pdev->dev.of_node; - master->setup = spi_clps711x_setup; master->prepare_message = spi_clps711x_prepare_message; master->transfer_one = spi_clps711x_transfer_one; From patchwork Mon Jan 7 15:51:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="cNU3CinQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKlC2B75z9sDP for ; Tue, 8 Jan 2019 02:56:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfAGP4y (ORCPT ); Mon, 7 Jan 2019 10:56:54 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43316 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfAGP4x (ORCPT ); Mon, 7 Jan 2019 10:56:53 -0500 Received: by mail-lj1-f196.google.com with SMTP id q2-v6so729896lji.10 for ; Mon, 07 Jan 2019 07:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xm+Cu8zBByKaKqXFO/NKMdT+rDKwaF0UxMq7adQloU4=; b=cNU3CinQW5zo+xIEt9jIp1uVC/k98YkuxcHznXMZTCmp7f3D8ApD9Ivh3xdIjhKFdP 1gvnijaMMnhcH7jMmlW1J4s81rcULhdwu4AQYZ4TxnGbft57cWaE6uw+lHCzjZcdj+AS blmvVOWy0/PIIDhCKKYVhTvzvs7nwcWjBpnXQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xm+Cu8zBByKaKqXFO/NKMdT+rDKwaF0UxMq7adQloU4=; b=OydP27OG8qkjV0Und7j2ksX9xsi6OihuLjVTcFJ9Bnsfc0bQu79xvmNj8D2RhzqCMF 03v0RVVywlC3cqrBD3K+AKF96b06jY/kSqTHWkxm4Fxh4jAQmzQ1DLe6rO6kpElrrd+h Xfmjfbusc6u4mjYvAtJ6nK76gSlBY4jRVBqTHCbC7vSjdNqHce3jqvyogAuEvSmblxp2 5h2dHTxxzDFKaFPvR0XOW3RA6KSOCmTPVUYAX9SJlOoLDbsmNSJO9EXgGNwcKV02S2o6 5IhFpgW3BgUHCdhxFvIu0Akz55lHWKdBPOFM7F/rcqViTgUlCXgoZqIHeXZtpmByRFaG 4lmw== X-Gm-Message-State: AJcUukdcEkb3rKSO6pV82j3UI07Fk38y54f8w8ue0SEYcGFwTO2Ajj/7 CYPoVoKKX6VqCxDA8zvHVLHbhbT4548PRff3 X-Google-Smtp-Source: ALg8bN4LTx2UbXCh/GRhuKn0F2YfZfhlOdEDdsIRjJXg5oHOMFRes9fTg3D+nn7rGzTo1UUgCpklMw== X-Received: by 2002:a2e:9b52:: with SMTP id o18-v6mr33691891ljj.108.1546876611000; Mon, 07 Jan 2019 07:56:51 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:49 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , David Lechner Subject: [PATCH 6/7 v2] spi: davinci: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:55 +0100 Message-Id: <20190107155156.3738-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the DaVinci SPI master driver to use GPIO descriptors for chip select handling. DaVinci parses the device tree a second time for the chip select GPIOs (no relying on the parsing already happening in the SPI core) and handles inversion semantics locally. We simply drop the extra parsing and set up and move the CS handling to the core and gpiolib. The fact that the driver is actively driving the GPIO in the davinci_spi_chipselect() callback is confusing since the host does not set SPI_MASTER_GPIO_SS so this should not ever get called when using GPIO CS. I put in a comment about this. This driver also supports instantiation from board files, but these are all using native chip selects so no problem with GPIO lines here. Cc: David Lechner Cc: Bartosz Golaszewski Cc: Linuxarm Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-davinci.c | 53 ++++++++++----------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 56adec83f8fc..5870afe3845b 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include #include @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -222,12 +221,17 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value) * Board specific chip select logic decides the polarity and cs * line for the controller */ - if (spi->cs_gpio >= 0) { + if (spi->cs_gpiod) { + /* + * FIXME: is this code ever executed? This host does not + * set SPI_MASTER_GPIO_SS so this chipselect callback should + * not get called from the SPI core when we are using + * GPIOs for chip select. + */ if (value == BITBANG_CS_ACTIVE) - gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH); + gpiod_set_value(spi->cs_gpiod, 1); else - gpio_set_value(spi->cs_gpio, - !(spi->mode & SPI_CS_HIGH)); + gpiod_set_value(spi->cs_gpiod, 0); } else { if (value == BITBANG_CS_ACTIVE) { if (!(spi->mode & SPI_CS_WORD)) @@ -418,7 +422,6 @@ static int davinci_spi_of_setup(struct spi_device *spi) */ static int davinci_spi_setup(struct spi_device *spi) { - int retval = 0; struct davinci_spi *dspi; struct spi_master *master = spi->master; struct device_node *np = spi->dev.of_node; @@ -427,21 +430,11 @@ static int davinci_spi_setup(struct spi_device *spi) dspi = spi_master_get_devdata(spi->master); if (!(spi->mode & SPI_NO_CS)) { - if (np && (master->cs_gpios != NULL) && (spi->cs_gpio >= 0)) { - retval = gpio_direction_output( - spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); + if (np && spi->cs_gpiod) internal_cs = false; - } - - if (retval) { - dev_err(&spi->dev, "GPIO %d setup failed (%d)\n", - spi->cs_gpio, retval); - return retval; - } - if (internal_cs) { + if (internal_cs) set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select); - } } if (spi->mode & SPI_READY) @@ -962,6 +955,7 @@ static int davinci_spi_probe(struct platform_device *pdev) if (ret) goto free_master; + master->use_gpio_descriptors = true; master->dev.of_node = pdev->dev.of_node; master->bus_num = pdev->id; master->num_chipselect = pdata->num_chipselect; @@ -980,27 +974,6 @@ static int davinci_spi_probe(struct platform_device *pdev) if (dspi->version == SPI_VERSION_2) dspi->bitbang.flags |= SPI_READY; - if (pdev->dev.of_node) { - int i; - - for (i = 0; i < pdata->num_chipselect; i++) { - int cs_gpio = of_get_named_gpio(pdev->dev.of_node, - "cs-gpios", i); - - if (cs_gpio == -EPROBE_DEFER) { - ret = cs_gpio; - goto free_clk; - } - - if (gpio_is_valid(cs_gpio)) { - ret = devm_gpio_request(&pdev->dev, cs_gpio, - dev_name(&pdev->dev)); - if (ret) - goto free_clk; - } - } - } - dspi->bitbang.txrx_bufs = davinci_spi_bufs; ret = davinci_spi_request_dma(dspi); From patchwork Mon Jan 7 15:51:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1021399 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="N1uNOoa2"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43YKlD6Xb5z9sDP for ; Tue, 8 Jan 2019 02:56:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbfAGP44 (ORCPT ); Mon, 7 Jan 2019 10:56:56 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43316 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfAGP4z (ORCPT ); Mon, 7 Jan 2019 10:56:55 -0500 Received: by mail-lj1-f193.google.com with SMTP id q2-v6so730010lji.10 for ; Mon, 07 Jan 2019 07:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dbTeetkKkenvzLrTieSfQxTaPQNcOHrf+mj+vmNzfaU=; b=N1uNOoa2AW/HAtLpjdEHtAPnCKtpXGgl50xhmpPWdozAwrnCWaLYMiGmyhzHvpSrHd JhzUfQLp/+SaevIh9SeHkRsSKJgX3CzSFg9huOoIAXut51wUwkapQVundnsqwA2G+RIV T6o9YLTUQ/jS8DhR0k25D68sFBZlUqqJ1e9CU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dbTeetkKkenvzLrTieSfQxTaPQNcOHrf+mj+vmNzfaU=; b=cnbFWPhNTwKTRvWgFjMD/6sPIodS8IdIeD82Y78v2n9gkxJX4sbh0sLX0Tnm6Q9n4/ +ssdbCcSnqo5B8WPdWtHCQQZ5fxhdZo57yNgmd9tvE5iWW3aH/QKGzQspe1A+thleDho BncFty486hpEeawWwATDR08ZsFzxV/CH6+MhrnzBGEGjMXemrrIiNPq/a/iltQ2YZkFf sDkreU2CJzsVJjHo74xjEG+ugP1bSRwOXY5AMVqydcqUMzWCv+b4ebufXfqYh7gDnvgc RqZHww2eke5iGa1GtxqaLrWMab3ka3H7lRiGEJL28xhz5fiwIkRPYv1FzSPvJWrxckU3 ufzw== X-Gm-Message-State: AJcUukfYyg4uo6fKJzhi26d0j6ZdxxvNtuCUPEdHLAZopprLslSe4uwm kafaPrepnfvq87lcjJeukLgZdQ== X-Google-Smtp-Source: ALg8bN41xcb7NiOYlwD96NfNQYQDSBHKfXg+2n8uTsSMX/qaGpU7P9Fa4C8cLpPvCsEkpvbWsVDLgA== X-Received: by 2002:a2e:484:: with SMTP id a4-v6mr34176665ljf.27.1546876613517; Mon, 07 Jan 2019 07:56:53 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id t22sm13269164lfb.0.2019.01.07.07.56.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Jan 2019 07:56:52 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , linuxarm@huawei.com, Linus Walleij , Talel Shenhar , Simon Goldschmidt , Alexandre Belloni Subject: [PATCH 7/7 v2] spi: dw: Convert to use CS GPIO descriptors Date: Mon, 7 Jan 2019 16:51:56 +0100 Message-Id: <20190107155156.3738-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107155156.3738-1-linus.walleij@linaro.org> References: <20190107155156.3738-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the DesignWare (dw) SPI master driver to use GPIO descriptors for chip select handling. This driver has a duplicate DT parser in addition to the one in the core, sets up the line as non-asserted and relies on the core to drive the GPIOs. It is a pretty straight-forward conversion. Cc: Talel Shenhar Cc: Simon Goldschmidt Cc: Alexandre Belloni Cc: Linuxarm Tested-by: Jay Fang Reviewed-by: Alexandre Belloni Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebase on v5.0-rc1 --- drivers/spi/spi-dw-mmio.c | 22 ---------------------- drivers/spi/spi-dw.c | 9 +-------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index d0dd7814e997..4bd59a93d988 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -185,27 +184,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->num_cs = num_cs; - if (pdev->dev.of_node) { - int i; - - for (i = 0; i < dws->num_cs; i++) { - int cs_gpio = of_get_named_gpio(pdev->dev.of_node, - "cs-gpios", i); - - if (cs_gpio == -EPROBE_DEFER) { - ret = cs_gpio; - goto out; - } - - if (gpio_is_valid(cs_gpio)) { - ret = devm_gpio_request(&pdev->dev, cs_gpio, - dev_name(&pdev->dev)); - if (ret) - goto out; - } - } - } - init_func = device_get_match_data(&pdev->dev); if (init_func) { ret = init_func(pdev, dwsmmio); diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 2e822a56576a..531f6ce5900d 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "spi-dw.h" @@ -425,13 +424,6 @@ static int dw_spi_setup(struct spi_device *spi) chip->tmode = SPI_TMOD_TR; - if (gpio_is_valid(spi->cs_gpio)) { - ret = gpio_direction_output(spi->cs_gpio, - !(spi->mode & SPI_CS_HIGH)); - if (ret) - return ret; - } - return 0; } @@ -496,6 +488,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) goto err_free_master; } + master->use_gpio_descriptors = true; master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP; master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); master->bus_num = dws->bus_num;