Lines Matching +full:out +full:- +full:of +full:- +full:window

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Normal mappings of flash chips in physical memory
11 * Eric Biederman, of course, was a major help in this effort.
38 /* This became a 16-bit register, and EN2 has disappeared */
56 /* these are 32-bit values */
118 static void esb2rom_cleanup(struct esb2rom_window *window) in esb2rom_cleanup() argument
123 /* Disable writes through the rom window */ in esb2rom_cleanup()
124 pci_read_config_byte(window->pdev, BIOS_CNTL, &byte); in esb2rom_cleanup()
125 pci_write_config_byte(window->pdev, BIOS_CNTL, in esb2rom_cleanup()
128 /* Free all of the mtd devices */ in esb2rom_cleanup()
129 list_for_each_entry_safe(map, scratch, &window->maps, list) { in esb2rom_cleanup()
130 if (map->rsrc.parent) in esb2rom_cleanup()
131 release_resource(&map->rsrc); in esb2rom_cleanup()
132 mtd_device_unregister(map->mtd); in esb2rom_cleanup()
133 map_destroy(map->mtd); in esb2rom_cleanup()
134 list_del(&map->list); in esb2rom_cleanup()
137 if (window->rsrc.parent) in esb2rom_cleanup()
138 release_resource(&window->rsrc); in esb2rom_cleanup()
139 if (window->virt) { in esb2rom_cleanup()
140 iounmap(window->virt); in esb2rom_cleanup()
141 window->virt = NULL; in esb2rom_cleanup()
142 window->phys = 0; in esb2rom_cleanup()
143 window->size = 0; in esb2rom_cleanup()
145 pci_dev_put(window->pdev); in esb2rom_cleanup()
152 struct esb2rom_window *window = &esb2rom_window; in esb2rom_init_one() local
159 * are not a lot of resources up at the top of the address in esb2rom_init_one()
163 * a number of simplifications you can make. in esb2rom_init_one()
165 * Also you can page firmware hubs if an 8MiB window isn't enough in esb2rom_init_one()
168 window->pdev = pci_dev_get(pdev); in esb2rom_init_one()
170 /* RLG: experiment 2. Force the window registers to the widest values */ in esb2rom_init_one()
186 /* Find a region continuous to the end of the ROM window */ in esb2rom_init_one()
187 window->phys = 0; in esb2rom_init_one()
192 window->phys = 0xff400000; in esb2rom_init_one()
194 window->phys = 0xff500000; in esb2rom_init_one()
196 window->phys = 0xff600000; in esb2rom_init_one()
198 window->phys = 0xFF700000; in esb2rom_init_one()
200 window->phys = 0xffc00000; in esb2rom_init_one()
202 window->phys = 0xffc80000; in esb2rom_init_one()
204 window->phys = 0xffd00000; in esb2rom_init_one()
206 window->phys = 0xffd80000; in esb2rom_init_one()
208 window->phys = 0xffe00000; in esb2rom_init_one()
210 window->phys = 0xffe80000; in esb2rom_init_one()
212 window->phys = 0xfff00000; in esb2rom_init_one()
214 window->phys = 0xfff80000; in esb2rom_init_one()
216 if (window->phys == 0) { in esb2rom_init_one()
217 printk(KERN_ERR MOD_NAME ": Rom window is closed\n"); in esb2rom_init_one()
218 goto out; in esb2rom_init_one()
222 window->phys -= 0x400000UL; in esb2rom_init_one()
223 window->size = (0xffffffffUL - window->phys) + 1UL; in esb2rom_init_one()
225 /* Enable writes through the rom window */ in esb2rom_init_one()
232 goto out; in esb2rom_init_one()
237 * Try to reserve the window mem region. If this fails then in esb2rom_init_one()
238 * it is likely due to the window being "reserved" by the BIOS. in esb2rom_init_one()
240 window->rsrc.name = MOD_NAME; in esb2rom_init_one()
241 window->rsrc.start = window->phys; in esb2rom_init_one()
242 window->rsrc.end = window->phys + window->size - 1; in esb2rom_init_one()
243 window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; in esb2rom_init_one()
244 if (request_resource(&iomem_resource, &window->rsrc)) { in esb2rom_init_one()
245 window->rsrc.parent = NULL; in esb2rom_init_one()
247 "%s(): Unable to register resource %pR - kernel bug?\n", in esb2rom_init_one()
248 __func__, &window->rsrc); in esb2rom_init_one()
252 window->virt = ioremap(window->phys, window->size); in esb2rom_init_one()
253 if (!window->virt) { in esb2rom_init_one()
255 window->phys, window->size); in esb2rom_init_one()
256 goto out; in esb2rom_init_one()
260 map_top = window->phys; in esb2rom_init_one()
261 if ((window->phys & 0x3fffff) != 0) { in esb2rom_init_one()
263 map_top = window->phys + 0x400000; in esb2rom_init_one()
269 * ==> Probe at most the last 4M of the address space. in esb2rom_init_one()
275 while ((map_top - 1) < 0xffffffffUL) { in esb2rom_init_one()
283 goto out; in esb2rom_init_one()
286 INIT_LIST_HEAD(&map->list); in esb2rom_init_one()
287 map->map.name = map->map_name; in esb2rom_init_one()
288 map->map.phys = map_top; in esb2rom_init_one()
289 offset = map_top - window->phys; in esb2rom_init_one()
290 map->map.virt = (void __iomem *) in esb2rom_init_one()
291 (((unsigned long)(window->virt)) + offset); in esb2rom_init_one()
292 map->map.size = 0xffffffffUL - map_top + 1UL; in esb2rom_init_one()
293 /* Set the name of the map to the address I am trying */ in esb2rom_init_one()
294 sprintf(map->map_name, "%s @%08Lx", in esb2rom_init_one()
295 MOD_NAME, (unsigned long long)map->map.phys); in esb2rom_init_one()
298 * in a factory setting. So in-place programming in esb2rom_init_one()
301 for(map->map.bankwidth = 32; map->map.bankwidth; in esb2rom_init_one()
302 map->map.bankwidth >>= 1) { in esb2rom_init_one()
305 if (!map_bankwidth_supported(map->map.bankwidth)) in esb2rom_init_one()
309 simple_map_init(&map->map); in esb2rom_init_one()
311 /* Try all of the probe methods */ in esb2rom_init_one()
314 map->mtd = do_map_probe(*probe_type, &map->map); in esb2rom_init_one()
315 if (map->mtd) in esb2rom_init_one()
323 if (map->mtd->size > map->map.size) { in esb2rom_init_one()
325 " rom(%llu) larger than window(%lu). fixing...\n", in esb2rom_init_one()
326 (unsigned long long)map->mtd->size, map->map.size); in esb2rom_init_one()
327 map->mtd->size = map->map.size; in esb2rom_init_one()
329 if (window->rsrc.parent) { in esb2rom_init_one()
335 map->rsrc.name = map->map_name; in esb2rom_init_one()
336 map->rsrc.start = map->map.phys; in esb2rom_init_one()
337 map->rsrc.end = map->map.phys + map->mtd->size - 1; in esb2rom_init_one()
338 map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; in esb2rom_init_one()
339 if (request_resource(&window->rsrc, &map->rsrc)) { in esb2rom_init_one()
342 map->rsrc.parent = NULL; in esb2rom_init_one()
347 map->map.virt = window->virt; in esb2rom_init_one()
348 map->map.phys = window->phys; in esb2rom_init_one()
349 cfi = map->map.fldrv_priv; in esb2rom_init_one()
350 for(i = 0; i < cfi->numchips; i++) in esb2rom_init_one()
351 cfi->chips[i].start += offset; in esb2rom_init_one()
354 map->mtd->owner = THIS_MODULE; in esb2rom_init_one()
355 if (mtd_device_register(map->mtd, NULL, 0)) { in esb2rom_init_one()
356 map_destroy(map->mtd); in esb2rom_init_one()
357 map->mtd = NULL; in esb2rom_init_one()
358 goto out; in esb2rom_init_one()
361 /* Calculate the new value of map_top */ in esb2rom_init_one()
362 map_top += map->mtd->size; in esb2rom_init_one()
365 list_add(&map->list, &window->maps); in esb2rom_init_one()
369 out: in esb2rom_init_one()
374 if (list_empty(&window->maps)) { in esb2rom_init_one()
375 esb2rom_cleanup(window); in esb2rom_init_one()
376 return -ENODEV; in esb2rom_init_one()
383 struct esb2rom_window *window = &esb2rom_window; in esb2rom_remove_one() local
384 esb2rom_cleanup(window); in esb2rom_remove_one()
421 for (id = esb2rom_pci_tbl; id->vendor; id++) { in init_esb2rom()
422 printk(KERN_DEBUG "device id = %x\n", id->device); in init_esb2rom()
423 pdev = pci_get_device(id->vendor, id->device, NULL); in init_esb2rom()
425 printk(KERN_DEBUG "matched device = %x\n", id->device); in init_esb2rom()
430 printk(KERN_DEBUG "matched device id %x\n", id->device); in init_esb2rom()
436 return -ENXIO; in init_esb2rom()