Commit | Line | Data |
---|---|---|
2dc7b4a1 RB |
1 | /* |
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> | |
15 | ||
16 | #ifdef CONFIG_PCI | |
17 | #include <linux/ath9k_platform.h> | |
2dc7b4a1 RB |
18 | #endif /* CONFIG_PCI */ |
19 | ||
93ef85b5 GJ |
20 | #include <asm/mach-ath79/irq.h> |
21 | ||
2dc7b4a1 RB |
22 | #include "machtypes.h" |
23 | #include "dev-gpio-buttons.h" | |
24 | #include "dev-leds-gpio.h" | |
25 | #include "dev-spi.h" | |
3a6208df | 26 | #include "pci.h" |
2dc7b4a1 RB |
27 | |
28 | #define UBNT_XM_GPIO_LED_L1 0 | |
29 | #define UBNT_XM_GPIO_LED_L2 1 | |
30 | #define UBNT_XM_GPIO_LED_L3 11 | |
31 | #define UBNT_XM_GPIO_LED_L4 7 | |
32 | ||
33 | #define UBNT_XM_GPIO_BTN_RESET 12 | |
34 | ||
35 | #define UBNT_XM_KEYS_POLL_INTERVAL 20 | |
36 | #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL) | |
37 | ||
2dc7b4a1 RB |
38 | #define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000) |
39 | ||
40 | static struct gpio_led ubnt_xm_leds_gpio[] __initdata = { | |
41 | { | |
42 | .name = "ubnt-xm:red:link1", | |
43 | .gpio = UBNT_XM_GPIO_LED_L1, | |
44 | .active_low = 0, | |
45 | }, { | |
46 | .name = "ubnt-xm:orange:link2", | |
47 | .gpio = UBNT_XM_GPIO_LED_L2, | |
48 | .active_low = 0, | |
49 | }, { | |
50 | .name = "ubnt-xm:green:link3", | |
51 | .gpio = UBNT_XM_GPIO_LED_L3, | |
52 | .active_low = 0, | |
53 | }, { | |
54 | .name = "ubnt-xm:green:link4", | |
55 | .gpio = UBNT_XM_GPIO_LED_L4, | |
56 | .active_low = 0, | |
57 | }, | |
58 | }; | |
59 | ||
60 | static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = { | |
61 | { | |
62 | .desc = "reset", | |
63 | .type = EV_KEY, | |
64 | .code = KEY_RESTART, | |
65 | .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL, | |
66 | .gpio = UBNT_XM_GPIO_BTN_RESET, | |
67 | .active_low = 1, | |
68 | } | |
69 | }; | |
70 | ||
71 | static struct spi_board_info ubnt_xm_spi_info[] = { | |
72 | { | |
73 | .bus_num = 0, | |
74 | .chip_select = 0, | |
75 | .max_speed_hz = 25000000, | |
76 | .modalias = "mx25l6405d", | |
77 | } | |
78 | }; | |
79 | ||
80 | static struct ath79_spi_platform_data ubnt_xm_spi_data = { | |
81 | .bus_num = 0, | |
82 | .num_chipselect = 1, | |
83 | }; | |
84 | ||
85 | #ifdef CONFIG_PCI | |
86 | static struct ath9k_platform_data ubnt_xm_eeprom_data; | |
87 | ||
d624bd3c | 88 | static struct ar724x_pci_data ubnt_xm_pci_data[] = { |
2dc7b4a1 | 89 | { |
93ef85b5 | 90 | .irq = ATH79_PCI_IRQ(0), |
2dc7b4a1 RB |
91 | .pdata = &ubnt_xm_eeprom_data, |
92 | }, | |
93 | }; | |
94 | #endif /* CONFIG_PCI */ | |
95 | ||
96 | static void __init ubnt_xm_init(void) | |
97 | { | |
98 | ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio), | |
99 | ubnt_xm_leds_gpio); | |
100 | ||
101 | ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL, | |
102 | ARRAY_SIZE(ubnt_xm_gpio_keys), | |
103 | ubnt_xm_gpio_keys); | |
104 | ||
105 | ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info, | |
106 | ARRAY_SIZE(ubnt_xm_spi_info)); | |
107 | ||
108 | #ifdef CONFIG_PCI | |
109 | memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR, | |
110 | sizeof(ubnt_xm_eeprom_data.eeprom_data)); | |
111 | ||
d624bd3c | 112 | ar724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data)); |
2dc7b4a1 RB |
113 | #endif /* CONFIG_PCI */ |
114 | ||
6335aef5 | 115 | ath79_register_pci(); |
2dc7b4a1 RB |
116 | } |
117 | ||
118 | MIPS_MACHINE(ATH79_MACH_UBNT_XM, | |
119 | "UBNT-XM", | |
120 | "Ubiquiti Networks XM (rev 1.0) board", | |
121 | ubnt_xm_init); |