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 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
39 *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
40 *(volatile uint8_t *)(bios + 0x555) = 0x90;
44 id1 = *(volatile uint8_t *)(bios + 0x100);
45 id2 = *(volatile uint8_t *)(bios + 0x101);
47 /* exit by writing F0 anywhere? or the code below */
48 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
49 *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
50 *(volatile uint8_t *)(bios + 0x555) = 0xF0;
52 printf_debug("%s: id1 0x%x, id2 0x%x\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 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
72 *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
73 *(volatile uint8_t *)(bios + 0x555) = 0x90;
77 id1 = *(volatile uint8_t *)(bios + 0x100);
78 id2 = *(volatile uint8_t *)(bios + 0x101);
80 /* exit by writing F0 anywhere? or the code below */
81 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
82 *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
83 *(volatile uint8_t *)(bios + 0x555) = 0xF0;
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 *(bios + 0x5555) = 0xAA;
111 *(bios + 0x2AAA) = 0x55;
112 *(bios + 0x5555) = 0xA0;
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");