Skip to contentSkip to conversation

MAPS: Support for BIOS flash chips on the nvidia ck804 southbridge

PATCH In review Ryan Jackson 2 participants 4 messages Oct 31, 2006 – Nov 6, 2006 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MAPS: Support for BIOS flash chips on the nvidia ck804 southbridge

From: Dave Olsen <[email protected]>

Add support for accessing BIOS flash chips connected to the NVIDIA ck804 southbridge.

---
 drivers/mtd/maps/Kconfig     |    9 +
 drivers/mtd/maps/Makefile    |    1 +
 drivers/mtd/maps/ck804xrom.c |  356 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 366 insertions(+), 0 deletions(-)
drivers/mtd/maps/Kconfig +9 -0
index 7514a9b..fa74668 100644
@@ -193,6 +193,15 @@ config MTD_ESB2ROM
 
           BE VERY CAREFUL.
 
+config MTD_CK804XROM
+	tristate "BIOS flash chip on Nvidia CK804"
+	depends on X86 && MTD_JEDECPROBE
+	help
+	  Support for treating the BIOS flash chip on nvidia motherboards
+	  as an MTD device - with this you can reprogram your BIOS.
+
+	  BE VERY CAREFUL.
+
 config MTD_SCB2_FLASH
 	tristate "BIOS flash chip on Intel SCB2 boards"
 	depends on X86 && MTD_JEDECPROBE
drivers/mtd/maps/Makefile +1 -0
index 9061432..3450521 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_L440GX)	+= l440gx.o
 obj-$(CONFIG_MTD_AMD76XROM)	+= amd76xrom.o
 obj-$(CONFIG_MTD_ESB2ROM)	+= esb2rom.o
 obj-$(CONFIG_MTD_ICHXROM)	+= ichxrom.o
+obj-$(CONFIG_MTD_CK804XROM)	+= ck804xrom.o
 obj-$(CONFIG_MTD_TSUNAMI)	+= tsunami_flash.o
 obj-$(CONFIG_MTD_LUBBOCK)	+= lubbock-flash.o
 obj-$(CONFIG_MTD_MAINSTONE)	+= mainstone-flash.o
drivers/mtd/maps/ck804xrom.c new file +356 -0

356 lines not on this page · raw message

Signature · 1 line
1.4.3.2
#1 lore raw

Hello Rayan,

I have few questions (may be silly) and comments.

drivers/mtd/maps/ck804xrom.c line 105

Quoted 2 lines · Ryan Jackson
drivers/mtd/maps/ck804xrom.c new file +2 -0
+static int __devinit ck804xrom_init_one (struct pci_dev *pdev,
+	const struct pci_device_id *ent)

I wonder why do you use __devinit here, not __init? AFAIK, __devinit is used for hotplug-able devices, is this the case for a video card?

Review

Quoted 2 lines
(quoted diff) +2 -0
+{
+	static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };

So the interface may really be JEDEC and CFI?

drivers/mtd/maps/ck804xrom.c line 207

Quoted 3 lines

phys;

drivers/mtd/maps/ck804xrom.c new file +2 -0
+		map->map.virt = (void __iomem *)
+			(((unsigned long)(window->virt)) + offset);

map->map.virt is 'void *', so

map->map.virt = window->virt + offset * sizeof(long);

could be used instead and it looks neater. In gcc sizeof(void) is 1 and is is widely used in the kernel.

Quoted 11 lines
drivers/mtd/maps/ck804xrom.c new file +11 -0
+static int __init init_ck804xrom(void)
+{
+	struct pci_dev *pdev;
+	struct pci_device_id *id;
+	int retVal;
+	pdev = NULL;
+
+	for(id = ck804xrom_pci_tbl; id->vendor; id++) {
+		pdev = pci_find_device(id->vendor, id->device, NULL);
+		if (pdev)
+			break;

drivers/mtd/maps/ck804xrom.c line 342

Quoted 10 lines
drivers/mtd/maps/ck804xrom.c new file +10 -0
+	}
+	if (pdev) {
+		retVal = ck804xrom_init_one(pdev, &ck804xrom_pci_tbl[0]);
+		pci_dev_put(pdev);
+		return retVal;
+	}
+	return -ENXIO;
+#if 0
+	return pci_module_init(&ck804xrom_driver);
+#endif

Why you commented out pci_module_init() and the related stuff? Why you do not use this standard mechanism?

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#2 lore raw
Quoted 1 line · Artem Bityutskiy

I have few questions (may be silly) and comments.

Thanks for the feedback. Sorry to take so long to reply.

Quoted 4 lines

drivers/mtd/maps/ck804xrom.c line 105

Quoted 2 lines
drivers/mtd/maps/ck804xrom.c new file +2 -0
+static int __devinit ck804xrom_init_one (struct pci_dev *pdev,
+	const struct pci_device_id *ent)

I wonder why do you use __devinit here, not __init? AFAIK, __devinit is used for hotplug-able devices, is this the case for a video card?

Habit, I guess. Technically the device isn't hotpluggable (unless you consider ripping the chip off the board hot-plugging). Some of the other drivers seem to use __devinit as well, such as scb2_rom.

Quoted 2 lines

drivers/mtd/maps/ck804xrom.c line 107

Quoted 1 line
drivers/mtd/maps/ck804xrom.c new file +1 -0
+	static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL };

So the interface may really be JEDEC and CFI?

I haven't seen any chips used with this southbridge that are detected by cfi_probe, but the probe is there in case one is used.

Quoted 6 lines

map->map.virt is 'void *', so

map->map.virt = window->virt + offset * sizeof(long);

could be used instead and it looks neater. In gcc sizeof(void) is 1 and is is widely used in the kernel.

Actually, I get an oops in jedec_probe_chip if I use this.

Quoted 2 lines

Why you commented out pci_module_init() and the related stuff? Why you do not use this standard mechanism?

After talking with the original author, the reason pci_module_init (or rather pci_register_driver) isn't called is simply a side-effect of cut-and-paste from an another, earlier driver. In that driver, it was not called because A) the mtd code barely touches the device and B) there was some other driver that wanted to use that device for something else.

I've changed the code to register and unregister the driver and it seems to work fine. I'll re-submit it.

Thanks.

Signature · 2 lines
Ryan Jackson
Linux Networx
#3 lore raw
In reply to Artem Bityutskiy

From: Dave Olsen <[email protected]>

Add support for accessing BIOS flash chips connected to the NVIDIA ck804 southbridge.

---
 drivers/mtd/maps/Kconfig     |    9 +
 drivers/mtd/maps/Makefile    |    1 +
 drivers/mtd/maps/ck804xrom.c |  356 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 366 insertions(+), 0 deletions(-)
drivers/mtd/maps/Kconfig +9 -0
index 7514a9b..fa74668 100644
@@ -193,6 +193,15 @@ config MTD_ESB2ROM
 
           BE VERY CAREFUL.
 
+config MTD_CK804XROM
+	tristate "BIOS flash chip on Nvidia CK804"
+	depends on X86 && MTD_JEDECPROBE
+	help
+	  Support for treating the BIOS flash chip on nvidia motherboards
+	  as an MTD device - with this you can reprogram your BIOS.
+
+	  BE VERY CAREFUL.
+
 config MTD_SCB2_FLASH
 	tristate "BIOS flash chip on Intel SCB2 boards"
 	depends on X86 && MTD_JEDECPROBE
drivers/mtd/maps/Makefile +1 -0
index 9061432..3450521 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_L440GX)	+= l440gx.o
 obj-$(CONFIG_MTD_AMD76XROM)	+= amd76xrom.o
 obj-$(CONFIG_MTD_ESB2ROM)	+= esb2rom.o
 obj-$(CONFIG_MTD_ICHXROM)	+= ichxrom.o
+obj-$(CONFIG_MTD_CK804XROM)	+= ck804xrom.o
 obj-$(CONFIG_MTD_TSUNAMI)	+= tsunami_flash.o
 obj-$(CONFIG_MTD_LUBBOCK)	+= lubbock-flash.o
 obj-$(CONFIG_MTD_MAINSTONE)	+= mainstone-flash.o
drivers/mtd/maps/ck804xrom.c new file +356 -0

356 lines not on this page · raw message

Signature · 1 line
1.4.3.2