📄 pnp2110.c
字号:
/* * Map driver for the SSV PNP/2110-3V platform. * * Author: Marco Hasewinkel * Copyright: (C) 2003 SSV Embedded Systems * * 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/init.h>#include <linux/device.h>#include <linux/dma-mapping.h>#include <linux/errno.h>#include <asm/io.h>#include <asm/hardware.h>#include <asm/arch/pnp2110.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>/* This window is probed for flash devices */#define WINDOW_ADDR 0x00000000#define WINDOW_SIZE (32*1024*1024)static void pnp2110_set_vpp(struct map_info *map, int on){ /* GPIO16: 1=Vpp on 0=Vpp off */ if (on) GPSR0 |= 0x00010000; else GPCR0 |= 0x00010000;} static void pnp2110_map_inval_cache(struct map_info *map, unsigned long from, ssize_t len){ consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);}static struct map_info pnp2110_map = { .name = "PNP/2110-3V flash", .size = WINDOW_SIZE, .phys = WINDOW_ADDR, .set_vpp = pnp2110_set_vpp, .inval_cache = pnp2110_map_inval_cache,};static struct mtd_partition pnp2110_partitions[] = { { name: "Bootloader", size: 0x00040000, offset: 0, mask_flags: MTD_WRITEABLE /* force read-only */ },{ name: "Kernel", size: 0x003C0000, offset: 0x00040000, },{ name: "Flash spare 1", size: 0x00400000, offset: 0x00400000 },{ name: "Flash spare 2", size: MTDPART_SIZ_FULL, offset: 0x00800000 }};#define NB_OF(x) (sizeof(x)/sizeof(x[0]))static struct mtd_info *mymtd;static struct mtd_partition *parsed_parts;static int __init init_pnp2110(void){ struct mtd_partition *parts; int nb_parts = 0; int parsed_nr_parts = 0; char *part_type = "static"; pnp2110_map.buswidth = (BOOT_DEF & 1) ? 2 : 4; /* Map flash chips */ pnp2110_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!pnp2110_map.virt) { printk("Failed to ioremap flash device\n"); return -ENOMEM; } pnp2110_map.cached = __ioremap(pnp2110_map.phys, WINDOW_SIZE, L_PTE_CACHEABLE, 1); if (!pnp2110_map.cached) printk(KERN_WARNING "Failed to ioremap cached %s\n", pnp2110_map.name); /* Use the default flash access functions */ simple_map_init(&pnp2110_map); /* MTD probing */ printk( "Probing PNP2110 flash at physical address 0x%08x (%d-bit buswidth)\n", WINDOW_ADDR, pnp2110_map.buswidth * 8 ); mymtd = do_map_probe("cfi_probe", &pnp2110_map); if (!mymtd) { iounmap((void *)pnp2110_map.virt); if (pnp2110_map.cached) iounmap(pnp2110_map.cached); return -EIO; } mymtd->owner = THIS_MODULE; /* Parse partitions */ if (parsed_nr_parts > 0) { parts = parsed_parts; nb_parts = parsed_nr_parts; } else { parts = pnp2110_partitions; nb_parts = NB_OF(pnp2110_partitions); } 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_pnp2110(void){ if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); if (parsed_parts) kfree(parsed_parts); } if (pnp2110_map.map_priv_1) iounmap((void *)pnp2110_map.map_priv_1); return;}module_init(init_pnp2110);module_exit(cleanup_pnp2110);MODULE_LICENSE("GPL");MODULE_AUTHOR("Marco Hasewinkel, SSV; Robert Schwebel, Pengutronix");MODULE_DESCRIPTION("MTD map driver for SSV PNP/2110");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -