| 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. |
|---|
| 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 | #include <string.h> |
|---|
| 22 | #include "flash.h" |
|---|
| 23 | |
|---|
| 24 | /* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A |
|---|
| 25 | * datasheets this is the only valid probe function for those chips. |
|---|
| 26 | */ |
|---|
| 27 | int probe_w29ee011(struct flashctx *flash) |
|---|
| 28 | { |
|---|
| 29 | chipaddr bios = flash->virtual_memory; |
|---|
| 30 | uint8_t id1, id2; |
|---|
| 31 | |
|---|
| 32 | if (!chip_to_probe || strcmp(chip_to_probe, flash->chip->name)) { |
|---|
| 33 | msg_cdbg("Old Winbond W29* probe method disabled because " |
|---|
| 34 | "the probing sequence puts the AMIC A49LF040A in " |
|---|
| 35 | "a funky state. Use 'flashrom -c %s' if you " |
|---|
| 36 | "have a board with such a chip.\n", flash->chip->name); |
|---|
| 37 | return 0; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | /* Issue JEDEC Product ID Entry command */ |
|---|
| 41 | chip_writeb(flash, 0xAA, bios + 0x5555); |
|---|
| 42 | programmer_delay(10); |
|---|
| 43 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
|---|
| 44 | programmer_delay(10); |
|---|
| 45 | chip_writeb(flash, 0x80, bios + 0x5555); |
|---|
| 46 | programmer_delay(10); |
|---|
| 47 | chip_writeb(flash, 0xAA, bios + 0x5555); |
|---|
| 48 | programmer_delay(10); |
|---|
| 49 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
|---|
| 50 | programmer_delay(10); |
|---|
| 51 | chip_writeb(flash, 0x60, bios + 0x5555); |
|---|
| 52 | programmer_delay(10); |
|---|
| 53 | |
|---|
| 54 | /* Read product ID */ |
|---|
| 55 | id1 = chip_readb(flash, bios); |
|---|
| 56 | id2 = chip_readb(flash, bios + 0x01); |
|---|
| 57 | |
|---|
| 58 | /* Issue JEDEC Product ID Exit command */ |
|---|
| 59 | chip_writeb(flash, 0xAA, bios + 0x5555); |
|---|
| 60 | programmer_delay(10); |
|---|
| 61 | chip_writeb(flash, 0x55, bios + 0x2AAA); |
|---|
| 62 | programmer_delay(10); |
|---|
| 63 | chip_writeb(flash, 0xF0, bios + 0x5555); |
|---|
| 64 | programmer_delay(10); |
|---|
| 65 | |
|---|
| 66 | msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2); |
|---|
| 67 | |
|---|
| 68 | if (id1 == flash->chip->manufacture_id && id2 == flash->chip->model_id) |
|---|
| 69 | return 1; |
|---|
| 70 | |
|---|
| 71 | return 0; |
|---|
| 72 | } |
|---|