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/delay.h>
14 #include <asm/mach-ar71xx/ar71xx.h>
15 #include <asm/mach-ar71xx/pci.h>
22 static int ath9k_num_fixups
;
23 static struct ath9k_fixup ath9k_fixups
[2];
25 static void ath9k_pci_fixup(struct pci_dev
*dev
)
34 for (i
= 0; i
< ath9k_num_fixups
; i
++) {
35 if (ath9k_fixups
[i
].cal_data
== NULL
)
38 if (ath9k_fixups
[i
].slot
!= PCI_SLOT(dev
->devfn
))
41 cal_data
= ath9k_fixups
[i
].cal_data
;
48 if (*cal_data
!= 0xa55a) {
49 pr_err("pci %s: invalid calibration data\n", pci_name(dev
));
53 pr_info("pci %s: fixup device configuration\n", pci_name(dev
));
55 mem
= ioremap(AR71XX_PCI_MEM_BASE
, 0x10000);
57 pr_err("pci %s: ioremap error\n", pci_name(dev
));
61 pci_read_config_dword(dev
, PCI_BASE_ADDRESS_0
, &bar0
);
64 case AR71XX_SOC_AR7161
:
65 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
,
68 case AR71XX_SOC_AR7240
:
69 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
, 0xffff);
72 case AR71XX_SOC_AR7241
:
73 case AR71XX_SOC_AR7242
:
74 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
, 0x1000ffff);
81 pci_read_config_word(dev
, PCI_COMMAND
, &cmd
);
82 cmd
|= PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
;
83 pci_write_config_word(dev
, PCI_COMMAND
, cmd
);
85 /* set pointer to first reg address */
87 while (*cal_data
!= 0xffff) {
91 val
|= (*cal_data
++) << 16;
93 __raw_writel(val
, mem
+ reg
);
97 pci_read_config_dword(dev
, PCI_VENDOR_ID
, &val
);
98 dev
->vendor
= val
& 0xffff;
99 dev
->device
= (val
>> 16) & 0xffff;
101 pci_read_config_dword(dev
, PCI_CLASS_REVISION
, &val
);
102 dev
->revision
= val
& 0xff;
103 dev
->class = val
>> 8; /* upper 3 bytes */
105 pci_read_config_word(dev
, PCI_COMMAND
, &cmd
);
106 cmd
&= ~(PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
);
107 pci_write_config_word(dev
, PCI_COMMAND
, cmd
);
109 pci_write_config_dword(dev
, PCI_BASE_ADDRESS_0
, bar0
);
113 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS
, PCI_ANY_ID
, ath9k_pci_fixup
);
115 void __init
pci_enable_ath9k_fixup(unsigned slot
, u16
*cal_data
)
117 if (ath9k_num_fixups
>= ARRAY_SIZE(ath9k_fixups
))
120 ath9k_fixups
[ath9k_num_fixups
].slot
= slot
;
121 ath9k_fixups
[ath9k_num_fixups
].cal_data
= cal_data
;
This page took 0.046927 seconds and 5 git commands to generate.