2 * This file is part of the flashrom project.
4 * Copyright (C) 2007 Carl-Daniel Hailfinger
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
25 * EN29LV010 has 1C,6E and uses short F0 reset sequence
26 * EN29LV040(A) has 1C,4F and uses short F0 reset sequence
33 int probe_en29f512(struct flashchip *flash)
35 volatile uint8_t *bios = flash->virtual_memory;
38 writeb(0xAA, bios + 0x555);
39 writeb(0x55, bios + 0x2AA);
40 writeb(0x90, bios + 0x555);
44 id1 = readb(bios + 0x100);
45 id2 = readb(bios + 0x101);
47 /* exit by writing F0 anywhere? or the code below */
48 writeb(0xAA, bios + 0x555);
49 writeb(0x55, bios + 0x2AA);
50 writeb(0xF0, bios + 0x555);
52 printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2);
54 if (id1 == flash->manufacture_id && id2 == flash->model_id)
61 * EN29F002AT has 1C,92
62 * EN29F002AB has 1C,97
65 /* This does not seem to function properly for EN29F002NT. */
66 int probe_en29f002a(struct flashchip *flash)
68 volatile uint8_t *bios = flash->virtual_memory;
71 writeb(0xAA, bios + 0x555);
72 writeb(0x55, bios + 0xAAA);
73 writeb(0x90, bios + 0x555);
77 id1 = readb(bios + 0x100);
78 id2 = readb(bios + 0x101);
80 /* exit by writing F0 anywhere? or the code below */
81 writeb(0xAA, bios + 0x555);
82 writeb(0x55, bios + 0xAAA);
83 writeb(0xF0, bios + 0x555);
85 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
87 if (id1 == flash->manufacture_id && id2 == flash->model_id)
93 /* The EN29F002 chip needs repeated single byte writing, no block writing. */
94 int write_en29f002a(struct flashchip *flash, uint8_t *buf)
97 int total_size = flash->total_size * 1024;
98 volatile uint8_t *bios = flash->virtual_memory;
99 volatile uint8_t *dst = bios;
103 erase_chip_jedec(flash);
105 printf("Programming page: ");
106 for (i = 0; i < total_size; i++) {
107 /* write to the sector */
108 if ((i & 0xfff) == 0)
109 printf("address: 0x%08lx", (unsigned long)i);
110 writeb(0xAA, bios + 0x5555);
111 writeb(0x55, bios + 0x2AAA);
112 writeb(0xA0, bios + 0x5555);
113 writeb(*buf++, dst++);
115 /* wait for Toggle bit ready */
116 toggle_ready_jedec(dst);
118 if ((i & 0xfff) == 0)
119 printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");