From patchwork Sat Apr 20 11:14:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 162592 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp467522jan; Sat, 20 Apr 2019 04:16:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt7lthfiB/3dRtMmuVrtBN9bE4TTtHzZwFmz0vE8uaEkYrI18Jeaac2TE9uyhUe8W9dbSF X-Received: by 2002:a63:1604:: with SMTP id w4mr3661996pgl.148.1555758984774; Sat, 20 Apr 2019 04:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555758984; cv=none; d=google.com; s=arc-20160816; b=0Nj/7ehyA7lIWePC+VG7bxVeYu9rv2sVQLN/whKFhp1Gh2SVqnWvnaoOhRqsuOpOix oIaBUPVcsuvO3Nu4M7k38dznlwLitgA98nMT+6KTBGY0WI0j7OlhiAtbUvvfQJqac4Yp 6v3tzJ9hpDzLIQLT+J6SbnHDlnaQ31fFe5ruKxTZb0W8Mn8Evda1n8TFAo2PikYFV1wF WSv86FYZv9IpfL8GpZ5ZwjBMLBO6sfmCX3gIQq52G8dNXHV0w1fVkaCf5MlhqHNp49us +mIamRQ8VAMoxFmH6hNaoOpfKZhQvDHlKGYkCRMKEVDWYwjUZKTtlusXlBriQHrvFu0/ 4iJA== 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=TSQYFWpzJQZwVuVCAnz5lxpQmD59owFtWJ0qEyX3T6o=; b=VHBx+/Xn1iQSNMKT3tEJBuNZkjh4ZOPeAAhbvOd+8FsSw1A2DhajljSC7QkVvSDexg qpAi/K+nWh41qFmqAHQp+xTI/G14SJB3L8PXm4H1zTCpMpCDoNAZpSYNGEpgermn9/tb g2Q9eKcudu1dcw9VSnYQn3Uffh5GRmV39M+LrM0THSvawF5Q3Dx8PJ6NzEF1pQ04HNUL zerGqpogtDxzA+PfO0fwkeeWk5wOsC64iSdO48Jc0RpUYvDThqp5CElPjwTP8Pj3GhpY cw0VY47+Z5nMgWsM5qR29Ymek4BSiY98/JIhCW/AMuUNy7xUPxi7H3NgfSLGLgPcW4F2 jlRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ccznE1bB; 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 o3si7796841pld.61.2019.04.20.04.16.24; Sat, 20 Apr 2019 04:16:24 -0700 (PDT) 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=ccznE1bB; 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 S1726267AbfDTLQY (ORCPT + 1 other); Sat, 20 Apr 2019 07:16:24 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46064 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfDTLQY (ORCPT ); Sat, 20 Apr 2019 07:16:24 -0400 Received: by mail-lj1-f194.google.com with SMTP id y6so6535057ljd.12 for ; Sat, 20 Apr 2019 04:16:23 -0700 (PDT) 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=TSQYFWpzJQZwVuVCAnz5lxpQmD59owFtWJ0qEyX3T6o=; b=ccznE1bBqSCeXVPQxH4UY3XD13jOfE0rkBofV3SGw344I/rdqhxcX/CJWAsCNqBKAc o0/IaM9IABRSaUhrVT51sk9b+aECMnisaplwK+RoALs6nMLw6jABjhOW1snWfhS6S4+M PozsW7kysH6Ja/CHbrE4+gNtok/HtoWfdhd3Q51o+wqb8iQlHqpq5BXIJSiz6+CF7g2c LZ+MWq4yskn8kAI8ucmVpN8YWVt0VhF5p41slB4UiyZUDwtfCnByqRq6i1PENHxPJLE/ y3ZLg3RR6tRfyW3IZmGg11dDtc6xHttT2qM06ibqlKKP1ZnqKaSSVSNnpnr2uxNAU8Yh HWig== 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=TSQYFWpzJQZwVuVCAnz5lxpQmD59owFtWJ0qEyX3T6o=; b=akFc2dZXbg32Uo7tRztzY2kr49B/HWZHJuTM5VQGPDLxB51gzhLlAFDvj4374xQ9rn MXtdnom40sreY0gL0b+rchGo28st38q/nQah9fs3N3OSeKiTBirUmiKcQ8hP8HhsAi6Y fN0x5IFWRfUstvAqHjCkxff0YxpN6oT7Dhh+aS7jRZARwns2S5cG+giBKrnG5BaZ+KGh lmTzxAGgE2+fq4KXOMiU5wX6/aCFro0SscYhCUX2i2U3hbamd+uNBv+8GoAZWeST+tD0 ZU/ox5BX7lDhjaQjMYehgGkdMwOUbiBsSkHeKgamN7bbjccDymLt+6HPAfvYsVpJLQF7 KuzQ== X-Gm-Message-State: APjAAAXEA7+bHO7AyyWasY6S68eajiZ2bcpkV9SdHvVakQgB8ErGh5Ve q5V8wSBru/73uF1mQ/K8fkLFAg== X-Received: by 2002:a2e:204e:: with SMTP id g75mr4974880ljg.92.1555758982299; Sat, 20 Apr 2019 04:16:22 -0700 (PDT) Received: from localhost.localdomain (c-c5d3225c.014-348-6c756e10.bbcust.telenor.se. [92.34.211.197]) by smtp.gmail.com with ESMTPSA id u2sm1649376lje.74.2019.04.20.04.16.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Apr 2019 04:16:21 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org, Fabio Estevam Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski , Linus Walleij Subject: [PATCH 1/2] gpio: of: Handle the Freescale SPI CS Date: Sat, 20 Apr 2019 13:14:03 +0200 Message-Id: <20190420111404.6225-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 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 SPI chipselects are special: while everyone else is using "cs-gpios" the Freescale platforms just use "gpios". Fix this by responding with "gpios" when asking for "cs-gpios" in a freescale device node, so we hide this pecularity from the SPI core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Rebased on v5.1-rc1 This is a prerequisite for the Freescale patch to work and should be merged to the SPI tree along with the rest. --- drivers/gpio/gpiolib-of.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- 2.20.1 diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 8b9c3ab70f6e..a46ae1248501 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -254,6 +254,37 @@ static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id return desc; } +/* + * The old Freescale bindings use simply "gpios" as name for the chip select + * lines rather than "cs-gpios" like all other SPI hardware. Account for this + * with a special quirk. + */ +static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev, + const char *con_id, + unsigned int idx, + enum gpio_lookup_flags *flags) +{ + struct device_node *np = dev->of_node; + + if (!IS_ENABLED(CONFIG_SPI_MASTER)) + return ERR_PTR(-ENOENT); + + /* Allow this specifically for Freescale devices */ + if (!of_device_is_compatible(np, "fsl,spi") && + !of_device_is_compatible(np, "aeroflexgaisler,spictrl")) + return ERR_PTR(-ENOENT); + /* Allow only if asking for "cs-gpios" */ + if (!con_id || strcmp(con_id, "cs")) + return ERR_PTR(-ENOENT); + + /* + * While all other SPI controllers use "cs-gpios" the Freescale + * uses just "gpios" so translate to that when "cs-gpios" is + * requested. + */ + return of_find_gpio(dev, NULL, idx, flags); +} + /* * Some regulator bindings happened before we managed to establish that GPIO * properties should be named "foo-gpios" so we have this special kludge for @@ -326,6 +357,12 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, /* Special handling for SPI GPIOs if used */ if (IS_ERR(desc)) desc = of_find_spi_gpio(dev, con_id, &of_flags); + if (IS_ERR(desc)) { + /* This quirk looks up flags and all */ + desc = of_find_spi_cs_gpio(dev, con_id, idx, flags); + if (!IS_ERR(desc)) + return desc; + } /* Special handling for regulator GPIOs if used */ if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)