blob: 6b88a1cc5348a290552831d64b2404322c7f2b7a [file] [log] [blame]
Markus Boasd2ac6fc2007-08-30 10:17:50 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2007 Markus Boas <ryven@ryven.de>
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
Jens Kuehnelb9f61742008-06-18 13:36:34 +000021#include <string.h>
Markus Boasd2ac6fc2007-08-30 10:17:50 +000022#include "flash.h"
Sean Nelson14ba6682010-02-26 05:48:29 +000023#include "chipdrivers.h"
Markus Boasd2ac6fc2007-08-30 10:17:50 +000024
25int probe_w29ee011(struct flashchip *flash)
26{
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000027 chipaddr bios = flash->virtual_memory;
Markus Boasd2ac6fc2007-08-30 10:17:50 +000028 uint8_t id1, id2;
Jens Kuehnelb9f61742008-06-18 13:36:34 +000029 extern char *chip_to_probe;
30
Uwe Hermann394131e2008-10-18 21:14:13 +000031 if (!chip_to_probe || strcmp(chip_to_probe, "W29EE011")) {
Sean Nelsoned479d22010-03-24 23:14:32 +000032 msg_cdbg("Probing disabled for Winbond W29EE011 because "
Carl-Daniel Hailfinger414bd322009-07-23 01:33:43 +000033 "the probing sequence puts the AMIC A49LF040A in "
34 "a funky state. Use 'flashrom -c W29EE011' if you "
35 "have a board with this chip.\n");
Jens Kuehnelb9f61742008-06-18 13:36:34 +000036 return 0;
37 }
Markus Boasd2ac6fc2007-08-30 10:17:50 +000038
39 /* Issue JEDEC Product ID Entry command */
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000040 chip_writeb(0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000041 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000042 chip_writeb(0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000043 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000044 chip_writeb(0x80, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000045 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000046 chip_writeb(0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000047 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000048 chip_writeb(0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000049 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000050 chip_writeb(0x60, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000051 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000052
53 /* Read product ID */
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000054 id1 = chip_readb(bios);
55 id2 = chip_readb(bios + 0x01);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000056
57 /* Issue JEDEC Product ID Exit command */
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000058 chip_writeb(0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000059 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000060 chip_writeb(0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000061 programmer_delay(10);
Carl-Daniel Hailfinger0472f3d2009-03-06 22:26:00 +000062 chip_writeb(0xF0, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000063 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000064
Sean Nelsoned479d22010-03-24 23:14:32 +000065 msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000066
67 if (id1 == flash->manufacture_id && id2 == flash->model_id)
68 return 1;
69
70 return 0;
71}