ar71xx: use spinlock in ar71xx_device_{start,stop}
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-eap7660d.c
1 /*
2 * Senao EAP7660D board support
3 *
4 * Copyright (C) 2010 Daniel Golle <daniel.golle@gmail.com>
5 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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/pci.h>
14 #include <linux/ath5k_platform.h>
15 #include <linux/delay.h>
16 #include <asm/mach-ar71xx/ar71xx.h>
17 #include <asm/mach-ar71xx/pci.h>
18
19 #include "machtype.h"
20 #include "devices.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24
25 #define EAP7660D_BUTTONS_POLL_INTERVAL 20
26 #define EAP7660D_GPIO_DS4 7
27 #define EAP7660D_GPIO_DS5 2
28 #define EAP7660D_GPIO_DS7 0
29 #define EAP7660D_GPIO_DS8 4
30 #define EAP7660D_GPIO_SW1 3
31 #define EAP7660D_GPIO_SW3 8
32 #define EAP7660D_PHYMASK BIT(20)
33 #define EAP7660D_BOARDCONFIG 0x1F7F0000
34 #define EAP7660D_GBIC_MAC_OFFSET 0x1000
35 #define EAP7660D_WMAC0_MAC_OFFSET 0x1010
36 #define EAP7660D_WMAC1_MAC_OFFSET 0x1016
37 #define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
38 #define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
39
40 static struct ath5k_platform_data eap7660d_wmac0_data;
41 static struct ath5k_platform_data eap7660d_wmac1_data;
42 static char eap7660d_wmac0_mac[6];
43 static char eap7660d_wmac1_mac[6];
44 static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
45 static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
46
47 static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
48 {
49 .slot = 0,
50 .pin = 1,
51 .irq = AR71XX_PCI_IRQ_DEV0,
52 }, {
53 .slot = 1,
54 .pin = 1,
55 .irq = AR71XX_PCI_IRQ_DEV1,
56 }
57 };
58
59 static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
60 {
61 switch (PCI_SLOT(dev->devfn)) {
62 case 17:
63 dev->dev.platform_data = &eap7660d_wmac0_data;
64 break;
65
66 case 18:
67 dev->dev.platform_data = &eap7660d_wmac1_data;
68 break;
69 }
70
71 return 0;
72 }
73
74 void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
75 u8 *cal_data1, u8 *mac_addr1)
76 {
77 if (cal_data0 && *cal_data0 == 0xa55a) {
78 memcpy(eap7660d_wmac0_eeprom, cal_data0,
79 ATH5K_PLAT_EEP_MAX_WORDS);
80 eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
81 }
82
83 if (cal_data1 && *cal_data1 == 0xa55a) {
84 memcpy(eap7660d_wmac1_eeprom, cal_data1,
85 ATH5K_PLAT_EEP_MAX_WORDS);
86 eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
87 }
88
89 if (mac_addr0) {
90 memcpy(eap7660d_wmac0_mac, mac_addr0,
91 sizeof(eap7660d_wmac0_mac));
92 eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
93 }
94
95 if (mac_addr1) {
96 memcpy(eap7660d_wmac1_mac, mac_addr1,
97 sizeof(eap7660d_wmac1_mac));
98 eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
99 }
100
101 ar71xx_pci_plat_dev_init = eap7660d_pci_plat_dev_init;
102 ar71xx_pci_init(ARRAY_SIZE(eap7660d_pci_irqs), eap7660d_pci_irqs);
103 }
104
105 static struct gpio_led eap7660d_leds_gpio[] __initdata = {
106 {
107 .name = "eap7660d:green:ds8",
108 .gpio = EAP7660D_GPIO_DS8,
109 .active_low = 0,
110 },
111 {
112 .name = "eap7660d:green:ds5",
113 .gpio = EAP7660D_GPIO_DS5,
114 .active_low = 0,
115 },
116 {
117 .name = "eap7660d:green:ds7",
118 .gpio = EAP7660D_GPIO_DS7,
119 .active_low = 0,
120 },
121 {
122 .name = "eap7660d:green:ds4",
123 .gpio = EAP7660D_GPIO_DS4,
124 .active_low = 0,
125 }
126 };
127
128 static struct gpio_button eap7660d_gpio_buttons[] __initdata = {
129 {
130 .desc = "reset",
131 .type = EV_KEY,
132 .code = KEY_RESTART,
133 .threshold = 3,
134 .gpio = EAP7660D_GPIO_SW1,
135 .active_low = 1,
136 },
137 {
138 .desc = "wps",
139 .type = EV_KEY,
140 .code = KEY_WPS_BUTTON,
141 .threshold = 3,
142 .gpio = EAP7660D_GPIO_SW3,
143 .active_low = 1,
144 }
145 };
146
147 static void __init eap7660d_setup(void)
148 {
149 u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
150
151 ar71xx_add_device_mdio(~EAP7660D_PHYMASK);
152
153 ar71xx_init_mac(ar71xx_eth0_data.mac_addr,
154 boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
155 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
156 ar71xx_eth0_data.phy_mask = EAP7660D_PHYMASK;
157 ar71xx_add_device_eth(0);
158 ar71xx_add_device_m25p80(NULL);
159 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
160 eap7660d_leds_gpio);
161 ar71xx_add_device_gpio_buttons(-1, EAP7660D_BUTTONS_POLL_INTERVAL,
162 ARRAY_SIZE(eap7660d_gpio_buttons),
163 eap7660d_gpio_buttons);
164 eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
165 boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
166 boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
167 boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
168 };
169
170 MIPS_MACHINE(AR71XX_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",
171 eap7660d_setup);
This page took 0.047712 seconds and 5 git commands to generate.