2436491b4ec1dacf6b05f3f7934ef5ab80d239ff
[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 static struct ath9k_platform_data ap94_wmac1_data;
23 static char ap94_wmac0_mac[6];
24 static char ap94_wmac1_mac[6];
25
26 static struct ar71xx_pci_irq ap94_pci_irqs[] __initdata = {
27 {
28 .slot = 0,
29 .pin = 1,
30 .irq = AR71XX_PCI_IRQ_DEV0,
31 }, {
32 .slot = 1,
33 .pin = 1,
34 .irq = AR71XX_PCI_IRQ_DEV1,
35 }
36 };
37
38 static int ap94_pci_plat_dev_init(struct pci_dev *dev)
39 {
40 switch(PCI_SLOT(dev->devfn)) {
41 case 17:
42 dev->dev.platform_data = &ap94_wmac0_data;
43 break;
44
45 case 18:
46 dev->dev.platform_data = &ap94_wmac1_data;
47 break;
48 }
49
50 return 0;
51 }
52
53 void __init ap94_pci_enable_quirk_wndr3700(void)
54 {
55 ap94_wmac0_data.quirk_wndr3700 = 1;
56 ap94_wmac1_data.quirk_wndr3700 = 1;
57 }
58
59 void __init ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
60 u8 *cal_data1, u8 *mac_addr1)
61 {
62 if (cal_data0)
63 memcpy(ap94_wmac0_data.eeprom_data, cal_data0,
64 sizeof(ap94_wmac0_data.eeprom_data));
65
66 if (cal_data1)
67 memcpy(ap94_wmac1_data.eeprom_data, cal_data1,
68 sizeof(ap94_wmac1_data.eeprom_data));
69
70 if (mac_addr0) {
71 memcpy(ap94_wmac0_mac, mac_addr0, sizeof(ap94_wmac0_mac));
72 ap94_wmac0_data.macaddr = ap94_wmac0_mac;
73 }
74
75 if (mac_addr1) {
76 memcpy(ap94_wmac1_mac, mac_addr1, sizeof(ap94_wmac1_mac));
77 ap94_wmac1_data.macaddr = ap94_wmac1_mac;
78 }
79
80 ar71xx_pci_plat_dev_init = ap94_pci_plat_dev_init;
81 ar71xx_pci_init(ARRAY_SIZE(ap94_pci_irqs), ap94_pci_irqs);
82
83 pci_enable_ath9k_fixup(17, ap94_wmac0_data.eeprom_data);
84 pci_enable_ath9k_fixup(18, ap94_wmac1_data.eeprom_data);
85 }