Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 1 | /* |
| 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 Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Jens Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 17 | #include <string.h> |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 18 | #include "flash.h" |
| 19 | |
Carl-Daniel Hailfinger | 2e88a9f | 2011-07-26 14:18:52 +0000 | [diff] [blame] | 20 | /* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A |
| 21 | * datasheets this is the only valid probe function for those chips. |
| 22 | */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 23 | int probe_w29ee011(struct flashctx *flash) |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 24 | { |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 25 | chipaddr bios = flash->virtual_memory; |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 26 | uint8_t id1, id2; |
Jens Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 27 | |
Carl-Daniel Hailfinger | 5a7cb84 | 2012-08-25 01:17:58 +0000 | [diff] [blame] | 28 | if (!chip_to_probe || strcmp(chip_to_probe, flash->chip->name)) { |
Carl-Daniel Hailfinger | 2e88a9f | 2011-07-26 14:18:52 +0000 | [diff] [blame] | 29 | 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 Hailfinger | 5a7cb84 | 2012-08-25 01:17:58 +0000 | [diff] [blame] | 32 | "have a board with such a chip.\n", flash->chip->name); |
Jens Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 33 | return 0; |
| 34 | } |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 35 | |
| 36 | /* Issue JEDEC Product ID Entry command */ |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 37 | chip_writeb(flash, 0xAA, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 38 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 39 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 40 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 41 | chip_writeb(flash, 0x80, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 42 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 43 | chip_writeb(flash, 0xAA, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 44 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 45 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 46 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 47 | chip_writeb(flash, 0x60, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 48 | programmer_delay(10); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 49 | |
| 50 | /* Read product ID */ |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 51 | id1 = chip_readb(flash, bios); |
| 52 | id2 = chip_readb(flash, bios + 0x01); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 53 | |
| 54 | /* Issue JEDEC Product ID Exit command */ |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 55 | chip_writeb(flash, 0xAA, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 56 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 57 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 58 | programmer_delay(10); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 59 | chip_writeb(flash, 0xF0, bios + 0x5555); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 60 | programmer_delay(10); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 61 | |
Sean Nelson | ed479d2 | 2010-03-24 23:14:32 +0000 | [diff] [blame] | 62 | msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 63 | |
Carl-Daniel Hailfinger | 5a7cb84 | 2012-08-25 01:17:58 +0000 | [diff] [blame] | 64 | if (id1 == flash->chip->manufacture_id && id2 == flash->chip->model_id) |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 65 | return 1; |
| 66 | |
| 67 | return 0; |
| 68 | } |