From patchwork Mon Nov 3 16:17:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torsten Fleischer X-Patchwork-Id: 5218051 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B71809F349 for ; Mon, 3 Nov 2014 16:18:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D77642015A for ; Mon, 3 Nov 2014 16:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFA1920121 for ; Mon, 3 Nov 2014 16:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752288AbaKCQSJ (ORCPT ); Mon, 3 Nov 2014 11:18:09 -0500 Received: from mail-la0-f49.google.com ([209.85.215.49]:58836 "EHLO mail-la0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbaKCQSH (ORCPT ); Mon, 3 Nov 2014 11:18:07 -0500 Received: by mail-la0-f49.google.com with SMTP id ge10so9624872lab.22 for ; Mon, 03 Nov 2014 08:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Rq8Bf5miwZ0jNuOPGhe+RBqm/Xrp6sykNOzhwZDDRo4=; b=ypKDI1xWupxuu/lWl5hvqfjoaD9xtoMfOWd9W3Biv+c72taYF3wVQ9ra5XsbBM2F/Q R4nHUvOopKODWJlduu3jgmK7z88mfIwCh5c9Ou5IJ+2GId+KKKc9H9jQIeN3QDZjjFzQ kq+6f+gRU/ATyBb4URF9qh6cI/k3MzwN83US9cIlDx9QbT+/sXczSIbDChAIG8ntq8V5 ekRrOPiIh8OeOqb4dsPjVa9LKbqv50Cv1FYxZHyMApsnkHof5uXqAPBkLV1Fr4/nM6WW NgFVIogOGQAHLozSQIxSj6SJZaFsrxyOF54G9pw7yfF6SBhldggiShG2lK5JvmhY+AhB Fc8w== X-Received: by 10.112.142.200 with SMTP id ry8mr52509477lbb.26.1415031485555; Mon, 03 Nov 2014 08:18:05 -0800 (PST) Received: from linux-1fbo.site.Speedport_W723_V_Typ_A_1_01_009 (p5798BAAB.dip0.t-ipconnect.de. [87.152.186.171]) by mx.google.com with ESMTPSA id g2sm180973lbd.35.2014.11.03.08.18.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Nov 2014 08:18:04 -0800 (PST) From: Torsten Fleischer X-Google-Original-From: Torsten Fleischer To: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Brown , devicetree@vger.kernel.org Cc: Torsten Fleischer Subject: [PATCH v2 1/1] spi: spi-gpio: Add dt support for a single device with no chip select Date: Mon, 3 Nov 2014 17:17:55 +0100 Message-Id: <1415031475-2268-1-git-send-email-torfl6749@gmail.com> X-Mailer: git-send-email 1.8.4.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Torsten Fleischer In order to describe a single slave device that has no chip select line the 'num-chipselects' property has to be <0> and the 'cs-gpios' property doesn't need to be set. Signed-off-by: Torsten Fleischer --- Documentation/devicetree/bindings/spi/spi-gpio.txt | 6 ++++-- drivers/spi/spi-gpio.c | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/spi-gpio.txt b/Documentation/devicetree/bindings/spi/spi-gpio.txt index 8a824be..a95603b 100644 --- a/Documentation/devicetree/bindings/spi/spi-gpio.txt +++ b/Documentation/devicetree/bindings/spi/spi-gpio.txt @@ -8,8 +8,10 @@ Required properties: - gpio-sck: GPIO spec for the SCK line to use - gpio-miso: GPIO spec for the MISO line to use - gpio-mosi: GPIO spec for the MOSI line to use - - cs-gpios: GPIOs to use for chipselect lines - - num-chipselects: number of chipselect lines + - cs-gpios: GPIOs to use for chipselect lines. + Not needed if num-chipselects = <0>. + - num-chipselects: Number of chipselect lines. Should be <0> if a single device + with no chip select is connected. Example: diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index 9f59553..f0492c9 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c @@ -413,6 +413,7 @@ static int spi_gpio_probe(struct platform_device *pdev) struct spi_gpio_platform_data *pdata; u16 master_flags = 0; bool use_of = 0; + int num_devices; status = spi_gpio_probe_dt(pdev); if (status < 0) @@ -422,16 +423,21 @@ static int spi_gpio_probe(struct platform_device *pdev) pdata = dev_get_platdata(&pdev->dev); #ifdef GENERIC_BITBANG - if (!pdata || !pdata->num_chipselect) + if (!pdata || (!use_of && !pdata->num_chipselect)) return -ENODEV; #endif + if (use_of && !SPI_N_CHIPSEL) + num_devices = 1; + else + num_devices = SPI_N_CHIPSEL; + status = spi_gpio_request(pdata, dev_name(&pdev->dev), &master_flags); if (status < 0) return status; master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio) + - (sizeof(int) * SPI_N_CHIPSEL)); + (sizeof(int) * num_devices)); if (!master) { status = -ENOMEM; goto gpio_free; @@ -446,7 +452,7 @@ static int spi_gpio_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); master->flags = master_flags; master->bus_num = pdev->id; - master->num_chipselect = SPI_N_CHIPSEL; + master->num_chipselect = num_devices; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup; #ifdef CONFIG_OF @@ -461,9 +467,12 @@ static int spi_gpio_probe(struct platform_device *pdev) * property of the node. */ - for (i = 0; i < SPI_N_CHIPSEL; i++) - spi_gpio->cs_gpios[i] = - of_get_named_gpio(np, "cs-gpios", i); + if (!SPI_N_CHIPSEL) + spi_gpio->cs_gpios[0] = SPI_GPIO_NO_CHIPSELECT; + else + for (i = 0; i < SPI_N_CHIPSEL; i++) + spi_gpio->cs_gpios[i] = + of_get_named_gpio(np, "cs-gpios", i); } #endif