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 | |
| 21 | #include "flash.h" |
| 22 | |
| 23 | int probe_w29ee011(struct flashchip *flash) |
| 24 | { |
| 25 | volatile uint8_t *bios = flash->virtual_memory; |
| 26 | uint8_t id1, id2; |
| 27 | |
| 28 | /* Issue JEDEC Product ID Entry command */ |
| 29 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 30 | myusec_delay(10); |
| 31 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 32 | myusec_delay(10); |
| 33 | *(volatile uint8_t *)(bios + 0x5555) = 0x80; |
| 34 | myusec_delay(10); |
| 35 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 36 | myusec_delay(10); |
| 37 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 38 | myusec_delay(10); |
| 39 | *(volatile uint8_t *)(bios + 0x5555) = 0x60; |
| 40 | myusec_delay(10); |
| 41 | |
| 42 | /* Read product ID */ |
| 43 | id1 = *(volatile uint8_t *)bios; |
| 44 | id2 = *(volatile uint8_t *)(bios + 0x01); |
| 45 | |
| 46 | /* Issue JEDEC Product ID Exit command */ |
| 47 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 48 | myusec_delay(10); |
| 49 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 50 | myusec_delay(10); |
| 51 | *(volatile uint8_t *)(bios + 0x5555) = 0xF0; |
| 52 | myusec_delay(10); |
| 53 | |
| 54 | printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); |
| 55 | |
| 56 | if (id1 == flash->manufacture_id && id2 == flash->model_id) |
| 57 | return 1; |
| 58 | |
| 59 | return 0; |
| 60 | } |