innokom.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 179 行
C
179 行
/* * Map driver for the Auerswald Innokom platform. * * Authors: Kai-Uwe Bloem, Robert Schwebel, Nicolas Pitre * Copyright: (C) 2001 MontaVista Software Inc. * (C) 2003 Pengutronix * (C) 2003 Auerswald GmbH & Co. KG * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/init.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#define WINDOW_ADDR 0#define WINDOW_SIZE (64*1024*1024) /* 2 Flashes in PXA nCS banks #0, #1 */static struct map_info innokom_map = { .name = "Innokom flash", .size = WINDOW_SIZE, .phys = WINDOW_ADDR, /* FIXME: wasn't there before... */};static struct mtd_partition innokom_partitions_16M[] = { { name: "U-Boot", size: 0x00040000, /* 256 kB */ offset: 0x00000000, /* mask_flags: MTD_WRITEABLE force read-only */ },{ name: "Kernel", size: 0x00140000, /* 1.25 MB */ offset: 0x00040000, },{ name: "Rootfs", size: 0x00680000, /* 6.5 MB */ offset: 0x00180000, },{ name: "FileSystem", size: 0x00800000, /* 8 MB */ offset: 0x00800000 }};static struct mtd_partition innokom_partitions_32M[] = { { name: "U-Boot", size: 0x00040000, /* 256 kB */ offset: 0x00000000, /* mask_flags: MTD_WRITEABLE force read-only */ },{ name: "Kernel", size: 0x001c0000, /* 1.5 MB - 256 kB */ offset: 0x00040000, },{ name: "RootFs", size: 0x00e00000, /* 8 MB - 1.5 MB */ offset: 0x00200000, },{ name: "FileSystem", size: 0x01000000, /* 24 MB */ offset: 0x01000000 }};static struct mtd_partition innokom_partitions_64M[] = { { name: "U-Boot", size: 0x00040000, /* 256 kB */ offset: 0x00000000, /* mask_flags: MTD_WRITEABLE force read-only */ },{ name: "Firmware-1", size: 0x00FE0000, /* 16 MB - 128 kB */ offset: 0x00040000, },{ name: "Firmware-2", size: 0x00FE0000, /* 16 MB - 128 kB */ offset: 0x01020000, },{ name: "Data", size: 0x02000000, /* 32 MB */ offset: 0x02000000 }};#define NB_OF(x) (sizeof(x)/sizeof(x[0]))static struct mtd_info *mymtd;static struct mtd_partition *parsed_parts;static int __init init_innokom(void){ struct mtd_partition *parts; int nb_parts = 0; int parsed_nr_parts = 0; char *part_type = "static"; innokom_map.bankwidth = 4;//(BOOT_DEF & 1) ? 2 : 4; printk( "Probing Auerswald Innokom flash at physical address 0x%08x (%d-bit buswidth)\n", WINDOW_ADDR, innokom_map.bankwidth * 8 ); /* FIXME: RS: is the "align" parameter (last one) correct? I * could not find an example for it... */ innokom_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!innokom_map.map_priv_1) { printk("Failed to ioremap\n"); return -EIO; } innokom_map.virt = innokom_map.map_priv_1; mymtd = do_map_probe("cfi_probe", &innokom_map); if (!mymtd) { iounmap((void *)innokom_map.map_priv_1); return -ENXIO; } mymtd->owner = THIS_MODULE; if (parsed_nr_parts > 0) { parts = parsed_parts; } else switch (mymtd->size) { case 64*1024*1024: parts = innokom_partitions_64M; part_type = "static (64M)"; nb_parts = NB_OF(innokom_partitions_64M); break; case 32*1024*1024: parts = innokom_partitions_32M; part_type = "static (32M)"; nb_parts = NB_OF(innokom_partitions_32M); break; case 16*1024*1024: parts = innokom_partitions_16M; part_type = "static (16M)"; nb_parts = NB_OF(innokom_partitions_16M); break; default: printk(KERN_WARNING "Can't derive partitioning from MTD size, using 16M as default\n"); parts = innokom_partitions_16M; part_type = "static (default)"; nb_parts = NB_OF(innokom_partitions_16M); break; } if (nb_parts) { printk(KERN_NOTICE "Using %s partition definition\n", part_type); add_mtd_partitions(mymtd, parts, nb_parts); } else { add_mtd_device(mymtd); } return 0;}static void __exit cleanup_innokom(void){ if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); if (parsed_parts) kfree(parsed_parts); } if (innokom_map.map_priv_1) iounmap((void *)innokom_map.map_priv_1); return;}module_init(init_innokom);module_exit(cleanup_innokom);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?