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/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/platform_device.h>
15 #include <asm/mach-ar71xx/ar71xx.h>
16 #include <asm/mach-ar71xx/gpio.h>
20 #include "dev-ap91-pci.h"
21 #include "dev-m25p80.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-gpio-buttons.h"
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
33 #define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
34 #define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
36 #define OM2P_WAN_PHYMASK BIT(4)
38 static struct flash_platform_data om2p_flash_data = {
40 .name = "ar7240-nor0",
43 static struct gpio_led om2p_leds_gpio[] __initdata = {
45 .name = "om2p:blue:power",
46 .gpio = OM2P_GPIO_LED_POWER,
49 .name = "om2p:red:wifi",
50 .gpio = OM2P_GPIO_LED_RED,
53 .name = "om2p:yellow:wifi",
54 .gpio = OM2P_GPIO_LED_YELLOW,
57 .name = "om2p:green:wifi",
58 .gpio = OM2P_GPIO_LED_GREEN,
61 .name = "om2p:blue:lan",
62 .gpio = OM2P_GPIO_LED_LAN,
65 .name = "om2p:blue:wan",
66 .gpio = OM2P_GPIO_LED_WAN,
71 static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
76 .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
77 .gpio = OM2P_GPIO_BTN_RESET,
82 static void __init om2p_setup(void)
84 u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
85 u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
86 u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
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);
94 ar71xx_add_device_m25p80(&om2p_flash_data);
96 ar71xx_add_device_mdio(~OM2P_WAN_PHYMASK);
98 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac1, 0);
99 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac2, 0);
101 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
102 ar71xx_eth0_data.speed = SPEED_100;
103 ar71xx_eth0_data.duplex = DUPLEX_FULL;
104 ar71xx_eth0_data.phy_mask = OM2P_WAN_PHYMASK;
106 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
107 ar71xx_eth1_data.speed = SPEED_1000;
108 ar71xx_eth1_data.duplex = DUPLEX_FULL;
109 ar71xx_eth1_data.has_ar7240_switch = 1;
111 ar71xx_add_device_eth(0);
112 ar71xx_add_device_eth(1);
114 ap91_pci_init(ee, NULL);
116 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
119 ar71xx_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
120 ARRAY_SIZE(om2p_gpio_keys),
124 MIPS_MACHINE(AR71XX_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);