blob: e2b4f9b09bb4b1eb8c7dbea41df189ca2365f9fe [file] [log] [blame]
Carl-Daniel Hailfingerae8afa92007-12-31 01:49:00 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2007 Carl-Daniel Hailfinger
5 *
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.
10 *
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.
15 *
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
19 */
20
21/*
22 EN29F512 has 1C,21
23 EN29F010 has 1C,20
24 EN29F040A has 1C,04
25 EN29LV010 has 1C,6E and uses short F0 reset sequence
26 EN29LV040(A) has 1C,4F and uses short F0 reset sequence
27 */
28int probe_en29f512(struct flashchip *flash)
29{
30 volatile uint8_t *bios = flash->virtual_memory;
31 uint8_t id1, id2;
32
33 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
34 *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
35 *(volatile uint8_t *)(bios + 0x555) = 0x90;
36
37 myusec_delay(10);
38
39 id1 = *(volatile uint8_t *)(bios + 0x100);
40 id2 = *(volatile uint8_t *)(bios + 0x101);
41
42 /* exit by writing F0 anywhere? or the code below */
43 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
44 *(volatile uint8_t *)(bios + 0x2AA) = 0x55;
45 *(volatile uint8_t *)(bios + 0x555) = 0xF0;
46
47 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
48
49 if (id1 == flash->manufacture_id && id2 == flash->model_id)
50 return 1;
51
52 return 0;
53}
54
55/*
56 EN29F002AT has 1C,92
57 EN29F002AB has 1C,97
58 */
59int probe_en29f002a(struct flashchip *flash)
60{
61 volatile uint8_t *bios = flash->virtual_memory;
62 uint8_t id1, id2;
63
64 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
65 *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
66 *(volatile uint8_t *)(bios + 0x555) = 0x90;
67
68 myusec_delay(10);
69
70 id1 = *(volatile uint8_t *)(bios + 0x100);
71 id2 = *(volatile uint8_t *)(bios + 0x101);
72
73 /* exit by writing F0 anywhere? or the code below */
74 *(volatile uint8_t *)(bios + 0x555) = 0xAA;
75 *(volatile uint8_t *)(bios + 0xAAA) = 0x55;
76 *(volatile uint8_t *)(bios + 0x555) = 0xF0;
77
78 printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
79
80 if (id1 == flash->manufacture_id && id2 == flash->model_id)
81 return 1;
82
83 return 0;
84}
85