2 * This file is part of the flashrom project.
4 * Copyright (C) 2000 Silicon Integrated System Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 void protect_m29f400bt(volatile uint8_t *bios)
25 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
26 *(volatile uint8_t *)(bios + 0x555) = 0x55;
27 *(volatile uint8_t *)(bios + 0xAAA) = 0xA0;
32 void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src,
33 volatile uint8_t *dst, int page_size)
37 for (i = 0; i < page_size; i++) {
38 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
39 *(volatile uint8_t *)(bios + 0x555) = 0x55;
40 *(volatile uint8_t *)(bios + 0xAAA) = 0xA0;
42 /* transfer data from source to destination */
44 //*(volatile char *) (bios) = 0xF0;
46 toggle_ready_jedec(dst);
48 ("Value in the flash at address %p = %#x, want %#x\n",
49 (uint8_t *) (dst - bios), *dst, *src);
55 int probe_m29f400bt(struct flashchip *flash)
57 volatile uint8_t *bios = flash->virtual_memory;
60 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
61 *(volatile uint8_t *)(bios + 0x555) = 0x55;
62 *(volatile uint8_t *)(bios + 0xAAA) = 0x90;
66 id1 = *(volatile uint8_t *)bios;
67 /* The data sheet says id2 is at (bios + 0x01) and id2 listed in
68 * flash.h does not match. It should be possible to use JEDEC probe.
70 id2 = *(volatile uint8_t *)(bios + 0x02);
72 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
73 *(volatile uint8_t *)(bios + 0x555) = 0x55;
74 *(volatile uint8_t *)(bios + 0xAAA) = 0xF0;
78 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
80 if (id1 == flash->manufacture_id && id2 == flash->model_id)
86 int erase_m29f400bt(struct flashchip *flash)
88 volatile uint8_t *bios = flash->virtual_memory;
90 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
91 *(volatile uint8_t *)(bios + 0x555) = 0x55;
92 *(volatile uint8_t *)(bios + 0xAAA) = 0x80;
94 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
95 *(volatile uint8_t *)(bios + 0x555) = 0x55;
96 *(volatile uint8_t *)(bios + 0xAAA) = 0x10;
99 toggle_ready_jedec(bios);
104 int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst)
107 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
108 *(volatile uint8_t *)(bios + 0x555) = 0x55;
109 *(volatile uint8_t *)(bios + 0xAAA) = 0x80;
111 *(volatile uint8_t *)(bios + 0xAAA) = 0xAA;
112 *(volatile uint8_t *)(bios + 0x555) = 0x55;
113 //*(volatile uint8_t *) (bios + 0xAAA) = 0x10;
117 toggle_ready_jedec(bios);
122 int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
125 int total_size = flash->total_size * 1024;
126 int page_size = flash->page_size;
127 volatile uint8_t *bios = flash->virtual_memory;
129 //erase_m29f400bt (flash);
130 printf("Programming page:\n ");
131 /*********************************
132 *Pages for M29F400BT:
133 * 16 0x7c000 0x7ffff TOP
140 *---------------------------------
144 * 64 0x00000 0x0ffff BOTTOM
145 *********************************/
146 printf("total_size/page_size = %d\n", total_size / page_size);
147 for (i = 0; i < (total_size / page_size) - 1; i++) {
148 printf("%04d at address: 0x%08x\n", i, i * page_size);
149 block_erase_m29f400bt(bios, bios + i * page_size);
150 write_page_m29f400bt(bios, buf + i * page_size,
151 bios + i * page_size, page_size);
152 printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
155 printf("%04d at address: 0x%08x\n", 7, 0x70000);
156 block_erase_m29f400bt(bios, bios + 0x70000);
157 write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000, 32 * 1024);
159 printf("%04d at address: 0x%08x\n", 8, 0x78000);
160 block_erase_m29f400bt(bios, bios + 0x78000);
161 write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000, 8 * 1024);
163 printf("%04d at address: 0x%08x\n", 9, 0x7a000);
164 block_erase_m29f400bt(bios, bios + 0x7a000);
165 write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000, 8 * 1024);
167 printf("%04d at address: 0x%08x\n", 10, 0x7c000);
168 block_erase_m29f400bt(bios, bios + 0x7c000);
169 write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000, 16 * 1024);
172 //protect_m29f400bt (bios);
177 int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf)
179 volatile uint8_t *bios = flash->virtual_memory;
181 printf("Programming page:\n ");
182 /*********************************
183 *Pages for M29F400BT:
184 * 16 0x7c000 0x7ffff TOP
191 *---------------------------------
195 * 64 0x00000 0x0ffff BOTTOM
196 *********************************/
197 printf("%04d at address: 0x%08x\n", 7, 0x00000);
198 block_erase_m29f400bt(bios, bios + 0x00000);
199 write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000, 64 * 1024);
201 printf("%04d at address: 0x%08x\n", 7, 0x10000);
202 block_erase_m29f400bt(bios, bios + 0x10000);
203 write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000, 64 * 1024);
205 printf("%04d at address: 0x%08x\n", 7, 0x20000);
206 block_erase_m29f400bt(bios, bios + 0x20000);
207 write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000, 64 * 1024);
209 printf("%04d at address: 0x%08x\n", 7, 0x30000);
210 block_erase_m29f400bt(bios, bios + 0x30000);
211 write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000, 64 * 1024);
214 //protect_m29f400bt (bios);