]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/mtd/chips/map_rom.c
[MTD] [LPDDR] qinfo_probe depends on lpddr
[mirror_ubuntu-artful-kernel.git] / drivers / mtd / chips / map_rom.c
CommitLineData
1da177e4
LT
1/*
2 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd.
1da177e4
LT
4 */
5
6#include <linux/module.h>
7#include <linux/types.h>
8#include <linux/kernel.h>
9#include <asm/io.h>
10#include <asm/byteorder.h>
11#include <linux/errno.h>
12#include <linux/slab.h>
13#include <linux/init.h>
14#include <linux/mtd/mtd.h>
15#include <linux/mtd/map.h>
16#include <linux/mtd/compatmac.h>
17
18static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
19static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
20static void maprom_nop (struct mtd_info *);
21static struct mtd_info *map_rom_probe(struct map_info *map);
22
23static struct mtd_chip_driver maprom_chipdrv = {
24 .probe = map_rom_probe,
25 .name = "map_rom",
26 .module = THIS_MODULE
27};
28
29static struct mtd_info *map_rom_probe(struct map_info *map)
30{
31 struct mtd_info *mtd;
32
95b93a0c 33 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
1da177e4
LT
34 if (!mtd)
35 return NULL;
36
1da177e4
LT
37 map->fldrv = &maprom_chipdrv;
38 mtd->priv = map;
39 mtd->name = map->name;
21c8db9e 40 mtd->type = MTD_ROM;
1da177e4
LT
41 mtd->size = map->size;
42 mtd->read = maprom_read;
43 mtd->write = maprom_write;
44 mtd->sync = maprom_nop;
45 mtd->flags = MTD_CAP_ROM;
e369d62e 46 mtd->erasesize = map->size;
17ffc7ba 47 mtd->writesize = 1;
1da177e4
LT
48
49 __module_get(THIS_MODULE);
50 return mtd;
51}
52
53
54static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
55{
56 struct map_info *map = mtd->priv;
57
58 map_copy_from(map, buf, from, len);
59 *retlen = len;
60 return 0;
61}
62
63static void maprom_nop(struct mtd_info *mtd)
64{
65 /* Nothing to see here */
66}
67
68static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
69{
70 printk(KERN_NOTICE "maprom_write called\n");
71 return -EIO;
72}
73
74static int __init map_rom_init(void)
75{
76 register_mtd_chip_driver(&maprom_chipdrv);
77 return 0;
78}
79
80static void __exit map_rom_exit(void)
81{
82 unregister_mtd_chip_driver(&maprom_chipdrv);
83}
84
85module_init(map_rom_init);
86module_exit(map_rom_exit);
87
88MODULE_LICENSE("GPL");
89MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
90MODULE_DESCRIPTION("MTD chip driver for ROM chips");