From patchwork Tue May 28 14:05:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Renner X-Patchwork-Id: 2625101 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id B4510DFB78 for ; Tue, 28 May 2013 14:18:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UhKja-0002UB-Nu; Tue, 28 May 2013 14:18:42 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UhKjZ-0002U4-RH for spi-devel-general@lists.sourceforge.net; Tue, 28 May 2013 14:18:41 +0000 X-ACL-Warn: Received: from moutng.kundenserver.de ([212.227.126.186]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1UhKjV-0005Sy-SS for spi-devel-general@lists.sourceforge.net; Tue, 28 May 2013 14:18:41 +0000 Received: from [192.168.0.18] (dslb-178-004-229-189.pools.arcor-ip.net [178.4.229.189]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LvzHJ-1UMa2q3NJV-017d6J; Tue, 28 May 2013 16:05:37 +0200 Message-ID: <51A4B9B5.6010203@efe-gmbh.de> Date: Tue, 28 May 2013 16:05:41 +0200 From: "Jens Renner (EFE)" Organization: EFE GmbH User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: spi-devel-general@lists.sourceforge.net Subject: [v2] spi: spi-xilinx: Use DT information for bits_per_word value X-Enigmail-Version: 1.5.1 X-Provags-ID: V02:K0:qRGkErXimzRAi2rpIYyf+DYTVJmDgrG7Wj3+353kDAH MknFmUSlLQD/3Gve34YmhJq+7x0QZD5Ipw4QfJsxlHaWB6Kyfv FHcb8joN362UWsSUMQgTs3ZdBIuVNqqbsrn4vj4SPwZIM6Q5Gj k+KV77CUW7gbLozUoksh8P0B1ely+nYLecwCfjZh/5oKzWwqEN KK82pLRfvZIDKSmzMhFTCj/KQt1nPqyRovIXtyeF4FVeUusILj pGcS+eimW6R0kzOkUwAHhxC2txkdEmuFCFTL1AXRcuKDZQDCPY uO+UTIV8D4oK/r4hoXLG5L5K3lHpQwKbP0KHTKbFon02dwKROM fb8PHr/0Vf84xoBY5jGI= X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.186 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1UhKjV-0005Sy-SS X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net This patch overrides the default value of bits_per_word with the actual value of "xlnx,num-transfer-bits" from the DTS file to allow for 16 and 32 bit word lengths. In case of a non-existing entry this will be ignored. Signed-off-by: Jens Renner --- Changes in v2: - use of_property_read_u32() instead of of_get_property() - added some documentation - original patch v1 #2124911 Grant Likely - March 2, 2013, 9:22 p.m. On Mon, 11 Feb 2013 17:28:01 +0100, "Jens Renner (EFE)" wrote: > From: Jens Renner > > This patch overrides the default value of bits_per_word with the actual value > of "xlnx,num-transfer-bits" from the DTS file to allow for 16 and 32 bit word > lengths. > > Signed-off-by: Jens Renner > --- > diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c > index e1d7696..03abdfa 100644 > --- a/drivers/spi/spi-xilinx.c > +++ b/drivers/spi/spi-xilinx.c > @@ -487,6 +487,12 @@ static int xilinx_spi_probe(struct platform_device *dev) > &len); > if (prop && len >= sizeof(*prop)) > num_cs = __be32_to_cpup(prop); > + > + /* override default number of bits per word */ > + prop = of_get_property(dev->dev.of_node, > + "xlnx,num-transfer-bits", &len); > + if (prop && len >= sizeof(*prop)) > + bits_per_word = __be32_to_cpup(prop); Hi Jens, Please remember to update documentation when modifying a DT binding. Also, if you use of_property_read_u32() the code will be a lot simpler. g. drivers/spi/spi-xilinx.c | 13 ++++++------- Documentation/devicetree/bindings/spi/spi-xilinx.txt | 32 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index e1d7696..6859833 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -479,14 +479,13 @@ static int xilinx_spi_probe(struct platform_device *dev) #ifdef CONFIG_OF if (dev->dev.of_node) { - const __be32 *prop; - int len; - /* number of slave select bits is required */ - prop = of_get_property(dev->dev.of_node, "xlnx,num-ss-bits", - &len); - if (prop && len >= sizeof(*prop)) - num_cs = __be32_to_cpup(prop); + of_property_read_u32(dev->dev.of_node, "xlnx,num-ss-bits", + &num_cs); + + /* override default number of bits per word */ + of_property_read_u32(dev->dev.of_node, "xlnx,num-transfer-bits", + &bits_per_word); } #endif diff --git a/Documentation/devicetree/bindings/spi/spi-xilinx.txt b/Documentation/devicetree/bindings/spi/spi-xilinx.txt new file mode 100644 index 0000000..768a1ea --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi-xilinx.txt @@ -0,0 +1,32 @@ +Xilinx SPI controller: + +Required properties: +- compatible : Must be "xlnx,axi-1.02.a" or "xlnx,xps-spi-2.00.a" +- interrupt-parent : reference to parent interrupt controller +- interrupts : SPI controller interrupt +- reg : SPI register location and length + +Optional properties: +- xlnx,num-ss-bits : # of slave select bits +- xlnx,num-transfer_bits : # of data transfer bits (defaults to 8) +- xlnx,... : not considered by kernel module +- #address-cells = <1> : if child nodes are defined +- #size-cells = <0> : if child nodes are defined +- Child nodes conforming to SPI bus binding + +Example with 3 slave select bits and 32 bit transfer size: + + axi_spi_0: spi@40a00000 { + compatible = "xlnx,axi-spi-1.02.a", "xlnx,xps-spi-2.00.a"; + interrupt-parent = <&axi_intc_0>; + interrupts = < 2 2 >; + reg = < 0x40a00000 0x10000 >; + xlnx,family = "spartan6"; + xlnx,fifo-exist = <0x1>; + xlnx,instance = "axi_spi_0"; + xlnx,num-ss-bits = <0x3>; + xlnx,num-transfer-bits = <0x20>; + xlnx,sck-ratio = <0x4>; + #address-cells = <1>; + #size-cells = <0>; + } ;