blob: a570bd6d1d950523168e48b92b45c8814cc2a939 [file] [log] [blame]
uwe2d828942007-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.
uwe2d828942007-08-30 10:17:50 +000015 */
16
stugee62e9fd2008-06-18 13:36:34 +000017#include <string.h>
uwe2d828942007-08-30 10:17:50 +000018#include "flash.h"
Edward O'Callaghan24fc8752019-09-09 00:56:44 +100019#include "chipdrivers.h"
uwe2d828942007-08-30 10:17:50 +000020
hailfingere51a2012011-07-26 14:18:52 +000021/* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A
22 * datasheets this is the only valid probe function for those chips.
23 */
Souvik Ghoshd75cd672016-06-17 14:21:39 -070024int probe_w29ee011(struct flashctx *flash)
uwe2d828942007-08-30 10:17:50 +000025{
hailfinger82719632009-05-16 21:22:56 +000026 chipaddr bios = flash->virtual_memory;
uwe2d828942007-08-30 10:17:50 +000027 uint8_t id1, id2;
stugee62e9fd2008-06-18 13:36:34 +000028
Patrick Georgif3fa2992017-02-02 16:24:44 +010029 if (!chip_to_probe || strcmp(chip_to_probe, flash->chip->name)) {
hailfingere51a2012011-07-26 14:18:52 +000030 msg_cdbg("Old Winbond W29* probe method disabled because "
31 "the probing sequence puts the AMIC A49LF040A in "
32 "a funky state. Use 'flashrom -c %s' if you "
Patrick Georgi860875a2017-02-03 18:44:55 +010033 "have a board with such a chip.\n", flash->chip->name);
stugee62e9fd2008-06-18 13:36:34 +000034 return 0;
35 }
uwe2d828942007-08-30 10:17:50 +000036
37 /* Issue JEDEC Product ID Entry command */
Souvik Ghoshd75cd672016-06-17 14:21:39 -070038 chip_writeb(flash, 0xAA, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000039 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070040 chip_writeb(flash, 0x55, bios + 0x2AAA);
hailfingere5829f62009-06-05 17:48:08 +000041 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070042 chip_writeb(flash, 0x80, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000043 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070044 chip_writeb(flash, 0xAA, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000045 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070046 chip_writeb(flash, 0x55, bios + 0x2AAA);
hailfingere5829f62009-06-05 17:48:08 +000047 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070048 chip_writeb(flash, 0x60, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000049 programmer_delay(10);
uwe2d828942007-08-30 10:17:50 +000050
51 /* Read product ID */
Souvik Ghoshd75cd672016-06-17 14:21:39 -070052 id1 = chip_readb(flash, bios);
53 id2 = chip_readb(flash, bios + 0x01);
uwe2d828942007-08-30 10:17:50 +000054
55 /* Issue JEDEC Product ID Exit command */
Souvik Ghoshd75cd672016-06-17 14:21:39 -070056 chip_writeb(flash, 0xAA, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000057 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070058 chip_writeb(flash, 0x55, bios + 0x2AAA);
hailfingere5829f62009-06-05 17:48:08 +000059 programmer_delay(10);
Souvik Ghoshd75cd672016-06-17 14:21:39 -070060 chip_writeb(flash, 0xF0, bios + 0x5555);
hailfingere5829f62009-06-05 17:48:08 +000061 programmer_delay(10);
uwe2d828942007-08-30 10:17:50 +000062
snelsonfc007bb2010-03-24 23:14:32 +000063 msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2);
uwe2d828942007-08-30 10:17:50 +000064
Patrick Georgif3fa2992017-02-02 16:24:44 +010065 if (id1 == flash->chip->manufacture_id && id2 == flash->chip->model_id)
uwe2d828942007-08-30 10:17:50 +000066 return 1;
67
68 return 0;
69}