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>
21 #define xstr(s) str(s)
23 #define MOD_NAME xstr(KBUILD_BASENAME)
25 #define ADDRESS_NAME_LEN 18
27 #define ROM_PROBE_STEP_SIZE (64*1024)
29 #define BIOS_CNTL 0x4e
30 #define FWH_DEC_EN1 0xE3
31 #define FWH_DEC_EN2 0xF0
56 static void ichxrom_cleanup(
struct ichxrom_window *
window)
75 if (window->
rsrc.parent)
90 static char *rom_probe_types[] = {
"cfi_probe",
"jedec_probe",
NULL };
91 struct ichxrom_window *window = &ichxrom_window;
93 unsigned long map_top;
113 window->
phys = 0xffc00000;
115 if ((byte & 0x0f) == 0x0f) {
116 window->
phys = 0xff400000;
118 else if ((byte & 0x0e) == 0x0e) {
119 window->
phys = 0xff500000;
121 else if ((byte & 0x0c) == 0x0c) {
122 window->
phys = 0xff600000;
124 else if ((byte & 0x08) == 0x08) {
125 window->
phys = 0xff700000;
128 else if ((byte & 0xfe) == 0xfe) {
129 window->
phys = 0xffc80000;
131 else if ((byte & 0xfc) == 0xfc) {
132 window->
phys = 0xffd00000;
134 else if ((byte & 0xf8) == 0xf8) {
135 window->
phys = 0xffd80000;
137 else if ((byte & 0xf0) == 0xf0) {
138 window->
phys = 0xffe00000;
140 else if ((byte & 0xe0) == 0xe0) {
141 window->
phys = 0xffe80000;
143 else if ((byte & 0xc0) == 0xc0) {
144 window->
phys = 0xfff00000;
146 else if ((byte & 0x80) == 0x80) {
147 window->
phys = 0xfff80000;
150 if (window->
phys == 0) {
154 window->
phys -= 0x400000
UL;
158 pci_read_config_word(pdev,
BIOS_CNTL, &word);
159 if (!(word & 1) && (word & (1<<1))) {
166 pci_write_config_word(pdev,
BIOS_CNTL, word | 1);
179 "%s(): Unable to register resource %pR - kernel bug?\n",
180 __func__, &window->
rsrc);
192 map_top = window->
phys;
193 if ((window->
phys & 0x3fffff) != 0) {
194 map_top = window->
phys + 0x400000;
201 if (map_top < 0xffc00000) {
202 map_top = 0xffc00000;
206 while((map_top - 1) < 0xffffffffUL) {
218 memset(map, 0,
sizeof(*map));
219 INIT_LIST_HEAD(&map->
list);
221 map->
map.phys = map_top;
222 offset = map_top - window->
phys;
225 map->
map.size = 0xffffffff
UL - map_top + 1
UL;
234 for(map->
map.bankwidth = 32; map->
map.bankwidth;
235 map->
map.bankwidth >>= 1)
239 if (!map_bankwidth_supported(map->
map.bankwidth))
246 probe_type = rom_probe_types;
247 for(; *probe_type; probe_type++) {
257 if (map->
mtd->size > map->
map.size) {
259 " rom(%llu) larger than window(%lu). fixing...\n",
260 (
unsigned long long)map->
mtd->size, map->
map.size);
261 map->
mtd->size = map->
map.size;
263 if (window->
rsrc.parent) {
270 map->
rsrc.start = map->
map.phys;
271 map->
rsrc.end = map->
map.phys + map->
mtd->size - 1;
275 ": cannot reserve MTD resource\n");
283 cfi = map->
map.fldrv_priv;
284 for(i = 0; i < cfi->
numchips; i++) {
298 map_top += map->
mtd->size;
301 list_add(&map->
list, &window->
maps);
310 if (list_empty(&window->
maps)) {
311 ichxrom_cleanup(window);
320 struct ichxrom_window *window = &ichxrom_window;
321 ichxrom_cleanup(window);
343 .id_table = ichxrom_pci_tbl,
344 .probe = ichxrom_init_one,
345 .remove = ichxrom_remove_one,
349 static int __init init_ichxrom(
void)
355 for (
id = ichxrom_pci_tbl;
id->vendor;
id++) {
362 return ichxrom_init_one(pdev, &ichxrom_pci_tbl[0]);
366 return pci_register_driver(&ichxrom_driver);
370 static void __exit cleanup_ichxrom(
void)
372 ichxrom_remove_one(ichxrom_window.
pdev);