+
+static void flash_switch_bank(unsigned long addr)
+{
+ unsigned long val;
+
+ /* Set GPIO as output */
+ val = *GPIO_IO | (1 << (FLASH_A20_GPIO+16));
+ if ( addr & FLASH_BOUNDARY ) {
+ val |= 1 << (FLASH_A20_GPIO + 24);
+ } else {
+ val &= ~(1 << (FLASH_A20_GPIO + 24));
+ }
+ *GPIO_IO = val;
+}
+
+static map_word adm5120_map_read(struct map_info *map, unsigned long ofs)
+{
+ flash_switch_bank(ofs);
+ return inline_map_read(map, ofs);
+}
+
+static void adm5120_map_write(struct map_info *map, const map_word datum, unsigned long ofs)
+{
+ flash_switch_bank(ofs);
+ inline_map_write(map, datum, ofs);
+}
+
+static void adm5120_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+ ssize_t tmp;
+
+ if (from < FLASH_BOUNDARY) {
+ tmp = (len < (FLASH_BOUNDARY - from)) ? len : (FLASH_BOUNDARY - from);
+ flash_switch_bank(0);
+ inline_map_copy_from(map, to, from, tmp);
+ to = (void *)((char *)to + tmp);
+ from += tmp;
+ len -= tmp;
+ }
+ if (len > 0) {
+ flash_switch_bank(FLASH_BOUNDARY);
+ inline_map_copy_from(map, to, from, len);
+ }
+
+}
+