1fd40bb62803a828b4ac25d09529a3c676cd402c
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / dev-ap94-pci.c
1 /*
2 * Atheros AP94 reference board PCI initialization
3 *
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
11 #include <linux/pci.h>
12 #include <linux/ath9k_platform.h>
13 #include <linux/delay.h>
14
15 #include <asm/mach-ar71xx/ar71xx.h>
16 #include <asm/mach-ar71xx/pci.h>
17
18 #include "dev-ap94-pci.h"
19 #include "pci-ath9k-fixup.h"
20
21 static struct ath9k_platform_data ap94_wmac0_data = {
22 .led_pin = -1,
23 };
24 static struct ath9k_platform_data ap94_wmac1_data = {
25 .led_pin = -1,
26 };
27 static char ap94_wmac0_mac[6];
28 static char ap94_wmac1_mac[6];
29
30 static struct ar71xx_pci_irq ap94_pci_irqs[] __initdata = {
31 {
32 .slot = 0,
33 .pin = 1,
34 .irq = AR71XX_PCI_IRQ_DEV0,
35 }, {
36 .slot = 1,
37 .pin = 1,
38 .irq = AR71XX_PCI_IRQ_DEV1,
39 }
40 };
41
42 static int ap94_pci_plat_dev_init(struct pci_dev *dev)
43 {
44 switch(PCI_SLOT(dev->devfn)) {
45 case 17:
46 dev->dev.platform_data = &ap94_wmac0_data;
47 break;
48
49 case 18:
50 dev->dev.platform_data = &ap94_wmac1_data;
51 break;
52 }
53
54 return 0;
55 }
56
57 void __init ap94_pci_enable_quirk_wndr3700(void)
58 {
59 /* WNDR3700 uses GPIO 6-9 for antenna configuration */
60
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 = (5 << 6);
65
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);
70 }
71
72 void __init ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
73 u8 *cal_data1, u8 *mac_addr1)
74 {
75 if (cal_data0)
76 memcpy(ap94_wmac0_data.eeprom_data, cal_data0,
77 sizeof(ap94_wmac0_data.eeprom_data));
78
79 if (cal_data1)
80 memcpy(ap94_wmac1_data.eeprom_data, cal_data1,
81 sizeof(ap94_wmac1_data.eeprom_data));
82
83 if (mac_addr0) {
84 memcpy(ap94_wmac0_mac, mac_addr0, sizeof(ap94_wmac0_mac));
85 ap94_wmac0_data.macaddr = ap94_wmac0_mac;
86 }
87
88 if (mac_addr1) {
89 memcpy(ap94_wmac1_mac, mac_addr1, sizeof(ap94_wmac1_mac));
90 ap94_wmac1_data.macaddr = ap94_wmac1_mac;
91 }
92
93 ar71xx_pci_plat_dev_init = ap94_pci_plat_dev_init;
94 ar71xx_pci_init(ARRAY_SIZE(ap94_pci_irqs), ap94_pci_irqs);
95
96 pci_enable_ath9k_fixup(17, ap94_wmac0_data.eeprom_data);
97 pci_enable_ath9k_fixup(18, ap94_wmac1_data.eeprom_data);
98 }