Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 2 | * $Id: beech-mtd.c,v 1.11 2005/11/07 11:14:26 gleixner Exp $ |
| 3 | * |
| 4 | * drivers/mtd/maps/beech-mtd.c MTD mappings and partition tables for |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * IBM 405LP Beech boards. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * |
| 21 | * Copyright (C) 2002, International Business Machines Corporation |
| 22 | * All Rights Reserved. |
| 23 | * |
| 24 | * Bishop Brock |
| 25 | * IBM Research, Austin Center for Low-Power Computing |
| 26 | * bcbrock@us.ibm.com |
| 27 | * March 2002 |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <linux/kernel.h> |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/types.h> |
| 34 | #include <linux/init.h> |
| 35 | |
| 36 | #include <linux/mtd/mtd.h> |
| 37 | #include <linux/mtd/map.h> |
| 38 | #include <linux/mtd/partitions.h> |
| 39 | |
| 40 | #include <asm/io.h> |
| 41 | #include <asm/ibm4xx.h> |
| 42 | |
| 43 | #define NAME "Beech Linux Flash" |
| 44 | #define PADDR BEECH_BIGFLASH_PADDR |
| 45 | #define SIZE BEECH_BIGFLASH_SIZE |
| 46 | #define BUSWIDTH 1 |
| 47 | |
| 48 | /* Flash memories on these boards are memory resources, accessed big-endian. */ |
| 49 | |
| 50 | |
| 51 | static struct map_info beech_mtd_map = { |
| 52 | .name = NAME, |
| 53 | .size = SIZE, |
| 54 | .bankwidth = BUSWIDTH, |
| 55 | .phys = PADDR |
| 56 | }; |
| 57 | |
| 58 | static struct mtd_info *beech_mtd; |
| 59 | |
| 60 | static struct mtd_partition beech_partitions[2] = { |
| 61 | { |
| 62 | .name = "Linux Kernel", |
| 63 | .size = BEECH_KERNEL_SIZE, |
| 64 | .offset = BEECH_KERNEL_OFFSET |
| 65 | }, { |
| 66 | .name = "Free Area", |
| 67 | .size = BEECH_FREE_AREA_SIZE, |
| 68 | .offset = BEECH_FREE_AREA_OFFSET |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | static int __init |
| 73 | init_beech_mtd(void) |
| 74 | { |
Amol Lad | 76a5027 | 2006-10-02 09:48:23 +0100 | [diff] [blame] | 75 | int err; |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); |
| 78 | |
| 79 | beech_mtd_map.virt = ioremap(PADDR, SIZE); |
| 80 | |
| 81 | if (!beech_mtd_map.virt) { |
| 82 | printk("%s: failed to ioremap 0x%x\n", NAME, PADDR); |
| 83 | return -EIO; |
| 84 | } |
| 85 | |
| 86 | simple_map_init(&beech_mtd_map); |
| 87 | |
| 88 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); |
| 89 | beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); |
| 90 | |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 91 | if (!beech_mtd) { |
Amol Lad | 76a5027 | 2006-10-02 09:48:23 +0100 | [diff] [blame] | 92 | iounmap(beech_mtd_map.virt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | return -ENXIO; |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 94 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | beech_mtd->owner = THIS_MODULE; |
| 97 | |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 98 | err = add_mtd_partitions(beech_mtd, beech_partitions, 2); |
| 99 | if (err) { |
| 100 | printk("%s: add_mtd_partitions failed\n", NAME); |
Amol Lad | 76a5027 | 2006-10-02 09:48:23 +0100 | [diff] [blame] | 101 | iounmap(beech_mtd_map.virt); |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void __exit |
| 108 | cleanup_beech_mtd(void) |
| 109 | { |
| 110 | if (beech_mtd) { |
| 111 | del_mtd_partitions(beech_mtd); |
| 112 | map_destroy(beech_mtd); |
| 113 | iounmap((void *) beech_mtd_map.virt); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | module_init(init_beech_mtd); |
| 118 | module_exit(cleanup_beech_mtd); |
| 119 | |
| 120 | MODULE_LICENSE("GPL"); |
| 121 | MODULE_AUTHOR("Bishop Brock <bcbrock@us.ibm.com>"); |
| 122 | MODULE_DESCRIPTION("MTD map and partitions for IBM 405LP Beech boards"); |