Commit 6582d7b7376aa587d74b08c74457dc28abc1a9fa

Authored by Magnus Damm
Committed by Paul Mundt
1 parent da2d7f4bc5

sh: add spi header and r2d platform data V3

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
point out 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>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

Showing 2 changed files with 55 additions and 0 deletions Side-by-side Diff

arch/sh/boards/renesas/rts7751r2d/setup.c
... ... @@ -16,9 +16,12 @@
16 16 #include <linux/sm501-regs.h>
17 17 #include <linux/pm.h>
18 18 #include <linux/fb.h>
  19 +#include <linux/spi/spi.h>
  20 +#include <linux/spi/spi_bitbang.h>
19 21 #include <asm/machvec.h>
20 22 #include <asm/rts7751r2d.h>
21 23 #include <asm/io.h>
  24 +#include <asm/spi.h>
22 25  
23 26 static struct resource cf_ide_resources[] = {
24 27 [0] = {
... ... @@ -53,6 +56,43 @@
53 56 },
54 57 };
55 58  
  59 +static struct spi_board_info spi_bus[] = {
  60 + {
  61 + .modalias = "rtc-r9701",
  62 + .max_speed_hz = 1000000,
  63 + .mode = SPI_MODE_3,
  64 + },
  65 +};
  66 +
  67 +static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
  68 +{
  69 + BUG_ON(cs != 0); /* Single Epson RTC-9701JE attached on CS0 */
  70 + ctrl_outw(state == BITBANG_CS_ACTIVE, PA_RTCCE);
  71 +}
  72 +
  73 +static struct sh_spi_info spi_info = {
  74 + .num_chipselect = 1,
  75 + .chip_select = r2d_chip_select,
  76 +};
  77 +
  78 +static struct resource spi_sh_sci_resources[] = {
  79 + {
  80 + .start = 0xffe00000,
  81 + .end = 0xffe0001f,
  82 + .flags = IORESOURCE_MEM,
  83 + },
  84 +};
  85 +
  86 +static struct platform_device spi_sh_sci_device = {
  87 + .name = "spi_sh_sci",
  88 + .id = -1,
  89 + .num_resources = ARRAY_SIZE(spi_sh_sci_resources),
  90 + .resource = spi_sh_sci_resources,
  91 + .dev = {
  92 + .platform_data = &spi_info,
  93 + },
  94 +};
  95 +
56 96 static struct resource heartbeat_resources[] = {
57 97 [0] = {
58 98 .start = PA_OUTPORT,
59 99  
... ... @@ -176,10 +216,12 @@
176 216 #endif
177 217 &cf_ide_device,
178 218 &heartbeat_device,
  219 + &spi_sh_sci_device,
179 220 };
180 221  
181 222 static int __init rts7751r2d_devices_setup(void)
182 223 {
  224 + spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
183 225 return platform_add_devices(rts7751r2d_devices,
184 226 ARRAY_SIZE(rts7751r2d_devices));
185 227 }
include/asm-sh/spi.h
  1 +#ifndef __ASM_SPI_H__
  2 +#define __ASM_SPI_H__
  3 +
  4 +struct sh_spi_info;
  5 +
  6 +struct sh_spi_info {
  7 + int bus_num;
  8 + int num_chipselect;
  9 +
  10 + void (*chip_select)(struct sh_spi_info *spi, int cs, int state);
  11 +};
  12 +
  13 +#endif /* __ASM_SPI_H__ */