summaryrefslogtreecommitdiffstats
path: root/target/linux/adm5120-2.6/files/drivers/mtd/maps/adm5120_mtd.c
blob: a9e97cb318ea377f764d9018ad4298b684d827c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 *	Flash device on the ADM5120 board
 *
 *	Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2005
 *
 *	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/autoconf.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>

#define FLASH_PHYS_ADDR		0x1FC00000
#define FLASH_SIZE 		0x200000  

static struct mtd_info *adm5120_mtd;

static struct map_info adm5120_mtd_map = {
	.name = "ADM5120",
	.size = FLASH_SIZE,
	.bankwidth = 2,
	.phys = FLASH_PHYS_ADDR,
};

static int __init adm5120_mtd_init(void)
{
	printk(KERN_INFO "ADM5120 board flash (0x%x at 0x%x)\n", FLASH_SIZE,
	    FLASH_PHYS_ADDR);
	adm5120_mtd_map.virt = ioremap_nocache(FLASH_PHYS_ADDR, FLASH_SIZE);
	simple_map_init(&adm5120_mtd_map);
	adm5120_mtd = do_map_probe("cfi_probe", &adm5120_mtd_map);
	if (adm5120_mtd) {
		adm5120_mtd->owner = THIS_MODULE;
		add_mtd_device(adm5120_mtd);
		return 0;
	}
	return -ENXIO;
}

static void __exit adm5120_mtd_exit(void)
{
	del_mtd_device(adm5120_mtd);
	map_destroy(adm5120_mtd);
}

module_init(adm5120_mtd_init);
module_exit(adm5120_mtd_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)");
MODULE_DESCRIPTION("MTD map driver for ADM5120 boards");