blob: 81dc2598bc0ac9085cadf7b332543e7752be5ade [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* netsc520.c -- MTD map driver for AMD NetSc520 Demonstration Board
2 *
3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
5 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 *
20 * The NetSc520 is a demonstration board for the Elan Sc520 processor available
21 * from AMD. It has a single back of 16 megs of 32-bit Flash ROM and another
22 * 16 megs of SDRAM.
23 */
24
25#include <linux/module.h>
26#include <linux/types.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <asm/io.h>
30#include <linux/mtd/mtd.h>
31#include <linux/mtd/map.h>
32#include <linux/mtd/partitions.h>
33
34
35/*
36** The single, 16 megabyte flash bank is divided into four virtual
37** partitions. The first partition is 768 KiB and is intended to
38** store the kernel image loaded by the bootstrap loader. The second
Thomas Gleixner69f34c92005-11-07 11:15:40 +000039** partition is 256 KiB and holds the BIOS image. The third
Linus Torvalds1da177e2005-04-16 15:20:36 -070040** partition is 14.5 MiB and is intended for the flash file system
41** image. The last partition is 512 KiB and contains another copy
42** of the BIOS image and the reset vector.
43**
44** Only the third partition should be mounted. The first partition
45** should not be mounted, but it can erased and written to using the
46** MTD character routines. The second and fourth partitions should
47** not be touched - it is possible to corrupt the BIOS image by
48** mounting these partitions, and potentially the board will not be
49** recoverable afterwards.
50*/
51
Thomas Gleixner69f34c92005-11-07 11:15:40 +000052/* partition_info gives details on the logical partitions that the split the
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 * single flash device into. If the size if zero we use up to the end of the
54 * device. */
55static struct mtd_partition partition_info[]={
Thomas Gleixner69f34c92005-11-07 11:15:40 +000056 {
57 .name = "NetSc520 boot kernel",
58 .offset = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 .size = 0xc0000
60 },
Thomas Gleixner69f34c92005-11-07 11:15:40 +000061 {
62 .name = "NetSc520 Low BIOS",
63 .offset = 0xc0000,
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 .size = 0x40000
65 },
Thomas Gleixner69f34c92005-11-07 11:15:40 +000066 {
67 .name = "NetSc520 file system",
68 .offset = 0x100000,
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 .size = 0xe80000
70 },
Thomas Gleixner69f34c92005-11-07 11:15:40 +000071 {
72 .name = "NetSc520 High BIOS",
73 .offset = 0xf80000,
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 .size = 0x80000
75 },
76};
Tobias Klauser87d10f32006-03-31 02:29:45 -080077#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79#define WINDOW_SIZE 0x00100000
80#define WINDOW_ADDR 0x00200000
81
82static struct map_info netsc520_map = {
83 .name = "netsc520 Flash Bank",
84 .size = WINDOW_SIZE,
85 .bankwidth = 4,
86 .phys = WINDOW_ADDR,
87};
88
Tobias Klauser87d10f32006-03-31 02:29:45 -080089#define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91static struct mtd_info *mymtd;
92
93static int __init init_netsc520(void)
94{
Andrew Morton3ce32f52007-02-17 16:02:07 -080095 printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx\n",
96 (unsigned long long)netsc520_map.size,
97 (unsigned long long)netsc520_map.phys);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
99
100 if (!netsc520_map.virt) {
101 printk("Failed to ioremap_nocache\n");
102 return -EIO;
103 }
104
105 simple_map_init(&netsc520_map);
106
107 mymtd = do_map_probe("cfi_probe", &netsc520_map);
108 if(!mymtd)
109 mymtd = do_map_probe("map_ram", &netsc520_map);
110 if(!mymtd)
111 mymtd = do_map_probe("map_rom", &netsc520_map);
112
113 if (!mymtd) {
114 iounmap(netsc520_map.virt);
115 return -ENXIO;
116 }
Thomas Gleixner69f34c92005-11-07 11:15:40 +0000117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 mymtd->owner = THIS_MODULE;
Jamie Ilesee0e87b2011-05-23 10:23:40 +0100119 mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 return 0;
121}
122
123static void __exit cleanup_netsc520(void)
124{
125 if (mymtd) {
Jamie Ilesee0e87b2011-05-23 10:23:40 +0100126 mtd_device_unregister(mymtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 map_destroy(mymtd);
128 }
129 if (netsc520_map.virt) {
130 iounmap(netsc520_map.virt);
131 netsc520_map.virt = NULL;
132 }
133}
134
135module_init(init_netsc520);
136module_exit(cleanup_netsc520);
137
138MODULE_LICENSE("GPL");
139MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
140MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");