flm01/mote/v2/openwrt/patches/400-spi_gpio_support.patch

83 lines
2.0 KiB
Diff

--- a/arch/mips/ar231x/ar2315.c 2010-08-07 10:15:11.696355750 +0200
+++ b/arch/mips/ar231x/ar2315.c 2010-08-07 10:33:47.588393782 +0200
@@ -36,6 +36,11 @@
#include "devices.h"
#include "ar2315.h"
+/* BVDM 04/06/2010 */
+#include <linux/spi/spi.h>
+#include <linux/spi/spidev.h>
+#include <linux/spi/spi_gpio.h>
+
static u32 gpiointmask = 0, gpiointval = 0;
static inline void ar2315_gpio_irq(void)
@@ -398,6 +403,37 @@
.name = "ar2315_wdt",
};
+/* BVDM 04/06/2010 */
+#define SPI_GPIO_SCK 3
+#define SPI_GPIO_MOSI 1
+#define SPI_GPIO_MISO 2
+
+static struct spi_gpio_platform_data ar2315_spi_gpio_platform_data = {
+ .sck = SPI_GPIO_SCK,
+ .mosi = SPI_GPIO_MOSI,
+ .miso = SPI_GPIO_MISO,
+ .num_chipselect = 1,
+};
+
+static struct platform_device ar2315_spi_gpio = {
+ .name = "spi_gpio",
+ .id = 0,
+ .dev = {
+ .platform_data = &ar2315_spi_gpio_platform_data,
+ },
+};
+
+static struct spi_board_info ar2315_spi_gpio_board_info[] __initdata = {
+{
+ .modalias = "spidev",
+ .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT,
+ .mode = SPI_MODE_0,
+ .max_speed_hz = 1000000, /* 1Mhz max, but the bitbanged spi doesn't clock faster than 572kHz */
+ .bus_num = 0,
+},
+};
+
+
#define SPI_FLASH_CTL 0x00
#define SPI_FLASH_OPCODE 0x04
#define SPI_FLASH_DATA 0x08
@@ -520,6 +556,7 @@
}
ar2315_led_data.num_leds = led;
platform_device_register(&ar2315_gpio_leds);
+ platform_device_register(&ar2315_spi_gpio);
}
#else
static inline void ar2315_init_gpio(void)
@@ -530,6 +567,8 @@
int __init
ar2315_init_devices(void)
{
+ int ret;
+
if (!is_2315())
return 0;
@@ -544,6 +583,12 @@
&ar2315_eth_data);
ar231x_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
+ /* BVDM 04/06/2010 */
+ platform_device_register(&ar2315_spi_gpio);
+ ret = spi_register_board_info(ar2315_spi_gpio_board_info, ARRAY_SIZE(ar2315_spi_gpio_board_info));
+ /* debugging */
+ printk(KERN_DEBUG "spi_register_board_info return value: %x\n", ret);
+
return 0;
}