X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmtd%2Fmaps%2Fscx200_docflash.c;h=7391fd544e86fc7351e46fb4efa209afe31fbb25;hb=16c70f8c1b54b61c3b951b6fb220df250fe09b32;hp=c909f4bda5eeb754323c035ebaa21b02befeb041;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c index c909f4bda..7391fd544 100644 --- a/drivers/mtd/maps/scx200_docflash.c +++ b/drivers/mtd/maps/scx200_docflash.c @@ -1,14 +1,13 @@ -/* linux/drivers/mtd/maps/scx200_docflash.c +/* linux/drivers/mtd/maps/scx200_docflash.c Copyright (c) 2001,2002 Christer Weinigel - $Id: scx200_docflash.c,v 1.5 2003/05/21 12:45:20 dwmw2 Exp $ + $Id: scx200_docflash.c,v 1.12 2005/11/07 11:14:28 gleixner Exp $ National Semiconductor SCx200 flash mapped with DOCCS */ #include -#include #include #include #include @@ -26,23 +25,20 @@ MODULE_AUTHOR("Christer Weinigel "); MODULE_DESCRIPTION("NatSemi SCx200 DOCCS Flash Driver"); MODULE_LICENSE("GPL"); -/* Set this to one if you want to partition the flash */ -#define PARTITION 1 +static int probe = 0; /* Don't autoprobe */ +static unsigned size = 0x1000000; /* 16 MiB the whole ISA address space */ +static unsigned width = 8; /* Default to 8 bits wide */ +static char *flashtype = "cfi_probe"; -MODULE_PARM(probe, "i"); +module_param(probe, int, 0); MODULE_PARM_DESC(probe, "Probe for a BIOS mapping"); -MODULE_PARM(size, "i"); +module_param(size, int, 0); MODULE_PARM_DESC(size, "Size of the flash mapping"); -MODULE_PARM(width, "i"); +module_param(width, int, 0); MODULE_PARM_DESC(width, "Data width of the flash mapping (8/16)"); -MODULE_PARM(flashtype, "s"); +module_param(flashtype, charp, 0); MODULE_PARM_DESC(flashtype, "Type of MTD probe to do"); -static int probe = 0; /* Don't autoprobe */ -static unsigned size = 0x1000000; /* 16 MiB the whole ISA address space */ -static unsigned width = 8; /* Default to 8 bits wide */ -static char *flashtype = "cfi_probe"; - static struct resource docmem = { .flags = IORESOURCE_MEM, .name = "NatSemi SCx200 DOCCS Flash", @@ -50,30 +46,30 @@ static struct resource docmem = { static struct mtd_info *mymtd; -#if PARTITION +#ifdef CONFIG_MTD_PARTITIONS static struct mtd_partition partition_info[] = { - { - .name = "DOCCS Boot kernel", - .offset = 0, + { + .name = "DOCCS Boot kernel", + .offset = 0, .size = 0xc0000 }, - { - .name = "DOCCS Low BIOS", - .offset = 0xc0000, + { + .name = "DOCCS Low BIOS", + .offset = 0xc0000, .size = 0x40000 }, - { - .name = "DOCCS File system", - .offset = 0x100000, + { + .name = "DOCCS File system", + .offset = 0x100000, .size = ~0 /* calculate from flash size */ }, - { - .name = "DOCCS High BIOS", + { + .name = "DOCCS High BIOS", .offset = ~0, /* calculate from flash size */ .size = 0x80000 }, }; -#define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) +#define NUM_PARTITIONS ARRAY_SIZE(partition_info) #endif @@ -81,7 +77,7 @@ static struct map_info scx200_docflash_map = { .name = "NatSemi SCx200 DOCCS Flash", }; -int __init init_scx200_docflash(void) +static int __init init_scx200_docflash(void) { unsigned u; unsigned base; @@ -91,21 +87,20 @@ int __init init_scx200_docflash(void) printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); - if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, + if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE, NULL)) == NULL) return -ENODEV; - - if (!scx200_cb_probe(SCx200_CB_BASE)) { - printk(KERN_WARNING NAME ": no configuration block found\n"); + + /* check that we have found the configuration block */ + if (!scx200_cb_present()) return -ENODEV; - } if (probe) { /* Try to use the present flash mapping if any */ pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base); pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl); - pmr = inl(SCx200_CB_BASE + SCx200_PMR); + pmr = inl(scx200_cb_base + SCx200_PMR); if (base == 0 || (ctrl & 0x07000000) != 0x07000000 @@ -138,49 +133,50 @@ int __init init_scx200_docflash(void) printk(KERN_ERR NAME ": invalid size for flash mapping\n"); return -EINVAL; } - + if (width != 8 && width != 16) { printk(KERN_ERR NAME ": invalid bus width for flash mapping\n"); return -EINVAL; } - - if (allocate_resource(&iomem_resource, &docmem, + + if (allocate_resource(&iomem_resource, &docmem, size, - 0xc0000000, 0xffffffff, + 0xc0000000, 0xffffffff, size, NULL, NULL)) { printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n"); return -ENOMEM; } - + ctrl = 0x07000000 | ((size-1) >> 13); printk(KERN_INFO "DOCCS BASE=0x%08lx, CTRL=0x%08lx\n", (long)docmem.start, (long)ctrl); - + pci_write_config_dword(bridge, SCx200_DOCCS_BASE, docmem.start); pci_write_config_dword(bridge, SCx200_DOCCS_CTRL, ctrl); - pmr = inl(SCx200_CB_BASE + SCx200_PMR); - + pmr = inl(scx200_cb_base + SCx200_PMR); + if (width == 8) { pmr &= ~(1<<6); } else { pmr |= (1<<6); } - outl(pmr, SCx200_CB_BASE + SCx200_PMR); + outl(pmr, scx200_cb_base + SCx200_PMR); } - - printk(KERN_INFO NAME ": DOCCS mapped at 0x%lx-0x%lx, width %d\n", - docmem.start, docmem.end, width); + + printk(KERN_INFO NAME ": DOCCS mapped at 0x%llx-0x%llx, width %d\n", + (unsigned long long)docmem.start, + (unsigned long long)docmem.end, width); scx200_docflash_map.size = size; if (width == 8) - scx200_docflash_map.buswidth = 1; + scx200_docflash_map.bankwidth = 1; else - scx200_docflash_map.buswidth = 2; + scx200_docflash_map.bankwidth = 2; simple_map_init(&scx200_docflash_map); scx200_docflash_map.phys = docmem.start; - scx200_docflash_map.virt = (unsigned long)ioremap(docmem.start, scx200_docflash_map.size); + scx200_docflash_map.virt = ioremap(docmem.start, scx200_docflash_map.size); if (!scx200_docflash_map.virt) { printk(KERN_ERR NAME ": failed to ioremap the flash\n"); release_resource(&docmem); @@ -190,7 +186,7 @@ int __init init_scx200_docflash(void) mymtd = do_map_probe(flashtype, &scx200_docflash_map); if (!mymtd) { printk(KERN_ERR NAME ": unable to detect flash\n"); - iounmap((void *)scx200_docflash_map.virt); + iounmap(scx200_docflash_map.virt); release_resource(&docmem); return -ENXIO; } @@ -200,7 +196,7 @@ int __init init_scx200_docflash(void) mymtd->owner = THIS_MODULE; -#if PARTITION +#ifdef CONFIG_MTD_PARTITIONS partition_info[3].offset = mymtd->size-partition_info[3].size; partition_info[2].size = partition_info[3].offset-partition_info[2].offset; add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS); @@ -213,7 +209,7 @@ int __init init_scx200_docflash(void) static void __exit cleanup_scx200_docflash(void) { if (mymtd) { -#if PARTITION +#ifdef CONFIG_MTD_PARTITIONS del_mtd_partitions(mymtd); #else del_mtd_device(mymtd); @@ -221,7 +217,7 @@ static void __exit cleanup_scx200_docflash(void) map_destroy(mymtd); } if (scx200_docflash_map.virt) { - iounmap((void *)scx200_docflash_map.virt); + iounmap(scx200_docflash_map.virt); release_resource(&docmem); } }