ar71xx: move AP91 specific ethernet initialization into a separate file
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-dir-600-a1.c
1 /*
2 * D-Link DIR-600 rev. A1 board support
3 *
4 * Copyright (C) 2010 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-eth.h"
20 #include "dev-ap91-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23
24 #define DIR_600_A1_GPIO_LED_WPS 0
25 #define DIR_600_A1_GPIO_LED_POWER_AMBER 1
26 #define DIR_600_A1_GPIO_LED_POWER_GREEN 6
27
28 #define DIR_600_A1_GPIO_BTN_RESET 8
29 #define DIR_600_A1_GPIO_BTN_WPS 12
30
31 #define DIR_600_A1_BUTTONS_POLL_INTERVAL 20
32
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition dir_600_a1_partitions[] = {
35 {
36 .name = "u-boot",
37 .offset = 0,
38 .size = 0x030000,
39 .mask_flags = MTD_WRITEABLE,
40 }, {
41 .name = "nvram",
42 .offset = 0x030000,
43 .size = 0x010000,
44 }, {
45 .name = "kernel",
46 .offset = 0x040000,
47 .size = 0x0e0000,
48 }, {
49 .name = "rootfs",
50 .offset = 0x120000,
51 .size = 0x2c0000,
52 }, {
53 .name = "mac",
54 .offset = 0x3e0000,
55 .size = 0x010000,
56 .mask_flags = MTD_WRITEABLE,
57 }, {
58 .name = "art",
59 .offset = 0x3f0000,
60 .size = 0x010000,
61 .mask_flags = MTD_WRITEABLE,
62 }, {
63 .name = "firmware",
64 .offset = 0x040000,
65 .size = 0x3a0000,
66 }
67 };
68 #endif /* CONFIG_MTD_PARTITIONS */
69
70 static struct flash_platform_data dir_600_a1_flash_data = {
71 #ifdef CONFIG_MTD_PARTITIONS
72 .parts = dir_600_a1_partitions,
73 .nr_parts = ARRAY_SIZE(dir_600_a1_partitions),
74 #endif
75 };
76
77 static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
78 {
79 .name = "dir-600-a1:green:power",
80 .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
81 }, {
82 .name = "dir-600-a1:amber:power",
83 .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
84 }, {
85 .name = "dir-600-a1:blue:wps",
86 .gpio = DIR_600_A1_GPIO_LED_WPS,
87 .active_low = 1,
88 }
89 };
90
91 static struct gpio_button dir_600_a1_gpio_buttons[] __initdata = {
92 {
93 .desc = "reset",
94 .type = EV_KEY,
95 .code = BTN_0,
96 .threshold = 3,
97 .gpio = DIR_600_A1_GPIO_BTN_RESET,
98 .active_low = 1,
99 }, {
100 .desc = "wps",
101 .type = EV_KEY,
102 .code = BTN_1,
103 .threshold = 3,
104 .gpio = DIR_600_A1_GPIO_BTN_WPS,
105 .active_low = 1,
106 }
107 };
108
109 static void __init dir_600_a1_setup(void)
110 {
111 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
112 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
113
114 ar71xx_add_device_m25p80(&dir_600_a1_flash_data);
115
116 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
117 dir_600_a1_leds_gpio);
118
119 ar71xx_add_device_gpio_buttons(-1, DIR_600_A1_BUTTONS_POLL_INTERVAL,
120 ARRAY_SIZE(dir_600_a1_gpio_buttons),
121 dir_600_a1_gpio_buttons);
122
123 ap91_eth_init(mac);
124 ap91_pci_init(ee, NULL);
125 }
126
127 MIPS_MACHINE(AR71XX_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
128 dir_600_a1_setup);