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