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