ar71xx: add inital support for the ALFA Network AP96 board
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-om2p.c
1 /*
2 * OpenMesh OM2P support
3 *
4 * Copyright (C) 2011 Marek Lindner <marek@open-mesh.com>
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 #include <linux/platform_device.h>
14
15 #include <asm/mach-ar71xx/ar71xx.h>
16 #include <asm/mach-ar71xx/gpio.h>
17
18 #include "machtype.h"
19 #include "devices.h"
20 #include "dev-ap91-pci.h"
21 #include "dev-m25p80.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-gpio-buttons.h"
24
25 #define OM2P_GPIO_LED_POWER 0
26 #define OM2P_GPIO_LED_GREEN 13
27 #define OM2P_GPIO_LED_RED 14
28 #define OM2P_GPIO_LED_YELLOW 15
29 #define OM2P_GPIO_LED_LAN 16
30 #define OM2P_GPIO_LED_WAN 17
31 #define OM2P_GPIO_BTN_RESET 11
32
33 #define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
34 #define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
35
36 #define OM2P_WAN_PHYMASK BIT(4)
37
38 static struct flash_platform_data om2p_flash_data = {
39 .type = "s25sl12800",
40 .name = "ar7240-nor0",
41 };
42
43 static struct gpio_led om2p_leds_gpio[] __initdata = {
44 {
45 .name = "om2p:blue:power",
46 .gpio = OM2P_GPIO_LED_POWER,
47 .active_low = 1,
48 }, {
49 .name = "om2p:red:wifi",
50 .gpio = OM2P_GPIO_LED_RED,
51 .active_low = 1,
52 }, {
53 .name = "om2p:yellow:wifi",
54 .gpio = OM2P_GPIO_LED_YELLOW,
55 .active_low = 1,
56 }, {
57 .name = "om2p:green:wifi",
58 .gpio = OM2P_GPIO_LED_GREEN,
59 .active_low = 1,
60 }, {
61 .name = "om2p:blue:lan",
62 .gpio = OM2P_GPIO_LED_LAN,
63 .active_low = 1,
64 }, {
65 .name = "om2p:blue:wan",
66 .gpio = OM2P_GPIO_LED_WAN,
67 .active_low = 1,
68 }
69 };
70
71 static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
72 {
73 .desc = "reset",
74 .type = EV_KEY,
75 .code = KEY_RESTART,
76 .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
77 .gpio = OM2P_GPIO_BTN_RESET,
78 .active_low = 1,
79 }
80 };
81
82 static void __init om2p_setup(void)
83 {
84 u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
85 u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
86 u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
87
88 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
89 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
90 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
91 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
92 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
93
94 ar71xx_add_device_m25p80(&om2p_flash_data);
95
96 ar71xx_add_device_mdio(0, ~OM2P_WAN_PHYMASK);
97
98 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac1, 0);
99 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac2, 0);
100
101 ar71xx_add_device_eth(0);
102 ar71xx_add_device_eth(1);
103
104 ap91_pci_init(ee, NULL);
105
106 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
107 om2p_leds_gpio);
108
109 ar71xx_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
110 ARRAY_SIZE(om2p_gpio_keys),
111 om2p_gpio_keys);
112 }
113
114 MIPS_MACHINE(AR71XX_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);