Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Handle mapping of the flash on MBX860 boards |
| 3 | * |
| 4 | * Author: Anton Todorov |
| 5 | * Copyright: (C) 2001 Emness Technology |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <asm/io.h> |
| 18 | #include <linux/mtd/mtd.h> |
| 19 | #include <linux/mtd/map.h> |
| 20 | #include <linux/mtd/partitions.h> |
| 21 | |
| 22 | |
| 23 | #define WINDOW_ADDR 0xfe000000 |
| 24 | #define WINDOW_SIZE 0x00200000 |
| 25 | |
| 26 | /* Flash / Partition sizing */ |
| 27 | #define MAX_SIZE_KiB 8192 |
| 28 | #define BOOT_PARTITION_SIZE_KiB 512 |
| 29 | #define KERNEL_PARTITION_SIZE_KiB 5632 |
| 30 | #define APP_PARTITION_SIZE_KiB 2048 |
| 31 | |
| 32 | #define NUM_PARTITIONS 3 |
| 33 | |
| 34 | /* partition_info gives details on the logical partitions that the split the |
| 35 | * single flash device into. If the size if zero we use up to the end of the |
| 36 | * device. */ |
| 37 | static struct mtd_partition partition_info[]={ |
| 38 | { .name = "MBX flash BOOT partition", |
| 39 | .offset = 0, |
| 40 | .size = BOOT_PARTITION_SIZE_KiB*1024 }, |
| 41 | { .name = "MBX flash DATA partition", |
| 42 | .offset = BOOT_PARTITION_SIZE_KiB*1024, |
| 43 | .size = (KERNEL_PARTITION_SIZE_KiB)*1024 }, |
| 44 | { .name = "MBX flash APPLICATION partition", |
| 45 | .offset = (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 } |
| 46 | }; |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | static struct mtd_info *mymtd; |
| 50 | |
| 51 | struct map_info mbx_map = { |
| 52 | .name = "MBX flash", |
| 53 | .size = WINDOW_SIZE, |
| 54 | .phys = WINDOW_ADDR, |
| 55 | .bankwidth = 4, |
| 56 | }; |
| 57 | |
Dmitri Vorobiev | 9cdd52f | 2008-11-25 02:55:01 +0200 | [diff] [blame] | 58 | static int __init init_mbx(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | { |
| 60 | printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR); |
| 61 | mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); |
| 62 | |
| 63 | if (!mbx_map.virt) { |
| 64 | printk("Failed to ioremap\n"); |
| 65 | return -EIO; |
| 66 | } |
| 67 | simple_map_init(&mbx_map); |
| 68 | |
| 69 | mymtd = do_map_probe("jedec_probe", &mbx_map); |
| 70 | if (mymtd) { |
| 71 | mymtd->owner = THIS_MODULE; |
Jamie Iles | ee0e87b | 2011-05-23 10:23:40 +0100 | [diff] [blame] | 72 | mtd_device_register(mymtd, NULL, 0); |
| 73 | mtd_device_register(mymtd, partition_info, NUM_PARTITIONS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | iounmap((void *)mbx_map.virt); |
| 78 | return -ENXIO; |
| 79 | } |
| 80 | |
| 81 | static void __exit cleanup_mbx(void) |
| 82 | { |
| 83 | if (mymtd) { |
Jamie Iles | ee0e87b | 2011-05-23 10:23:40 +0100 | [diff] [blame] | 84 | mtd_device_unregister(mymtd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | map_destroy(mymtd); |
| 86 | } |
| 87 | if (mbx_map.virt) { |
| 88 | iounmap((void *)mbx_map.virt); |
| 89 | mbx_map.virt = 0; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | module_init(init_mbx); |
| 94 | module_exit(cleanup_mbx); |
| 95 | |
| 96 | MODULE_AUTHOR("Anton Todorov <a.todorov@emness.com>"); |
| 97 | MODULE_DESCRIPTION("MTD map driver for Motorola MBX860 board"); |
| 98 | MODULE_LICENSE("GPL"); |