Commit 4ff7118a authored by Russell King's avatar Russell King

[ARM] mtd: update mapping drivers.

This updates dc21285.c, integrator-flash.c and sa1100-flash.c map
drivers.
parent 18c204c8
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* This code is GPL * This code is GPL
* *
* $Id: dc21285.c,v 1.21 2004/09/16 23:27:13 gleixner Exp $ * $Id: dc21285.c,v 1.22 2004/11/01 13:39:21 rmk Exp $
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -32,7 +32,8 @@ static struct mtd_info *dc21285_mtd; ...@@ -32,7 +32,8 @@ static struct mtd_info *dc21285_mtd;
* is unpredictible. So we have a 25us penalty per * is unpredictible. So we have a 25us penalty per
* write access. * write access.
*/ */
static void nw_en_write(void) { static void nw_en_write(void)
{
extern spinlock_t gpio_lock; extern spinlock_t gpio_lock;
unsigned long flags; unsigned long flags;
...@@ -55,53 +56,60 @@ static void nw_en_write(void) { ...@@ -55,53 +56,60 @@ static void nw_en_write(void) {
static map_word dc21285_read8(struct map_info *map, unsigned long ofs) static map_word dc21285_read8(struct map_info *map, unsigned long ofs)
{ {
return *(uint8_t*)(map->map_priv_1 + ofs); map_word val;
val.x[0] = *(uint8_t*)(map->virt + ofs);
return val;
} }
static map_word dc21285_read16(struct map_info *map, unsigned long ofs) static map_word dc21285_read16(struct map_info *map, unsigned long ofs)
{ {
return *(uint16_t*)(map->map_priv_1 + ofs); map_word val;
val.x[0] = *(uint16_t*)(map->virt + ofs);
return val;
} }
static map_word dc21285_read32(struct map_info *map, unsigned long ofs) static map_word dc21285_read32(struct map_info *map, unsigned long ofs)
{ {
return *(uint32_t*)(map->map_priv_1 + ofs); map_word val;
val.x[0] = *(uint32_t*)(map->virt + ofs);
return val;
} }
static void dc21285_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) static void dc21285_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{ {
memcpy(to, (void*)(map->map_priv_1 + from), len); memcpy(to, (void*)(map->virt + from), len);
} }
static void dc21285_write(struct map_info *map, map_word d, unsigned long adr) static void dc21285_write8(struct map_info *map, const map_word d, unsigned long adr)
{ {
if (machine_is_netwinder()) if (machine_is_netwinder())
nw_en_write(); nw_en_write();
*CSR_ROMWRITEREG = adr & 3; *CSR_ROMWRITEREG = adr & 3;
adr &= ~3; adr &= ~3;
*(uint8_t*)(map->map_priv_1 + adr) = d.x[0]; *(uint8_t*)(map->virt + adr) = d.x[0];
} }
static void dc21285_write16(struct map_info *map, map_word d, unsigned long adr) static void dc21285_write16(struct map_info *map, const map_word d, unsigned long adr)
{ {
if (machine_is_netwinder()) if (machine_is_netwinder())
nw_en_write(); nw_en_write();
*CSR_ROMWRITEREG = adr & 3; *CSR_ROMWRITEREG = adr & 3;
adr &= ~3; adr &= ~3;
*(uint16_t*)(map->map_priv_1 + adr) = d.x[0]; *(uint16_t*)(map->virt + adr) = d.x[0];
} }
static void dc21285_write32(struct map_info *map, map_word d, unsigned long adr) static void dc21285_write32(struct map_info *map, const map_word d, unsigned long adr)
{ {
if (machine_is_netwinder()) if (machine_is_netwinder())
nw_en_write(); nw_en_write();
*(uint32_t*)(map->map_priv_1 + adr) = d.x[0]; *(uint32_t*)(map->virt + adr) = d.x[0];
} }
static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const void *from, ssize_t len) static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{ {
while (len > 0) { while (len > 0) {
uint32_t d = *((uint32_t*)from)++; map_word d;
d.x[0] = *((uint32_t*)from)++;
dc21285_write32(map, d, to); dc21285_write32(map, d, to);
to += 4; to += 4;
len -= 4; len -= 4;
...@@ -111,7 +119,8 @@ static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const voi ...@@ -111,7 +119,8 @@ static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const voi
static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const void *from, ssize_t len) static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{ {
while (len > 0) { while (len > 0) {
uint16_t d = *((uint16_t*)from)++; map_word d;
d.x[0] = *((uint16_t*)from)++;
dc21285_write16(map, d, to); dc21285_write16(map, d, to);
to += 2; to += 2;
len -= 2; len -= 2;
...@@ -120,7 +129,8 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi ...@@ -120,7 +129,8 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len) static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{ {
uint8_t d = *((uint8_t*)from)++; map_word d;
d.x[0] = *((uint8_t*)from)++;
dc21285_write8(map, d, to); dc21285_write8(map, d, to);
to++; to++;
len--; len--;
...@@ -135,8 +145,8 @@ static struct map_info dc21285_map = { ...@@ -135,8 +145,8 @@ static struct map_info dc21285_map = {
/* Partition stuff */ /* Partition stuff */
static struct mtd_partition *dc21285_parts;
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition *dc21285_parts;
static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
#endif #endif
...@@ -163,10 +173,10 @@ static int __init init_dc21285(void) ...@@ -163,10 +173,10 @@ static int __init init_dc21285(void)
break; break;
case SA110_CNTL_ROMWIDTH_32: case SA110_CNTL_ROMWIDTH_32:
dc21285_map.bankwidth = 4; dc21285_map.bankwidth = 4;
break;
dc21285_map.read = dc21285_read32; dc21285_map.read = dc21285_read32;
dc21285_map.write = dc21285_write32; dc21285_map.write = dc21285_write32;
dc21285_map.copy_to = dc21285_copy_to_32; dc21285_map.copy_to = dc21285_copy_to_32;
break;
default: default:
printk (KERN_ERR "DC21285 flash: undefined bankwidth\n"); printk (KERN_ERR "DC21285 flash: undefined bankwidth\n");
return -ENXIO; return -ENXIO;
...@@ -175,8 +185,8 @@ static int __init init_dc21285(void) ...@@ -175,8 +185,8 @@ static int __init init_dc21285(void)
dc21285_map.bankwidth*8); dc21285_map.bankwidth*8);
/* Let's map the flash area */ /* Let's map the flash area */
dc21285_map.map_priv_1 = (void __iomem *)ioremap(DC21285_FLASH, 16*1024*1024); dc21285_map.virt = ioremap(DC21285_FLASH, 16*1024*1024);
if (!dc21285_map.map_priv_1) { if (!dc21285_map.virt) {
printk("Failed to ioremap\n"); printk("Failed to ioremap\n");
return -EIO; return -EIO;
} }
...@@ -188,14 +198,14 @@ static int __init init_dc21285(void) ...@@ -188,14 +198,14 @@ static int __init init_dc21285(void)
} }
if (!dc21285_mtd) { if (!dc21285_mtd) {
iounmap((void *)dc21285_map.map_priv_1); iounmap(dc21285_map.virt);
return -ENXIO; return -ENXIO;
} }
dc21285_mtd->owner = THIS_MODULE; dc21285_mtd->owner = THIS_MODULE;
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, (void *)0); nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0);
if (nrparts > 0) if (nrparts > 0)
add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts); add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts);
else else
...@@ -231,7 +241,7 @@ static void __exit cleanup_dc21285(void) ...@@ -231,7 +241,7 @@ static void __exit cleanup_dc21285(void)
del_mtd_device(dc21285_mtd); del_mtd_device(dc21285_mtd);
map_destroy(dc21285_mtd); map_destroy(dc21285_mtd);
iounmap((void *)dc21285_map.map_priv_1); iounmap(dc21285_map.virt);
} }
module_init(init_dc21285); module_init(init_dc21285);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
This is access code for flashes using ARM's flash partitioning This is access code for flashes using ARM's flash partitioning
standards. standards.
$Id: integrator-flash.c,v 1.17 2004/09/16 23:27:13 gleixner Exp $ $Id: integrator-flash.c,v 1.18 2004/11/01 13:26:15 rmk Exp $
======================================================================*/ ======================================================================*/
...@@ -75,7 +75,7 @@ static int armflash_probe(struct device *_dev) ...@@ -75,7 +75,7 @@ static int armflash_probe(struct device *_dev)
unsigned int size = res->end - res->start + 1; unsigned int size = res->end - res->start + 1;
struct armflash_info *info; struct armflash_info *info;
int err; int err;
void *base; void __iomem *base;
info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL); info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
if (!info) { if (!info) {
...@@ -110,7 +110,7 @@ static int armflash_probe(struct device *_dev) ...@@ -110,7 +110,7 @@ static int armflash_probe(struct device *_dev)
info->map.size = size; info->map.size = size;
info->map.bankwidth = plat->width; info->map.bankwidth = plat->width;
info->map.phys = res->start; info->map.phys = res->start;
info->map.virt = (void __iomem *) base; info->map.virt = base;
info->map.name = dev->dev.bus_id; info->map.name = dev->dev.bus_id;
info->map.set_vpp = armflash_set_vpp; info->map.set_vpp = armflash_set_vpp;
...@@ -179,7 +179,7 @@ static int armflash_remove(struct device *_dev) ...@@ -179,7 +179,7 @@ static int armflash_remove(struct device *_dev)
if (info->parts) if (info->parts)
kfree(info->parts); kfree(info->parts);
iounmap((void *)info->map.virt); iounmap(info->map.virt);
release_resource(info->res); release_resource(info->res);
kfree(info->res); kfree(info->res);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* (C) 2000 Nicolas Pitre <nico@cam.org> * (C) 2000 Nicolas Pitre <nico@cam.org>
* *
* $Id: sa1100-flash.c,v 1.39 2004/07/12 21:59:44 dwmw2 Exp $ * $Id: sa1100-flash.c,v 1.47 2004/11/01 13:44:36 rmk Exp $
*/ */
#include <linux/config.h> #include <linux/config.h>
...@@ -496,6 +496,32 @@ static struct mtd_partition huw_webpanel_partitions[] = { ...@@ -496,6 +496,32 @@ static struct mtd_partition huw_webpanel_partitions[] = {
}; };
#endif #endif
#ifdef CONFIG_SA1100_JORNADA56X
static struct mtd_partition jornada56x_partitions[] = {
{
.name = "bootldr",
.size = 0x00040000,
.offset = 0,
.mask_flags = MTD_WRITEABLE,
}, {
.name = "rootfs",
.size = MTDPART_SIZ_FULL,
.offset = MTDPART_OFS_APPEND,
}
};
static void jornada56x_set_vpp(struct map_info *map, int vpp)
{
if (vpp)
GPSR = GPIO_GPIO26;
else
GPCR = GPIO_GPIO26;
GPDR |= GPIO_GPIO26;
}
#else
#define jornada56x_set_vpp NULL
#endif
#ifdef CONFIG_SA1100_JORNADA720 #ifdef CONFIG_SA1100_JORNADA720
static struct mtd_partition jornada720_partitions[] = { static struct mtd_partition jornada720_partitions[] = {
{ {
...@@ -822,6 +848,12 @@ static int __init sa1100_static_partitions(struct mtd_partition **parts) ...@@ -822,6 +848,12 @@ static int __init sa1100_static_partitions(struct mtd_partition **parts)
nb_parts = ARRAY_SIZE(huw_webpanel_partitions); nb_parts = ARRAY_SIZE(huw_webpanel_partitions);
} }
#endif #endif
#ifdef CONFIG_SA1100_JORNADA56X
if (machine_is_jornada56x()) {
*parts = jornada56x_partitions;
nb_parts = ARRAY_SIZE(jornada56x_partitions);
}
#endif
#ifdef CONFIG_SA1100_JORNADA720 #ifdef CONFIG_SA1100_JORNADA720
if (machine_is_jornada720()) { if (machine_is_jornada720()) {
*parts = jornada720_partitions; *parts = jornada720_partitions;
...@@ -885,11 +917,10 @@ struct sa_info { ...@@ -885,11 +917,10 @@ struct sa_info {
unsigned long base; unsigned long base;
unsigned long size; unsigned long size;
int width; int width;
void __iomem *vbase;
void (*set_vpp)(struct map_info *, int); void (*set_vpp)(struct map_info *, int);
char name[16];
struct map_info *map; struct map_info *map;
struct mtd_info *mtd; struct mtd_info *mtd;
struct resource *res;
}; };
#define NR_SUBMTD 4 #define NR_SUBMTD 4
...@@ -918,21 +949,22 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info * ...@@ -918,21 +949,22 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info *
if (sa[i].base == (unsigned long)-1) if (sa[i].base == (unsigned long)-1)
break; break;
sa[i].res = request_mem_region(sa[i].base, sa[i].size, "sa1100 flash"); sa[i].map = maps + i;
if (!sa[i].res) { sa[i].map->name = sa[i].name;
sprintf(sa[i].name, "sa1100-%d", i);
if (!request_mem_region(sa[i].base, sa[i].size, sa[i].name)) {
i -= 1;
ret = -EBUSY; ret = -EBUSY;
break; break;
} }
sa[i].map = maps + i; sa[i].map->virt = ioremap(sa[i].base, sa[i].size);
if (!sa[i].map->virt) {
sa[i].vbase = ioremap(sa[i].base, sa[i].size);
if (!sa[i].vbase) {
ret = -ENOMEM; ret = -ENOMEM;
break; break;
} }
sa[i].map->virt = sa[i].vbase;
sa[i].map->phys = sa[i].base; sa[i].map->phys = sa[i].base;
sa[i].map->set_vpp = sa[i].set_vpp; sa[i].map->set_vpp = sa[i].set_vpp;
sa[i].map->bankwidth = sa[i].width; sa[i].map->bankwidth = sa[i].width;
...@@ -964,10 +996,9 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info * ...@@ -964,10 +996,9 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info *
* resource and mark it as such. * resource and mark it as such.
*/ */
if (ret == -ENXIO) { if (ret == -ENXIO) {
iounmap(sa[i].vbase); iounmap(sa[i].map->virt);
sa[i].vbase = NULL; sa[i].map->virt = NULL;
release_resource(sa[i].res); release_mem_region(sa[i].base, sa[i].size);
sa[i].res = NULL;
} }
/* /*
...@@ -986,7 +1017,7 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info * ...@@ -986,7 +1017,7 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info *
*/ */
#ifdef CONFIG_MTD_CONCAT #ifdef CONFIG_MTD_CONCAT
*rmtd = mtd_concat_create(subdev, found, *rmtd = mtd_concat_create(subdev, found,
"sa1100 flash"); "sa1100");
if (*rmtd == NULL) if (*rmtd == NULL)
ret = -ENXIO; ret = -ENXIO;
#else #else
...@@ -1004,11 +1035,10 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info * ...@@ -1004,11 +1035,10 @@ static int __init sa1100_setup_mtd(struct sa_info *sa, int nr, struct mtd_info *
do { do {
if (sa[i].mtd) if (sa[i].mtd)
map_destroy(sa[i].mtd); map_destroy(sa[i].mtd);
if (sa[i].vbase) if (sa[i].map->virt)
iounmap(sa[i].vbase); iounmap(sa[i].map->virt);
if (sa[i].res) release_mem_region(sa[i].base, sa[i].size);
release_resource(sa[i].res); } while (i-- > 0);
} while (i--);
kfree(maps); kfree(maps);
} }
...@@ -1030,10 +1060,9 @@ static void __exit sa1100_destroy_mtd(struct sa_info *sa, struct mtd_info *mtd) ...@@ -1030,10 +1060,9 @@ static void __exit sa1100_destroy_mtd(struct sa_info *sa, struct mtd_info *mtd)
for (i = NR_SUBMTD; i >= 0; i--) { for (i = NR_SUBMTD; i >= 0; i--) {
if (sa[i].mtd) if (sa[i].mtd)
map_destroy(sa[i].mtd); map_destroy(sa[i].mtd);
if (sa[i].vbase) if (sa[i].map->virt)
iounmap(sa[i].vbase); iounmap(sa[i].map->virt);
if (sa[i].res) release_mem_region(sa[i].base, sa[i].size);
release_resource(sa[i].res);
} }
kfree(sa[0].map); kfree(sa[0].map);
} }
...@@ -1044,13 +1073,9 @@ static void __exit sa1100_destroy_mtd(struct sa_info *sa, struct mtd_info *mtd) ...@@ -1044,13 +1073,9 @@ static void __exit sa1100_destroy_mtd(struct sa_info *sa, struct mtd_info *mtd)
* - Is the MSC setup for flash (no -> failure) * - Is the MSC setup for flash (no -> failure)
* - Probe for flash * - Probe for flash
*/ */
static struct map_info sa1100_probe_map __initdata = {
.name = "SA1100-flash",
};
static void __init sa1100_probe_one_cs(unsigned int msc, unsigned long phys) static void __init sa1100_probe_one_cs(unsigned int msc, unsigned long phys)
{ {
struct map_info map;
struct mtd_info *mtd; struct mtd_info *mtd;
printk(KERN_INFO "* Probing 0x%08lx: MSC = 0x%04x %d bit ", printk(KERN_INFO "* Probing 0x%08lx: MSC = 0x%04x %d bit ",
...@@ -1066,19 +1091,23 @@ static void __init sa1100_probe_one_cs(unsigned int msc, unsigned long phys) ...@@ -1066,19 +1091,23 @@ static void __init sa1100_probe_one_cs(unsigned int msc, unsigned long phys)
return; return;
} }
sa1100_probe_map.bankwidth = msc & MSC_RBW ? 2 : 4; memset(&map, 0, sizeof(struct map_info));
sa1100_probe_map.size = SZ_1M;
sa1100_probe_map.phys = phys; map.name = "Probe";
sa1100_probe_map.virt = (unsigned long)ioremap(phys, SZ_1M); map.bankwidth = msc & MSC_RBW ? 2 : 4;
if (sa1100_probe_map.virt == 0) map.size = SZ_1M;
map.phys = phys;
map.virt = ioremap(phys, SZ_1M);
if (map.virt == NULL)
goto fail; goto fail;
simple_map_init(&sa1100_probe_map);
simple_map_init(&map);
/* Shame cfi_probe blurts out kernel messages... */ /* Shame cfi_probe blurts out kernel messages... */
mtd = do_map_probe("cfi_probe", &sa1100_probe_map); mtd = do_map_probe("cfi_probe", &map);
if (mtd) if (mtd)
map_destroy(mtd); map_destroy(mtd);
iounmap((void *)sa1100_probe_map.virt); iounmap(map.virt);
if (!mtd) if (!mtd)
goto fail; goto fail;
...@@ -1176,6 +1205,12 @@ static int __init sa1100_locate_flash(void) ...@@ -1176,6 +1205,12 @@ static int __init sa1100_locate_flash(void)
info[0].size = SZ_32M; info[0].size = SZ_32M;
nr = 1; nr = 1;
} }
if (machine_is_jornada56x()) {
info[0].set_vpp = jornada56x_set_vpp;
info[0].base = SA1100_CS0_PHYS;
info[0].size = SZ_32M;
nr = 1;
}
if (machine_is_jornada720()) { if (machine_is_jornada720()) {
info[0].set_vpp = jornada720_set_vpp; info[0].set_vpp = jornada720_set_vpp;
info[0].base = SA1100_CS0_PHYS; info[0].base = SA1100_CS0_PHYS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment