7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
11 #include <linux/slab.h>
17 #include <linux/pci.h>
19 #include <linux/list.h>
22 #define xstr(s) str(s)
24 #define MOD_NAME xstr(KBUILD_BASENAME)
26 #define ADDRESS_NAME_LEN 18
28 #define ROM_PROBE_STEP_SIZE (64*1024)
60 static uint win_size_bits;
62 MODULE_PARM_DESC(win_size_bits,
"ROM window size bits override for 0x43 byte, normally set by BIOS.");
68 static void amd76xrom_cleanup(
struct amd76xrom_window *
window)
75 pci_read_config_byte(window->
pdev, 0x40, &byte);
76 pci_write_config_byte(window->
pdev, 0x40, byte & ~1);
82 if (map->
rsrc.parent) {
90 if (window->
rsrc.parent)
106 static char *rom_probe_types[] = {
"cfi_probe",
"jedec_probe",
NULL };
108 struct amd76xrom_window *window = &amd76xrom_window;
110 unsigned long map_top;
122 pci_read_config_byte(pdev, 0x43, &byte);
123 pci_write_config_byte(pdev, 0x43, byte | win_size_bits );
126 pci_read_config_byte(pdev, 0x43, &byte);
127 if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6))) {
128 window->
phys = 0xffb00000;
130 else if ((byte & (1<<7)) == (1<<7)) {
131 window->
phys = 0xffc00000;
134 window->
phys = 0xffff0000;
152 " %s(): Unable to register resource %pR - kernel bug?\n",
153 __func__, &window->
rsrc);
159 pci_read_config_byte(pdev, 0x40, &byte);
160 pci_write_config_byte(pdev, 0x40, byte | 1);
173 map_top = window->
phys;
179 if (map_top < 0xffc00000) {
180 map_top = 0xffc00000;
184 while((map_top - 1) < 0xffffffffUL) {
196 memset(map, 0,
sizeof(*map));
197 INIT_LIST_HEAD(&map->
list);
199 map->
map.phys = map_top;
200 offset = map_top - window->
phys;
203 map->
map.size = 0xffffffff
UL - map_top + 1
UL;
209 for(map->
map.bankwidth = 32; map->
map.bankwidth;
210 map->
map.bankwidth >>= 1)
214 if (!map_bankwidth_supported(map->
map.bankwidth))
221 probe_type = rom_probe_types;
222 for(; *probe_type; probe_type++) {
232 if (map->
mtd->size > map->
map.size) {
234 " rom(%llu) larger than window(%lu). fixing...\n",
235 (
unsigned long long)map->
mtd->size, map->
map.size);
236 map->
mtd->size = map->
map.size;
238 if (window->
rsrc.parent) {
245 map->
rsrc.start = map->
map.phys;
246 map->
rsrc.end = map->
map.phys + map->
mtd->size - 1;
250 ": cannot reserve MTD resource\n");
258 cfi = map->
map.fldrv_priv;
259 for(i = 0; i < cfi->
numchips; i++) {
273 map_top += map->
mtd->size;
276 list_add(&map->
list, &window->
maps);
284 if (list_empty(&window->
maps)) {
285 amd76xrom_cleanup(window);
294 struct amd76xrom_window *window = &amd76xrom_window;
296 amd76xrom_cleanup(window);
313 .id_table = amd76xrom_pci_tbl,
314 .probe = amd76xrom_init_one,
315 .remove = amd76xrom_remove_one,
319 static int __init init_amd76xrom(
void)
324 for(
id = amd76xrom_pci_tbl;
id->
vendor;
id++) {
331 return amd76xrom_init_one(pdev, &amd76xrom_pci_tbl[0]);
335 return pci_register_driver(&amd76xrom_driver);
339 static void __exit cleanup_amd76xrom(
void)
341 amd76xrom_remove_one(amd76xrom_window.
pdev);