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
,
91 sizeof(eap7660d_wmac0_mac
));
92 eap7660d_wmac0_data
.macaddr
= eap7660d_wmac0_mac
;
96 memcpy(eap7660d_wmac1_mac
, mac_addr1
,
97 sizeof(eap7660d_wmac1_mac
));
98 eap7660d_wmac1_data
.macaddr
= eap7660d_wmac1_mac
;
101 ar71xx_pci_plat_dev_init
= eap7660d_pci_plat_dev_init
;
102 ar71xx_pci_init(ARRAY_SIZE(eap7660d_pci_irqs
), eap7660d_pci_irqs
);
105 static struct gpio_led eap7660d_leds_gpio
[] __initdata
= {
107 .name
= "eap7660d:green:ds8",
108 .gpio
= EAP7660D_GPIO_DS8
,
112 .name
= "eap7660d:green:ds5",
113 .gpio
= EAP7660D_GPIO_DS5
,
117 .name
= "eap7660d:green:ds7",
118 .gpio
= EAP7660D_GPIO_DS7
,
122 .name
= "eap7660d:green:ds4",
123 .gpio
= EAP7660D_GPIO_DS4
,
128 static struct gpio_button eap7660d_gpio_buttons
[] __initdata
= {
134 .gpio
= EAP7660D_GPIO_SW1
,
140 .code
= KEY_WPS_BUTTON
,
142 .gpio
= EAP7660D_GPIO_SW3
,
147 static void __init
eap7660d_setup(void)
149 u8
*boardconfig
= (u8
*) KSEG1ADDR(EAP7660D_BOARDCONFIG
);
151 ar71xx_add_device_mdio(~EAP7660D_PHYMASK
);
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
),
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
);
170 MIPS_MACHINE(AR71XX_MACH_EAP7660D
, "EAP7660D", "Senao EAP7660D",