18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ck804xrom.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Normal mappings of chips in physical memory 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Dave Olsen <dolsen@lnxi.com> 88c2ecf20Sopenharmony_ci * Ryan Jackson <rjackson@lnxi.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/module.h> 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci#include <linux/kernel.h> 148c2ecf20Sopenharmony_ci#include <linux/init.h> 158c2ecf20Sopenharmony_ci#include <linux/slab.h> 168c2ecf20Sopenharmony_ci#include <asm/io.h> 178c2ecf20Sopenharmony_ci#include <linux/mtd/mtd.h> 188c2ecf20Sopenharmony_ci#include <linux/mtd/map.h> 198c2ecf20Sopenharmony_ci#include <linux/mtd/cfi.h> 208c2ecf20Sopenharmony_ci#include <linux/mtd/flashchip.h> 218c2ecf20Sopenharmony_ci#include <linux/pci.h> 228c2ecf20Sopenharmony_ci#include <linux/pci_ids.h> 238c2ecf20Sopenharmony_ci#include <linux/list.h> 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define MOD_NAME KBUILD_BASENAME 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define ADDRESS_NAME_LEN 18 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define ROM_PROBE_STEP_SIZE (64*1024) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define DEV_CK804 1 338c2ecf20Sopenharmony_ci#define DEV_MCP55 2 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct ck804xrom_window { 368c2ecf20Sopenharmony_ci void __iomem *virt; 378c2ecf20Sopenharmony_ci unsigned long phys; 388c2ecf20Sopenharmony_ci unsigned long size; 398c2ecf20Sopenharmony_ci struct list_head maps; 408c2ecf20Sopenharmony_ci struct resource rsrc; 418c2ecf20Sopenharmony_ci struct pci_dev *pdev; 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct ck804xrom_map_info { 458c2ecf20Sopenharmony_ci struct list_head list; 468c2ecf20Sopenharmony_ci struct map_info map; 478c2ecf20Sopenharmony_ci struct mtd_info *mtd; 488c2ecf20Sopenharmony_ci struct resource rsrc; 498c2ecf20Sopenharmony_ci char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN]; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * The following applies to ck804 only: 548c2ecf20Sopenharmony_ci * The 2 bits controlling the window size are often set to allow reading 558c2ecf20Sopenharmony_ci * the BIOS, but too small to allow writing, since the lock registers are 568c2ecf20Sopenharmony_ci * 4MiB lower in the address space than the data. 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * This is intended to prevent flashing the bios, perhaps accidentally. 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * This parameter allows the normal driver to override the BIOS settings. 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * The bits are 6 and 7. If both bits are set, it is a 5MiB window. 638c2ecf20Sopenharmony_ci * If only the 7 Bit is set, it is a 4MiB window. Otherwise, a 648c2ecf20Sopenharmony_ci * 64KiB window. 658c2ecf20Sopenharmony_ci * 668c2ecf20Sopenharmony_ci * The following applies to mcp55 only: 678c2ecf20Sopenharmony_ci * The 15 bits controlling the window size are distributed as follows: 688c2ecf20Sopenharmony_ci * byte @0x88: bit 0..7 698c2ecf20Sopenharmony_ci * byte @0x8c: bit 8..15 708c2ecf20Sopenharmony_ci * word @0x90: bit 16..30 718c2ecf20Sopenharmony_ci * If all bits are enabled, we have a 16? MiB window 728c2ecf20Sopenharmony_ci * Please set win_size_bits to 0x7fffffff if you actually want to do something 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_cistatic uint win_size_bits = 0; 758c2ecf20Sopenharmony_cimodule_param(win_size_bits, uint, 0); 768c2ecf20Sopenharmony_ciMODULE_PARM_DESC(win_size_bits, "ROM window size bits override, normally set by BIOS."); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic struct ck804xrom_window ck804xrom_window = { 798c2ecf20Sopenharmony_ci .maps = LIST_HEAD_INIT(ck804xrom_window.maps), 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistatic void ck804xrom_cleanup(struct ck804xrom_window *window) 838c2ecf20Sopenharmony_ci{ 848c2ecf20Sopenharmony_ci struct ck804xrom_map_info *map, *scratch; 858c2ecf20Sopenharmony_ci u8 byte; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci if (window->pdev) { 888c2ecf20Sopenharmony_ci /* Disable writes through the rom window */ 898c2ecf20Sopenharmony_ci pci_read_config_byte(window->pdev, 0x6d, &byte); 908c2ecf20Sopenharmony_ci pci_write_config_byte(window->pdev, 0x6d, byte & ~1); 918c2ecf20Sopenharmony_ci } 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci /* Free all of the mtd devices */ 948c2ecf20Sopenharmony_ci list_for_each_entry_safe(map, scratch, &window->maps, list) { 958c2ecf20Sopenharmony_ci if (map->rsrc.parent) 968c2ecf20Sopenharmony_ci release_resource(&map->rsrc); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci mtd_device_unregister(map->mtd); 998c2ecf20Sopenharmony_ci map_destroy(map->mtd); 1008c2ecf20Sopenharmony_ci list_del(&map->list); 1018c2ecf20Sopenharmony_ci kfree(map); 1028c2ecf20Sopenharmony_ci } 1038c2ecf20Sopenharmony_ci if (window->rsrc.parent) 1048c2ecf20Sopenharmony_ci release_resource(&window->rsrc); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci if (window->virt) { 1078c2ecf20Sopenharmony_ci iounmap(window->virt); 1088c2ecf20Sopenharmony_ci window->virt = NULL; 1098c2ecf20Sopenharmony_ci window->phys = 0; 1108c2ecf20Sopenharmony_ci window->size = 0; 1118c2ecf20Sopenharmony_ci } 1128c2ecf20Sopenharmony_ci pci_dev_put(window->pdev); 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cistatic int __init ck804xrom_init_one(struct pci_dev *pdev, 1178c2ecf20Sopenharmony_ci const struct pci_device_id *ent) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL }; 1208c2ecf20Sopenharmony_ci u8 byte; 1218c2ecf20Sopenharmony_ci u16 word; 1228c2ecf20Sopenharmony_ci struct ck804xrom_window *window = &ck804xrom_window; 1238c2ecf20Sopenharmony_ci struct ck804xrom_map_info *map = NULL; 1248c2ecf20Sopenharmony_ci unsigned long map_top; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci /* Remember the pci dev I find the window in */ 1278c2ecf20Sopenharmony_ci window->pdev = pci_dev_get(pdev); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci switch (ent->driver_data) { 1308c2ecf20Sopenharmony_ci case DEV_CK804: 1318c2ecf20Sopenharmony_ci /* Enable the selected rom window. This is often incorrectly 1328c2ecf20Sopenharmony_ci * set up by the BIOS, and the 4MiB offset for the lock registers 1338c2ecf20Sopenharmony_ci * requires the full 5MiB of window space. 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci * This 'write, then read' approach leaves the bits for 1368c2ecf20Sopenharmony_ci * other uses of the hardware info. 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x88, &byte); 1398c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x88, byte | win_size_bits ); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci /* Assume the rom window is properly setup, and find it's size */ 1428c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x88, &byte); 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6))) 1458c2ecf20Sopenharmony_ci window->phys = 0xffb00000; /* 5MiB */ 1468c2ecf20Sopenharmony_ci else if ((byte & (1<<7)) == (1<<7)) 1478c2ecf20Sopenharmony_ci window->phys = 0xffc00000; /* 4MiB */ 1488c2ecf20Sopenharmony_ci else 1498c2ecf20Sopenharmony_ci window->phys = 0xffff0000; /* 64KiB */ 1508c2ecf20Sopenharmony_ci break; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci case DEV_MCP55: 1538c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x88, &byte); 1548c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x88, byte | (win_size_bits & 0xff)); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x8c, &byte); 1578c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x8c, byte | ((win_size_bits & 0xff00) >> 8)); 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci pci_read_config_word(pdev, 0x90, &word); 1608c2ecf20Sopenharmony_ci pci_write_config_word(pdev, 0x90, word | ((win_size_bits & 0x7fff0000) >> 16)); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci window->phys = 0xff000000; /* 16MiB, hardcoded for now */ 1638c2ecf20Sopenharmony_ci break; 1648c2ecf20Sopenharmony_ci } 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci window->size = 0xffffffffUL - window->phys + 1UL; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci /* 1698c2ecf20Sopenharmony_ci * Try to reserve the window mem region. If this fails then 1708c2ecf20Sopenharmony_ci * it is likely due to a fragment of the window being 1718c2ecf20Sopenharmony_ci * "reserved" by the BIOS. In the case that the 1728c2ecf20Sopenharmony_ci * request_mem_region() fails then once the rom size is 1738c2ecf20Sopenharmony_ci * discovered we will try to reserve the unreserved fragment. 1748c2ecf20Sopenharmony_ci */ 1758c2ecf20Sopenharmony_ci window->rsrc.name = MOD_NAME; 1768c2ecf20Sopenharmony_ci window->rsrc.start = window->phys; 1778c2ecf20Sopenharmony_ci window->rsrc.end = window->phys + window->size - 1; 1788c2ecf20Sopenharmony_ci window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 1798c2ecf20Sopenharmony_ci if (request_resource(&iomem_resource, &window->rsrc)) { 1808c2ecf20Sopenharmony_ci window->rsrc.parent = NULL; 1818c2ecf20Sopenharmony_ci printk(KERN_ERR MOD_NAME 1828c2ecf20Sopenharmony_ci " %s(): Unable to register resource %pR - kernel bug?\n", 1838c2ecf20Sopenharmony_ci __func__, &window->rsrc); 1848c2ecf20Sopenharmony_ci } 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci /* Enable writes through the rom window */ 1888c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x6d, &byte); 1898c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x6d, byte | 1); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci /* FIXME handle registers 0x80 - 0x8C the bios region locks */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* For write accesses caches are useless */ 1948c2ecf20Sopenharmony_ci window->virt = ioremap(window->phys, window->size); 1958c2ecf20Sopenharmony_ci if (!window->virt) { 1968c2ecf20Sopenharmony_ci printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n", 1978c2ecf20Sopenharmony_ci window->phys, window->size); 1988c2ecf20Sopenharmony_ci goto out; 1998c2ecf20Sopenharmony_ci } 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci /* Get the first address to look for a rom chip at */ 2028c2ecf20Sopenharmony_ci map_top = window->phys; 2038c2ecf20Sopenharmony_ci#if 1 2048c2ecf20Sopenharmony_ci /* The probe sequence run over the firmware hub lock 2058c2ecf20Sopenharmony_ci * registers sets them to 0x7 (no access). 2068c2ecf20Sopenharmony_ci * Probe at most the last 4MiB of the address space. 2078c2ecf20Sopenharmony_ci */ 2088c2ecf20Sopenharmony_ci if (map_top < 0xffc00000) 2098c2ecf20Sopenharmony_ci map_top = 0xffc00000; 2108c2ecf20Sopenharmony_ci#endif 2118c2ecf20Sopenharmony_ci /* Loop through and look for rom chips. Since we don't know the 2128c2ecf20Sopenharmony_ci * starting address for each chip, probe every ROM_PROBE_STEP_SIZE 2138c2ecf20Sopenharmony_ci * bytes from the starting address of the window. 2148c2ecf20Sopenharmony_ci */ 2158c2ecf20Sopenharmony_ci while((map_top - 1) < 0xffffffffUL) { 2168c2ecf20Sopenharmony_ci struct cfi_private *cfi; 2178c2ecf20Sopenharmony_ci unsigned long offset; 2188c2ecf20Sopenharmony_ci int i; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci if (!map) 2218c2ecf20Sopenharmony_ci map = kmalloc(sizeof(*map), GFP_KERNEL); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci if (!map) { 2248c2ecf20Sopenharmony_ci printk(KERN_ERR MOD_NAME ": kmalloc failed"); 2258c2ecf20Sopenharmony_ci goto out; 2268c2ecf20Sopenharmony_ci } 2278c2ecf20Sopenharmony_ci memset(map, 0, sizeof(*map)); 2288c2ecf20Sopenharmony_ci INIT_LIST_HEAD(&map->list); 2298c2ecf20Sopenharmony_ci map->map.name = map->map_name; 2308c2ecf20Sopenharmony_ci map->map.phys = map_top; 2318c2ecf20Sopenharmony_ci offset = map_top - window->phys; 2328c2ecf20Sopenharmony_ci map->map.virt = (void __iomem *) 2338c2ecf20Sopenharmony_ci (((unsigned long)(window->virt)) + offset); 2348c2ecf20Sopenharmony_ci map->map.size = 0xffffffffUL - map_top + 1UL; 2358c2ecf20Sopenharmony_ci /* Set the name of the map to the address I am trying */ 2368c2ecf20Sopenharmony_ci sprintf(map->map_name, "%s @%08Lx", 2378c2ecf20Sopenharmony_ci MOD_NAME, (unsigned long long)map->map.phys); 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci /* There is no generic VPP support */ 2408c2ecf20Sopenharmony_ci for(map->map.bankwidth = 32; map->map.bankwidth; 2418c2ecf20Sopenharmony_ci map->map.bankwidth >>= 1) 2428c2ecf20Sopenharmony_ci { 2438c2ecf20Sopenharmony_ci char **probe_type; 2448c2ecf20Sopenharmony_ci /* Skip bankwidths that are not supported */ 2458c2ecf20Sopenharmony_ci if (!map_bankwidth_supported(map->map.bankwidth)) 2468c2ecf20Sopenharmony_ci continue; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci /* Setup the map methods */ 2498c2ecf20Sopenharmony_ci simple_map_init(&map->map); 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci /* Try all of the probe methods */ 2528c2ecf20Sopenharmony_ci probe_type = rom_probe_types; 2538c2ecf20Sopenharmony_ci for(; *probe_type; probe_type++) { 2548c2ecf20Sopenharmony_ci map->mtd = do_map_probe(*probe_type, &map->map); 2558c2ecf20Sopenharmony_ci if (map->mtd) 2568c2ecf20Sopenharmony_ci goto found; 2578c2ecf20Sopenharmony_ci } 2588c2ecf20Sopenharmony_ci } 2598c2ecf20Sopenharmony_ci map_top += ROM_PROBE_STEP_SIZE; 2608c2ecf20Sopenharmony_ci continue; 2618c2ecf20Sopenharmony_ci found: 2628c2ecf20Sopenharmony_ci /* Trim the size if we are larger than the map */ 2638c2ecf20Sopenharmony_ci if (map->mtd->size > map->map.size) { 2648c2ecf20Sopenharmony_ci printk(KERN_WARNING MOD_NAME 2658c2ecf20Sopenharmony_ci " rom(%llu) larger than window(%lu). fixing...\n", 2668c2ecf20Sopenharmony_ci (unsigned long long)map->mtd->size, map->map.size); 2678c2ecf20Sopenharmony_ci map->mtd->size = map->map.size; 2688c2ecf20Sopenharmony_ci } 2698c2ecf20Sopenharmony_ci if (window->rsrc.parent) { 2708c2ecf20Sopenharmony_ci /* 2718c2ecf20Sopenharmony_ci * Registering the MTD device in iomem may not be possible 2728c2ecf20Sopenharmony_ci * if there is a BIOS "reserved" and BUSY range. If this 2738c2ecf20Sopenharmony_ci * fails then continue anyway. 2748c2ecf20Sopenharmony_ci */ 2758c2ecf20Sopenharmony_ci map->rsrc.name = map->map_name; 2768c2ecf20Sopenharmony_ci map->rsrc.start = map->map.phys; 2778c2ecf20Sopenharmony_ci map->rsrc.end = map->map.phys + map->mtd->size - 1; 2788c2ecf20Sopenharmony_ci map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 2798c2ecf20Sopenharmony_ci if (request_resource(&window->rsrc, &map->rsrc)) { 2808c2ecf20Sopenharmony_ci printk(KERN_ERR MOD_NAME 2818c2ecf20Sopenharmony_ci ": cannot reserve MTD resource\n"); 2828c2ecf20Sopenharmony_ci map->rsrc.parent = NULL; 2838c2ecf20Sopenharmony_ci } 2848c2ecf20Sopenharmony_ci } 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci /* Make the whole region visible in the map */ 2878c2ecf20Sopenharmony_ci map->map.virt = window->virt; 2888c2ecf20Sopenharmony_ci map->map.phys = window->phys; 2898c2ecf20Sopenharmony_ci cfi = map->map.fldrv_priv; 2908c2ecf20Sopenharmony_ci for(i = 0; i < cfi->numchips; i++) 2918c2ecf20Sopenharmony_ci cfi->chips[i].start += offset; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci /* Now that the mtd devices is complete claim and export it */ 2948c2ecf20Sopenharmony_ci map->mtd->owner = THIS_MODULE; 2958c2ecf20Sopenharmony_ci if (mtd_device_register(map->mtd, NULL, 0)) { 2968c2ecf20Sopenharmony_ci map_destroy(map->mtd); 2978c2ecf20Sopenharmony_ci map->mtd = NULL; 2988c2ecf20Sopenharmony_ci goto out; 2998c2ecf20Sopenharmony_ci } 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci /* Calculate the new value of map_top */ 3038c2ecf20Sopenharmony_ci map_top += map->mtd->size; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci /* File away the map structure */ 3068c2ecf20Sopenharmony_ci list_add(&map->list, &window->maps); 3078c2ecf20Sopenharmony_ci map = NULL; 3088c2ecf20Sopenharmony_ci } 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci out: 3118c2ecf20Sopenharmony_ci /* Free any left over map structures */ 3128c2ecf20Sopenharmony_ci kfree(map); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci /* See if I have any map structures */ 3158c2ecf20Sopenharmony_ci if (list_empty(&window->maps)) { 3168c2ecf20Sopenharmony_ci ck804xrom_cleanup(window); 3178c2ecf20Sopenharmony_ci return -ENODEV; 3188c2ecf20Sopenharmony_ci } 3198c2ecf20Sopenharmony_ci return 0; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_cistatic void ck804xrom_remove_one(struct pci_dev *pdev) 3248c2ecf20Sopenharmony_ci{ 3258c2ecf20Sopenharmony_ci struct ck804xrom_window *window = &ck804xrom_window; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci ck804xrom_cleanup(window); 3288c2ecf20Sopenharmony_ci} 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_cistatic const struct pci_device_id ck804xrom_pci_tbl[] = { 3318c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0051), .driver_data = DEV_CK804 }, 3328c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0360), .driver_data = DEV_MCP55 }, 3338c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0361), .driver_data = DEV_MCP55 }, 3348c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0362), .driver_data = DEV_MCP55 }, 3358c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0363), .driver_data = DEV_MCP55 }, 3368c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0364), .driver_data = DEV_MCP55 }, 3378c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0365), .driver_data = DEV_MCP55 }, 3388c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0366), .driver_data = DEV_MCP55 }, 3398c2ecf20Sopenharmony_ci { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x0367), .driver_data = DEV_MCP55 }, 3408c2ecf20Sopenharmony_ci { 0, } 3418c2ecf20Sopenharmony_ci}; 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci#if 0 3448c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pci, ck804xrom_pci_tbl); 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_cistatic struct pci_driver ck804xrom_driver = { 3478c2ecf20Sopenharmony_ci .name = MOD_NAME, 3488c2ecf20Sopenharmony_ci .id_table = ck804xrom_pci_tbl, 3498c2ecf20Sopenharmony_ci .probe = ck804xrom_init_one, 3508c2ecf20Sopenharmony_ci .remove = ck804xrom_remove_one, 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_ci#endif 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistatic int __init init_ck804xrom(void) 3558c2ecf20Sopenharmony_ci{ 3568c2ecf20Sopenharmony_ci struct pci_dev *pdev; 3578c2ecf20Sopenharmony_ci const struct pci_device_id *id; 3588c2ecf20Sopenharmony_ci int retVal; 3598c2ecf20Sopenharmony_ci pdev = NULL; 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci for(id = ck804xrom_pci_tbl; id->vendor; id++) { 3628c2ecf20Sopenharmony_ci pdev = pci_get_device(id->vendor, id->device, NULL); 3638c2ecf20Sopenharmony_ci if (pdev) 3648c2ecf20Sopenharmony_ci break; 3658c2ecf20Sopenharmony_ci } 3668c2ecf20Sopenharmony_ci if (pdev) { 3678c2ecf20Sopenharmony_ci retVal = ck804xrom_init_one(pdev, id); 3688c2ecf20Sopenharmony_ci pci_dev_put(pdev); 3698c2ecf20Sopenharmony_ci return retVal; 3708c2ecf20Sopenharmony_ci } 3718c2ecf20Sopenharmony_ci return -ENXIO; 3728c2ecf20Sopenharmony_ci#if 0 3738c2ecf20Sopenharmony_ci return pci_register_driver(&ck804xrom_driver); 3748c2ecf20Sopenharmony_ci#endif 3758c2ecf20Sopenharmony_ci} 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_cistatic void __exit cleanup_ck804xrom(void) 3788c2ecf20Sopenharmony_ci{ 3798c2ecf20Sopenharmony_ci ck804xrom_remove_one(ck804xrom_window.pdev); 3808c2ecf20Sopenharmony_ci} 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cimodule_init(init_ck804xrom); 3838c2ecf20Sopenharmony_cimodule_exit(cleanup_ck804xrom); 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 3868c2ecf20Sopenharmony_ciMODULE_AUTHOR("Eric Biederman <ebiederman@lnxi.com>, Dave Olsen <dolsen@lnxi.com>"); 3878c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("MTD map driver for BIOS chips on the Nvidia ck804 southbridge"); 3888c2ecf20Sopenharmony_ci 389