From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919AbcF0K5V (ORCPT ); Mon, 27 Jun 2016 06:57:21 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:51968 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbcF0K5T (ORCPT ); Mon, 27 Jun 2016 06:57:19 -0400 X-AuditID: cbfee68f-f79476d000001429-4b-5771068c8680 Date: Mon, 27 Jun 2016 19:57:16 +0900 From: Andi Shyti To: Mark Brown Cc: Andi Shyti , Kukjin Kim , Krzysztof Kozlowski , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/5] spi: do not fail if the CS line is not connected Message-id: <20160627105716.GA7240@samsunx.samsung> References: <1466150245-2648-1-git-send-email-andi.shyti@samsung.com> <1466150245-2648-2-git-send-email-andi.shyti@samsung.com> <20160617104725.GC26099@sirena.org.uk> <20160617113622.GA10760@jack.zhora.eu> <20160617122803.GN26099@sirena.org.uk> <20160619060902.GB424@jack.zhora.eu> <20160626124843.GP28202@sirena.org.uk> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline In-reply-to: <20160626124843.GP28202@sirena.org.uk> User-Agent: Mutt/1.6.0 (2016-04-01) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMIsWRmVeSWpSXmKPExsWyRsSkULeHrTDcYPUmLYvFP54zWUx9+ITN 4vULQ4v+x6+ZLTY9vsZqcXnXHDaLxo832R3YPa4v+cTssWlVJ5vH5iX1Hn1bVjF6fN4kF8Aa xWWTkpqTWZZapG+XwJXxfvZ79oI5MhXTlyxkbWC8I9rFyMkhIWAi8eveZXYIW0ziwr31bF2M XBxCAisYJZa9vc4GUzT58zsWiMRSRokXLyczQzgfGSVmTF4IVsUioCqxbddqVhCbTUBToun2 D7C4iICyxNXve8G6mQUuMUpcO7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0LSfcCRuZVjBKpBckFxUnpuYZ5qeV6xYm5xaV56XrJ+bmbGMGx/UxqB+PBXe6HGAU4 GJV4eBfYFoQLsSaWFVfmHmKU4GBWEuF9z1oYLsSbklhZlVqUH19UmpNafIjRFBgiE5mlRJPz gWknryTe0NjEzMjSyNzQwsjYXEmc9/H/dWFCAumJJanZqakFqUUwfUwcnFINjMt1V67VbJdY n3KhSZIzb9OqxbxCez05m5YmmZuIikVPzwkIvsG9OLhMTUetfcsV9WUmfewfgha/2sawIZFL Jvq0wbkgs1d7p7OvyDwpEhYndt+7NepW7cq4yRua619ns1rztgvWOS29tYnxQJ5JkQHjB6XH n2csnL7N8tw2v/RJWzS4+7KuKbEUZyQaajEXFScCAKVrCbUDAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, > > > > This is true, but there are cases where the CS is not connected > > > > and this case needs to be treated separately to allow the device > > > > to work. > > > > In what way? It is just as easy for a device with no physical chip > > > select to have a logical chip select of 0 that it does nothing with as > > > it is for that device to handle any other number. > > > That is indeed my case: the s3c64xx doesn't send anything, unless > > I manually enable CS (from the next patches I need to write '0' > > in the CS register). But I need smoething to tell to the > > device that the CS line is not connected, for example a flag in > > the DTS. > > I'm sorry but I just don't understand what you're saying here. You are > saying that there is no chip select but you need to enable the chip > select? yes, sorry, I have to admit that didn't explain myself properly, but code speaks better than words. What I meant is that if we do not like num-cs = <0>, the unlinked CS line can be handled only this way (case of the s3c64xx driver): diff --git a/Documentation/devicetree/bindings/spi/spi-samsung.txt b/Documentation/devicetree/bindings/spi/spi-samsung.txt index 6dbdeb3..62f19b6 100644 --- a/Documentation/devicetree/bindings/spi/spi-samsung.txt +++ b/Documentation/devicetree/bindings/spi/spi-samsung.txt @@ -40,6 +40,9 @@ Optional Board Specific Properties: - cs-gpios: should specify GPIOs used for chipselects (see spi-bus.txt) +- broken-cs: the CS line is disconnected, therefore the device should not wait + for the CS protocol to be established + SPI Controller specific data in SPI slave nodes: - The spi slave nodes should provide the following information which is required diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 972367d..5e6ad59 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -315,6 +315,9 @@ static void s3c64xx_spi_set_cs(struct spi_device *spi, bool enable) struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi->master); + if (sdd->cntrlr_info->broken_cs) + return; + if (enable) { if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) { writel(0, sdd->regs + S3C64XX_SPI_SLAVE_SEL); [ ... ] @@ -1015,6 +1020,8 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) sci->num_cs = temp; } + sci->broken_cs = of_property_read_bool(dev->of_node, "broken-cs"); + return sci; } #else diff --git a/include/linux/platform_data/spi-s3c64xx.h b/include/linux/platform_data/spi-s3c64xx.h index fb5625b..75793b9 100644 --- a/include/linux/platform_data/spi-s3c64xx.h +++ b/include/linux/platform_data/spi-s3c64xx.h @@ -38,6 +38,7 @@ struct s3c64xx_spi_csinfo { struct s3c64xx_spi_info { int src_clk_nr; int num_cs; + bool broken_cs; int (*cfg_gpio)(void); dma_filter_fn filter; void *dma_tx; Which is not something I like, because it means adding a new flag in the dts. What I want to suggest, instead, is to slightly change the logic behind the num-cs property: i.e. if "num-cs = <0>", doesn't necessarily mean that we don't have a CS controller, but, while we can have as many as we wish, non of them is connected. Looking around in the spi drivers, apparently I am not the only one who has this need, as I pointed out in my previous mail. Thanks a lot, Andi