mx1fs2.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 130 行
C
130 行
/* * linux/drivers/mtd/maps/mx1fs2.c * * Mapping driver for the Viasys Flowscreen 2 platform, * derived from the innokom.c driver. * * Authors: Robert Schwebel, Kai-Uwe Bloem, Nicolas Pitre * Copyright: (C) 2001 MontaVista Software Inc. * (C) 2003, 2004 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 as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/init.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <asm/io.h>#include <asm/arch/mx1fs2.h>static struct map_info mx1fs2_map = { .name = "Flowscreen 2 Flash", .bankwidth = 4, .size = MX1FS2_FLASH_SIZE, .phys = MX1FS2_FLASH_PHYS,};static struct mtd_partition mx1fs2_partitions[] = { { .name = "U-Boot", .size = 128*1024, .offset = 0x00000000, /* mask_flags: MTD_WRITEABLE force read-only */ },{ .name = "U-Boot-Environment", .size = 128*1024, .offset = 0x00020000, },{ .name = "Start-Logo", .size = 256*1024, .offset = 0x00040000, },{ .name = "Kernel", .size = 1536*1024, .offset = 0x00080000, },{ .name = "Root-FS", .size = 5*1024*1024, .offset = 0x00200000, },{ .name = "User-FS", .size = 9*1024*1024, .offset = 0x00700000, }};#define NB_OF(x) (sizeof(x)/sizeof(x[0]))static struct mtd_info *mymtd;static struct mtd_partition *parsed_parts;static int __init init_mx1fs2(void){ struct mtd_partition *parts; int nb_parts = 0; char *part_type = "static"; printk("mx1fs2: probing flash at 0x%08x\n", MX1FS2_FLASH_PHYS); mx1fs2_map.virt = (unsigned long)ioremap(MX1FS2_FLASH_PHYS, MX1FS2_FLASH_SIZE); if (!mx1fs2_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&mx1fs2_map); mymtd = do_map_probe("cfi_probe", &mx1fs2_map); if (!mymtd) { iounmap((void *)mx1fs2_map.map_priv_1); return -ENXIO; } /* set partition table */ parts = mx1fs2_partitions; part_type = "static"; nb_parts = NB_OF(mx1fs2_partitions); printk(KERN_NOTICE "Using %s partition definition\n", part_type); add_mtd_partitions(mymtd, parts, nb_parts); return 0;}static void __exit cleanup_mx1fs2(void){ if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); if (parsed_parts) kfree(parsed_parts); } if (mx1fs2_map.map_priv_1) iounmap((void *)mx1fs2_map.map_priv_1); return;}module_init(init_mx1fs2);module_exit(cleanup_mx1fs2);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?