Re: [PATCH - v2] spi: davinci: add OF support for the spi controller

2012-12-19 Thread Murali Karicheri
On 12/19/2012 08:18 AM, Grant Likely wrote:
> On Sat, 15 Dec 2012 00:27:58 +, Grant Likely  
> wrote:
>> On Tue, 11 Dec 2012 16:20:39 -0500, Murali Karicheri  
>> wrote:
>>> This adds OF support to DaVinci SPI controller to configure platform
>>> data through device bindings. Also replaces clk_enable() with
>>> of clk_prepare_enable() as well as clk_disable() with
>>> clk_disable_unprepare().
>>>
>>> Signed-off-by: Murali Karicheri
>>> Reviewed-by : Grant Likely
>> Applied, thanks.
>>
>> I did remove the OF_ALIAS_N property though. I know the COMPATIBLE one
>> uses it, but it is actually kind of redundant since it can also be
>> determined by counting the number of OF_ALIAS_* entries, and having the
>> _N one in there means extra work needs to be done to filter it out.
>>
>> Also, I had to add a #ifndef _LINUX_OF_PRIVATE_H wrapper around the
>> whole header file. This is needed for all header files to protect
>> against multiple includes.
> Ummm oops. I replied to the wrong email when applying another patch.
> Sorry for the noise.
>
> But I have applied your patch now. It will appear in linux-next after
> the merge window closes.
>
> g.
>
>
Grant,

Thanks for taking care of this.

Murali

--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH - v2] spi: davinci: add OF support for the spi controller

2012-12-19 Thread Grant Likely
On Sat, 15 Dec 2012 00:27:58 +, Grant Likely  
wrote:
> On Tue, 11 Dec 2012 16:20:39 -0500, Murali Karicheri  
> wrote:
> > This adds OF support to DaVinci SPI controller to configure platform
> > data through device bindings. Also replaces clk_enable() with
> > of clk_prepare_enable() as well as clk_disable() with
> > clk_disable_unprepare().
> > 
> > Signed-off-by: Murali Karicheri 
> > Reviewed-by : Grant Likely 
> 
> Applied, thanks.
> 
> I did remove the OF_ALIAS_N property though. I know the COMPATIBLE one
> uses it, but it is actually kind of redundant since it can also be
> determined by counting the number of OF_ALIAS_* entries, and having the
> _N one in there means extra work needs to be done to filter it out.
> 
> Also, I had to add a #ifndef _LINUX_OF_PRIVATE_H wrapper around the
> whole header file. This is needed for all header files to protect
> against multiple includes.

Ummm oops. I replied to the wrong email when applying another patch.
Sorry for the noise.

But I have applied your patch now. It will appear in linux-next after
the merge window closes.

g.


--
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH - v2] spi: davinci: add OF support for the spi controller

2012-12-14 Thread Grant Likely
On Tue, 11 Dec 2012 16:20:39 -0500, Murali Karicheri  
wrote:
> This adds OF support to DaVinci SPI controller to configure platform
> data through device bindings. Also replaces clk_enable() with
> of clk_prepare_enable() as well as clk_disable() with
> clk_disable_unprepare().
> 
> Signed-off-by: Murali Karicheri 
> Reviewed-by : Grant Likely 

Applied, thanks.

I did remove the OF_ALIAS_N property though. I know the COMPATIBLE one
uses it, but it is actually kind of redundant since it can also be
determined by counting the number of OF_ALIAS_* entries, and having the
_N one in there means extra work needs to be done to filter it out.

Also, I had to add a #ifndef _LINUX_OF_PRIVATE_H wrapper around the
whole header file. This is needed for all header files to protect
against multiple includes.

g.

> ---
>  - Change log
>  - v2 - changed the compatibility strings to include soc name
>   -  changed ti,davinci-num-cs to num-cs
>v1 - removed attribute for spi version. instead, compatibility string is
>  modified to include version info.
>   - pdata ptr in davinci_spi_platform_data is replaced with struct itself.
>   - spi_davinci_get_pdata() now populates the pdata in the above structure
>  with parsed values from DT bindings.
>   - rebased to v3.7 rc7 of linux-next
>   - replaces clk_* APIs with their prepare/unprepare version
>  .../devicetree/bindings/spi/spi-davinci.txt|   51 ++
>  drivers/spi/spi-davinci.c  |  102 
> +---
>  2 files changed, 139 insertions(+), 14 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/spi/spi-davinci.txt
> 
> diff --git a/Documentation/devicetree/bindings/spi/spi-davinci.txt 
> b/Documentation/devicetree/bindings/spi/spi-davinci.txt
> new file mode 100644
> index 000..8cb3fee
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/spi/spi-davinci.txt
> @@ -0,0 +1,51 @@
> +Davinci SPI controller device bindings
> +
> +Required properties:
> +- #address-cells: number of cells required to define a chip select
> + address on the SPI bus. Should be set to 1.
> +- #size-cells: should be zero.
> +- compatible:
> + - "ti,dm644x-spi" for SPI used similar to that on DM644x SoC family
> + - "ti,da8xx-spi" for SPI used similar to that on DA8xx SoC family
> +- reg: Offset and length of SPI controller register space
> +- num-cs: Number of chip selects
> +- ti,davinci-spi-intr-line: interrupt line used to connect the SPI
> + IP to the interrupt controller withn the SoC. Possible values
> + are 0 and 1. Manual says one of the two possible interrupt
> + lines can be tied to the interrupt controller. Set this
> + based on a specifc SoC configuration.
> +- interrupts: interrupt number offset at the irq parent
> +- clocks: spi clk phandle
> +
> +Example of a NOR flash slave device (n25q032) connected to DaVinci
> +SPI controller device over the SPI bus.
> +
> +spi0:spi@20BF {
> + #address-cells  = <1>;
> + #size-cells = <0>;
> + compatible  = "ti,dm644x-spi";
> + reg = <0x20BF 0x1000>;
> + num-cs  = <4>;
> + ti,davinci-spi-intr-line= <0>;
> + interrupts  = <338>;
> + clocks  = <&clkspi>;
> +
> + flash: n25q032@0 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "st,m25p32";
> + spi-max-frequency = <2500>;
> + reg = <0>;
> +
> + partition@0 {
> + label = "u-boot-spl";
> + reg = <0x0 0x8>;
> + read-only;
> + };
> +
> + partition@1 {
> + label = "test";
> + reg = <0x8 0x38>;
> + };
> + };
> +};
> diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
> index 147dfa8..e5d8489 100644
> --- a/drivers/spi/spi-davinci.c
> +++ b/drivers/spi/spi-davinci.c
> @@ -28,6 +28,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -135,7 +137,7 @@ struct davinci_spi {
>   int dma_rx_chnum;
>   int dma_tx_chnum;
>  
> - struct davinci_spi_platform_data *pdata;
> + struct davinci_spi_platform_data pdata;
>  
>   void(*get_rx)(u32 rx_data, struct davinci_spi *);
>   u32 (*get_tx)(struct davinci_spi *);
> @@ -213,7 +215,7 @@ static void davinci_spi_chipselect(struct spi_device 
> *spi, int value)
>   bool gpio_chipsel = false;
>  
>   dspi = spi_master_get_devdata(spi->master);
> - pdata = dspi->pdata;
> + pdata = &dspi->pdata;
>  
>   if (pdata->chip_sel && chip_sel < pdata->num_chipselect &&
>   pdata->chip

[PATCH - v2] spi: davinci: add OF support for the spi controller

2012-12-11 Thread Murali Karicheri
This adds OF support to DaVinci SPI controller to configure platform
data through device bindings. Also replaces clk_enable() with
of clk_prepare_enable() as well as clk_disable() with
clk_disable_unprepare().

Signed-off-by: Murali Karicheri 
Reviewed-by : Grant Likely 
---
 - Change log
 - v2 - changed the compatibility strings to include soc name
  -  changed ti,davinci-num-cs to num-cs
   v1 - removed attribute for spi version. instead, compatibility string is
 modified to include version info.
  - pdata ptr in davinci_spi_platform_data is replaced with struct itself.
  - spi_davinci_get_pdata() now populates the pdata in the above structure
 with parsed values from DT bindings.
  - rebased to v3.7 rc7 of linux-next
  - replaces clk_* APIs with their prepare/unprepare version
 .../devicetree/bindings/spi/spi-davinci.txt|   51 ++
 drivers/spi/spi-davinci.c  |  102 +---
 2 files changed, 139 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-davinci.txt

diff --git a/Documentation/devicetree/bindings/spi/spi-davinci.txt 
b/Documentation/devicetree/bindings/spi/spi-davinci.txt
new file mode 100644
index 000..8cb3fee
--- /dev/null
+++ b/Documentation/devicetree/bindings/spi/spi-davinci.txt
@@ -0,0 +1,51 @@
+Davinci SPI controller device bindings
+
+Required properties:
+- #address-cells: number of cells required to define a chip select
+   address on the SPI bus. Should be set to 1.
+- #size-cells: should be zero.
+- compatible:
+   - "ti,dm644x-spi" for SPI used similar to that on DM644x SoC family
+   - "ti,da8xx-spi" for SPI used similar to that on DA8xx SoC family
+- reg: Offset and length of SPI controller register space
+- num-cs: Number of chip selects
+- ti,davinci-spi-intr-line: interrupt line used to connect the SPI
+   IP to the interrupt controller withn the SoC. Possible values
+   are 0 and 1. Manual says one of the two possible interrupt
+   lines can be tied to the interrupt controller. Set this
+   based on a specifc SoC configuration.
+- interrupts: interrupt number offset at the irq parent
+- clocks: spi clk phandle
+
+Example of a NOR flash slave device (n25q032) connected to DaVinci
+SPI controller device over the SPI bus.
+
+spi0:spi@20BF {
+   #address-cells  = <1>;
+   #size-cells = <0>;
+   compatible  = "ti,dm644x-spi";
+   reg = <0x20BF 0x1000>;
+   num-cs  = <4>;
+   ti,davinci-spi-intr-line= <0>;
+   interrupts  = <338>;
+   clocks  = <&clkspi>;
+
+   flash: n25q032@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "st,m25p32";
+   spi-max-frequency = <2500>;
+   reg = <0>;
+
+   partition@0 {
+   label = "u-boot-spl";
+   reg = <0x0 0x8>;
+   read-only;
+   };
+
+   partition@1 {
+   label = "test";
+   reg = <0x8 0x38>;
+   };
+   };
+};
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 147dfa8..e5d8489 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -135,7 +137,7 @@ struct davinci_spi {
int dma_rx_chnum;
int dma_tx_chnum;
 
-   struct davinci_spi_platform_data *pdata;
+   struct davinci_spi_platform_data pdata;
 
void(*get_rx)(u32 rx_data, struct davinci_spi *);
u32 (*get_tx)(struct davinci_spi *);
@@ -213,7 +215,7 @@ static void davinci_spi_chipselect(struct spi_device *spi, 
int value)
bool gpio_chipsel = false;
 
dspi = spi_master_get_devdata(spi->master);
-   pdata = dspi->pdata;
+   pdata = &dspi->pdata;
 
if (pdata->chip_sel && chip_sel < pdata->num_chipselect &&
pdata->chip_sel[chip_sel] != SPI_INTERN_CS)
@@ -392,7 +394,7 @@ static int davinci_spi_setup(struct spi_device *spi)
struct davinci_spi_platform_data *pdata;
 
dspi = spi_master_get_devdata(spi->master);
-   pdata = dspi->pdata;
+   pdata = &dspi->pdata;
 
/* if bits per word length is zero then set it default 8 */
if (!spi->bits_per_word)
@@ -534,7 +536,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct 
spi_transfer *t)
struct scatterlist sg_rx, sg_tx;
 
dspi = spi_master_get_devdata(spi->master);
-   pdata = dspi->pdata;
+   pdata = &dspi->pdata;
spicfg = (struct davinci_spi_config *)s