[ar71xx] WP543: add static mtd partitions
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wp543.c
1 /*
2 * Compex WP543 board support
3 *
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18
19 #include <asm/mips_machine.h>
20 #include <asm/mach-ar71xx/ar71xx.h>
21 #include <asm/mach-ar71xx/pci.h>
22 #include <asm/mach-ar71xx/platform.h>
23
24 #define WP543_GPIO_SW6 2
25 #define WP543_GPIO_LED_1 3
26 #define WP543_GPIO_LED_2 4
27 #define WP543_GPIO_LED_WLAN 5
28 #define WP543_GPIO_LED_CONN 6
29 #define WP543_GPIO_LED_DIAG 7
30 #define WP543_GPIO_SW4 8
31
32 #define WP543_BUTTONS_POLL_INTERVAL 20
33
34 #ifdef CONFIG_MTD_PARTITIONS
35 static struct mtd_partition wp543_partitions[] = {
36 {
37 .name = "myloader",
38 .offset = 0,
39 .size = 0x20000,
40 .mask_flags = MTD_WRITEABLE,
41 } , {
42 .name = "kernel",
43 .offset = 0x30000,
44 .size = 0xd0000,
45 } , {
46 .name = "rootfs",
47 .offset = 0x100000,
48 .size = 0x100000,
49 }
50 };
51 #endif /* CONFIG_MTD_PARTITIONS */
52
53 static struct flash_platform_data wp543_flash_data = {
54 #ifdef CONFIG_MTD_PARTITIONS
55 .parts = wp543_partitions,
56 .nr_parts = ARRAY_SIZE(wp543_partitions),
57 #endif
58 };
59
60 static struct spi_board_info wp543_spi_info[] = {
61 {
62 .bus_num = 0,
63 .chip_select = 0,
64 .max_speed_hz = 25000000,
65 .modalias = "m25p80",
66 .platform_data = &wp543_flash_data,
67 }
68 };
69
70 static struct ar71xx_pci_irq wp543_pci_irqs[] __initdata = {
71 {
72 .slot = 1,
73 .pin = 1,
74 .irq = AR71XX_PCI_IRQ_DEV0,
75 }, {
76 .slot = 1,
77 .pin = 2,
78 .irq = AR71XX_PCI_IRQ_DEV1,
79 }
80 };
81
82 static struct gpio_led wp543_leds_gpio[] __initdata = {
83 {
84 .name = "wp543:green:led1",
85 .gpio = WP543_GPIO_LED_1,
86 .active_low = 1,
87 }, {
88 .name = "wp543:green:led2",
89 .gpio = WP543_GPIO_LED_2,
90 .active_low = 1,
91 }, {
92 .name = "wp543:green:wlan",
93 .gpio = WP543_GPIO_LED_WLAN,
94 .active_low = 1,
95 }, {
96 .name = "wp543:green:conn",
97 .gpio = WP543_GPIO_LED_CONN,
98 .active_low = 1,
99 }, {
100 .name = "wp543:green:diag",
101 .gpio = WP543_GPIO_LED_DIAG,
102 .active_low = 1,
103 }
104 };
105
106 static struct gpio_button wp543_gpio_buttons[] __initdata = {
107 {
108 .desc = "sw6",
109 .type = EV_KEY,
110 .code = BTN_0,
111 .threshold = 5,
112 .gpio = WP543_GPIO_SW6,
113 }, {
114 .desc = "sw4",
115 .type = EV_KEY,
116 .code = BTN_1,
117 .threshold = 5,
118 .gpio = WP543_GPIO_SW4,
119 }
120 };
121
122 static void __init wp543_setup(void)
123 {
124 ar71xx_add_device_spi(NULL, wp543_spi_info, ARRAY_SIZE(wp543_spi_info));
125
126 ar71xx_add_device_mdio(0xfffffff7);
127 ar71xx_add_device_eth(0, PHY_INTERFACE_MODE_MII, 0x00000008);
128
129 ar71xx_add_device_usb();
130
131 ar71xx_pci_init(ARRAY_SIZE(wp543_pci_irqs), wp543_pci_irqs);
132
133 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wp543_leds_gpio),
134 wp543_leds_gpio);
135
136 ar71xx_add_device_gpio_buttons(-1, WP543_BUTTONS_POLL_INTERVAL,
137 ARRAY_SIZE(wp543_gpio_buttons),
138 wp543_gpio_buttons);
139 }
140
141 MIPS_MACHINE(MACH_AR71XX_WP543, "Compex WP543", wp543_setup);