flm01/mote/v2/openwrt/patches/100.spi_gpio_support.patch

91 lines
2.3 KiB
Diff

--- openwrt/10.03/build_dir/linux-atheros/linux-2.6.30.10/arch/mips/ar231x/ar2315.c 2010-06-12 13:10:09.887070347 +0200
+++ openwrt/10.03/build_dir/linux-atheros/linux-2.6.30.10/arch/mips/ar231x/ar2315.c 2010-07-19 21:51:56.000000000 +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 2
+#define SPI_GPIO_MISO 1
+
+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 = 10000000, /* 10kHz */
+ .bus_num = 0,
+},
+};
+
+
#define SPI_FLASH_CTL 0x00
#define SPI_FLASH_OPCODE 0x04
#define SPI_FLASH_DATA 0x08
@@ -519,7 +555,7 @@
led++;
}
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 +566,8 @@
int __init
ar2315_init_devices(void)
{
+ int ret;
+
if (!is_2315())
return 0;
@@ -537,13 +575,19 @@
ar231x_find_config(ar2315_flash_limit());
ar2315_eth_data.macaddr = ar231x_board.config->enet0_mac;
- ar2315_init_gpio();
+ // ar2315_init_gpio();
platform_device_register(&ar2315_wdt);
platform_device_register(&ar2315_spiflash);
ar231x_add_ethernet(0, AR2315_ENET0, AR2315_IRQ_ENET0_INTRS,
&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;
}