summaryrefslogtreecommitdiffstats
path: root/linux-2.4.x/drivers/mtd/maps/sc520cdp.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-2.4.x/drivers/mtd/maps/sc520cdp.c')
-rw-r--r--linux-2.4.x/drivers/mtd/maps/sc520cdp.c131
1 files changed, 37 insertions, 94 deletions
diff --git a/linux-2.4.x/drivers/mtd/maps/sc520cdp.c b/linux-2.4.x/drivers/mtd/maps/sc520cdp.c
index ac7bd98..a93a998 100644
--- a/linux-2.4.x/drivers/mtd/maps/sc520cdp.c
+++ b/linux-2.4.x/drivers/mtd/maps/sc520cdp.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: sc520cdp.c,v 1.11 2002/03/08 16:34:35 rkaiser Exp $
+ * $Id: sc520cdp.c,v 1.24 2006/03/29 08:31:11 dwmw2 Exp $
*
*
* The SC520CDP is an evaluation board for the Elan SC520 processor available
@@ -29,6 +29,7 @@
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/init.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
@@ -84,92 +85,29 @@
#define WINDOW_SIZE_1 0x00800000
#define WINDOW_SIZE_2 0x00080000
-static __u8 sc520cdp_read8(struct map_info *map, unsigned long ofs)
-{
- return readb(map->map_priv_1 + ofs);
-}
-
-static __u16 sc520cdp_read16(struct map_info *map, unsigned long ofs)
-{
- return readw(map->map_priv_1 + ofs);
-}
-
-static __u32 sc520cdp_read32(struct map_info *map, unsigned long ofs)
-{
- return readl(map->map_priv_1 + ofs);
-}
-
-static void sc520cdp_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
-{
- memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
-}
-
-static void sc520cdp_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- writeb(d, map->map_priv_1 + adr);
-}
-
-static void sc520cdp_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- writew(d, map->map_priv_1 + adr);
-}
-
-static void sc520cdp_write32(struct map_info *map, __u32 d, unsigned long adr)
-{
- writel(d, map->map_priv_1 + adr);
-}
-
-static void sc520cdp_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
-{
- memcpy_toio((void *)(map->map_priv_1 + to), from, len);
-}
static struct map_info sc520cdp_map[] = {
{
- name: "SC520CDP Flash Bank #0",
- size: WINDOW_SIZE_0,
- buswidth: 4,
- read8: sc520cdp_read8,
- read16: sc520cdp_read16,
- read32: sc520cdp_read32,
- copy_from: sc520cdp_copy_from,
- write8: sc520cdp_write8,
- write16: sc520cdp_write16,
- write32: sc520cdp_write32,
- copy_to: sc520cdp_copy_to,
- map_priv_2: WINDOW_ADDR_0
+ .name = "SC520CDP Flash Bank #0",
+ .size = WINDOW_SIZE_0,
+ .bankwidth = 4,
+ .phys = WINDOW_ADDR_0
},
{
- name: "SC520CDP Flash Bank #1",
- size: WINDOW_SIZE_1,
- buswidth: 4,
- read8: sc520cdp_read8,
- read16: sc520cdp_read16,
- read32: sc520cdp_read32,
- copy_from: sc520cdp_copy_from,
- write8: sc520cdp_write8,
- write16: sc520cdp_write16,
- write32: sc520cdp_write32,
- copy_to: sc520cdp_copy_to,
- map_priv_2: WINDOW_ADDR_1
+ .name = "SC520CDP Flash Bank #1",
+ .size = WINDOW_SIZE_1,
+ .bankwidth = 4,
+ .phys = WINDOW_ADDR_1
},
{
- name: "SC520CDP DIL Flash",
- size: WINDOW_SIZE_2,
- buswidth: 1,
- read8: sc520cdp_read8,
- read16: sc520cdp_read16,
- read32: sc520cdp_read32,
- copy_from: sc520cdp_copy_from,
- write8: sc520cdp_write8,
- write16: sc520cdp_write16,
- write32: sc520cdp_write32,
- copy_to: sc520cdp_copy_to,
- map_priv_2: WINDOW_ADDR_2
+ .name = "SC520CDP DIL Flash",
+ .size = WINDOW_SIZE_2,
+ .bankwidth = 1,
+ .phys = WINDOW_ADDR_2
},
};
-#define NUM_FLASH_BANKS (sizeof(sc520cdp_map)/sizeof(struct map_info))
+#define NUM_FLASH_BANKS ARRAY_SIZE(sc520cdp_map)
static struct mtd_info *mymtd[NUM_FLASH_BANKS];
static struct mtd_info *merged_mtd;
@@ -226,7 +164,7 @@ struct sc520_par_table
unsigned long default_address;
};
-static struct sc520_par_table par_table[NUM_FLASH_BANKS] =
+static const struct sc520_par_table par_table[NUM_FLASH_BANKS] =
{
{ /* Flash Bank #0: selected by ROMCS0 */
SC520_PAR_ROMCS0,
@@ -248,16 +186,16 @@ static struct sc520_par_table par_table[NUM_FLASH_BANKS] =
static void sc520cdp_setup_par(void)
{
- volatile unsigned long *mmcr;
+ volatile unsigned long __iomem *mmcr;
unsigned long mmcr_val;
int i, j;
/* map in SC520's MMCR area */
- mmcr = (unsigned long *)ioremap_nocache(SC520_MMCR_BASE, SC520_MMCR_EXTENT);
+ mmcr = ioremap_nocache(SC520_MMCR_BASE, SC520_MMCR_EXTENT);
if(!mmcr) { /* ioremap_nocache failed: skip the PAR reprogramming */
- /* force map_priv_2 fields to BIOS defaults: */
+ /* force physical address fields to BIOS defaults: */
for(i = 0; i < NUM_FLASH_BANKS; i++)
- sc520cdp_map[i].map_priv_2 = par_table[i].default_address;
+ sc520cdp_map[i].phys = par_table[i].default_address;
return;
}
@@ -282,10 +220,10 @@ static void sc520cdp_setup_par(void)
sc520cdp_map[i].name);
printk(KERN_NOTICE "Trying default address 0x%lx\n",
par_table[i].default_address);
- sc520cdp_map[i].map_priv_2 = par_table[i].default_address;
+ sc520cdp_map[i].phys = par_table[i].default_address;
}
}
- iounmap((void *)mmcr);
+ iounmap(mmcr);
}
#endif
@@ -293,20 +231,25 @@ static void sc520cdp_setup_par(void)
static int __init init_sc520cdp(void)
{
int i, devices_found = 0;
-
+
#ifdef REPROGRAM_PAR
/* reprogram PAR registers so flash appears at the desired addresses */
sc520cdp_setup_par();
#endif
for (i = 0; i < NUM_FLASH_BANKS; i++) {
- printk(KERN_NOTICE "SC520 CDP flash device: %lx at %lx\n", sc520cdp_map[i].size, sc520cdp_map[i].map_priv_2);
- sc520cdp_map[i].map_priv_1 = (unsigned long)ioremap_nocache(sc520cdp_map[i].map_priv_2, sc520cdp_map[i].size);
+ printk(KERN_NOTICE "SC520 CDP flash device: 0x%lx at 0x%lx\n",
+ sc520cdp_map[i].size, sc520cdp_map[i].phys);
+
+ sc520cdp_map[i].virt = ioremap_nocache(sc520cdp_map[i].phys, sc520cdp_map[i].size);
- if (!sc520cdp_map[i].map_priv_1) {
+ if (!sc520cdp_map[i].virt) {
printk("Failed to ioremap_nocache\n");
return -EIO;
}
+
+ simple_map_init(&sc520cdp_map[i]);
+
mymtd[i] = do_map_probe("cfi_probe", &sc520cdp_map[i]);
if(!mymtd[i])
mymtd[i] = do_map_probe("jedec_probe", &sc520cdp_map[i]);
@@ -314,11 +257,11 @@ static int __init init_sc520cdp(void)
mymtd[i] = do_map_probe("map_rom", &sc520cdp_map[i]);
if (mymtd[i]) {
- mymtd[i]->module = THIS_MODULE;
+ mymtd[i]->owner = THIS_MODULE;
++devices_found;
}
else {
- iounmap((void *)sc520cdp_map[i].map_priv_1);
+ iounmap(sc520cdp_map[i].virt);
}
}
if(devices_found >= 2) {
@@ -335,7 +278,7 @@ static int __init init_sc520cdp(void)
static void __exit cleanup_sc520cdp(void)
{
int i;
-
+
if (merged_mtd) {
del_mtd_device(merged_mtd);
mtd_concat_destroy(merged_mtd);
@@ -346,9 +289,9 @@ static void __exit cleanup_sc520cdp(void)
for (i = 0; i < NUM_FLASH_BANKS; i++) {
if (mymtd[i])
map_destroy(mymtd[i]);
- if (sc520cdp_map[i].map_priv_1) {
- iounmap((void *)sc520cdp_map[i].map_priv_1);
- sc520cdp_map[i].map_priv_1 = 0;
+ if (sc520cdp_map[i].virt) {
+ iounmap(sc520cdp_map[i].virt);
+ sc520cdp_map[i].virt = NULL;
}
}
}