blob: 999f4bb3d845ce475322c88db98f774036dbcbfb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sharpsl-flash.c
Thomas Gleixner69f34c92005-11-07 11:15:40 +00003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Copyright (C) 2001 Lineo Japan, Inc.
5 * Copyright (C) 2002 SHARP
6 *
Thomas Gleixner69f34c92005-11-07 11:15:40 +00007 * $Id: sharpsl-flash.c,v 1.7 2005/11/07 11:14:28 gleixner Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
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 Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/mtd/mtd.h>
28#include <linux/mtd/map.h>
29#include <linux/mtd/partitions.h>
Richard Purdieba380692005-03-21 00:10:24 +000030#include <asm/io.h>
31#include <asm/mach-types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#define WINDOW_ADDR 0x00000000
Richard Purdieba380692005-03-21 00:10:24 +000034#define WINDOW_SIZE 0x00800000
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#define BANK_WIDTH 2
36
37static struct mtd_info *mymtd;
38
39struct map_info sharpsl_map = {
40 .name = "sharpsl-flash",
41 .size = WINDOW_SIZE,
42 .bankwidth = BANK_WIDTH,
43 .phys = WINDOW_ADDR
44};
45
46static struct mtd_partition sharpsl_partitions[1] = {
47 {
Richard Purdieba380692005-03-21 00:10:24 +000048 name: "Boot PROM Filesystem",
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 }
50};
51
52#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
53
54int __init init_sharpsl(void)
55{
56 struct mtd_partition *parts;
57 int nb_parts = 0;
58 char *part_type = "static";
59
Thomas Gleixner69f34c92005-11-07 11:15:40 +000060 printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n",
Richard Purdie8f5a4482005-03-21 08:42:14 +000061 WINDOW_SIZE, WINDOW_ADDR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
63 if (!sharpsl_map.virt) {
64 printk("Failed to ioremap\n");
65 return -EIO;
66 }
Richard Purdieba380692005-03-21 00:10:24 +000067
68 simple_map_init(&sharpsl_map);
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 mymtd = do_map_probe("map_rom", &sharpsl_map);
71 if (!mymtd) {
72 iounmap(sharpsl_map.virt);
73 return -ENXIO;
74 }
75
76 mymtd->owner = THIS_MODULE;
77
Thomas Gleixner69f34c92005-11-07 11:15:40 +000078 if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky()
Richard Purdie8f5a4482005-03-21 08:42:14 +000079 || machine_is_poodle()) {
Richard Purdieba380692005-03-21 00:10:24 +000080 sharpsl_partitions[0].size=0x006d0000;
81 sharpsl_partitions[0].offset=0x00120000;
82 } else if (machine_is_tosa()) {
83 sharpsl_partitions[0].size=0x006a0000;
84 sharpsl_partitions[0].offset=0x00160000;
Richard Purdie62052d42005-09-16 19:27:31 -070085 } else if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) {
Richard Purdieba380692005-03-21 00:10:24 +000086 sharpsl_partitions[0].size=0x006b0000;
87 sharpsl_partitions[0].offset=0x00140000;
Richard Purdie8f5a4482005-03-21 08:42:14 +000088 } else {
89 map_destroy(mymtd);
Thomas Gleixner69f34c92005-11-07 11:15:40 +000090 iounmap(sharpsl_map.virt);
Richard Purdie8f5a4482005-03-21 08:42:14 +000091 return -ENODEV;
92 }
Thomas Gleixner69f34c92005-11-07 11:15:40 +000093
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 parts = sharpsl_partitions;
95 nb_parts = NB_OF(sharpsl_partitions);
96
97 printk(KERN_NOTICE "Using %s partision definition\n", part_type);
98 add_mtd_partitions(mymtd, parts, nb_parts);
99
100 return 0;
101}
102
103static void __exit cleanup_sharpsl(void)
104{
105 if (mymtd) {
106 del_mtd_partitions(mymtd);
107 map_destroy(mymtd);
108 }
109 if (sharpsl_map.virt) {
110 iounmap(sharpsl_map.virt);
111 sharpsl_map.virt = 0;
112 }
113}
114
115module_init(init_sharpsl);
116module_exit(cleanup_sharpsl);
117
118MODULE_LICENSE("GPL");
119MODULE_AUTHOR("SHARP (Original: Arnold Christensen <AKC@pel.dk>)");
120MODULE_DESCRIPTION("MTD map driver for SHARP SL series");