f05d8cbdd73cc61fd09531c4972a64c7076bb1df
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-ubnt.c
1 /*
2 * Ubiquiti RouterStation support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2008 Ubiquiti <support@ubnt.com>
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/platform_device.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16 #include <linux/input.h>
17
18 #include <asm/mips_machine.h>
19 #include <asm/mach-ar71xx/ar71xx.h>
20 #include <asm/mach-ar71xx/pci.h>
21
22 #include "devices.h"
23
24 #define UBNT_RS_GPIO_LED_RF 2
25 #define UBNT_RS_GPIO_SW4 8
26
27 #define UBNT_BUTTONS_POLL_INTERVAL 20
28
29 static struct spi_board_info ubnt_spi_info[] = {
30 {
31 .bus_num = 0,
32 .chip_select = 0,
33 .max_speed_hz = 25000000,
34 .modalias = "m25p80",
35 }
36 };
37
38 static struct ar71xx_pci_irq ubnt_pci_irqs[] __initdata = {
39 {
40 .slot = 0,
41 .pin = 1,
42 .irq = AR71XX_PCI_IRQ_DEV0,
43 }, {
44 .slot = 1,
45 .pin = 1,
46 .irq = AR71XX_PCI_IRQ_DEV1,
47 }, {
48 .slot = 2,
49 .pin = 1,
50 .irq = AR71XX_PCI_IRQ_DEV2,
51 }
52 };
53
54 static struct gpio_led ubnt_rs_leds_gpio[] __initdata = {
55 {
56 .name = "ubnt:green:rf",
57 .gpio = UBNT_RS_GPIO_LED_RF,
58 .active_low = 0,
59 }
60 };
61
62 static struct gpio_button ubnt_rs_gpio_buttons[] __initdata = {
63 {
64 .desc = "sw4",
65 .type = EV_KEY,
66 .code = BTN_0,
67 .threshold = 5,
68 .gpio = UBNT_RS_GPIO_SW4,
69 .active_low = 1,
70 }
71 };
72
73 #define UBNT_RS_WAN_PHYMASK (1 << 20)
74 #define UBNT_RS_LAN_PHYMASK ((1 << 16) | (1 << 17) | (1 << 18) | (1 << 19))
75
76 static void __init ubnt_rs_setup(void)
77 {
78 ar71xx_add_device_spi(NULL, ubnt_spi_info,
79 ARRAY_SIZE(ubnt_spi_info));
80
81 ar71xx_add_device_mdio(~(UBNT_RS_WAN_PHYMASK | UBNT_RS_LAN_PHYMASK));
82
83 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
84 ar71xx_eth0_data.phy_mask = UBNT_RS_WAN_PHYMASK;
85
86 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
87 ar71xx_eth1_data.phy_mask = UBNT_RS_LAN_PHYMASK;
88
89 ar71xx_eth1_data.speed = SPEED_100;
90 ar71xx_eth1_data.duplex = DUPLEX_FULL;
91
92 ar71xx_add_device_eth(0);
93 ar71xx_add_device_eth(1);
94
95 ar71xx_add_device_usb();
96
97 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs), ubnt_pci_irqs);
98
99 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ubnt_rs_leds_gpio),
100 ubnt_rs_leds_gpio);
101
102 ar71xx_add_device_gpio_buttons(-1, UBNT_BUTTONS_POLL_INTERVAL,
103 ARRAY_SIZE(ubnt_rs_gpio_buttons),
104 ubnt_rs_gpio_buttons);
105 }
106
107 MIPS_MACHINE(AR71XX_MACH_UBNT_RS, "Ubiquiti RouterStation", ubnt_rs_setup);
108
109 static void __init ubnt_rspro_setup(void)
110 {
111 ar71xx_add_device_spi(NULL, ubnt_spi_info,
112 ARRAY_SIZE(ubnt_spi_info));
113
114 ar71xx_add_device_usb();
115
116 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs), ubnt_pci_irqs);
117 }
118
119 MIPS_MACHINE(AR71XX_MACH_UBNT_RSPRO, "Ubiquiti RouterStation Pro",
120 ubnt_rspro_setup);
121
122 static void __init ubnt_lsx_setup(void)
123 {
124 ar71xx_add_device_spi(NULL, ubnt_spi_info,
125 ARRAY_SIZE(ubnt_spi_info));
126
127 }
128
129 MIPS_MACHINE(AR71XX_MACH_UBNT_LSX, "Ubiquiti LSX", ubnt_lsx_setup);
130
131 #define UBNT_LSSR71_PHY_MASK (1 << 1)
132
133 static void __init ubnt_lssr71_setup(void)
134 {
135 ar71xx_add_device_spi(NULL, ubnt_spi_info,
136 ARRAY_SIZE(ubnt_spi_info));
137
138 ar71xx_add_device_mdio(~UBNT_LSSR71_PHY_MASK);
139
140 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
141 ar71xx_eth0_data.phy_mask = UBNT_LSSR71_PHY_MASK;
142
143 ar71xx_add_device_eth(0);
144
145 ar71xx_pci_init(ARRAY_SIZE(ubnt_pci_irqs), ubnt_pci_irqs);
146 }
147
148 MIPS_MACHINE(AR71XX_MACH_UBNT_LSSR71, "Ubiquiti LS-SR71", ubnt_lssr71_setup);