blob: 8a62e4c71d5cc4704c7311e24c9bc7462a3311ab [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.
Markus Boasd2ac6fc2007-08-30 10:17:50 +000015 */
16
Jens Kuehnelb9f61742008-06-18 13:36:34 +000017#include <string.h>
Markus Boasd2ac6fc2007-08-30 10:17:50 +000018#include "flash.h"
19
Carl-Daniel Hailfinger2e88a9f2011-07-26 14:18:52 +000020/* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A
21 * datasheets this is the only valid probe function for those chips.
22 */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000023int probe_w29ee011(struct flashctx *flash)
Markus Boasd2ac6fc2007-08-30 10:17:50 +000024{
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000025 chipaddr bios = flash->virtual_memory;
Markus Boasd2ac6fc2007-08-30 10:17:50 +000026 uint8_t id1, id2;
Jens Kuehnelb9f61742008-06-18 13:36:34 +000027
Carl-Daniel Hailfinger5a7cb842012-08-25 01:17:58 +000028 if (!chip_to_probe || strcmp(chip_to_probe, flash->chip->name)) {
Carl-Daniel Hailfinger2e88a9f2011-07-26 14:18:52 +000029 msg_cdbg("Old Winbond W29* probe method disabled because "
30 "the probing sequence puts the AMIC A49LF040A in "
31 "a funky state. Use 'flashrom -c %s' if you "
Carl-Daniel Hailfinger5a7cb842012-08-25 01:17:58 +000032 "have a board with such a chip.\n", flash->chip->name);
Jens Kuehnelb9f61742008-06-18 13:36:34 +000033 return 0;
34 }
Markus Boasd2ac6fc2007-08-30 10:17:50 +000035
36 /* Issue JEDEC Product ID Entry command */
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000037 chip_writeb(flash, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000038 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000039 chip_writeb(flash, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000040 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000041 chip_writeb(flash, 0x80, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000042 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000043 chip_writeb(flash, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000044 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000045 chip_writeb(flash, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000046 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000047 chip_writeb(flash, 0x60, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000048 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000049
50 /* Read product ID */
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000051 id1 = chip_readb(flash, bios);
52 id2 = chip_readb(flash, bios + 0x01);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000053
54 /* Issue JEDEC Product ID Exit command */
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000055 chip_writeb(flash, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000056 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000057 chip_writeb(flash, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000058 programmer_delay(10);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000059 chip_writeb(flash, 0xF0, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000060 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000061
Sean Nelsoned479d22010-03-24 23:14:32 +000062 msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000063
Carl-Daniel Hailfinger5a7cb842012-08-25 01:17:58 +000064 if (id1 == flash->chip->manufacture_id && id2 == flash->chip->model_id)
Markus Boasd2ac6fc2007-08-30 10:17:50 +000065 return 1;
66
67 return 0;
68}