summaryrefslogtreecommitdiff
path: root/target/linux/ar71xx/files/arch/mips
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-07-15 07:36:52 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-07-15 07:36:52 +0000
commite14f929ec7584802939782a42bb110d6b02c7f43 (patch)
tree2db34e176a8b421bb46717545e8bd8b655fc68a2 /target/linux/ar71xx/files/arch/mips
parent8ec9d56a59cced2b14d8c21497182701559b77eb (diff)
ar71xx: in-flash macs and eeprom for mach-eap7660d
This adds in-flash mac-addresses and calibration data for the Senao EAP7660D board. Signed-off-by: Daniel Golle <daniel.golle@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22187 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar71xx/files/arch/mips')
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig1
-rw-r--r--target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c81
2 files changed, 79 insertions, 3 deletions
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
index 95c65bc88f..6162f800c4 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig
@@ -226,7 +226,6 @@ config AR71XX_MACH_UBNT
config AR71XX_MACH_EAP7660D
bool "Senao EAP7660D support"
select AR71XX_DEV_M25P80
- select AR71XX_DEV_PB42_PCI if PCI
select AR71XX_DEV_GPIO_BUTTONS
select AR71XX_DEV_LEDS_GPIO
default n
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
index f7e72563ff..6da318e2d1 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-eap7660d.c
@@ -10,13 +10,16 @@
* by the Free Software Foundation.
*/
+#include <linux/pci.h>
+#include <linux/ath5k_platform.h>
+#include <linux/delay.h>
#include <asm/mach-ar71xx/ar71xx.h>
+#include <asm/mach-ar71xx/pci.h>
#include "machtype.h"
#include "devices.h"
#include "dev-gpio-buttons.h"
#include "dev-leds-gpio.h"
-#include "dev-pb42-pci.h"
#include "dev-m25p80.h"
#define EAP7660D_BUTTONS_POLL_INTERVAL 20
@@ -27,6 +30,75 @@
#define EAP7660D_GPIO_SW1 3
#define EAP7660D_GPIO_SW3 8
#define EAP7660D_PHYMASK BIT(20)
+#define EAP7660D_BOARDCONFIG 0x1F7F0000
+#define EAP7660D_GBIC_MAC_OFFSET 0x1000
+#define EAP7660D_WMAC0_MAC_OFFSET 0x1010
+#define EAP7660D_WMAC1_MAC_OFFSET 0x1016
+#define EAP7660D_WMAC0_CALDATA_OFFSET 0x2000
+#define EAP7660D_WMAC1_CALDATA_OFFSET 0x3000
+
+static struct ath5k_platform_data eap7660d_wmac0_data;
+static struct ath5k_platform_data eap7660d_wmac1_data;
+static char eap7660d_wmac0_mac[6];
+static char eap7660d_wmac1_mac[6];
+static u16 eap7660d_wmac0_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
+static u16 eap7660d_wmac1_eeprom[ATH5K_PLAT_EEP_MAX_WORDS];
+
+static struct ar71xx_pci_irq eap7660d_pci_irqs[] __initdata = {
+ {
+ .slot = 0,
+ .pin = 1,
+ .irq = AR71XX_PCI_IRQ_DEV0,
+ }, {
+ .slot = 1,
+ .pin = 1,
+ .irq = AR71XX_PCI_IRQ_DEV1,
+ }
+};
+
+static int eap7660d_pci_plat_dev_init(struct pci_dev *dev)
+{
+ switch(PCI_SLOT(dev->devfn)) {
+ case 17:
+ dev->dev.platform_data = &eap7660d_wmac0_data;
+ break;
+
+ case 18:
+ dev->dev.platform_data = &eap7660d_wmac1_data;
+ break;
+ }
+
+ return 0;
+}
+
+void __init eap7660d_pci_init(u8 *cal_data0, u8 *mac_addr0,
+ u8 *cal_data1, u8 *mac_addr1)
+{
+ if (cal_data0 && *cal_data0 == 0xa55a) {
+ memcpy(eap7660d_wmac0_eeprom, cal_data0,
+ ATH5K_PLAT_EEP_MAX_WORDS);
+ eap7660d_wmac0_data.eeprom_data = eap7660d_wmac0_eeprom;
+ }
+
+ if (cal_data1 && *cal_data1 == 0xa55a) {
+ memcpy(eap7660d_wmac1_eeprom, cal_data1,
+ ATH5K_PLAT_EEP_MAX_WORDS);
+ eap7660d_wmac1_data.eeprom_data = eap7660d_wmac1_eeprom;
+ }
+
+ if (mac_addr0) {
+ memcpy(eap7660d_wmac0_mac, mac_addr0, sizeof(eap7660d_wmac0_mac));
+ eap7660d_wmac0_data.macaddr = eap7660d_wmac0_mac;
+ }
+
+ if (mac_addr1) {
+ memcpy(eap7660d_wmac1_mac, mac_addr1, sizeof(eap7660d_wmac1_mac));
+ eap7660d_wmac1_data.macaddr = eap7660d_wmac1_mac;
+ }
+
+ ar71xx_pci_plat_dev_init = eap7660d_pci_plat_dev_init;
+ ar71xx_pci_init(ARRAY_SIZE(eap7660d_pci_irqs), eap7660d_pci_irqs);
+}
static struct gpio_led eap7660d_leds_gpio[] __initdata = {
{
@@ -72,6 +144,8 @@ static struct gpio_button eap7660d_gpio_buttons[] __initdata = {
static void __init eap7660d_setup(void)
{
+ u8 *boardconfig = (u8 *) KSEG1ADDR(EAP7660D_BOARDCONFIG);
+ ar71xx_set_mac_base(boardconfig + EAP7660D_GBIC_MAC_OFFSET);
ar71xx_add_device_mdio(~EAP7660D_PHYMASK);
ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
ar71xx_eth0_data.phy_mask = EAP7660D_PHYMASK;
@@ -82,7 +156,10 @@ static void __init eap7660d_setup(void)
ar71xx_add_device_gpio_buttons(-1, EAP7660D_BUTTONS_POLL_INTERVAL,
ARRAY_SIZE(eap7660d_gpio_buttons),
eap7660d_gpio_buttons);
- pb42_pci_init();
+ eap7660d_pci_init(boardconfig + EAP7660D_WMAC0_CALDATA_OFFSET,
+ boardconfig + EAP7660D_WMAC0_MAC_OFFSET,
+ boardconfig + EAP7660D_WMAC1_CALDATA_OFFSET,
+ boardconfig + EAP7660D_WMAC1_MAC_OFFSET);
};
MIPS_MACHINE(AR71XX_MACH_EAP7660D, "EAP7660D", "Senao EAP7660D",