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