4cdfc199dbd03db899597123d4d600317b90759a
[openwrt/svn-archive/archive.git] / target / linux / lantiq / files-3.3 / arch / mips / lantiq / falcon / mach-easy98020.c
1 #include <linux/init.h>
2 #include <linux/platform_device.h>
3 #include <linux/leds.h>
4 #include <linux/gpio.h>
5 #include <linux/gpio_buttons.h>
6 #include <linux/mtd/mtd.h>
7 #include <linux/mtd/partitions.h>
8 #include <linux/input.h>
9 #include <linux/interrupt.h>
10 #include <linux/spi/spi.h>
11 #include <linux/spi/flash.h>
12
13 #include <dev-gpio-leds.h>
14
15 #include "../machtypes.h"
16 #include "devices.h"
17
18 #define EASY98020_GPIO_LED_0 9
19 #define EASY98020_GPIO_LED_1 10
20 #define EASY98020_GPIO_LED_2 11
21 #define EASY98020_GPIO_LED_3 12
22 #define EASY98020_GPIO_LED_GE0_ACT 110
23 #define EASY98020_GPIO_LED_GE0_LINK 109
24 #define EASY98020_GPIO_LED_GE1_ACT 106
25 #define EASY98020_GPIO_LED_GE1_LINK 105
26
27 static struct mtd_partition easy98020_spi_partitions[] =
28 {
29 {
30 .name = "uboot",
31 .offset = 0x0,
32 .size = 0x40000,
33 },
34 {
35 .name = "uboot_env",
36 .offset = 0x40000,
37 .size = 0x40000, /* 2 sectors for redundant env. */
38 },
39 {
40 .name = "linux",
41 .offset = 0x80000,
42 .size = 0xF80000, /* map only 16 MiB */
43 },
44 };
45
46 static struct flash_platform_data easy98020_spi_flash_platform_data = {
47 .name = "sflash",
48 .parts = easy98020_spi_partitions,
49 .nr_parts = ARRAY_SIZE(easy98020_spi_partitions)
50 };
51
52 static struct spi_board_info easy98020_spi_flash_data __initdata = {
53 .modalias = "m25p80",
54 .bus_num = 0,
55 .chip_select = 0,
56 .max_speed_hz = 10 * 1000 * 1000,
57 .mode = SPI_MODE_3,
58 .platform_data = &easy98020_spi_flash_platform_data
59 };
60
61 static struct gpio_led easy98020_gpio_leds[] __initdata = {
62 {
63 .name = "easy98020:green:0",
64 .gpio = EASY98020_GPIO_LED_0,
65 .active_low = 0,
66 }, {
67 .name = "easy98020:green:1",
68 .gpio = EASY98020_GPIO_LED_1,
69 .active_low = 0,
70 }, {
71 .name = "easy98020:green:2",
72 .gpio = EASY98020_GPIO_LED_2,
73 .active_low = 0,
74 }, {
75 .name = "easy98020:green:3",
76 .gpio = EASY98020_GPIO_LED_3,
77 .active_low = 0,
78 }, {
79 .name = "easy98020:ge0_act",
80 .gpio = EASY98020_GPIO_LED_GE0_ACT,
81 .active_low = 0,
82 }, {
83 .name = "easy98020:ge0_link",
84 .gpio = EASY98020_GPIO_LED_GE0_LINK,
85 .active_low = 0,
86 }, {
87 .name = "easy98020:ge1_act",
88 .gpio = EASY98020_GPIO_LED_GE1_ACT,
89 .active_low = 0,
90 }, {
91 .name = "easy98020:ge1_link",
92 .gpio = EASY98020_GPIO_LED_GE1_LINK,
93 .active_low = 0,
94 }
95 };
96
97 static void __init easy98020_init(void)
98 {
99 falcon_register_i2c();
100 falcon_register_spi_flash(&easy98020_spi_flash_data);
101 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(easy98020_gpio_leds),
102 easy98020_gpio_leds);
103 }
104
105 MIPS_MACHINE(LANTIQ_MACH_EASY98020,
106 "EASY98020",
107 "EASY98020 Eval Board",
108 easy98020_init);
109
110 MIPS_MACHINE(LANTIQ_MACH_EASY98020_1LAN,
111 "EASY98020_1LAN",
112 "EASY98020 Eval Board (1 LAN port)",
113 easy98020_init);
114
115 MIPS_MACHINE(LANTIQ_MACH_EASY98020_2LAN,
116 "EASY98020_2LAN",
117 "EASY98020 Eval Board (2 LAN ports)",
118 easy98020_init);