<div dir="ltr"><div class="gmail_extra">Hello,<br><br></div><div class="gmail_extra"><div class="gmail_quote">2013/3/26 Matthias Brugger <span dir="ltr"><<a href="mailto:matthias.bgg@gmail.com" target="_blank">matthias.bgg@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">TI omap2 mcspi allows the slave devices to configure the behavior of<br>
the SPI master. This patch adds device tree support to the existing<br>
options.<br>
<br>
Signed-off-by: Matthias Brugger <<a href="mailto:matthias.bgg@gmail.com">matthias.bgg@gmail.com</a>><br>
---<br></blockquote><div><br></div><div>Any comments on this patch?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 Documentation/devicetree/bindings/spi/omap-spi.txt | 23 ++++++++++++<br>
 drivers/spi/spi-omap2-mcspi.c                      | 41 ++++++++++++++++++++++<br>
 2 files changed, 64 insertions(+)<br>
<br>
diff --git a/Documentation/devicetree/bindings/spi/omap-spi.txt b/Documentation/devicetree/bindings/spi/omap-spi.txt<br>
index 938809c..fef16bf 100644<br>
--- a/Documentation/devicetree/bindings/spi/omap-spi.txt<br>
+++ b/Documentation/devicetree/bindings/spi/omap-spi.txt<br>
@@ -10,8 +10,20 @@ Required properties:<br>
                          input. The default is D0 as input and<br>
                          D1 as output.<br>
<br>
+SPI Controller specific data in SPI slave nodes:<br>
+<br>
+- The spi slave nodes can provide the following information which is used<br>
+  by the spi controller.<br>
+<br>
+- ti,spi-cs-per-word: Set chipselect to be toggled on every word send.<br>
+<br>
+- ti,spi-turbo-mode: Set turbo mode for this device.<br>
+<br>
+<br>
 Example:<br>
<br>
+- SoC Specific Portion:<br>
+<br>
 mcspi1: mcspi@1 {<br>
     #address-cells = <1>;<br>
     #size-cells = <0>;<br>
@@ -20,3 +32,14 @@ mcspi1: mcspi@1 {<br>
     ti,spi-num-cs = <4>;<br>
 };<br>
<br>
+- Board Specific Portion:<br>
+<br>
+       spi-device@0 {<br>
+               #address-cells = <1>;<br>
+               #size-cells = <1>;<br>
+<br>
+               controller-data {<br>
+                       ti,spi-cs-per-word = <1>;<br>
+                       ti,spi-turbo-mode = <0>;<br>
+               };<br>
+       };<br>
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c<br>
index 893c3d7..1ae5009 100644<br>
--- a/drivers/spi/spi-omap2-mcspi.c<br>
+++ b/drivers/spi/spi-omap2-mcspi.c<br>
@@ -731,11 +731,47 @@ static u32 omap2_mcspi_calc_divisor(u32 speed_hz)<br>
        return 15;<br>
 }<br>
<br>
+static struct omap2_mcspi_device_config *omap2_mcspi_get_slave_ctrldata(<br>
+                       struct spi_device *spi)<br>
+{<br>
+       struct omap2_mcspi_device_config *cd;<br>
+       struct device_node *slave_np, *data_np = NULL;<br>
+<br>
+       slave_np = spi->dev.of_node;<br>
+       if (!slave_np) {<br>
+               dev_err(&spi->dev, "device node not found\n");<br>
+               return ERR_PTR(-EINVAL);<br>
+       }<br>
+<br>
+       data_np = of_get_child_by_name(slave_np, "controller-data");<br>
+       if (!data_np) {<br>
+               dev_err(&spi->dev, "child node 'controller-data' not found\n");<br>
+               return ERR_PTR(-EINVAL);<br>
+       }<br>
+<br>
+       cd = kzalloc(sizeof(*cd), GFP_KERNEL);<br>
+       if (!cd) {<br>
+               dev_err(&spi->dev, "could not allocate memory for controller data\n");<br>
+               of_node_put(data_np);<br>
+               return ERR_PTR(-ENOMEM);<br>
+       }<br>
+<br>
+       if (of_get_property(data_np, "ti,spi-cs-per-word", NULL))<br>
+               cd->cs_per_word = 1;<br>
+<br>
+       if (of_get_property(data_np, "ti,spi-turbo-mode", NULL))<br>
+               cd->turbo_mode = 1;<br>
+<br>
+       of_node_put(data_np);<br>
+       return cd;<br>
+}<br>
+<br>
 /* called only when no transfer is active to this device */<br>
 static int omap2_mcspi_setup_transfer(struct spi_device *spi,<br>
                struct spi_transfer *t)<br>
 {<br>
        struct omap2_mcspi_cs *cs = spi->controller_state;<br>
+       struct omap2_mcspi_device_config *cd = spi->controller_data;<br>
        struct omap2_mcspi *mcspi;<br>
        struct spi_master *spi_cntrl;<br>
        u32 l = 0, div = 0;<br>
@@ -745,6 +781,11 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,<br>
        mcspi = spi_master_get_devdata(spi->master);<br>
        spi_cntrl = mcspi->master;<br>
<br>
+       if (!cd && spi->dev.of_node) {<br>
+               cd = omap2_mcspi_get_slave_ctrldata(spi);<br>
+               spi->controller_data = cd;<br>
+       }<br>
+<br>
        if (t != NULL && t->bits_per_word)<br>
                word_len = t->bits_per_word;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.7.11.7<br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>---<br><a href="http://motzblog.wordpress.com" target="_blank">motzblog.wordpress.com</a>
</div></div>