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>
16 #include <asm/mach-ar71xx/ar71xx.h>
17 #include <asm/mach-ar71xx/pci.h>
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
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
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];
47 static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
51 .irq = AR71XX_PCI_IRQ_DEV0,
55 .irq = AR71XX_PCI_IRQ_DEV1,
59 static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
61 switch(PCI_SLOT(dev->devfn)) {
63 dev->dev.platform_data = &eap7660d_wmac0_data;
67 dev->dev.platform_data = &eap7660d_wmac1_data;
74 void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
75 u8 *cal_data1, u8 *mac_addr1)
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;
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;
90 memcpy(eap7660d_wmac0_mac, mac_addr0, sizeof(eap7660d_wmac0_mac));
91 eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
95 memcpy(eap7660d_wmac1_mac, mac_addr1, sizeof(eap7660d_wmac1_mac));
96 eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
99 ar71xx_pci_plat_dev_init = eap7660d_pci_plat_dev_init;
100 ar71xx_pci_init(ARRAY_SIZE(eap7660d_pci_irqs), eap7660d_pci_irqs);
103 static struct gpio_led eap7660d_leds_gpio[] __initdata = {
105 .name = "eap7660d:green:ds8",
106 .gpio = EAP7660D_GPIO_DS8,
110 .name = "eap7660d:green:ds5",
111 .gpio = EAP7660D_GPIO_DS5,
115 .name = "eap7660d:green:ds7",
116 .gpio = EAP7660D_GPIO_DS7,
120 .name = "eap7660d:green:ds4",
121 .gpio = EAP7660D_GPIO_DS4,
126 static struct gpio_button eap7660d_gpio_buttons[] __initdata = {
132 .gpio = EAP7660D_GPIO_SW1,
138 .code = KEY_WPS_BUTTON,
140 .gpio = EAP7660D_GPIO_SW3,
145 static void __init eap7660d_setup(void)
147 u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
148 ar71xx_set_mac_base(boardconfig + EAP7660D_GBIC_MAC_OFFSET);
149 ar71xx_add_device_mdio(~EAP7660D_PHYMASK);
150 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
151 ar71xx_eth0_data.phy_mask = EAP7660D_PHYMASK;
152 ar71xx_add_device_eth(0);
153 ar71xx_add_device_m25p80(NULL);
154 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(eap7660d_leds_gpio),
156 ar71xx_add_device_gpio_buttons(-1, EAP7660D_BUTTONS_POLL_INTERVAL,
157 ARRAY_SIZE(eap7660d_gpio_buttons),
158 eap7660d_gpio_buttons);
159 eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
160 boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
161 boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
162 boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
165 MIPS_MACHINE(AR71XX_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",