Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sharpsl-flash.c |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Copyright (C) 2001 Lineo Japan, Inc. |
| 5 | * Copyright (C) 2002 SHARP |
| 6 | * |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 7 | * $Id: sharpsl-flash.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * based on rpxlite.c,v 1.15 2001/10/02 15:05:14 dwmw2 Exp |
| 10 | * Handle mapping of the flash on the RPX Lite and CLLF boards |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/types.h> |
| 26 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/mtd/mtd.h> |
| 28 | #include <linux/mtd/map.h> |
| 29 | #include <linux/mtd/partitions.h> |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 30 | #include <asm/io.h> |
| 31 | #include <asm/mach-types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | #define WINDOW_ADDR 0x00000000 |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 34 | #define WINDOW_SIZE 0x00800000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define BANK_WIDTH 2 |
| 36 | |
| 37 | static struct mtd_info *mymtd; |
| 38 | |
| 39 | struct map_info sharpsl_map = { |
| 40 | .name = "sharpsl-flash", |
| 41 | .size = WINDOW_SIZE, |
| 42 | .bankwidth = BANK_WIDTH, |
| 43 | .phys = WINDOW_ADDR |
| 44 | }; |
| 45 | |
| 46 | static struct mtd_partition sharpsl_partitions[1] = { |
| 47 | { |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 48 | name: "Boot PROM Filesystem", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | } |
| 50 | }; |
| 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int __init init_sharpsl(void) |
| 53 | { |
| 54 | struct mtd_partition *parts; |
| 55 | int nb_parts = 0; |
| 56 | char *part_type = "static"; |
| 57 | |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 58 | printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n", |
Richard Purdie | 8f5a448 | 2005-03-21 08:42:14 +0000 | [diff] [blame] | 59 | WINDOW_SIZE, WINDOW_ADDR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); |
| 61 | if (!sharpsl_map.virt) { |
| 62 | printk("Failed to ioremap\n"); |
| 63 | return -EIO; |
| 64 | } |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 65 | |
| 66 | simple_map_init(&sharpsl_map); |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | mymtd = do_map_probe("map_rom", &sharpsl_map); |
| 69 | if (!mymtd) { |
| 70 | iounmap(sharpsl_map.virt); |
| 71 | return -ENXIO; |
| 72 | } |
| 73 | |
| 74 | mymtd->owner = THIS_MODULE; |
| 75 | |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 76 | if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky() |
Richard Purdie | 8f5a448 | 2005-03-21 08:42:14 +0000 | [diff] [blame] | 77 | || machine_is_poodle()) { |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 78 | sharpsl_partitions[0].size=0x006d0000; |
| 79 | sharpsl_partitions[0].offset=0x00120000; |
| 80 | } else if (machine_is_tosa()) { |
| 81 | sharpsl_partitions[0].size=0x006a0000; |
| 82 | sharpsl_partitions[0].offset=0x00160000; |
Richard Purdie | 62052d4 | 2005-09-16 19:27:31 -0700 | [diff] [blame] | 83 | } else if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) { |
Richard Purdie | ba38069 | 2005-03-21 00:10:24 +0000 | [diff] [blame] | 84 | sharpsl_partitions[0].size=0x006b0000; |
| 85 | sharpsl_partitions[0].offset=0x00140000; |
Richard Purdie | 8f5a448 | 2005-03-21 08:42:14 +0000 | [diff] [blame] | 86 | } else { |
| 87 | map_destroy(mymtd); |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 88 | iounmap(sharpsl_map.virt); |
Richard Purdie | 8f5a448 | 2005-03-21 08:42:14 +0000 | [diff] [blame] | 89 | return -ENODEV; |
| 90 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | parts = sharpsl_partitions; |
Tobias Klauser | 87d10f3 | 2006-03-31 02:29:45 -0800 | [diff] [blame] | 93 | nb_parts = ARRAY_SIZE(sharpsl_partitions); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | printk(KERN_NOTICE "Using %s partision definition\n", part_type); |
| 96 | add_mtd_partitions(mymtd, parts, nb_parts); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | static void __exit cleanup_sharpsl(void) |
| 102 | { |
| 103 | if (mymtd) { |
| 104 | del_mtd_partitions(mymtd); |
| 105 | map_destroy(mymtd); |
| 106 | } |
| 107 | if (sharpsl_map.virt) { |
| 108 | iounmap(sharpsl_map.virt); |
| 109 | sharpsl_map.virt = 0; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | module_init(init_sharpsl); |
| 114 | module_exit(cleanup_sharpsl); |
| 115 | |
| 116 | MODULE_LICENSE("GPL"); |
| 117 | MODULE_AUTHOR("SHARP (Original: Arnold Christensen <AKC@pel.dk>)"); |
| 118 | MODULE_DESCRIPTION("MTD map driver for SHARP SL series"); |