mx1ads.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 125 行
C
125 行
/* * linux/drivers/mtd/maps/mx1ads.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>#define MX1ADS_FLASH_SIZE 0x01000000#define MX1ADS_FLASH_PHYS 0x0C000000static struct map_info mx1ads_map = { .name = "mx1ads Flash", .bankwidth = 4, .size = MX1ADS_FLASH_SIZE, .phys = MX1ADS_FLASH_PHYS,};static struct mtd_partition mx1ads_partitions[] = { { .name = "U-Boot", .size = 1024*1024, .offset = 0x00000000, /* mask_flags: MTD_WRITEABLE force read-only */ },{ .name = "Kernel", .size = 1024*1024, .offset = 0x00100000, },{ .name = "Root-FS", .size = 13*1024*1024, .offset = 0x00200000, },{ .name = "U-Boot-Environment", .size = 1024*1024, .offset = 0x00F00000, }};#define NB_OF(x) (sizeof(x)/sizeof(x[0]))static struct mtd_info *mymtd;static struct mtd_partition *parsed_parts;static int __init init_mx1ads(void){ struct mtd_partition *parts; int nb_parts = 0; char *part_type = "static"; printk("mx1ads: probing flash at 0x%08x\n", MX1ADS_FLASH_PHYS); mx1ads_map.virt = (unsigned long)ioremap(MX1ADS_FLASH_PHYS, MX1ADS_FLASH_SIZE); if (!mx1ads_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&mx1ads_map); mymtd = do_map_probe("map_rom", &mx1ads_map); if (!mymtd) { printk("probing failed\n"); iounmap((void *)mx1ads_map.map_priv_1); return -ENXIO; } /* set partition table */ parts = mx1ads_partitions; part_type = "static"; nb_parts = NB_OF(mx1ads_partitions); printk(KERN_NOTICE "Using %s partition definition\n", part_type); add_mtd_partitions(mymtd, parts, nb_parts); return 0;}static void __exit cleanup_mx1ads(void){ if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); if (parsed_parts) kfree(parsed_parts); } if (mx1ads_map.map_priv_1) iounmap((void *)mx1ads_map.map_priv_1); return;}module_init(init_mx1ads);module_exit(cleanup_mx1ads);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?