2 * This file is part of the flashrom project.
4 * Copyright (C) 2004 Tyan Corporation
5 * Copyright (C) 2007 Nikolay Petukhov <nikolay.petukhov@gmail.com>
6 * Copyright (C) 2007 Reinder E.N. de Haan <lb_reha@mveas.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 extern int exclude_start_page, exclude_end_page;
28 void write_lockbits_49fl00x(volatile uint8_t *bios, int size,
29 unsigned char bits, int block_size)
33 for (i = 0; left >= block_size; i++, left -= block_size) {
36 if (block_size == 16384 && i%2)
39 *(bios + (i * block_size) + 2) = bits;
43 int probe_49fl00x(struct flashchip *flash)
45 int ret = probe_jedec(flash);
48 map_flash_registers(flash);
53 int erase_49fl00x(struct flashchip *flash)
56 int total_size = flash->total_size * 1024;
57 int page_size = flash->page_size;
58 volatile uint8_t *bios = flash->virtual_memory;
61 write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, page_size);
63 //erase_chip_jedec will not work ... datasheet says "Chip erase is available in A/A Mux Mode only"
64 printf("Erasing page: ");
65 for (i = 0; i < total_size / page_size; i++) {
66 if ((i >= exclude_start_page) && (i < exclude_end_page))
70 erase_block_jedec(bios, i * page_size);
71 printf("%04d at address: 0x%08x", i, i * page_size);
72 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");
78 write_lockbits_49fl00x(flash->virtual_registers, total_size, 1, page_size);
83 int write_49fl00x(struct flashchip *flash, uint8_t *buf)
86 int total_size = flash->total_size * 1024;
87 int page_size = flash->page_size;
88 volatile uint8_t *bios = flash->virtual_memory;
91 write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, page_size);
93 printf("Programming page: ");
94 for (i = 0; i < total_size / page_size; i++) {
95 if ((i >= exclude_start_page) && (i < exclude_end_page))
98 /* erase the page before programming */
99 erase_block_jedec(bios, i * page_size);
101 /* write to the sector */
102 printf("%04d at address: 0x%08x", i, i * page_size);
103 write_sector_jedec(bios, buf + i * page_size,
104 bios + i * page_size, page_size);
105 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");
111 write_lockbits_49fl00x(flash->virtual_registers, total_size, 1, page_size);