spi-topcliff-pch: supports a spi mode setup and bit order setup by IO control
[zen-stable.git] / arch / mips / ath79 / mach-ubnt-xm.c
blob3c311a5393471cb69cfa158bb2ba0c9ab417ddec
1 /*
2 * Ubiquiti Networks XM (rev 1.0) board support
4 * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com>
6 * Derived from: mach-pb44.c
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.
13 #include <linux/init.h>
14 #include <linux/pci.h>
16 #ifdef CONFIG_PCI
17 #include <linux/ath9k_platform.h>
18 #include <asm/mach-ath79/pci-ath724x.h>
19 #endif /* CONFIG_PCI */
21 #include "machtypes.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-spi.h"
26 #define UBNT_XM_GPIO_LED_L1 0
27 #define UBNT_XM_GPIO_LED_L2 1
28 #define UBNT_XM_GPIO_LED_L3 11
29 #define UBNT_XM_GPIO_LED_L4 7
31 #define UBNT_XM_GPIO_BTN_RESET 12
33 #define UBNT_XM_KEYS_POLL_INTERVAL 20
34 #define UBNT_XM_KEYS_DEBOUNCE_INTERVAL (3 * UBNT_XM_KEYS_POLL_INTERVAL)
36 #define UBNT_XM_PCI_IRQ 48
37 #define UBNT_XM_EEPROM_ADDR (u8 *) KSEG1ADDR(0x1fff1000)
39 static struct gpio_led ubnt_xm_leds_gpio[] __initdata = {
41 .name = "ubnt-xm:red:link1",
42 .gpio = UBNT_XM_GPIO_LED_L1,
43 .active_low = 0,
44 }, {
45 .name = "ubnt-xm:orange:link2",
46 .gpio = UBNT_XM_GPIO_LED_L2,
47 .active_low = 0,
48 }, {
49 .name = "ubnt-xm:green:link3",
50 .gpio = UBNT_XM_GPIO_LED_L3,
51 .active_low = 0,
52 }, {
53 .name = "ubnt-xm:green:link4",
54 .gpio = UBNT_XM_GPIO_LED_L4,
55 .active_low = 0,
59 static struct gpio_keys_button ubnt_xm_gpio_keys[] __initdata = {
61 .desc = "reset",
62 .type = EV_KEY,
63 .code = KEY_RESTART,
64 .debounce_interval = UBNT_XM_KEYS_DEBOUNCE_INTERVAL,
65 .gpio = UBNT_XM_GPIO_BTN_RESET,
66 .active_low = 1,
70 static struct spi_board_info ubnt_xm_spi_info[] = {
72 .bus_num = 0,
73 .chip_select = 0,
74 .max_speed_hz = 25000000,
75 .modalias = "mx25l6405d",
79 static struct ath79_spi_platform_data ubnt_xm_spi_data = {
80 .bus_num = 0,
81 .num_chipselect = 1,
84 #ifdef CONFIG_PCI
85 static struct ath9k_platform_data ubnt_xm_eeprom_data;
87 static struct ath724x_pci_data ubnt_xm_pci_data[] = {
89 .irq = UBNT_XM_PCI_IRQ,
90 .pdata = &ubnt_xm_eeprom_data,
93 #endif /* CONFIG_PCI */
95 static void __init ubnt_xm_init(void)
97 ath79_register_leds_gpio(-1, ARRAY_SIZE(ubnt_xm_leds_gpio),
98 ubnt_xm_leds_gpio);
100 ath79_register_gpio_keys_polled(-1, UBNT_XM_KEYS_POLL_INTERVAL,
101 ARRAY_SIZE(ubnt_xm_gpio_keys),
102 ubnt_xm_gpio_keys);
104 ath79_register_spi(&ubnt_xm_spi_data, ubnt_xm_spi_info,
105 ARRAY_SIZE(ubnt_xm_spi_info));
107 #ifdef CONFIG_PCI
108 memcpy(ubnt_xm_eeprom_data.eeprom_data, UBNT_XM_EEPROM_ADDR,
109 sizeof(ubnt_xm_eeprom_data.eeprom_data));
111 ath724x_pci_add_data(ubnt_xm_pci_data, ARRAY_SIZE(ubnt_xm_pci_data));
112 #endif /* CONFIG_PCI */
116 MIPS_MACHINE(ATH79_MACH_UBNT_XM,
117 "UBNT-XM",
118 "Ubiquiti Networks XM (rev 1.0) board",
119 ubnt_xm_init);