ar71xx: move arch specific files to files-2.6.39
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files-2.6.39 / arch / mips / ar71xx / mach-alfa-nx.c
1 /*
2 * ALFA Network N2/N5 board support
3 *
4 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10
11 #include <linux/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13
14 #include <asm/mach-ar71xx/ar71xx.h>
15
16 #include "machtype.h"
17 #include "devices.h"
18 #include "dev-m25p80.h"
19 #include "dev-ap91-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22
23 #define ALFA_NX_GPIO_LED_2 17
24 #define ALFA_NX_GPIO_LED_3 16
25 #define ALFA_NX_GPIO_LED_5 12
26 #define ALFA_NX_GPIO_LED_6 8
27 #define ALFA_NX_GPIO_LED_7 6
28 #define ALFA_NX_GPIO_LED_8 7
29
30 #define ALFA_NX_GPIO_BTN_RESET 11
31
32 #define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
34
35 #define ALFA_NX_MAC0_OFFSET 0
36 #define ALFA_NX_MAC1_OFFSET 6
37 #define ALFA_NX_CALDATA_OFFSET 0x1000
38
39 #ifdef CONFIG_MTD_PARTITIONS
40 static struct mtd_partition alfa_nx_partitions[] = {
41 {
42 .name = "u-boot",
43 .offset = 0,
44 .size = 0x040000,
45 .mask_flags = MTD_WRITEABLE,
46 }, {
47 .name = "u-boot-env",
48 .offset = 0x040000,
49 .size = 0x010000,
50 .mask_flags = MTD_WRITEABLE,
51 }, {
52 .name = "rootfs",
53 .offset = 0x050000,
54 .size = 0x600000,
55 }, {
56 .name = "kernel",
57 .offset = 0x650000,
58 .size = 0x190000,
59 }, {
60 .name = "nvram",
61 .offset = 0x7e0000,
62 .size = 0x010000,
63 .mask_flags = MTD_WRITEABLE,
64 }, {
65 .name = "art",
66 .offset = 0x7f0000,
67 .size = 0x010000,
68 .mask_flags = MTD_WRITEABLE,
69 }, {
70 .name = "firmware",
71 .offset = 0x050000,
72 .size = 0x780000,
73 }
74 };
75 #endif /* CONFIG_MTD_PARTITIONS */
76
77 static struct flash_platform_data alfa_nx_flash_data = {
78 #ifdef CONFIG_MTD_PARTITIONS
79 .parts = alfa_nx_partitions,
80 .nr_parts = ARRAY_SIZE(alfa_nx_partitions),
81 #endif
82 };
83
84 static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = {
85 {
86 .desc = "Reset button",
87 .type = EV_KEY,
88 .code = KEY_RESTART,
89 .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = ALFA_NX_GPIO_BTN_RESET,
91 .active_low = 1,
92 }
93 };
94
95 static struct gpio_led alfa_nx_leds_gpio[] __initdata = {
96 {
97 .name = "alfa:green:led_2",
98 .gpio = ALFA_NX_GPIO_LED_2,
99 .active_low = 1,
100 }, {
101 .name = "alfa:green:led_3",
102 .gpio = ALFA_NX_GPIO_LED_3,
103 .active_low = 1,
104 }, {
105 .name = "alfa:red:led_5",
106 .gpio = ALFA_NX_GPIO_LED_5,
107 .active_low = 1,
108 }, {
109 .name = "alfa:amber:led_6",
110 .gpio = ALFA_NX_GPIO_LED_6,
111 .active_low = 1,
112 }, {
113 .name = "alfa:green:led_7",
114 .gpio = ALFA_NX_GPIO_LED_7,
115 .active_low = 1,
116 }, {
117 .name = "alfa:green:led_8",
118 .gpio = ALFA_NX_GPIO_LED_8,
119 .active_low = 1,
120 }
121 };
122
123 static void __init alfa_nx_setup(void)
124 {
125 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
126
127 ar71xx_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
128 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
129 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
130 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
131 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
132 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
133
134 ar71xx_add_device_m25p80(&alfa_nx_flash_data);
135
136 ar71xx_add_device_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio),
137 alfa_nx_leds_gpio);
138
139 ar71xx_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL,
140 ARRAY_SIZE(alfa_nx_gpio_keys),
141 alfa_nx_gpio_keys);
142
143 ar71xx_add_device_mdio(0, 0x0);
144
145 ar71xx_init_mac(ar71xx_eth0_data.mac_addr,
146 art + ALFA_NX_MAC0_OFFSET, 0);
147 ar71xx_init_mac(ar71xx_eth1_data.mac_addr,
148 art + ALFA_NX_MAC1_OFFSET, 0);
149
150 /* WAN port */
151 ar71xx_add_device_eth(0);
152 /* LAN port */
153 ar71xx_add_device_eth(1);
154
155 ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL);
156 }
157
158 MIPS_MACHINE(AR71XX_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5",
159 alfa_nx_setup);