2 * OpenMesh OM2P support
4 * Copyright (C) 2011 Marek Lindner <marek@open-mesh.com>
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.
11 #include <linux/gpio.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/platform_device.h>
16 #include <asm/mach-ath79/ar71xx_regs.h>
17 #include <asm/mach-ath79/ath79.h>
20 #include "dev-ap9x-pci.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-m25p80.h"
25 #include "machtypes.h"
27 #define OM2P_GPIO_LED_POWER 0
28 #define OM2P_GPIO_LED_GREEN 13
29 #define OM2P_GPIO_LED_RED 14
30 #define OM2P_GPIO_LED_YELLOW 15
31 #define OM2P_GPIO_LED_LAN 16
32 #define OM2P_GPIO_LED_WAN 17
33 #define OM2P_GPIO_BTN_RESET 11
35 #define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
38 #define OM2P_WAN_PHYMASK BIT(4)
40 static struct flash_platform_data om2p_flash_data
= {
42 .name
= "ar7240-nor0",
45 static struct gpio_led om2p_leds_gpio
[] __initdata
= {
47 .name
= "om2p:blue:power",
48 .gpio
= OM2P_GPIO_LED_POWER
,
51 .name
= "om2p:red:wifi",
52 .gpio
= OM2P_GPIO_LED_RED
,
55 .name
= "om2p:yellow:wifi",
56 .gpio
= OM2P_GPIO_LED_YELLOW
,
59 .name
= "om2p:green:wifi",
60 .gpio
= OM2P_GPIO_LED_GREEN
,
63 .name
= "om2p:blue:lan",
64 .gpio
= OM2P_GPIO_LED_LAN
,
67 .name
= "om2p:blue:wan",
68 .gpio
= OM2P_GPIO_LED_WAN
,
73 static struct gpio_keys_button om2p_gpio_keys
[] __initdata
= {
78 .debounce_interval
= OM2P_KEYS_DEBOUNCE_INTERVAL
,
79 .gpio
= OM2P_GPIO_BTN_RESET
,
84 static void __init
om2p_setup(void)
86 u8
*mac1
= (u8
*)KSEG1ADDR(0x1ffc0000);
87 u8
*mac2
= (u8
*)KSEG1ADDR(0x1ffc0000 + ETH_ALEN
);
88 u8
*ee
= (u8
*)KSEG1ADDR(0x1ffc1000);
90 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
91 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
92 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
93 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
94 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
96 ath79_register_m25p80(&om2p_flash_data
);
98 ath79_register_mdio(0, ~OM2P_WAN_PHYMASK
);
100 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac1
, 0);
101 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac2
, 0);
103 ath79_register_eth(0);
104 ath79_register_eth(1);
106 ap91_pci_init(ee
, NULL
);
108 ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio
),
111 ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL
,
112 ARRAY_SIZE(om2p_gpio_keys
),
116 MIPS_MACHINE(ATH79_MACH_OM2P
, "OM2P", "OpenMesh OM2P", om2p_setup
);