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. |
| 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 Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 21 | #include <string.h> |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 22 | #include "flash.h" |
| 23 | |
| 24 | int probe_w29ee011(struct flashchip *flash) |
| 25 | { |
| 26 | volatile uint8_t *bios = flash->virtual_memory; |
| 27 | uint8_t id1, id2; |
Jens Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 28 | extern char *chip_to_probe; |
| 29 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 30 | if (!chip_to_probe || strcmp(chip_to_probe, "W29EE011")) { |
Jens Kuehnel | b9f6174 | 2008-06-18 13:36:34 +0000 | [diff] [blame] | 31 | printf_debug("\n===\n"); |
| 32 | printf_debug(" Probing disabled for Winbond W29EE011 because the probing sequence puts the\n"); |
| 33 | printf_debug(" AMIC A49LF040A in a funky state.\n"); |
| 34 | printf_debug(" Use 'flashrom -c W29EE011' if you have a board with this chip."); |
| 35 | printf_debug("\n===\n"); |
| 36 | return 0; |
| 37 | } |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 38 | |
| 39 | /* Issue JEDEC Product ID Entry command */ |
| 40 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 41 | myusec_delay(10); |
| 42 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 43 | myusec_delay(10); |
| 44 | *(volatile uint8_t *)(bios + 0x5555) = 0x80; |
| 45 | myusec_delay(10); |
| 46 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 47 | myusec_delay(10); |
| 48 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 49 | myusec_delay(10); |
| 50 | *(volatile uint8_t *)(bios + 0x5555) = 0x60; |
| 51 | myusec_delay(10); |
| 52 | |
| 53 | /* Read product ID */ |
| 54 | id1 = *(volatile uint8_t *)bios; |
| 55 | id2 = *(volatile uint8_t *)(bios + 0x01); |
| 56 | |
| 57 | /* Issue JEDEC Product ID Exit command */ |
| 58 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 59 | myusec_delay(10); |
| 60 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 61 | myusec_delay(10); |
| 62 | *(volatile uint8_t *)(bios + 0x5555) = 0xF0; |
| 63 | myusec_delay(10); |
| 64 | |
Peter Stuge | 5cafc33 | 2009-01-25 23:52:45 +0000 | [diff] [blame] | 65 | printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __FUNCTION__, id1, id2); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 66 | |
| 67 | if (id1 == flash->manufacture_id && id2 == flash->model_id) |
| 68 | return 1; |
| 69 | |
| 70 | return 0; |
| 71 | } |