5 #include <linux/module.h>
6 #include <linux/types.h>
7 #include <linux/kernel.h>
9 #include <linux/string.h>
17 #define MAX_NUM_REGIONS 4
18 #define MAX_NUM_PARTITIONS 8
20 #define DEF_WINDOW_ADDR_PHY 0x00000000
21 #define DEF_WINDOW_SIZE 0x00800000 // 8 Mega Bytes
23 #define MTD_FORTUNET_PK "MTD FortuNet: "
25 #define MAX_NAME_SIZE 128
49 static char *
__init get_string_option(
char *
dest,
int dest_size,
char *sor)
103 get_options (get_string_option(
string,
sizeof(
string),line),6,params);
107 " name,region-number[,base,size,bankwidth,altbankwidth]\n");
116 memset(&map_regions[params[1]],0,
sizeof(map_regions[params[1]]));
118 &default_map,
sizeof(map_regions[params[1]].map_info));
119 map_regions_set[params[1]] = 1;
121 map_regions[params[1]].altbankwidth = 2;
122 map_regions[params[1]].mymtd =
NULL;
123 map_regions[params[1]].map_info.name = map_regions[params[1]].map_name;
124 strcpy(map_regions[params[1]].map_info.name,
string);
127 map_regions[params[1]].window_addr_physical = params[2];
131 map_regions[params[1]].map_info.size = params[3];
135 map_regions[params[1]].map_info.bankwidth = params[4];
139 map_regions[params[1]].altbankwidth = params[5];
144 static int __init MTD_New_Partition(
char *line)
148 get_options (get_string_option(
string,
sizeof(
string),line),4,params);
152 " name,region-number,size,offset\n");
166 map_regions[params[1]].parts[map_regions_parts[params[1]]].name =
167 map_regions[params[1]]. parts_name[map_regions_parts[params[1]]];
168 strcpy(map_regions[params[1]].parts[map_regions_parts[params[1]]].
name,
string);
169 map_regions[params[1]].parts[map_regions_parts[params[1]]].size =
171 map_regions[params[1]].parts[map_regions_parts[params[1]]].offset =
173 map_regions[params[1]].parts[map_regions_parts[params[1]]].mask_flags = 0;
174 map_regions_parts[params[1]]++;
178 __setup(
"MTD_Region=", MTD_New_Region);
179 __setup(
"MTD_Partition=", MTD_New_Partition);
182 __setup(
"MTD_Partion=", MTD_New_Partition);
184 static int __init init_fortunet(
void)
189 if(map_regions_parts[ix]&&(!map_regions_set[ix]))
193 memset(&map_regions[ix],0,
sizeof(map_regions[ix]));
194 memcpy(&map_regions[ix].map_info,&default_map,
195 sizeof(map_regions[ix].map_info));
196 map_regions_set[ix] = 1;
198 map_regions[ix].altbankwidth = 2;
199 map_regions[ix].mymtd =
NULL;
200 map_regions[ix].map_info.name = map_regions[ix].map_name;
201 strcpy(map_regions[ix].map_info.name,
"FORTUNET");
203 if(map_regions_set[ix])
207 " address %x size %x\n",
208 map_regions[ix].map_info.name,
209 map_regions[ix].window_addr_physical,
210 map_regions[ix].map_info.size);
212 map_regions[ix].map_info.phys = map_regions[ix].window_addr_physical,
214 map_regions[ix].map_info.virt =
216 map_regions[ix].window_addr_physical,
217 map_regions[ix].map_info.size);
218 if(!map_regions[ix].map_info.virt)
222 map_regions[ix].map_info.name);
223 for (j = 0 ; j < ix; j++)
224 iounmap(map_regions[j].map_info.virt);
230 map_regions[ix].map_info.name,
231 map_regions[ix].map_info.virt);
233 &map_regions[ix].map_info);
234 if((!map_regions[ix].mymtd)&&(
235 map_regions[ix].altbankwidth!=map_regions[ix].map_info.bankwidth))
239 map_regions[ix].map_info.name);
240 map_regions[ix].map_info.bankwidth =
241 map_regions[ix].altbankwidth;
243 &map_regions[ix].map_info);
247 map_regions[ix].parts,
248 map_regions_parts[ix]);
256 static void __exit cleanup_fortunet(
void)
261 if(map_regions_set[ix])
263 if( map_regions[ix].mymtd )
268 iounmap((
void *)map_regions[ix].map_info.virt);