2 * $Id: l440gx.c,v 1.18 2005/11/07 11:14:27 gleixner Exp $
4 * BIOS Flash chip on Intel 440GX board.
6 * Bugs this currently does not work under linuxBIOS.
9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/config.h>
18 #define PIIXE_IOBASE_RESOURCE 11
20 #define WINDOW_ADDR 0xfff00000
21 #define WINDOW_SIZE 0x00100000
26 #define TRIBUF_PORT (IOBASE+0x37)
27 #define VPP_PORT (IOBASE+0x28)
29 static struct mtd_info *mymtd;
32 /* Is this really the vpp port? */
33 static void l440gx_set_vpp(struct map_info *map, int vpp)
46 static struct map_info l440gx_map = {
47 .name = "L440GX BIOS",
49 .bankwidth = BUSWIDTH,
52 /* FIXME verify that this is the
53 * appripriate code for vpp enable/disable
55 .set_vpp = l440gx_set_vpp
59 static int __init init_l440gx(void)
61 struct pci_dev *dev, *pm_dev;
62 struct resource *pm_iobase;
65 dev = pci_find_device(PCI_VENDOR_ID_INTEL,
66 PCI_DEVICE_ID_INTEL_82371AB_0, NULL);
68 pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL,
69 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
71 if (!dev || !pm_dev) {
72 printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n");
76 l440gx_map.virt = ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
78 if (!l440gx_map.virt) {
79 printk(KERN_WARNING "Failed to ioremap L440GX flash region\n");
82 simple_map_init(&l440gx_map);
83 printk(KERN_NOTICE "window_addr = 0x%08lx\n", (unsigned long)l440gx_map.virt);
85 /* Setup the pm iobase resource
86 * This code should move into some kind of generic bridge
87 * driver but for the moment I'm content with getting the
90 pm_iobase = &pm_dev->resource[PIIXE_IOBASE_RESOURCE];
91 if (!(pm_iobase->flags & IORESOURCE_IO)) {
92 pm_iobase->name = "pm iobase";
95 pm_iobase->flags = IORESOURCE_IO;
97 /* Put the current value in the resource */
98 pci_read_config_dword(pm_dev, 0x40, &iobase);
100 pm_iobase->start += iobase & ~1;
101 pm_iobase->end += iobase & ~1;
103 /* Allocate the resource region */
104 if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) {
105 printk(KERN_WARNING "Could not allocate pm iobase resource\n");
106 iounmap(l440gx_map.virt);
111 iobase = pm_iobase->start;
112 pci_write_config_dword(pm_dev, 0x40, iobase | 1);
116 pci_read_config_word(dev, 0x4e, &word);
118 pci_write_config_word(dev, 0x4e, word);
120 /* Supply write voltage to the chip */
121 l440gx_set_vpp(&l440gx_map, 1);
123 /* Enable the gate on the WE line */
124 outb(inb(TRIBUF_PORT) & ~1, TRIBUF_PORT);
126 printk(KERN_NOTICE "Enabled WE line to L440GX BIOS flash chip.\n");
128 mymtd = do_map_probe("jedec_probe", &l440gx_map);
130 printk(KERN_NOTICE "JEDEC probe on BIOS chip failed. Using ROM\n");
131 mymtd = do_map_probe("map_rom", &l440gx_map);
134 mymtd->owner = THIS_MODULE;
136 add_mtd_device(mymtd);
140 iounmap(l440gx_map.virt);
144 static void __exit cleanup_l440gx(void)
146 del_mtd_device(mymtd);
149 iounmap(l440gx_map.virt);
152 module_init(init_l440gx);
153 module_exit(cleanup_l440gx);
155 MODULE_LICENSE("GPL");
156 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
157 MODULE_DESCRIPTION("MTD map driver for BIOS chips on Intel L440GX motherboards");