blob: 0342e98a8f4d2fef8f9f5c2d94f8938cc7ac7637 [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
Nico Huber2cadbe32026-03-05 18:34:57 +010017#include <stdint.h>
18
19#include "programmer.h"
Nico Huber10337f72026-03-04 19:57:27 +010020#include "chipdrivers/memory_bus.h"
Markus Boasd2ac6fc2007-08-30 10:17:50 +000021
Carl-Daniel Hailfinger2e88a9f2011-07-26 14:18:52 +000022/* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A
23 * datasheets this is the only valid probe function for those chips.
24 */
Nico Huber2cadbe32026-03-05 18:34:57 +010025struct found_id *probe_w29ee011(const struct bus_probe *probe,
26 const struct master_common *mst,
27 const struct flashchip *chip)
Markus Boasd2ac6fc2007-08-30 10:17:50 +000028{
Nico Huber2cadbe32026-03-05 18:34:57 +010029 const struct par_master *const par = (const struct par_master *)mst;
30 const chipsize_t chip_size = chip ? chip->total_size * KiB : 128*KiB;
31 uint8_t raw[2];
Jens Kuehnelb9f61742008-06-18 13:36:34 +000032
Nico Huber2cadbe32026-03-05 18:34:57 +010033 const chipaddr bios = (chipaddr)programmer_map_flash_data(par, chip_size, "");
34 if (bios == (chipaddr)ERROR_PTR)
35 return NULL;
Markus Boasd2ac6fc2007-08-30 10:17:50 +000036
37 /* Issue JEDEC Product ID Entry command */
Nico Huber2cadbe32026-03-05 18:34:57 +010038 par->chip_writeb(par, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000039 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010040 par->chip_writeb(par, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000041 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010042 par->chip_writeb(par, 0x80, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000043 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010044 par->chip_writeb(par, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000045 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010046 par->chip_writeb(par, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000047 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010048 par->chip_writeb(par, 0x60, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000049 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000050
51 /* Read product ID */
Nico Huber2cadbe32026-03-05 18:34:57 +010052 raw[0] = par->chip_readb(par, bios);
53 raw[1] = par->chip_readb(par, bios + 0x01);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000054
55 /* Issue JEDEC Product ID Exit command */
Nico Huber2cadbe32026-03-05 18:34:57 +010056 par->chip_writeb(par, 0xAA, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000057 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010058 par->chip_writeb(par, 0x55, bios + 0x2AAA);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000059 programmer_delay(10);
Nico Huber2cadbe32026-03-05 18:34:57 +010060 par->chip_writeb(par, 0xF0, bios + 0x5555);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +000061 programmer_delay(10);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000062
Nico Huber2cadbe32026-03-05 18:34:57 +010063 programmer_unmap_flash_region(par, (void *)bios, chip_size);
Markus Boasd2ac6fc2007-08-30 10:17:50 +000064
Nico Huber2cadbe32026-03-05 18:34:57 +010065 if (flashprog_no_data(raw, sizeof(raw)))
66 return NULL;
Markus Boasd2ac6fc2007-08-30 10:17:50 +000067
Nico Huber2cadbe32026-03-05 18:34:57 +010068 msg_cdbg("%s (%uKiB): id1 0x%02x, id2 0x%02x\n",
69 __func__, chip_size / KiB, raw[0], raw[1]);
70
71 struct memory_found_id *const found = alloc_memory_found_id();
72 if (!found) {
73 msg_cerr("Out of memory!\n");
74 return NULL;
75 }
76
77 found->generic.info.id.manufacture = raw[0];
78 found->generic.info.id.model = raw[1];
79 found->generic.info.id.type = ID_W29EE011;
80 found->memory_info.chip_size = chip_size;
81 found->memory_info.chip_features = 0;
82
83 return &found->generic;
Markus Boasd2ac6fc2007-08-30 10:17:50 +000084}