2 * ALFA Network N2/N5 board support
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
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>
14 #include <asm/mach-ath79/ar71xx_regs.h>
15 #include <asm/mach-ath79/ath79.h>
19 #include "dev-ap9x-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define ALFA_NX_GPIO_LED_2 17
26 #define ALFA_NX_GPIO_LED_3 16
27 #define ALFA_NX_GPIO_LED_5 12
28 #define ALFA_NX_GPIO_LED_6 8
29 #define ALFA_NX_GPIO_LED_7 6
30 #define ALFA_NX_GPIO_LED_8 7
32 #define ALFA_NX_GPIO_BTN_RESET 11
34 #define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
37 #define ALFA_NX_MAC0_OFFSET 0
38 #define ALFA_NX_MAC1_OFFSET 6
39 #define ALFA_NX_CALDATA_OFFSET 0x1000
41 static struct mtd_partition alfa_nx_partitions
[] = {
46 .mask_flags
= MTD_WRITEABLE
,
51 .mask_flags
= MTD_WRITEABLE
,
64 .mask_flags
= MTD_WRITEABLE
,
69 .mask_flags
= MTD_WRITEABLE
,
77 static struct flash_platform_data alfa_nx_flash_data
= {
78 .parts
= alfa_nx_partitions
,
79 .nr_parts
= ARRAY_SIZE(alfa_nx_partitions
),
82 static struct gpio_keys_button alfa_nx_gpio_keys
[] __initdata
= {
84 .desc
= "Reset button",
87 .debounce_interval
= ALFA_NX_KEYS_DEBOUNCE_INTERVAL
,
88 .gpio
= ALFA_NX_GPIO_BTN_RESET
,
93 static struct gpio_led alfa_nx_leds_gpio
[] __initdata
= {
95 .name
= "alfa:green:led_2",
96 .gpio
= ALFA_NX_GPIO_LED_2
,
99 .name
= "alfa:green:led_3",
100 .gpio
= ALFA_NX_GPIO_LED_3
,
103 .name
= "alfa:red:led_5",
104 .gpio
= ALFA_NX_GPIO_LED_5
,
107 .name
= "alfa:amber:led_6",
108 .gpio
= ALFA_NX_GPIO_LED_6
,
111 .name
= "alfa:green:led_7",
112 .gpio
= ALFA_NX_GPIO_LED_7
,
115 .name
= "alfa:green:led_8",
116 .gpio
= ALFA_NX_GPIO_LED_8
,
121 static void __init
alfa_nx_setup(void)
123 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
125 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE
,
126 AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
127 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
128 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
129 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
130 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
132 ath79_register_m25p80(&alfa_nx_flash_data
);
134 ath79_register_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio
),
137 ath79_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL
,
138 ARRAY_SIZE(alfa_nx_gpio_keys
),
141 ath79_register_mdio(0, 0x0);
143 ath79_init_mac(ath79_eth0_data
.mac_addr
,
144 art
+ ALFA_NX_MAC0_OFFSET
, 0);
145 ath79_init_mac(ath79_eth1_data
.mac_addr
,
146 art
+ ALFA_NX_MAC1_OFFSET
, 0);
149 ath79_register_eth(0);
151 ath79_register_eth(1);
153 ap91_pci_init(art
+ ALFA_NX_CALDATA_OFFSET
, NULL
);
156 MIPS_MACHINE(ATH79_MACH_ALFA_NX
, "ALFA-NX", "ALFA Network N2/N5",