Root/target/linux/ar71xx/files/arch/mips/ath79/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/gpio.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/platform_device.h>
15
16#include <asm/mach-ath79/ar71xx_regs.h>
17#include <asm/mach-ath79/ath79.h>
18
19#include "common.h"
20#include "dev-ap9x-pci.h"
21#include "dev-eth.h"
22#include "dev-gpio-buttons.h"
23#include "dev-leds-gpio.h"
24#include "dev-m25p80.h"
25#include "machtypes.h"
26
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
34
35#define OM2P_KEYS_POLL_INTERVAL 20 /* msecs */
36#define OM2P_KEYS_DEBOUNCE_INTERVAL (3 * OM2P_KEYS_POLL_INTERVAL)
37
38#define OM2P_WAN_PHYMASK BIT(4)
39
40static struct flash_platform_data om2p_flash_data = {
41    .type = "s25sl12800",
42    .name = "ar7240-nor0",
43};
44
45static struct gpio_led om2p_leds_gpio[] __initdata = {
46    {
47        .name = "om2p:blue:power",
48        .gpio = OM2P_GPIO_LED_POWER,
49        .active_low = 1,
50    }, {
51        .name = "om2p:red:wifi",
52        .gpio = OM2P_GPIO_LED_RED,
53        .active_low = 1,
54    }, {
55        .name = "om2p:yellow:wifi",
56        .gpio = OM2P_GPIO_LED_YELLOW,
57        .active_low = 1,
58    }, {
59        .name = "om2p:green:wifi",
60        .gpio = OM2P_GPIO_LED_GREEN,
61        .active_low = 1,
62    }, {
63        .name = "om2p:blue:lan",
64        .gpio = OM2P_GPIO_LED_LAN,
65        .active_low = 1,
66    }, {
67        .name = "om2p:blue:wan",
68        .gpio = OM2P_GPIO_LED_WAN,
69        .active_low = 1,
70    }
71};
72
73static struct gpio_keys_button om2p_gpio_keys[] __initdata = {
74    {
75        .desc = "reset",
76        .type = EV_KEY,
77        .code = KEY_RESTART,
78        .debounce_interval = OM2P_KEYS_DEBOUNCE_INTERVAL,
79        .gpio = OM2P_GPIO_BTN_RESET,
80        .active_low = 1,
81    }
82};
83
84static void __init om2p_setup(void)
85{
86    u8 *mac1 = (u8 *)KSEG1ADDR(0x1ffc0000);
87    u8 *mac2 = (u8 *)KSEG1ADDR(0x1ffc0000 + ETH_ALEN);
88    u8 *ee = (u8 *)KSEG1ADDR(0x1ffc1000);
89
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);
95
96    ath79_register_m25p80(&om2p_flash_data);
97
98    ath79_register_mdio(0, ~OM2P_WAN_PHYMASK);
99
100    ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
101    ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 0);
102
103    ath79_register_eth(0);
104    ath79_register_eth(1);
105
106    ap91_pci_init(ee, NULL);
107
108    ath79_register_leds_gpio(-1, ARRAY_SIZE(om2p_leds_gpio),
109                 om2p_leds_gpio);
110
111    ath79_register_gpio_keys_polled(-1, OM2P_KEYS_POLL_INTERVAL,
112                    ARRAY_SIZE(om2p_gpio_keys),
113                    om2p_gpio_keys);
114}
115
116MIPS_MACHINE(ATH79_MACH_OM2P, "OM2P", "OpenMesh OM2P", om2p_setup);
117

Archive Download this file



interactive