23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/kernel.h>
27 #include <linux/slab.h>
35 #define FLASH_ADDR 0x40000000
36 #define FLASH_SIZE 0x00800000
37 #define FLASH_BANK_MAX 4
51 static unsigned long num_banks;
52 static void __iomem *start_scan_addr;
66 static unsigned long tqm8xxl_max_flash_size = 0x00800000;
104 .offset = 0x00200000,
110 static int __init init_tqm_mtd(
void)
113 unsigned long flash_addr, flash_size,
mtd_size = 0;
121 start_scan_addr =
ioremap(flash_addr, flash_size);
122 if (!start_scan_addr) {
128 if(mtd_size >= flash_size)
134 if(map_banks[idx] ==
NULL) {
142 if (!map_banks[idx]->
name) {
149 map_banks[
idx]->
size = flash_size;
154 map_banks[
idx]->
virt = start_scan_addr;
155 map_banks[
idx]->
phys = flash_addr;
164 if (idx && mtd_banks[idx-1]) {
172 if (mtd_banks[idx]) {
174 mtd_size += mtd_banks[
idx]->
size;
177 printk(
KERN_INFO "%s: bank%d, name:%s, size:%dbytes \n", __func__, num_banks,
178 mtd_banks[idx]->
name, mtd_banks[idx]->
size);
192 part_banks[0].mtd_part = tqm8xxl_partitions;
193 part_banks[0].type =
"Static image";
194 part_banks[0].nums =
ARRAY_SIZE(tqm8xxl_partitions);
196 part_banks[1].mtd_part = tqm8xxl_fs_partitions;
197 part_banks[1].type =
"Static file system";
198 part_banks[1].nums =
ARRAY_SIZE(tqm8xxl_fs_partitions);
200 for(idx = 0; idx < num_banks ; idx++) {
201 if (part_banks[idx].nums == 0)
202 printk(
KERN_NOTICE "TQM flash%d: no partition info available, registering whole flash at once\n", idx);
205 idx, part_banks[idx].
type);
207 part_banks[idx].nums);
212 if(map_banks[idx] !=
NULL) {
215 kfree(map_banks[idx]);
224 static void __exit cleanup_tqm_mtd(
void)
226 unsigned int idx = 0;
227 for(idx = 0 ; idx < num_banks ; idx++) {
229 if (mtd_banks[idx]) {
235 kfree(map_banks[idx]);
238 if (start_scan_addr) {