projects
/
openwrt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lua: Fixed some cross-platform issues for PPC (and probably other architectures)
[openwrt.git]
/
target
/
linux
/
ifxmips
/
files
/
drivers
/
mtd
/
maps
/
ifxmips.c
diff --git
a/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
b/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
index
3dd41d1
..
98359eb
100644
(file)
--- a/
target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
+++ b/
target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
@@
-1,6
+1,4
@@
/*
/*
- * Driver for IFXMIPS flashmap
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@
-16,7
+14,7
@@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright (C) 2004 Liu Peng Infineon IFAP DC COM CPE
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright (C) 2004 Liu Peng Infineon IFAP DC COM CPE
- * Copyright (C) 200
7
John Crispin <blogic@openwrt.org>
+ * Copyright (C) 200
8
John Crispin <blogic@openwrt.org>
*/
#include <linux/module.h>
*/
#include <linux/module.h>
@@
-29,61
+27,66
@@
#include <linux/mtd/partitions.h>
#include <linux/mtd/cfi.h>
#include <asm/ifxmips/ifxmips.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/cfi.h>
#include <asm/ifxmips/ifxmips.h>
+#include <asm/ifxmips/ifxmips_ebu.h>
#include <linux/magic.h>
#include <linux/platform_device.h>
#include <linux/magic.h>
#include <linux/platform_device.h>
-#define DRVNAME "ifxmips_mtd"
-
static struct map_info
ifxmips_map = {
static struct map_info
ifxmips_map = {
- .name =
DRVNAME
,
+ .name =
"ifxmips_mtd"
,
.bankwidth = 2,
.size = 0x400000,
};
static map_word
.bankwidth = 2,
.size = 0x400000,
};
static map_word
-ifxmips_read16
(struct map_info * map, unsigned long adr)
+ifxmips_read16(struct map_info * map, unsigned long adr)
{
{
+ unsigned long flags;
map_word temp;
map_word temp;
-
+ spin_lock_irqsave(&ebu_lock, flags);
adr ^= 2;
adr ^= 2;
- temp.x[0] = *((__u16
*)
(map->virt + adr));
-
+ temp.x[0] = *((__u16
*)
(map->virt + adr));
+ spin_unlock_irqrestore(&ebu_lock, flags);
return temp;
}
static void
return temp;
}
static void
-ifxmips_write16
(struct map_info *map, map_word d, unsigned long adr)
+ifxmips_write16(struct map_info *map, map_word d, unsigned long adr)
{
{
+ unsigned long flags;
+ spin_lock_irqsave(&ebu_lock, flags);
adr ^= 2;
adr ^= 2;
- *((__u16 *) (map->virt + adr)) = d.x[0];
+ *((__u16*)(map->virt + adr)) = d.x[0];
+ spin_unlock_irqrestore(&ebu_lock, flags);
}
void
}
void
-ifxmips_copy_from
(struct map_info *map, void *to, unsigned long from, ssize_t len)
+ifxmips_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
{
- u8 *p;
- u8 *to_8;
-
- from = (unsigned long) (from + map->virt);
- p = (u8 *) from;
- to_8 = (u8 *) to;
- while(len--){
+ unsigned char *p;
+ unsigned char *to_8;
+ unsigned long flags;
+ spin_lock_irqsave(&ebu_lock, flags);
+ from = (unsigned long)(from + map->virt);
+ p = (unsigned char*) from;
+ to_8 = (unsigned char*) to;
+ while(len--)
*to_8++ = *p++;
*to_8++ = *p++;
- }
+ spin_unlock_irqrestore(&ebu_lock, flags);
}
void
}
void
-ifxmips_copy_to
(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+ifxmips_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
{
- u8 *p = (u8*) from;
- u8 *to_8;
-
+ unsigned char *p = (unsigned char*)from;
+ unsigned char *to_8;
+ unsigned long flags;
+ spin_lock_irqsave(&ebu_lock, flags);
to += (unsigned long) map->virt;
to += (unsigned long) map->virt;
- to_8 = (u
8
*)to;
- while(len--)
{
+ to_8 = (u
nsigned char
*)to;
+ while(len--)
*p++ = *to_8++;
*p++ = *to_8++;
- }
+ spin_unlock_irqrestore(&ebu_lock, flags);
}
static struct mtd_partition
}
static struct mtd_partition
@@
-111,58
+114,57
@@
ifxmips_partitions[4] = {
};
int
};
int
-find_uImage_size
(unsigned long start_offset){
+find_uImage_size(unsigned long start_offset){
unsigned long temp;
unsigned long temp;
-
ifxmips_copy_from(&ifxmips_map, &temp, start_offset + 12, 4);
ifxmips_copy_from(&ifxmips_map, &temp, start_offset + 12, 4);
- printk(KERN_INFO
DRVNAME "
: kernel size is %ld \n", temp + 0x40);
+ printk(KERN_INFO
"ifxmips_mtd
: kernel size is %ld \n", temp + 0x40);
return temp + 0x40;
}
int
return temp + 0x40;
}
int
-detect_squashfs_partition
(unsigned long start_offset){
+detect_squashfs_partition(unsigned long start_offset){
unsigned long temp;
unsigned long temp;
-
ifxmips_copy_from(&ifxmips_map, &temp, start_offset, 4);
ifxmips_copy_from(&ifxmips_map, &temp, start_offset, 4);
-
return (temp == SQUASHFS_MAGIC);
}
static int
return (temp == SQUASHFS_MAGIC);
}
static int
-ifxmips_mtd_probe
(void
)
+ifxmips_mtd_probe
(struct platform_device *dev
)
{
struct mtd_info *ifxmips_mtd = NULL;
struct mtd_partition *parts = NULL;
unsigned long uimage_size;
{
struct mtd_info *ifxmips_mtd = NULL;
struct mtd_partition *parts = NULL;
unsigned long uimage_size;
-
writel
(0x1d7ff, IFXMIPS_EBU_BUSCON0);
+
ifxmips_w32
(0x1d7ff, IFXMIPS_EBU_BUSCON0);
ifxmips_map.read = ifxmips_read16;
ifxmips_map.write = ifxmips_write16;
ifxmips_map.copy_from = ifxmips_copy_from;
ifxmips_map.copy_to = ifxmips_copy_to;
ifxmips_map.read = ifxmips_read16;
ifxmips_map.write = ifxmips_write16;
ifxmips_map.copy_from = ifxmips_copy_from;
ifxmips_map.copy_to = ifxmips_copy_to;
+ ifxmips_map.phys = dev->resource->start;
+ ifxmips_map.size = dev->resource->end - ifxmips_map.phys + 1;
+ ifxmips_map.virt = ioremap_nocache(ifxmips_map.phys, ifxmips_map.size);
- ifxmips_map.phys = IFXMIPS_FLASH_START;
- ifxmips_map.virt = ioremap_nocache(IFXMIPS_FLASH_START, IFXMIPS_FLASH_MAX);
- ifxmips_map.size = IFXMIPS_FLASH_MAX;
- if (!ifxmips_map.virt) {
- printk(KERN_WARNING DRVNAME ": failed to ioremap!\n");
+ if(!ifxmips_map.virt)
+ {
+ printk(KERN_WARNING "ifxmips_mtd: failed to ioremap!\n");
return -EIO;
}
ifxmips_mtd = (struct mtd_info *) do_map_probe("cfi_probe", &ifxmips_map);
return -EIO;
}
ifxmips_mtd = (struct mtd_info *) do_map_probe("cfi_probe", &ifxmips_map);
- if (!ifxmips_mtd) {
+ if(!ifxmips_mtd)
+ {
iounmap(ifxmips_map.virt);
iounmap(ifxmips_map.virt);
- printk(KERN_WARNING
DRVNAME "
: probing failed\n");
+ printk(KERN_WARNING
"ifxmips_mtd
: probing failed\n");
return -ENXIO;
}
ifxmips_mtd->owner = THIS_MODULE;
return -ENXIO;
}
ifxmips_mtd->owner = THIS_MODULE;
-
uimage_size = find_uImage_size(ifxmips_partitions[2].offset);
uimage_size = find_uImage_size(ifxmips_partitions[2].offset);
- if(detect_squashfs_partition(ifxmips_partitions[2].offset + uimage_size)){
- printk(KERN_INFO DRVNAME ": found a squashfs following the uImage\n");
+ if(detect_squashfs_partition(ifxmips_partitions[2].offset + uimage_size))
+ {
+ printk(KERN_INFO "ifxmips_mtd: found a squashfs following the uImage\n");
} else {
uimage_size &= ~0xffff;
uimage_size += 0x10000;
} else {
uimage_size &= ~0xffff;
uimage_size += 0x10000;
@@
-175,39
+177,37
@@
ifxmips_mtd_probe (void)
parts = &ifxmips_partitions[0];
add_mtd_partitions(ifxmips_mtd, parts, 4);
parts = &ifxmips_partitions[0];
add_mtd_partitions(ifxmips_mtd, parts, 4);
- printk(KERN_INFO
DRVNAME "
: added ifxmips flash with %dMB\n", ifxmips_mtd->size >> 20);
+ printk(KERN_INFO
"ifxmips_mtd
: added ifxmips flash with %dMB\n", ifxmips_mtd->size >> 20);
return 0;
}
return 0;
}
-static struct
-platform_driver ifxmips_mtd_driver = {
- .probe = ifxmips_mtd_probe,
- .driver = {
- .name =
DRVNAME,
- .owner = THIS_MODULE,
- },
-};
+static struct
+platform_driver ifxmips_mtd_driver = {
+ .probe = ifxmips_mtd_probe,
+ .driver = {
+ .name =
"ifxmips_mtd",
+ .owner = THIS_MODULE,
+ },
+};
int __init
int __init
-init_ifxmips_mtd
(void)
+init_ifxmips_mtd(void)
{
{
- int ret = platform_driver_register(&ifxmips_mtd_driver);
- if (ret)
- printk(KERN_INFO DRVNAME ": error registering platfom driver!");
-
- return ret;
+ int ret = platform_driver_register(&ifxmips_mtd_driver);
+ if(ret)
+ printk(KERN_INFO "ifxmips_mtd: error registering platfom driver!");
+ return ret;
}
}
-static void
-__exit
-cleanup_ifxmips_mtd (void)
+static void __exit
+cleanup_ifxmips_mtd(void)
{
platform_driver_unregister(&ifxmips_mtd_driver);
}
{
platform_driver_unregister(&ifxmips_mtd_driver);
}
-module_init
(init_ifxmips_mtd);
-module_exit
(cleanup_ifxmips_mtd);
+module_init(init_ifxmips_mtd);
+module_exit(cleanup_ifxmips_mtd);
-MODULE_LICENSE
("GPL");
-MODULE_AUTHOR
("John Crispin <blogic@openwrt.org>");
-MODULE_DESCRIPTION
("MTD map driver for IFXMIPS boards");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
+MODULE_DESCRIPTION("MTD map driver for IFXMIPS boards");
This page took
0.057668 seconds
and
4
git commands to generate.