blob: 1e6b986cb470f7a48fe1b7e03434cebf8710e7be [file] [log] [blame]
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +00001/*
2 * Ubiquiti Networks XM (rev 1.0) board support
3 *
4 * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
5 *
6 * Derived from: mach-pb44.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/pci.h>
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000015#include <linux/ath9k_platform.h>
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000016
Gabor Juhos93ef85b2012-03-14 10:36:06 +010017#include <asm/mach-ath79/irq.h>
18
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000019#include "machtypes.h"
20#include "dev-gpio-buttons.h"
21#include "dev-leds-gpio.h"
22#include "dev-spi.h"
Gabor Juhos3a6208d2012-03-14 10:29:22 +010023#include "pci.h"
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000024
25#define UBNT_XM_GPIO_LED_L1 0
26#define UBNT_XM_GPIO_LED_L2 1
27#define UBNT_XM_GPIO_LED_L3 11
28#define UBNT_XM_GPIO_LED_L4 7
29
30#define UBNT_XM_GPIO_BTN_RESET 12
31
32#define UBNT_XM_KEYS_POLL_INTERVAL 20
33#define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
34
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000035#define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
36
37static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
38 {
39 .name = "ubnt-xm:red:link1",
40 .gpio = UBNT_XM_GPIO_LED_L1,
41 .active_low = 0,
42 }, {
43 .name = "ubnt-xm:orange:link2",
44 .gpio = UBNT_XM_GPIO_LED_L2,
45 .active_low = 0,
46 }, {
47 .name = "ubnt-xm:green:link3",
48 .gpio = UBNT_XM_GPIO_LED_L3,
49 .active_low = 0,
50 }, {
51 .name = "ubnt-xm:green:link4",
52 .gpio = UBNT_XM_GPIO_LED_L4,
53 .active_low = 0,
54 },
55};
56
57static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
58 {
59 .desc = "reset",
60 .type = EV_KEY,
61 .code = KEY_RESTART,
62 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = UBNT_XM_GPIO_BTN_RESET,
64 .active_low = 1,
65 }
66};
67
68static struct spi_board_info ubnt_xm_spi_info[] = {
69 {
70 .bus_num = 0,
71 .chip_select = 0,
72 .max_speed_hz = 25000000,
73 .modalias = "mx25l6405d",
74 }
75};
76
77static struct ath79_spi_platform_data ubnt_xm_spi_data = {
78 .bus_num = 0,
79 .num_chipselect = 1,
80};
81
82#ifdef CONFIG_PCI
83static struct ath9k_platform_data ubnt_xm_eeprom_data;
84
Gabor Juhosd624bd32012-03-14 10:29:26 +010085static struct ar724x_pci_data ubnt_xm_pci_data[] = {
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000086 {
Gabor Juhos93ef85b2012-03-14 10:36:06 +010087 .irq = ATH79_PCI_IRQ(0),
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +000088 .pdata = &ubnt_xm_eeprom_data,
89 },
90};
Gabor Juhos881b6ef2012-03-14 10:36:08 +010091
92static void __init ubnt_xm_pci_init(void)
93{
94 memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
95 sizeof(ubnt_xm_eeprom_data.eeprom_data));
96
97 ar724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
98 ath79_register_pci();
99}
100#else
101static inline void ubnt_xm_pci_init(void) {}
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +0000102#endif /* CONFIG_PCI */
103
104static void __init ubnt_xm_init(void)
105{
106 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
107 ubnt_xm_leds_gpio);
108
109 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
110 ARRAY_SIZE(ubnt_xm_gpio_keys),
111 ubnt_xm_gpio_keys);
112
113 ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
114 ARRAY_SIZE(ubnt_xm_spi_info));
115
Gabor Juhos881b6ef2012-03-14 10:36:08 +0100116 ubnt_xm_pci_init();
Rene Bolldorf2dc7b4a2011-11-18 00:17:42 +0000117}
118
119MIPS_MACHINE(ATH79_MACH_UBNT_XM,
120 "UBNT-XM",
121 "Ubiquiti Networks XM (rev 1.0) board",
122 ubnt_xm_init);