diff mbox

[2/6] Davinci: DM365: Adding support for SPI in DM365 SOC

Message ID 1247690314-1033-1-git-send-email-s-paulraj@ti.com (mailing list archive)
State Superseded
Headers show

Commit Message

s-paulraj@ti.com July 15, 2009, 8:38 p.m. UTC
From: Sandeep Paulraj <s-paulraj@ti.com>

The patch adds support for SPI in DM365 SOC.

Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
---
 arch/arm/mach-davinci/dm365.c              |   56 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/dm365.h |    3 +
 2 files changed, 59 insertions(+), 0 deletions(-)

Comments

Kevin Hilman July 16, 2009, 2:59 p.m. UTC | #1
s-paulraj@ti.com writes:

> From: Sandeep Paulraj <s-paulraj@ti.com>
>
> The patch adds support for SPI in DM365 SOC.
>
> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>

[...]

> +void __init dm365_init_spi0(unsigned chipselect_mask,
> +		struct spi_board_info *info, unsigned len)
> +{
> +	davinci_cfg_reg(DM365_SPI0_SCLK);
> +	davinci_cfg_reg(DM365_SPI0_SDI);
> +	davinci_cfg_reg(DM365_SPI0_SDO);
> +
> +	/* not all slaves will be wired up */
> +	if (chipselect_mask & BIT(0))
> +		davinci_cfg_reg(DM365_SPI0_SDENA0);
> +	if (chipselect_mask & BIT(1))
> +		davinci_cfg_reg(DM365_SPI0_SDENA1);
> +
> +	spi_register_board_info(info, len);
> +
> +	platform_device_register(&dm365_spi0_device);
> +}

If a board has something wired to something other than SPI0, how will
the board code communicate that it wants say SPI3 mux'd instead of
SPI0.

Kevin
s-paulraj@ti.com July 16, 2009, 3:12 p.m. UTC | #2
> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> Sent: Thursday, July 16, 2009 10:59 AM
> To: Paulraj, Sandeep
> Cc: davinci-linux-open-source@linux.davincidsp.com
> Subject: Re: [PATCH 2/6] Davinci: DM365: Adding support for SPI in DM365
> SOC
> 
> s-paulraj@ti.com writes:
> 
> > From: Sandeep Paulraj <s-paulraj@ti.com>
> >
> > The patch adds support for SPI in DM365 SOC.
> >
> > Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
> 
> [...]
> 
> > +void __init dm365_init_spi0(unsigned chipselect_mask,
> > +		struct spi_board_info *info, unsigned len)
> > +{
> > +	davinci_cfg_reg(DM365_SPI0_SCLK);
> > +	davinci_cfg_reg(DM365_SPI0_SDI);
> > +	davinci_cfg_reg(DM365_SPI0_SDO);
> > +
> > +	/* not all slaves will be wired up */
> > +	if (chipselect_mask & BIT(0))
> > +		davinci_cfg_reg(DM365_SPI0_SDENA0);
> > +	if (chipselect_mask & BIT(1))
> > +		davinci_cfg_reg(DM365_SPI0_SDENA1);
> > +
> > +	spi_register_board_info(info, len);
> > +
> > +	platform_device_register(&dm365_spi0_device);
> > +}
> 
> If a board has something wired to something other than SPI0, how will
> the board code communicate that it wants say SPI3 mux'd instead of
> SPI0.
[Sandeep] the way we are doing things at the moment, we will need a "dm365_init_spi3" in dm365.c along with the other structs/resources part of this patch.

This function (dm365_init_spi3) should then be called from board specific code.

> 
> Kevin
Kevin Hilman July 16, 2009, 3:28 p.m. UTC | #3
"Paulraj, Sandeep" <s-paulraj@ti.com> writes:

>> -----Original Message-----
>> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
>> Sent: Thursday, July 16, 2009 10:59 AM
>> To: Paulraj, Sandeep
>> Cc: davinci-linux-open-source@linux.davincidsp.com
>> Subject: Re: [PATCH 2/6] Davinci: DM365: Adding support for SPI in DM365
>> SOC
>> 
>> s-paulraj@ti.com writes:
>> 
>> > From: Sandeep Paulraj <s-paulraj@ti.com>
>> >
>> > The patch adds support for SPI in DM365 SOC.
>> >
>> > Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
>> 
>> [...]
>> 
>> > +void __init dm365_init_spi0(unsigned chipselect_mask,
>> > +		struct spi_board_info *info, unsigned len)
>> > +{
>> > +	davinci_cfg_reg(DM365_SPI0_SCLK);
>> > +	davinci_cfg_reg(DM365_SPI0_SDI);
>> > +	davinci_cfg_reg(DM365_SPI0_SDO);
>> > +
>> > +	/* not all slaves will be wired up */
>> > +	if (chipselect_mask & BIT(0))
>> > +		davinci_cfg_reg(DM365_SPI0_SDENA0);
>> > +	if (chipselect_mask & BIT(1))
>> > +		davinci_cfg_reg(DM365_SPI0_SDENA1);
>> > +
>> > +	spi_register_board_info(info, len);
>> > +
>> > +	platform_device_register(&dm365_spi0_device);
>> > +}
>> 
>> If a board has something wired to something other than SPI0, how will
>> the board code communicate that it wants say SPI3 mux'd instead of
>> SPI0.
> [Sandeep] the way we are doing things at the moment, we will need a "dm365_init_spi3" in dm365.c along with the other structs/resources part of this patch.
>
> This function (dm365_init_spi3) should then be called from board specific code.
>

ah, I see.  I didn't catch the zero at the end of this function name.

I think that's fine for now, but it might be worth considering
a general function so board code can request any SPI.

Kevin
s-paulraj@ti.com July 16, 2009, 3:31 p.m. UTC | #4
> -----Original Message-----
> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> Sent: Thursday, July 16, 2009 11:28 AM
> To: Paulraj, Sandeep
> Cc: davinci-linux-open-source@linux.davincidsp.com
> Subject: Re: [PATCH 2/6] Davinci: DM365: Adding support for SPI in DM365
> SOC
> 
> "Paulraj, Sandeep" <s-paulraj@ti.com> writes:
> 
> >> -----Original Message-----
> >> From: Kevin Hilman [mailto:khilman@deeprootsystems.com]
> >> Sent: Thursday, July 16, 2009 10:59 AM
> >> To: Paulraj, Sandeep
> >> Cc: davinci-linux-open-source@linux.davincidsp.com
> >> Subject: Re: [PATCH 2/6] Davinci: DM365: Adding support for SPI in
> DM365
> >> SOC
> >>
> >> s-paulraj@ti.com writes:
> >>
> >> > From: Sandeep Paulraj <s-paulraj@ti.com>
> >> >
> >> > The patch adds support for SPI in DM365 SOC.
> >> >
> >> > Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
> >>
> >> [...]
> >>
> >> > +void __init dm365_init_spi0(unsigned chipselect_mask,
> >> > +		struct spi_board_info *info, unsigned len)
> >> > +{
> >> > +	davinci_cfg_reg(DM365_SPI0_SCLK);
> >> > +	davinci_cfg_reg(DM365_SPI0_SDI);
> >> > +	davinci_cfg_reg(DM365_SPI0_SDO);
> >> > +
> >> > +	/* not all slaves will be wired up */
> >> > +	if (chipselect_mask & BIT(0))
> >> > +		davinci_cfg_reg(DM365_SPI0_SDENA0);
> >> > +	if (chipselect_mask & BIT(1))
> >> > +		davinci_cfg_reg(DM365_SPI0_SDENA1);
> >> > +
> >> > +	spi_register_board_info(info, len);
> >> > +
> >> > +	platform_device_register(&dm365_spi0_device);
> >> > +}
> >>
> >> If a board has something wired to something other than SPI0, how will
> >> the board code communicate that it wants say SPI3 mux'd instead of
> >> SPI0.
> > [Sandeep] the way we are doing things at the moment, we will need a
> "dm365_init_spi3" in dm365.c along with the other structs/resources part
> of this patch.
> >
> > This function (dm365_init_spi3) should then be called from board
> specific code.
> >
> 
> ah, I see.  I didn't catch the zero at the end of this function name.
> 
> I think that's fine for now, but it might be worth considering
> a general function so board code can request any SPI.
[Sandeep] Yes, I will need to do that along with provision for GPIOs as chip selects.
I removed that yesterday in my SPI driver patch.
> 
> Kevin
>
diff mbox

Patch

diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index f02bce8..d8fe0c7 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -19,6 +19,7 @@ 
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/gpio.h>
+#include <linux/spi/spi.h>
 
 #include <asm/mach/map.h>
 
@@ -32,6 +33,7 @@ 
 #include <mach/time.h>
 #include <mach/serial.h>
 #include <mach/common.h>
+#include <mach/spi.h>
 
 #include "clock.h"
 #include "mux.h"
@@ -597,6 +599,60 @@  INT_CFG(DM365,  INT_EMAC_MISCPULSE,  17,    1,    1,     false)
 #endif
 };
 
+static u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32);
+
+static struct davinci_spi_platform_data dm365_spi0_pdata = {
+	.version 	= SPI_VERSION_1,
+	.num_chipselect = 2,
+	.clk_internal	= 1,
+	.cs_hold	= 1,
+	.intr_level	= 0,
+	.poll_mode	= 1,
+	.c2tdelay	= 8,
+	.t2cdelay	= 8,
+};
+
+static struct resource dm365_spi0_resources[] = {
+	{
+		.start = 0x01c66000,
+		.end   = 0x01c667ff,
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.start = IRQ_DM365_SPIINT0_0,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device dm365_spi0_device = {
+	.name = "spi_davinci",
+	.id = 0,
+	.dev = {
+		.dma_mask = &dm365_spi0_dma_mask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+		.platform_data = &dm365_spi0_pdata,
+	},
+	.num_resources = ARRAY_SIZE(dm365_spi0_resources),
+	.resource = dm365_spi0_resources,
+};
+
+void __init dm365_init_spi0(unsigned chipselect_mask,
+		struct spi_board_info *info, unsigned len)
+{
+	davinci_cfg_reg(DM365_SPI0_SCLK);
+	davinci_cfg_reg(DM365_SPI0_SDI);
+	davinci_cfg_reg(DM365_SPI0_SDO);
+
+	/* not all slaves will be wired up */
+	if (chipselect_mask & BIT(0))
+		davinci_cfg_reg(DM365_SPI0_SDENA0);
+	if (chipselect_mask & BIT(1))
+		davinci_cfg_reg(DM365_SPI0_SDENA1);
+
+	spi_register_board_info(info, len);
+
+	platform_device_register(&dm365_spi0_device);
+}
 static struct emac_platform_data dm365_emac_pdata = {
 	.ctrl_reg_offset	= DM365_EMAC_CNTRL_OFFSET,
 	.ctrl_mod_reg_offset	= DM365_EMAC_CNTRL_MOD_OFFSET,
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h
index 09db434..61cfd30 100644
--- a/arch/arm/mach-davinci/include/mach/dm365.h
+++ b/arch/arm/mach-davinci/include/mach/dm365.h
@@ -25,5 +25,8 @@ 
 #define DM365_EMAC_CNTRL_RAM_SIZE	(0x2000)
 
 void __init dm365_init(void);
+struct spi_board_info;
+void dm365_init_spi0(unsigned chipselect_mask,
+		struct spi_board_info *info, unsigned len);
 
 #endif /* __ASM_ARCH_DM365_H */