]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4 LT |
2 | /* netsc520.c -- MTD map driver for AMD NetSc520 Demonstration Board |
3 | * | |
4 | * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com) | |
5 | * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH | |
6 | * | |
1da177e4 LT |
7 | * The NetSc520 is a demonstration board for the Elan Sc520 processor available |
8 | * from AMD. It has a single back of 16 megs of 32-bit Flash ROM and another | |
9 | * 16 megs of SDRAM. | |
10 | */ | |
11 | ||
12 | #include <linux/module.h> | |
13 | #include <linux/types.h> | |
14 | #include <linux/kernel.h> | |
15 | #include <linux/init.h> | |
16 | #include <asm/io.h> | |
17 | #include <linux/mtd/mtd.h> | |
18 | #include <linux/mtd/map.h> | |
19 | #include <linux/mtd/partitions.h> | |
20 | ||
21 | ||
22 | /* | |
23 | ** The single, 16 megabyte flash bank is divided into four virtual | |
24 | ** partitions. The first partition is 768 KiB and is intended to | |
25 | ** store the kernel image loaded by the bootstrap loader. The second | |
69f34c98 | 26 | ** partition is 256 KiB and holds the BIOS image. The third |
1da177e4 LT |
27 | ** partition is 14.5 MiB and is intended for the flash file system |
28 | ** image. The last partition is 512 KiB and contains another copy | |
29 | ** of the BIOS image and the reset vector. | |
30 | ** | |
31 | ** Only the third partition should be mounted. The first partition | |
32 | ** should not be mounted, but it can erased and written to using the | |
33 | ** MTD character routines. The second and fourth partitions should | |
34 | ** not be touched - it is possible to corrupt the BIOS image by | |
35 | ** mounting these partitions, and potentially the board will not be | |
36 | ** recoverable afterwards. | |
37 | */ | |
38 | ||
69f34c98 | 39 | /* partition_info gives details on the logical partitions that the split the |
1da177e4 LT |
40 | * single flash device into. If the size if zero we use up to the end of the |
41 | * device. */ | |
d4906688 | 42 | static const struct mtd_partition partition_info[] = { |
69f34c98 TG |
43 | { |
44 | .name = "NetSc520 boot kernel", | |
45 | .offset = 0, | |
1da177e4 LT |
46 | .size = 0xc0000 |
47 | }, | |
69f34c98 TG |
48 | { |
49 | .name = "NetSc520 Low BIOS", | |
50 | .offset = 0xc0000, | |
1da177e4 LT |
51 | .size = 0x40000 |
52 | }, | |
69f34c98 TG |
53 | { |
54 | .name = "NetSc520 file system", | |
55 | .offset = 0x100000, | |
1da177e4 LT |
56 | .size = 0xe80000 |
57 | }, | |
69f34c98 TG |
58 | { |
59 | .name = "NetSc520 High BIOS", | |
60 | .offset = 0xf80000, | |
1da177e4 LT |
61 | .size = 0x80000 |
62 | }, | |
63 | }; | |
87d10f3c | 64 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
1da177e4 LT |
65 | |
66 | #define WINDOW_SIZE 0x00100000 | |
67 | #define WINDOW_ADDR 0x00200000 | |
68 | ||
69 | static struct map_info netsc520_map = { | |
70 | .name = "netsc520 Flash Bank", | |
71 | .size = WINDOW_SIZE, | |
72 | .bankwidth = 4, | |
73 | .phys = WINDOW_ADDR, | |
74 | }; | |
75 | ||
87d10f3c | 76 | #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map) |
1da177e4 LT |
77 | |
78 | static struct mtd_info *mymtd; | |
79 | ||
80 | static int __init init_netsc520(void) | |
81 | { | |
3ce32f5d AM |
82 | printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx\n", |
83 | (unsigned long long)netsc520_map.size, | |
84 | (unsigned long long)netsc520_map.phys); | |
1da177e4 LT |
85 | netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size); |
86 | ||
87 | if (!netsc520_map.virt) { | |
88 | printk("Failed to ioremap_nocache\n"); | |
89 | return -EIO; | |
90 | } | |
91 | ||
92 | simple_map_init(&netsc520_map); | |
93 | ||
94 | mymtd = do_map_probe("cfi_probe", &netsc520_map); | |
95 | if(!mymtd) | |
96 | mymtd = do_map_probe("map_ram", &netsc520_map); | |
97 | if(!mymtd) | |
98 | mymtd = do_map_probe("map_rom", &netsc520_map); | |
99 | ||
100 | if (!mymtd) { | |
101 | iounmap(netsc520_map.virt); | |
102 | return -ENXIO; | |
103 | } | |
69f34c98 | 104 | |
1da177e4 | 105 | mymtd->owner = THIS_MODULE; |
ee0e87b1 | 106 | mtd_device_register(mymtd, partition_info, NUM_PARTITIONS); |
1da177e4 LT |
107 | return 0; |
108 | } | |
109 | ||
110 | static void __exit cleanup_netsc520(void) | |
111 | { | |
112 | if (mymtd) { | |
ee0e87b1 | 113 | mtd_device_unregister(mymtd); |
1da177e4 LT |
114 | map_destroy(mymtd); |
115 | } | |
116 | if (netsc520_map.virt) { | |
117 | iounmap(netsc520_map.virt); | |
118 | netsc520_map.virt = NULL; | |
119 | } | |
120 | } | |
121 | ||
122 | module_init(init_netsc520); | |
123 | module_exit(cleanup_netsc520); | |
124 | ||
125 | MODULE_LICENSE("GPL"); | |
126 | MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>"); | |
127 | MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board"); |