2 * Atheros AP94 reference board PCI initialization
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/pci.h>
12 #include <linux/ath9k_platform.h>
13 #include <linux/delay.h>
15 #include <asm/mach-ar71xx/ar71xx.h>
16 #include <asm/mach-ar71xx/pci.h>
18 #include "dev-ap94-pci.h"
19 #include "pci-ath9k-fixup.h"
21 static struct ath9k_platform_data ap94_wmac0_data
= {
24 static struct ath9k_platform_data ap94_wmac1_data
= {
27 static char ap94_wmac0_mac
[6];
28 static char ap94_wmac1_mac
[6];
30 static struct ar71xx_pci_irq ap94_pci_irqs
[] __initdata
= {
34 .irq
= AR71XX_PCI_IRQ_DEV0
,
38 .irq
= AR71XX_PCI_IRQ_DEV1
,
42 static int ap94_pci_plat_dev_init(struct pci_dev
*dev
)
44 switch (PCI_SLOT(dev
->devfn
)) {
46 dev
->dev
.platform_data
= &ap94_wmac0_data
;
50 dev
->dev
.platform_data
= &ap94_wmac1_data
;
57 void __init
ap94_pci_enable_quirk_wndr3700(void)
59 /* WNDR3700 uses GPIO 6-9 for antenna configuration */
61 ap94_wmac0_data
.led_pin
= 5;
62 ap94_wmac0_data
.gpio_mask
= (0xf << 6);
63 /* 2.4 GHz uses the first fixed antenna group (0, 1, 0, 1) */
64 ap94_wmac0_data
.gpio_val
= (10 << 6);
66 ap94_wmac1_data
.led_pin
= 5;
67 ap94_wmac1_data
.gpio_mask
= (0xf << 6);
68 /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
69 ap94_wmac1_data
.gpio_val
= (6 << 6);
72 void __init
ap94_pci_init(u8
*cal_data0
, u8
*mac_addr0
,
73 u8
*cal_data1
, u8
*mac_addr1
)
76 memcpy(ap94_wmac0_data
.eeprom_data
, cal_data0
,
77 sizeof(ap94_wmac0_data
.eeprom_data
));
80 memcpy(ap94_wmac1_data
.eeprom_data
, cal_data1
,
81 sizeof(ap94_wmac1_data
.eeprom_data
));
84 memcpy(ap94_wmac0_mac
, mac_addr0
, sizeof(ap94_wmac0_mac
));
85 ap94_wmac0_data
.macaddr
= ap94_wmac0_mac
;
89 memcpy(ap94_wmac1_mac
, mac_addr1
, sizeof(ap94_wmac1_mac
));
90 ap94_wmac1_data
.macaddr
= ap94_wmac1_mac
;
93 ar71xx_pci_plat_dev_init
= ap94_pci_plat_dev_init
;
94 ar71xx_pci_init(ARRAY_SIZE(ap94_pci_irqs
), ap94_pci_irqs
);
96 pci_enable_ath9k_fixup(17, ap94_wmac0_data
.eeprom_data
);
97 pci_enable_ath9k_fixup(18, ap94_wmac1_data
.eeprom_data
);