From patchwork Wed Nov 27 13:54:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180296 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6150359ilf; Wed, 27 Nov 2019 05:54:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwHMKYsEfEuy9rxoNG4t9q9SfmIgFl/XwVCPQxEibrgR4UMiNV+Ws4sH4NmT7eueWxSiv2G X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr49129991ejw.286.1574862862524; Wed, 27 Nov 2019 05:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574862862; cv=none; d=google.com; s=arc-20160816; b=h0jN1LphqZKKQ/8rig7eZik+YDR+ZgKPTo7mvkAjo1nSsjdjaMq0D8VqY0cBR7mKXr Uwwa3+j80s9MWnLoN1MB3XY3K3jcR9RJLO6KME/C+zk0LC35osHH4EHrcfKTz+oGD07y bVVvNBz7LpMtO3q1wGwSoHnCR3xA2ke8+vNM6t+4I2kHpuaRTcIZXMCkhwlvO/97POOR V5ZoBpX10uyOTw9vujFqlf2WuaGs6Doz/viG+CrjKHl+SdgSaryROxVImpPE8LsoE3i4 6mtYdiFS/9AkfcfpbG8NTExV1pTtU56+gpJB8Uhvk+ItnarunWjwwg4j3TjuPJvJPGDJ 6i2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=44702Gw3ZAM2iREdSIkTlwApDDVA5N67h6DOU9Ptf4I=; b=tn2ixAIJgRb6L5wwWt1Sbgg+wZzjF9s66qJ6PnmFdmItJT2gc9pNtG+piFq6JERKj6 fLt5ETgYnPQsmwld7YIWUjh9ueicaGWYwhoEEEkS+CnRrb7Edh+M1LAR+g/k5gOPR+6x n2wKHtqCpNNFWMGi/PkQqSPp/7OV6hEw4El7Cmm2xEnn+usP0bGrF86WGtIHpovw8zzd 17JRFUqRd0CNIK3C5iZf85oFJ253YVEaCSSKQFx47FOg2kDPH7oER/yTX1a6cABF1tIg wq6jRjhltRfH0Jgco1mO8WJLGX6XYRNTFgDUFmHLsn1OWH1Lovq41WNJ7WzDc9EZd15A NAdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdOIu4tv; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si9666810edp.264.2019.11.27.05.54.22; Wed, 27 Nov 2019 05:54:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdOIu4tv; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726603AbfK0NyW (ORCPT + 2 others); Wed, 27 Nov 2019 08:54:22 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40519 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbfK0NyV (ORCPT ); Wed, 27 Nov 2019 08:54:21 -0500 Received: by mail-lf1-f68.google.com with SMTP id y5so4525443lfy.7 for ; Wed, 27 Nov 2019 05:54:20 -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:mime-version :content-transfer-encoding; bh=44702Gw3ZAM2iREdSIkTlwApDDVA5N67h6DOU9Ptf4I=; b=hdOIu4tv6tllw/KWE2yRviLR61rwCfpLpUHi5G9WBuFmm9quzNH+avKQZC7QukVlSd S8Xn9EU5RmJKJTad/mZc3A37j8SMokiwphzSGnB8JmsTgxE5TqbftomZlNUOO1AQhpnm fmtYyWA5ZTxjh0rEymmo3KtvVnU7Rt19yI5/zrXUSAASNS1x0V3b6aPozhO7zrvilji2 czH+s90iXRqYlerl5GIt2tLsr1DYsKnd6qFSjyHH3ClCANYXXRrIMZ6MyvDGpKoJ76qL 37xS8mnHU9Z+DQdw7ZqJb7SzaeQkHnyCi52rQ9uUlzj1L7i0ifIY2ypUUA2Y6Kn/73xc hMJQ== 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:mime-version :content-transfer-encoding; bh=44702Gw3ZAM2iREdSIkTlwApDDVA5N67h6DOU9Ptf4I=; b=BWFnm6I6c2ZmhvGk9yqVKhPny1CeHIphJMDE2TB/HOVFUWTY/nEI00GjG2N6Gl3dOA Sw+Pjtj8FJqSMS57SSYh4TkV77TroaqjR0L/88D2fmLC6uWWkyse9DAjZAaiVa/hWIAC t17Vu+yXoLLv57IZCrPfB/AVhHZ06DgAotPH4Z7kJtPmx3lIf+9guinr0fgDcL/svkUC 6lMEfpfOKcCk9ia7TPCnmHPkNrjkLJxnpI1kU3y4gU7CiL7m0e7hhhf3qqNk/73XWDOn bX5oEbXGg9L92ChY0a9UbU1r7MVfdMHc65pUidZSp+QFpakK2rxz1bT6VGdYryR1acIN Ib7Q== X-Gm-Message-State: APjAAAWDpoSGaK3eypm8ziaMFR7IdRj+aol8eE7jllLtd77X06skg2yU zx0KXoqBL9u+WHY5qyaLv1jTQw== X-Received: by 2002:ac2:455c:: with SMTP id j28mr25414287lfm.184.1574862859524; Wed, 27 Nov 2019 05:54:19 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j18sm2343561lfh.6.2019.11.27.05.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 05:54:17 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Christophe Leroy Subject: [PATCH 1/3 v2] spi: fsl: Fix GPIO descriptor support Date: Wed, 27 Nov 2019 14:54:08 +0100 Message-Id: <20191127135410.156430-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This makes the driver actually support looking up GPIO descriptor. A coding mistake in the initial descriptor support patch was that it was failing to turn on the very feature it was implementing. Mea culpa. Cc: Christophe Leroy Reported-by: Christophe Leroy Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch fixing this specific problem. --- drivers/spi/spi-fsl-spi.c | 1 + 1 file changed, 1 insertion(+) -- 2.23.0 diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 114801a32371..c87e9c4506c2 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -611,6 +611,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev, master->setup = fsl_spi_setup; master->cleanup = fsl_spi_cleanup; master->transfer_one_message = fsl_spi_do_one_msg; + master->use_gpio_descriptors = true; mpc8xxx_spi = spi_master_get_devdata(master); mpc8xxx_spi->max_bits_per_word = 32; From patchwork Wed Nov 27 13:54:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180297 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6150442ilf; Wed, 27 Nov 2019 05:54:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyhbLNE/2EzSh9+J/PL9sZNkEze7sRYFu8HEi5aRwmhH90D0LTFoD0st8PLqGnIxdP5a3zi X-Received: by 2002:a50:ec82:: with SMTP id e2mr32387637edr.68.1574862867212; Wed, 27 Nov 2019 05:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574862867; cv=none; d=google.com; s=arc-20160816; b=VJDdqbHDwjQYm40OlSnYaIO/8MSiNQVnlxu3uF/5USkFoc+th+0GXDta0cAjs5E+l6 4Y9jYj8Ue1et+coiWTPU65YlC72Vr4Big03qXrK6tv/YSKpSr9Hv1Qy8VGZutYs0FGt2 EMdjG38OXGlP3f87cgm+5Y39XmF4TR6hdsbiHzISIJpUFQLCv4MV74fOJG32ZSUIww89 bEAhsCIbGrzSOcIgTzqg873vgsp/XZe3XoPLJh9rhlqskEccwIK1uM2s42+1HPaVU0MS 9HVsBIAeSXWehE+uTZM7Dhg0gDjmQMUaoQkwIkycy1mVWaLWWEmRwtUwqsOosH2RqJ/I 4etA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ze5hvXCplepJyWjwgkySScV2FO5TtWlZUcDiUJMYMsA=; b=FRSwp0mpBFOQAToM0Xn3bpOpyHaIKQVS5v9CvRBRhVDi4/11CACu6OrDS5N+sRBYW/ a164T4v6F8h7Nq2Er+8MWllmZLjIkIwCColZdNXC1RlEa4oMmzmsNxT1GDzpFuCAyqgQ /ilFB3xNtGWCcrkeK6DdSffgxFPfr2JgPHkZu2gZTm3q3EfzIjIGW9ff5j8sfrD6XOF9 iDhSvQzplWFR6f1am5rd0ZzMdvHpcZzDpgQ8b7E/ecBGTnifkKBFwVMpVxhgSoB+8LzE vI67wMxqt7xcp2Xd0TQQwcUaMMMcXqI/lEwLOMTs51vuMpCbdWlwn6ScCgOKby4A1BhD uzpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCGKYWsi; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x17si9267291ejs.178.2019.11.27.05.54.27; Wed, 27 Nov 2019 05:54:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZCGKYWsi; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfK0NyZ (ORCPT + 2 others); Wed, 27 Nov 2019 08:54:25 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35663 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0NyZ (ORCPT ); Wed, 27 Nov 2019 08:54:25 -0500 Received: by mail-lj1-f193.google.com with SMTP id j6so15571638lja.2 for ; Wed, 27 Nov 2019 05:54:23 -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=Ze5hvXCplepJyWjwgkySScV2FO5TtWlZUcDiUJMYMsA=; b=ZCGKYWsiinnFBhR/ovPRoqpJ/8qXeVhMLeaVJqOoLLtY27y18Jgl9k7T/cKKtZMB4a VrbOK7iw0tueIbg5MRQAWVKXQEHoc/CofCoQmbIRpV9+oI09ZpN/zddGl/kCYDF4R7hG JxYdioLqxcYKl2UxjQrDA41oSTHVobiWPAHokFH3/ARoiRk6fdfsO0mcT87r0dVKcKyT r6S03KPMvdgLhfFOC3Dp66wvZJOeKhsNycoN6YEpKMxKKDqnoe8Hw5uS81bTr1hhN6SH hSpvUqo6o0aWplpDR2yzWKEQQkigJUXULDvnl2YxMhxF6nslImbWIawkYG4bL2snPPod ql9A== 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=Ze5hvXCplepJyWjwgkySScV2FO5TtWlZUcDiUJMYMsA=; b=UEV7AdppGJOueGJkxvbQmg4yYYDkWOCBVxEcb79BqUDLpt6xnm/at9zeyj2dJkTwI3 F3QWneCNOnDKfl2g/cJArAXZ1MGEL0vpVwAD0T5xzEvcGdjEWqHw1iOP1NYux0MMq5De Kyy1i/BaqDPLhh6HBo9PYE5t02y/+wBlAioTjFe9DffAcxyZMl8xW+XI3ZrK5B8j3T4d YSQIUsIPeGOCFbMVS+ARVj7VGZwG1E/NXhjE6Y9ffa2mYxgswzE3WOfKtxrz8jmhGHXG WFkRSYeaTM7u3EuyF7PYjMV3JQEwi98WGOTnEf2enRvAdc1gImMofaAZHvwTK0Xp7J0U ptag== X-Gm-Message-State: APjAAAVoIB4/ITfcI3dIHhu9IXz0JLECFpPZ4j0zDXP0DhzPjch0RZ4Y q3L65K8Lda+uXcosLsVsG98C4w== X-Received: by 2002:a2e:2201:: with SMTP id i1mr17841502lji.110.1574862862903; Wed, 27 Nov 2019 05:54:22 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j18sm2343561lfh.6.2019.11.27.05.54.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 05:54:21 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Christophe Leroy Subject: [PATCH 2/3 v2] gpio: Handle counting of Freescale chipselects Date: Wed, 27 Nov 2019 14:54:09 +0100 Message-Id: <20191127135410.156430-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191127135410.156430-1-linus.walleij@linaro.org> References: <20191127135410.156430-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org We have a special quirk to handle the Freescale nonstandard SPI chipselect GPIOs in the gpiolib-of.c file, but it currently only handles the case where the GPIOs are actually requested (gpiod_*get()). We also need to handle that the SPI core attempts to count the GPIOs before use, and that needs a similar quirk in the OF part of the library. Cc: Christophe Leroy Reported-by: Christophe Leroy Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Hardcode the quirk to look for "gpios" as this is all we support and else the call would just recurse back and fail again. - Provide a proper NULL check so we don't upset strcmp(). Mark: I change my mind, better to keep the patches together, once Christophe has it working with my patch stack let's just merge all of it. --- drivers/gpio/gpiolib-of.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.23.0 diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 80ea49f570f4..ae8b296160bf 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -23,6 +23,29 @@ #include "gpiolib.h" #include "gpiolib-of.h" +/** + * of_gpio_spi_cs_get_count() - special GPIO counting for SPI + * Some elder GPIO controllers need special quirks. Currently we handle + * the Freescale GPIO controller with bindings that doesn't use the + * established "cs-gpios" for chip selects but instead rely on + * "gpios" for the chip select lines. If we detect this, we redirect + * the counting of "cs-gpios" to count "gpios" transparent to the + * driver. + */ +int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id) +{ + struct device_node *np = dev->of_node; + + if (!IS_ENABLED(CONFIG_SPI_MASTER)) + return 0; + if (!con_id || strcmp(con_id, "cs")) + return 0; + if (!of_device_is_compatible(np, "fsl,spi") && + !of_device_is_compatible(np, "aeroflexgaisler,spictrl")) + return 0; + return of_gpio_get_count(dev, "gpios"); +} + /* * This is used by external users of of_gpio_count() from * @@ -35,6 +58,10 @@ int of_gpio_get_count(struct device *dev, const char *con_id) char propname[32]; unsigned int i; + ret = of_gpio_spi_cs_get_count(dev, con_id); + if (ret > 0) + return ret; + for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { if (con_id) snprintf(propname, sizeof(propname), "%s-%s", From patchwork Wed Nov 27 13:54:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180298 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6150477ilf; Wed, 27 Nov 2019 05:54:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyqOPyda4hesexdvimUr6YtWTLvTjSoSW9rLQVpwUqLWYXhss57l7FS4oH26OyAPpz6tjNY X-Received: by 2002:a50:c3c5:: with SMTP id i5mr32065253edf.137.1574862869218; Wed, 27 Nov 2019 05:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574862869; cv=none; d=google.com; s=arc-20160816; b=AoR0mVKfbBdaOSfpC2kx0lDJTFJv1JSyirGRfbZW26e3hDx0uZVN2XXWSlcJEoAWaq dgpqto3ZWO2yKBUfHaqOL2D0erGyvZYxCU8Bf7xwO0YDrgXGW3/T9VtezXHR9yTb5en4 GYZ6Nbiv43VmDa8lOSlHE9H9E+XhgRGB6ZELUxuK0b6vDn1Ux2WyWc0sdl9AdR/HP3td FbwCM/whkYLi05ZsRmQfJnQPItjfV0OvmUVvh7NSuyULCipr6jHAX6VW/VSqDkm5oRLS w9/xEKM50ltGBgNBOlQOUp+p1TvpIl3lhbIP9QDgsuku4iIEXXa8MIsuNw4+YU7ol0ys p7pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OmjuVawMhvfVD9JOPWyCm3fewK5I8v6LD5uaG6j2MhM=; b=D/2F+hma9zUl6VvvaoAYbA16nrY1Bip+ioq7MXUOhjSx8X29pMMsufpr62AaMw4A0l +Aw7q84WDt3Bz/RexbQ0DCc6JkewBYVK2PA1k2oPegRRmqKeZ92ba5DQSO6EQ2lQTbHn QfR77r0HhRAny6Qg5DYPqaviZrwpHxHlSyEhJGeqK3b7TFySxESAcl2Rudb8D+vIN9vv ypo46wpgwAeEqCxz1D7I3xN1wKZe/WlU0VB1wrWbffAab58vqD105E+xrlElsujZSA5i kYMDaJpCiD53w6cgZJU6ncGleQBbQcDjTY29jbCpDXzXcWhvBUS0a7aB0Eg2+JnGrxYT F8vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fj1gtrBw; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x17si9267291ejs.178.2019.11.27.05.54.29; Wed, 27 Nov 2019 05:54:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fj1gtrBw; spf=pass (google.com: best guess record for domain of linux-spi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfK0Ny2 (ORCPT + 2 others); Wed, 27 Nov 2019 08:54:28 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46239 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbfK0Ny2 (ORCPT ); Wed, 27 Nov 2019 08:54:28 -0500 Received: by mail-lf1-f68.google.com with SMTP id a17so17206687lfi.13 for ; Wed, 27 Nov 2019 05:54:27 -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=OmjuVawMhvfVD9JOPWyCm3fewK5I8v6LD5uaG6j2MhM=; b=fj1gtrBw/+KHGWourkrK2BexXQtWwQO6TEvDijehjCAUBZRzPtpWiONgne8uaVlPNL +sxrWRQobCmSBcRcYIuSUhsPuyFDSKCDgWZDMO6Juu673NcXquk/IfarAB0H6T3JBi1V o7aClwqZiiy35WtXtwtMJXN58kWCKOnZJRZXLB04DXh2zV9ToYPpZBJtabcDcgcX4t12 6fzXFFlHiLx6fZqRQ51sNIdVrWoIZaupC2pkFIvPwxmIJ0onVlB60MbaUyiO5XzinOoE d0PE+OlOBw99h8SQDYG5HkyhnRWu3YoDX/Q8rW20NRuJHb+SdoNNkV2A0HqIxJMan6jM IBng== 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=OmjuVawMhvfVD9JOPWyCm3fewK5I8v6LD5uaG6j2MhM=; b=LGytNFo7yZuuyANCwmLPQssbjLdH5u5lFkrpdfu3xTKnxbTgb1X2Xp3bekSZ6VKEsO aUaaSE4ornaBOtBgz0VJAuMarTeAcJsB0n7lSqujuZOyT8PdQt9O6l0sQi5NDPRcS/Oq QAyoD0Sd+mlmfeI2+jzSaSYTsBqRm0lR70XcuAN+wz4xZytF/6VwGvEG0O4cSStb57tT f7VWmSJYozmm8SUyPQrFpnL+AJX3B6S2PcznBHjs3h2eSHdDAZKynj3YFZ3RtYx/qUcz mHIgTzx0yB3bbrsmemJMabMKefD2H2GGpBEFc3Svav0DcPIVRD/gXYD1MY5aVScY6pPW 6+KA== X-Gm-Message-State: APjAAAVc3hrJBGBgHKb7HIlSZUxm3yz4guoOU/pvMBG0Yd0bFQSAiDza IvSRNhhblVNrumLAGGSZVUUVlQ== X-Received: by 2002:ac2:5c09:: with SMTP id r9mr26635541lfp.136.1574862866457; Wed, 27 Nov 2019 05:54:26 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j18sm2343561lfh.6.2019.11.27.05.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 05:54:24 -0800 (PST) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Christophe Leroy Subject: [PATCH 3/3 v2] spi: fsl: Handle the single hardwired chipselect case Date: Wed, 27 Nov 2019 14:54:10 +0100 Message-Id: <20191127135410.156430-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191127135410.156430-1-linus.walleij@linaro.org> References: <20191127135410.156430-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The Freescale MPC8xxx had a special quirk for handling a single hardwired chipselect, the case when we're using neither GPIO nor native chip select: when inspecting the device tree and finding zero "cs-gpios" on the device node the code would assume we have a single hardwired chipselect that leaves the device always selected. This quirk is not handled by the new core code, so we need to check the "cs-gpios" explicitly in the driver and set pdata->max_chipselect = 1 which will later fall through to the SPI master ->num_chipselect. Make sure not to assign the chip select handler in this case: there is no handling needed since the chip is always selected, and this is what the old code did as well. Cc: Christophe Leroy Reported-by: Christophe Leroy Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Reordered patches. - Expanded comment a bit. --- drivers/spi/spi-fsl-spi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.23.0 diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index c87e9c4506c2..4b70887cf443 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -728,8 +728,18 @@ static int of_fsl_spi_probe(struct platform_device *ofdev) } } #endif - - pdata->cs_control = fsl_spi_cs_control; + /* + * Handle the case where we have one hardwired (always selected) + * device on the first "chipselect". Else we let the core code + * handle any GPIOs or native chip selects and assign the + * appropriate callback for dealing with the CS lines. This isn't + * supported on the GRLIB variant. + */ + ret = gpiod_count(dev, "cs"); + if (ret <= 0) + pdata->max_chipselect = 1; + else + pdata->cs_control = fsl_spi_cs_control; } ret = of_address_to_resource(np, 0, &mem);