Blame view

drivers/mtd/maps/netsc520.c 4.1 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
  /* netsc520.c -- MTD map driver for AMD NetSc520 Demonstration Board
   *
   * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
   *	based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
   *
   * The NetSc520 is a demonstration board for the Elan Sc520 processor available
   * from AMD.  It has a single back of 16 megs of 32-bit Flash ROM and another
   * 16 megs of SDRAM.
   */
  
  #include <linux/module.h>
  #include <linux/types.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <asm/io.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/map.h>
  #include <linux/mtd/partitions.h>
  
  
  /*
  ** The single, 16 megabyte flash bank is divided into four virtual
  ** partitions.  The first partition is 768 KiB and is intended to
  ** store the kernel image loaded by the bootstrap loader.  The second
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
39
  ** partition is 256 KiB and holds the BIOS image.  The third
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
45
46
47
48
49
50
  ** partition is 14.5 MiB and is intended for the flash file system
  ** image.  The last partition is 512 KiB and contains another copy
  ** of the BIOS image and the reset vector.
  **
  ** Only the third partition should be mounted.  The first partition
  ** should not be mounted, but it can erased and written to using the
  ** MTD character routines.  The second and fourth partitions should
  ** not be touched - it is possible to corrupt the BIOS image by
  ** mounting these partitions, and potentially the board will not be
  ** recoverable afterwards.
  */
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
51
  /* partition_info gives details on the logical partitions that the split the
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
53
54
   * single flash device into. If the size if zero we use up to the end of the
   * device. */
  static struct mtd_partition partition_info[]={
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
55
56
57
      {
  	    .name = "NetSc520 boot kernel",
  	    .offset = 0,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
  	    .size = 0xc0000
      },
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
60
61
62
      {
  	    .name = "NetSc520 Low BIOS",
  	    .offset = 0xc0000,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
64
  	    .size = 0x40000
      },
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
65
66
67
      {
  	    .name = "NetSc520 file system",
  	    .offset = 0x100000,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
  	    .size = 0xe80000
      },
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
70
71
72
      {
  	    .name = "NetSc520 High BIOS",
  	    .offset = 0xf80000,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
73
74
75
  	    .size = 0x80000
      },
  };
87d10f3c7   Tobias Klauser   [PATCH] drivers/m...
76
  #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
81
82
83
84
85
86
  
  #define WINDOW_SIZE	0x00100000
  #define WINDOW_ADDR	0x00200000
  
  static struct map_info netsc520_map = {
  	.name = "netsc520 Flash Bank",
  	.size = WINDOW_SIZE,
  	.bankwidth = 4,
  	.phys = WINDOW_ADDR,
  };
87d10f3c7   Tobias Klauser   [PATCH] drivers/m...
87
  #define NUM_FLASH_BANKS	ARRAY_SIZE(netsc520_map)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
89
90
91
92
  
  static struct mtd_info *mymtd;
  
  static int __init init_netsc520(void)
  {
3ce32f5d1   Andrew Morton   [MTD] [MAPS] nets...
93
94
95
96
  	printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx
  ",
  			(unsigned long long)netsc520_map.size,
  			(unsigned long long)netsc520_map.phys);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  	netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
  
  	if (!netsc520_map.virt) {
  		printk("Failed to ioremap_nocache
  ");
  		return -EIO;
  	}
  
  	simple_map_init(&netsc520_map);
  
  	mymtd = do_map_probe("cfi_probe", &netsc520_map);
  	if(!mymtd)
  		mymtd = do_map_probe("map_ram", &netsc520_map);
  	if(!mymtd)
  		mymtd = do_map_probe("map_rom", &netsc520_map);
  
  	if (!mymtd) {
  		iounmap(netsc520_map.virt);
  		return -ENXIO;
  	}
69f34c98c   Thomas Gleixner   [MTD] maps: Clean...
117

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
  	mymtd->owner = THIS_MODULE;
ee0e87b17   Jamie Iles   mtd: convert rema...
119
  	mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
122
123
124
125
  	return 0;
  }
  
  static void __exit cleanup_netsc520(void)
  {
  	if (mymtd) {
ee0e87b17   Jamie Iles   mtd: convert rema...
126
  		mtd_device_unregister(mymtd);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  		map_destroy(mymtd);
  	}
  	if (netsc520_map.virt) {
  		iounmap(netsc520_map.virt);
  		netsc520_map.virt = NULL;
  	}
  }
  
  module_init(init_netsc520);
  module_exit(cleanup_netsc520);
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
  MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");