Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615AbcDRO5S (ORCPT ); Mon, 18 Apr 2016 10:57:18 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:64793 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbcDRO5P (ORCPT ); Mon, 18 Apr 2016 10:57:15 -0400 From: Arnd Bergmann To: "Reizer, Eyal" Cc: Kalle Valo , Eyal Reizer , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-spi@vger.kernel.org" Subject: Re: [PATCHv2] wlcore: spi: add wl18xx support Date: Mon, 18 Apr 2016 16:57:03 +0200 Message-ID: <1463330011.BhWEcYYuGD@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <8665E2433BC68541A24DFFCA87B70F5B360BF614@DFRE01.ent.ti.com> References: <1460273570-12298-1-git-send-email-eyalr@ti.com> <14313437.cDJIgY3kzo@wuerfel> <8665E2433BC68541A24DFFCA87B70F5B360BF614@DFRE01.ent.ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:hAuvDEgI8YXS42OC2WN8H2hnJ6B8YA7jxp47X/B/3gmu5jYim4j I3uLTsa1y42dYjLNx5t8x4HQz7D8TRX7Xsal06pKe+dcSDaPr8HgKTT19YpObW8VDXLLgA9 1I3bMpSjL6KFhuiqPFHQ73Y/dRdpNqXT9ttmg42DmQLY4z+3XQYiBDluG3aWM3nkviONOn6 cIUEy6loF2tRfa2IjuuEg== X-UI-Out-Filterresults: notjunk:1;V01:K0:MKE0pM1+vX0=:79/79h7Ieklg27Fl0UFzdz QHL29eeppn+Q+5SDjVt+H2BWTWLgprotv7AA25ltpfaEJo6ITaB55Yga+VcJHHp7tOgXMx1EU WsdU7ozAybX9zqLhrPGNuRRQEdJzvclg9WTs/RyVWPOlajA/Yqmd8u0aNe16OcscYrN9Bqgj/ ezDNzVXFFFM/leIaZ/sQB1ppOVECNIL0VFLjg+FxPR1WkL+5VQ+F3DR1bqIXEz+q11xxOIlQ5 5Bkhid9PuclYPjb1hbJ415jvbHlq4lcviPqjiHgFGRt7CzsNwfp78rr68p9UogdCYg9bv1lap bpmyP14FR1rwtT7gJcg25UGBQZWNmU0Um+T9tqqDtyDvB00ujd/YcEu2pKPnSOnKeX6YveWDF zig1DvY26IWiRrx3Gb5h0Mg4xWMjvKiUr/lzJzfdvzS6RTlVzUSNkUK+/Xvc8WwxHjlFVS8gw Ggo8OFrYhswJ3xkfErgKjKK5nUWLtbMZJDaHllUw/zhMIYP9htJbxXZ44htLSM/TWZGI4TfgM HIp4+9YHyCOpR48TKzBBsFZ5tQ1EqoVSiUDMLKddIM+RwrPxkX9VMdoZ8nzMU0a6n1+SUMyen Cc0269k84vJTVG+piuLE+88XSNOnP1pv0dgFzJApz5KWhuvNh5V8jWqKVvD/Z0OiXr3M4A9PS kv5u5BYPSASpaieIzm6mAft/GJo0DjW8cQWsxhMWiPtaHTPVUc2C8ZQG/uQzWapUDG79MWDd8 SYDXwHS8yJhWd0JU Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2242 Lines: 53 On Monday 18 April 2016 05:55:51 Reizer, Eyal wrote: > > > > > > - all wilink family needs special init command for entering wspi mode. > > > extra clock cycles should be sent after the spi init command while the > > > cs pin is high. > > > - switch to controling the cs pin from the spi driver for achieveing the > > > above. > > > - the selected cs gpio is read from the spi device-tree node using the > > > cs-gpios field and setup as a gpio. > > > - See the example below for specifying the cs gpio using the cs-gpios entry > > > &spi0 { > > > ... > > > cs-gpios = <&gpio0 5 0>; > > > ... > > > wlcore: wlcore@0 { > > > compatible = "ti,wl1835"; > > > ... > > > ... > > > }; > > > }; > > > > > > Signed-off-by: Eyal Reizer > > > > I don't think this can work in general: not all SPI hosts uses GPIOs for > > controlling CS, so the logic can't work, and it's also a layering violation for the > > driver to look at the parent. > > > > I would suggest fixing this using a new API function from the SPI core, if we > > don't already have a generic way to do it. > > > Originally this is what I have done until I was pointed to the generic cs-gpio mechanism > in the SPI core. > It is a generic mechanism already in the SPI core driver. > See: Documentation/devicetree/bindings/spi/spi-bus.txt The cs-gpios property is documented as optional, it defines how you should list the gpios if CS is implemented using gpio, but not all hardware does it like this. > It is also part of the generic spi.h (include/Linux/spi/spi.h), already part of > " struct spi_device" So it seemed redundant adding another mechanism for > implementing the same. > Platform that interact with a wilink need to use it, and platforms that don't > have this capability will probably not interact with a wilink device using SPI. The cs_gpio field in spi_device belongs to the spi host controller, no other slave driver uses it. I wasn't asking for a duplication of this mechanism, but an interface to use it properly. Internally, the spi core uses the spi_set_cs() function to pick a CS. Find a way to use that rather than reimplementing it incorrectly. Arnd