2 * Senao EAP7660D board support
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>
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/pci.h>
14 #include <linux/ath5k_platform.h>
15 #include <linux/delay.h>
17 #include <asm/mach-ath79/ath79.h>
18 #include <asm/mach-ath79/pci.h>
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "machtypes.h"
27 #define EAP7660D_KEYS_POLL_INTERVAL 20 /* msecs */
28 #define EAP7660D_KEYS_DEBOUNCE_INTERVAL (3 * EAP7660D_KEYS_POLL_INTERVAL)
30 #define EAP7660D_GPIO_DS4 7
31 #define EAP7660D_GPIO_DS5 2
32 #define EAP7660D_GPIO_DS7 0
33 #define EAP7660D_GPIO_DS8 4
34 #define EAP7660D_GPIO_SW1 3
35 #define EAP7660D_GPIO_SW3 8
36 #define EAP7660D_PHYMASK BIT(20)
37 #define EAP7660D_BOARDCONFIG 0x1F7F0000
38 #define EAP7660D_GBIC_MAC_OFFSET 0x1000
39 #define EAP7660D_WMAC0_MAC_OFFSET 0x1010
40 #define EAP7660D_WMAC1_MAC_OFFSET 0x1016
41 #define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
42 #define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
45 static struct ath5k_platform_data eap7660d_wmac0_data;
46 static struct ath5k_platform_data eap7660d_wmac1_data;
47 static char eap7660d_wmac0_mac[6];
48 static char eap7660d_wmac1_mac[6];
49 static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
50 static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
52 static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
54 switch (PCI_SLOT(dev->devfn)) {
56 dev->dev.platform_data = &eap7660d_wmac0_data;
60 dev->dev.platform_data = &eap7660d_wmac1_data;
67 void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
68 u8 *cal_data1, u8 *mac_addr1)
70 if (cal_data0 && *cal_data0 == 0xa55a) {
71 memcpy(eap7660d_wmac0_eeprom, cal_data0,
72 ATH5K_PLAT_EEP_MAX_WORDS);
73 eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
76 if (cal_data1 && *cal_data1 == 0xa55a) {
77 memcpy(eap7660d_wmac1_eeprom, cal_data1,
78 ATH5K_PLAT_EEP_MAX_WORDS);
79 eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
83 memcpy(eap7660d_wmac0_mac, mac_addr0,
84 sizeof(eap7660d_wmac0_mac));
85 eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
89 memcpy(eap7660d_wmac1_mac, mac_addr1,
90 sizeof(eap7660d_wmac1_mac));
91 eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
94 ath79_pci_set_plat_dev_init(eap7660d_pci_plat_dev_init);
98 static inline void eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
99 u8 *cal_data1, u8 *mac_addr1)
102 #endif /* CONFIG_PCI */
104 static struct gpio_led eap7660d_leds_gpio[] __initdata = {
106 .name = "eap7660d:green:ds8",
107 .gpio = EAP7660D_GPIO_DS8,
111 .name = "eap7660d:green:ds5",
112 .gpio = EAP7660D_GPIO_DS5,
116 .name = "eap7660d:green:ds7",
117 .gpio = EAP7660D_GPIO_DS7,
121 .name = "eap7660d:green:ds4",
122 .gpio = EAP7660D_GPIO_DS4,
127 static struct gpio_keys_button eap7660d_gpio_keys[] __initdata = {
132 .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
133 .gpio = EAP7660D_GPIO_SW1,
139 .code = KEY_WPS_BUTTON,
140 .debounce_interval = EAP7660D_KEYS_DEBOUNCE_INTERVAL,
141 .gpio = EAP7660D_GPIO_SW3,
146 static const char *eap7660d_part_probes[] = {
151 static struct flash_platform_data eap7660d_flash_data = {
152 .part_probes = eap7660d_part_probes,
155 static void __init eap7660d_setup(void)
157 u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
159 ath79_register_mdio(0, ~EAP7660D_PHYMASK);
161 ath79_init_mac(ath79_eth0_data.mac_addr,
162 boardconfig + EAP7660D_GBIC_MAC_OFFSET, 0);
163 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
164 ath79_eth0_data.phy_mask = EAP7660D_PHYMASK;
165 ath79_register_eth(0);
166 ath79_register_m25p80(&eap7660d_flash_data);
167 ath79_register_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
169 ath79_register_gpio_keys_polled(-1, EAP7660D_KEYS_POLL_INTERVAL,
170 ARRAY_SIZE(eap7660d_gpio_keys),
172 eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
173 boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
174 boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
175 boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
178 MIPS_MACHINE(ATH79_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",