📄 sa1100-flash.c
字号:
/* * Flash memory access on SA11x0 based devices * * (C) 2000 Nicolas Pitre <nico@cam.org> * * $Id: sa1100-flash.c,v 1.28 2002/05/07 13:48:38 abz Exp $ */#include <linux/config.h>#include <linux/module.h>#include <linux/types.h>#include <linux/ioport.h>#include <linux/kernel.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <asm/hardware.h>#include <asm/io.h>#ifndef CONFIG_ARCH_SA1100#error This is for SA1100 architecture only#endif#define WINDOW_ADDR 0xe8000000static __u8 sa1100_read8(struct map_info *map, unsigned long ofs){ return readb(map->map_priv_1 + ofs);}static __u16 sa1100_read16(struct map_info *map, unsigned long ofs){ return readw(map->map_priv_1 + ofs);}static __u32 sa1100_read32(struct map_info *map, unsigned long ofs){ return readl(map->map_priv_1 + ofs);}static void sa1100_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len){ memcpy(to, (void *)(map->map_priv_1 + from), len);}static void sa1100_write8(struct map_info *map, __u8 d, unsigned long adr){ writeb(d, map->map_priv_1 + adr);}static void sa1100_write16(struct map_info *map, __u16 d, unsigned long adr){ writew(d, map->map_priv_1 + adr);}static void sa1100_write32(struct map_info *map, __u32 d, unsigned long adr){ writel(d, map->map_priv_1 + adr);}static void sa1100_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len){ memcpy((void *)(map->map_priv_1 + to), from, len);}static struct map_info sa1100_map = { name: "SA1100 flash", read8: sa1100_read8, read16: sa1100_read16, read32: sa1100_read32, copy_from: sa1100_copy_from, write8: sa1100_write8, write16: sa1100_write16, write32: sa1100_write32, copy_to: sa1100_copy_to, map_priv_1: WINDOW_ADDR, map_priv_2: -1,};/* * Here are partition information for all known SA1100-based devices. * See include/linux/mtd/partitions.h for definition of the mtd_partition * structure. * * The *_max_flash_size is the maximum possible mapped flash size which * is not necessarily the actual flash size. It must be no more than * the value specified in the "struct map_desc *_io_desc" mapping * definition for the corresponding machine. * * Please keep these in alphabetical order, and formatted as per existing * entries. Thanks. */#ifdef CONFIG_SA1100_ADSBITSY#define ADSBITSY_FLASH_SIZE 0x02000000static struct mtd_partition adsbitsy_partitions[] = { { name: "bootROM", size: 0x80000, offset: 0, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "zImage", size: 0x100000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "ramdisk.gz", size: 0x300000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "User FS", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};#endif#ifdef CONFIG_SA1100_ASSABET/* Phase 4 Assabet has two 28F160B3 flash parts in bank 0: */#define ASSABET4_FLASH_SIZE 0x00400000static struct mtd_partition assabet4_partitions[] = { { name: "bootloader", size: 0x00020000, offset: 0, mask_flags: MTD_WRITEABLE, }, { name: "bootloader params", size: 0x00020000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "jffs", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};/* Phase 5 Assabet has two 28F128J3A flash parts in bank 0: */#define ASSABET5_FLASH_SIZE 0x02000000static struct mtd_partition assabet5_partitions[] = { { name: "bootloader", size: 0x00040000, offset: 0, mask_flags: MTD_WRITEABLE, }, { name: "bootloader params", size: 0x00040000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "jffs", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};#define ASSABET_FLASH_SIZE ASSABET5_FLASH_SIZE#define assabet_partitions assabet5_partitions#endif#ifdef CONFIG_SA1100_BADGE4/* * 1 x Intel 28F320C3BA100 Advanced+ Boot Block Flash (32 Mi bit) * Eight 4 KiW Parameter Bottom Blocks (64 KiB) * Sixty-three 32 KiW Main Blocks (4032 Ki b) */#define BADGE4_FLASH_SIZE 0x00400000static struct mtd_partition badge4_partitions[] = { { name: "BLOB boot loader", offset: 0, size: 0x0000A000 }, { name: "params", offset: MTDPART_OFS_APPEND, size: 0x00006000 }, { name: "kernel", offset: MTDPART_OFS_APPEND, size: 0x00100000 }, { name: "root", offset: MTDPART_OFS_APPEND, size: MTDPART_SIZ_FULL }};#endif#ifdef CONFIG_SA1100_CERF#ifdef CONFIG_SA1100_CERF_FLASH_32MB#define CERF_FLASH_SIZE 0x02000000static struct mtd_partition cerf_partitions[] = { { name: "firmware", size: 0x00040000, offset: 0, }, { name: "params", size: 0x00040000, offset: 0x00040000, }, { name: "kernel", size: 0x00100000, offset: 0x00080000, }, { name: "rootdisk", size: 0x01E80000, offset: 0x00180000, }};#elif defined CONFIG_SA1100_CERF_FLASH_16MB#define CERF_FLASH_SIZE 0x01000000static struct mtd_partition cerf_partitions[] = { { name: "firmware", size: 0x00020000, offset: 0, }, { name: "params", size: 0x00020000, offset: 0x00020000, }, { name: "kernel", size: 0x00100000, offset: 0x00040000, }, { name: "rootdisk", size: 0x00EC0000, offset: 0x00140000, }};#elif defined CONFIG_SA1100_CERF_FLASH_8MB# error "Unwritten type definition"#else# error "Undefined memory orientation for CERF in sa1100-flash.c"#endif#endif#ifdef CONFIG_SA1100_CONSUS#define CONSUS_FLASH_SIZE 0x02000000static struct mtd_partition consus_partitions[] = { { name: "Consus boot firmware", offset: 0, size: 0x00040000, mask_flags: MTD_WRITABLE, /* force read-only */ }, { name: "Consus kernel", offset: 0x00040000, size: 0x00100000, mask_flags: 0, }, { name: "Consus disk", offset: 0x00140000, /* The rest (up to 16M) for jffs. We could put 0 and make it find the size automatically, but right now i have 32 megs. jffs will use all 32 megs if given the chance, and this leads to horrible problems when you try to re-flash the image because blob won't erase the whole partition. */ size: 0x01000000 - 0x00140000, mask_flags: 0, }, { /* this disk is a secondary disk, which can be used as needed, for simplicity, make it the size of the other consus partition, although realistically it could be the remainder of the disk (depending on the file system used) */ name: "Consus disk2", offset: 0x01000000, size: 0x01000000 - 0x00140000, mask_flags: 0, }};#endif#ifdef CONFIG_SA1100_FLEXANET/* Flexanet has two 28F128J3A flash parts in bank 0: */#define FLEXANET_FLASH_SIZE 0x02000000static struct mtd_partition flexanet_partitions[] = { { name: "bootloader", size: 0x00040000, offset: 0, mask_flags: MTD_WRITEABLE, }, { name: "bootloader params", size: 0x00040000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "kernel", size: 0x000C0000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "altkernel", size: 0x000C0000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "root", size: 0x00400000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "free1", size: 0x00300000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "free2", size: 0x00300000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }, { name: "free3", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, }};#endif#ifdef CONFIG_SA1100_FREEBIRD#define FREEBIRD_FLASH_SIZE 0x02000000static struct mtd_partition freebird_partitions[] = {#if CONFIG_SA1100_FREEBIRD_NEW { name: "firmware", size: 0x00040000, offset: 0, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "kernel", size: 0x00080000, offset: 0x00040000, }, { name: "params", size: 0x00040000, offset: 0x000C0000, }, { name: "initrd", size: 0x00100000, offset: 0x00100000, }, { name: "root cramfs", size: 0x00300000, offset: 0x00200000, }, { name: "usr cramfs", size: 0x00C00000, offset: 0x00500000, }, { name: "local", size: MTDPART_SIZ_FULL, offset: 0x01100000, }#else { size: 0x00040000, offset: 0, }, { size: 0x000c0000, offset: MTDPART_OFS_APPEND, }, { size: 0x00400000, offset: MTDPART_OFS_APPEND, }, { size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }#endif};#endif#ifdef CONFIG_SA1100_FRODO/* Frodo has 2 x 16M 28F128J3A flash chips in bank 0: */#define FRODO_FLASH_SIZE 0x02000000static struct mtd_partition frodo_partitions[] ={ { name: "bootloader", size: 0x00040000, offset: 0x00000000, mask_flags: MTD_WRITEABLE }, { name: "bootloader params", size: 0x00040000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE }, { name: "kernel", size: 0x00100000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE }, { name: "ramdisk", size: 0x00400000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE }, { name: "file system", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND }};#endif#ifdef CONFIG_SA1100_GRAPHICSCLIENT#define GRAPHICSCLIENT_FLASH_SIZE 0x02000000static struct mtd_partition graphicsclient_partitions[] = { { name: "zImage", size: 0x100000, offset: 0, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "ramdisk.gz", size: 0x300000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "User FS", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};#endif#ifdef CONFIG_SA1100_GRAPHICSMASTER#define GRAPHICSMASTER_FLASH_SIZE 0x01000000static struct mtd_partition graphicsmaster_partitions[] = { { name: "zImage", size: 0x100000, offset: 0, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "ramdisk.gz", size: 0x300000, offset: MTDPART_OFS_APPEND, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "User FS", size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};#endif#ifdef CONFIG_SA1100_H3600#define H3600_FLASH_SIZE 0x02000000static struct mtd_partition h3600_partitions[] = { { name: "H3600 boot firmware", size: 0x00040000, offset: 0, mask_flags: MTD_WRITEABLE, /* force read-only */ }, { name: "H3600 kernel", size: 0x00080000, offset: 0x00040000, }, { name: "H3600 params", size: 0x00040000, offset: 0x000C0000, }, {#ifdef CONFIG_JFFS2_FS name: "H3600 root jffs2", size: MTDPART_SIZ_FULL, offset: 0x00100000,#else name: "H3600 initrd", size: 0x00100000, offset: 0x00100000, }, { name: "H3600 root cramfs", size: 0x00300000, offset: 0x00200000, }, { name: "H3600 usr cramfs", size: 0x00800000, offset: 0x00500000, }, { name: "H3600 usr local", size: MTDPART_SIZ_FULL, offset: 0x00d00000,#endif }};static void h3600_set_vpp(struct map_info *map, int vpp){ assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);}#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL#define HUW_WEBPANEL_FLASH_SIZE 0x01000000static struct mtd_partition huw_webpanel_partitions[] = { { name: "Loader", size: 0x00040000, offset: 0, }, { name: "Sector 1", size: 0x00040000, offset: MTDPART_OFS_APPEND, }, { size: MTDPART_SIZ_FULL, offset: MTDPART_OFS_APPEND, }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -