public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sh: add spi header and r2d platform data
@ 2008-01-21 10:24 Magnus Damm
  2008-01-23  4:53 ` [PATCH] sh: add spi header and r2d platform data V2 Magnus Damm
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Magnus Damm @ 2008-01-21 10:24 UTC (permalink / raw)
  To: linux-sh

sh: add spi header and r2d platform data

This patch adds the header file asm/spi.h and board specific code for the
r2d board. The header file contains a structure that should be used to
describe a single spi bus. The board specific code for r2d is updated with
such a structure for the new spi_sh_sci driver. The structure contains a
chip select callback plus information about the R9701 rtc chip which is
attached to the spi bus.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 arch/sh/boards/renesas/rts7751r2d/setup.c |   42 +++++++++++++++++++++++++++++
 include/asm-sh/spi.h                      |   17 +++++++++++
 2 files changed, 59 insertions(+)

--- 0001/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ work/arch/sh/boards/renesas/rts7751r2d/setup.c	2008-01-21 10:51:17.000000000 +0900
@@ -16,9 +16,12 @@
 #include <linux/sm501-regs.h>
 #include <linux/pm.h>
 #include <linux/fb.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_bitbang.h>
 #include <asm/machvec.h>
 #include <asm/rts7751r2d.h>
 #include <asm/io.h>
+#include <asm/spi.h>
 
 static struct resource cf_ide_resources[] = {
 	[0] = {
@@ -53,6 +56,44 @@ static struct platform_device cf_ide_dev
 	},
 };
 
+static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
+{
+	BUG_ON(cs != 0);  /* Single Epson RTC-9701JE attached on CS0 */
+	ctrl_outw(state = BITBANG_CS_ACTIVE ? 1 : 0, PA_RTCCE);
+}
+
+static struct resource spi_sh_sci_resources[] = {
+	{
+		.start	= 0xffe00000,
+		.end	= 0xffe0001f,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct spi_board_info spi_board_info[] = {
+	{
+		.modalias	= "rtc-r9701",
+		.max_speed_hz	= 1000000,
+	},
+};
+
+static struct sh_spi_info spi_info = {
+	.num_chipselect = 1,
+	.chip_select = r2d_chip_select,
+	.board_info = spi_board_info,
+	.board_size = ARRAY_SIZE(spi_board_info),
+};
+
+static struct platform_device spi_sh_sci_device  = {
+	.name		= "spi_sh_sci",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(spi_sh_sci_resources),
+	.resource	= spi_sh_sci_resources,
+	.dev	= {
+		.platform_data	= &spi_info,
+	},
+};
+
 static struct resource heartbeat_resources[] = {
 	[0] = {
 		.start	= PA_OUTPORT,
@@ -176,6 +217,7 @@ static struct platform_device *rts7751r2
 #endif
 	&cf_ide_device,
 	&heartbeat_device,
+	&spi_sh_sci_device,
 };
 
 static int __init rts7751r2d_devices_setup(void)
--- /dev/null
+++ work/include/asm-sh/spi.h	2008-01-21 10:51:18.000000000 +0900
@@ -0,0 +1,17 @@
+#ifndef __ASM_SPI_H__
+#define __ASM_SPI_H__
+
+struct sh_spi_info;
+struct spi_board_info;
+
+struct sh_spi_info {
+	int			 bus_num;
+	int			 num_chipselect;
+
+	struct spi_board_info	*board_info;
+	unsigned long		 board_size;
+
+	void (*chip_select)(struct sh_spi_info *spi, int cs, int state);
+};
+
+#endif /* __ASM_SPI_H__ */

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-01-23  7:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 10:24 [PATCH] sh: add spi header and r2d platform data Magnus Damm
2008-01-23  4:53 ` [PATCH] sh: add spi header and r2d platform data V2 Magnus Damm
2008-01-23  5:25 ` Paul Mundt
2008-01-23  7:21 ` [PATCH] sh: add spi header and r2d platform data V3 Magnus Damm
2008-01-23  7:31 ` Paul Mundt
2008-01-23  7:38 ` Magnus Damm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox