// SPDX-License-Identifier: GPL-2.0-only /* * ck804xrom.c * * Normal mappings of chips in physical memory * * Dave Olsen <dolsen@lnxi.com> * Ryan Jackson <rjackson@lnxi.com>
*/
/* * The following applies to ck804 only: * The 2 bits controlling the window size are often set to allow reading * the BIOS, but too small to allow writing, since the lock registers are * 4MiB lower in the address space than the data. * * This is intended to prevent flashing the bios, perhaps accidentally. * * This parameter allows the normal driver to override the BIOS settings. * * The bits are 6 and 7. If both bits are set, it is a 5MiB window. * If only the 7 Bit is set, it is a 4MiB window. Otherwise, a * 64KiB window. * * The following applies to mcp55 only: * The 15 bits controlling the window size are distributed as follows: * byte @0x88: bit 0..7 * byte @0x8c: bit 8..15 * word @0x90: bit 16..30 * If all bits are enabled, we have a 16? MiB window * Please set win_size_bits to 0x7fffffff if you actually want to do something
*/ static uint win_size_bits = 0;
module_param(win_size_bits, uint, 0);
MODULE_PARM_DESC(win_size_bits, "ROM window size bits override, normally set by BIOS.");
if (window->pdev) { /* Disable writes through the rom window */
pci_read_config_byte(window->pdev, 0x6d, &byte);
pci_write_config_byte(window->pdev, 0x6d, byte & ~1);
}
/* Free all of the mtd devices */
list_for_each_entry_safe(map, scratch, &window->maps, list) { if (map->rsrc.parent)
release_resource(&map->rsrc);
mtd_device_unregister(map->mtd);
map_destroy(map->mtd);
list_del(&map->list);
kfree(map);
} if (window->rsrc.parent)
release_resource(&window->rsrc);
/* Remember the pci dev I find the window in */
window->pdev = pci_dev_get(pdev);
switch (ent->driver_data) { case DEV_CK804: /* Enable the selected rom window. This is often incorrectly * set up by the BIOS, and the 4MiB offset for the lock registers * requires the full 5MiB of window space. * * This 'write, then read' approach leaves the bits for * other uses of the hardware info.
*/
pci_read_config_byte(pdev, 0x88, &byte);
pci_write_config_byte(pdev, 0x88, byte | win_size_bits );
/* Assume the rom window is properly setup, and find it's size */
pci_read_config_byte(pdev, 0x88, &byte);
window->phys = 0xff000000; /* 16MiB, hardcoded for now */ break;
}
window->size = 0xffffffffUL - window->phys + 1UL;
/* * Try to reserve the window mem region. If this fails then * it is likely due to a fragment of the window being * "reserved" by the BIOS. In the case that the * request_mem_region() fails then once the rom size is * discovered we will try to reserve the unreserved fragment.
*/
window->rsrc.name = MOD_NAME;
window->rsrc.start = window->phys;
window->rsrc.end = window->phys + window->size - 1;
window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; if (request_resource(&iomem_resource, &window->rsrc)) {
window->rsrc.parent = NULL;
printk(KERN_ERR MOD_NAME " %s(): Unable to register resource %pR - kernel bug?\n",
__func__, &window->rsrc);
}
/* Enable writes through the rom window */
pci_read_config_byte(pdev, 0x6d, &byte);
pci_write_config_byte(pdev, 0x6d, byte | 1);
/* FIXME handle registers 0x80 - 0x8C the bios region locks */
/* For write accesses caches are useless */
window->virt = ioremap(window->phys, window->size); if (!window->virt) {
printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n",
window->phys, window->size); goto out;
}
/* Get the first address to look for a rom chip at */
map_top = window->phys; #if 1 /* The probe sequence run over the firmware hub lock * registers sets them to 0x7 (no access). * Probe at most the last 4MiB of the address space.
*/ if (map_top < 0xffc00000)
map_top = 0xffc00000; #endif /* Loop through and look for rom chips. Since we don't know the * starting address for each chip, probe every ROM_PROBE_STEP_SIZE * bytes from the starting address of the window.
*/ while((map_top - 1) < 0xffffffffUL) { struct cfi_private *cfi; unsignedlong offset; int i;
if (!map) {
map = kmalloc(sizeof(*map), GFP_KERNEL); if (!map) goto out;
}
memset(map, 0, sizeof(*map));
INIT_LIST_HEAD(&map->list);
map->map.name = map->map_name;
map->map.phys = map_top;
offset = map_top - window->phys;
map->map.virt = (void __iomem *)
(((unsignedlong)(window->virt)) + offset);
map->map.size = 0xffffffffUL - map_top + 1UL; /* Set the name of the map to the address I am trying */
sprintf(map->map_name, "%s @%08Lx",
MOD_NAME, (unsignedlonglong)map->map.phys);
/* There is no generic VPP support */ for(map->map.bankwidth = 32; map->map.bankwidth;
map->map.bankwidth >>= 1)
{ char **probe_type; /* Skip bankwidths that are not supported */ if (!map_bankwidth_supported(map->map.bankwidth)) continue;
/* Setup the map methods */
simple_map_init(&map->map);
/* Try all of the probe methods */
probe_type = rom_probe_types; for(; *probe_type; probe_type++) {
map->mtd = do_map_probe(*probe_type, &map->map); if (map->mtd) goto found;
}
}
map_top += ROM_PROBE_STEP_SIZE; continue;
found: /* Trim the size if we are larger than the map */ if (map->mtd->size > map->map.size) {
printk(KERN_WARNING MOD_NAME " rom(%llu) larger than window(%lu). fixing...\n",
(unsignedlonglong)map->mtd->size, map->map.size);
map->mtd->size = map->map.size;
} if (window->rsrc.parent) { /* * Registering the MTD device in iomem may not be possible * if there is a BIOS "reserved" and BUSY range. If this * fails then continue anyway.
*/
map->rsrc.name = map->map_name;
map->rsrc.start = map->map.phys;
map->rsrc.end = map->map.phys + map->mtd->size - 1;
map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; if (request_resource(&window->rsrc, &map->rsrc)) {
printk(KERN_ERR MOD_NAME ": cannot reserve MTD resource\n");
map->rsrc.parent = NULL;
}
}
/* Make the whole region visible in the map */
map->map.virt = window->virt;
map->map.phys = window->phys;
cfi = map->map.fldrv_priv; for(i = 0; i < cfi->numchips; i++)
cfi->chips[i].start += offset;
/* Now that the mtd devices is complete claim and export it */
map->mtd->owner = THIS_MODULE; if (mtd_device_register(map->mtd, NULL, 0)) {
map_destroy(map->mtd);
map->mtd = NULL; goto out;
}
/* Calculate the new value of map_top */
map_top += map->mtd->size;
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Eric Biederman , Dave Olsen ");
MODULE_DESCRIPTION("MTD map driver for BIOS chips on the Nvidia ck804 southbridge");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.