blob: dc4de1c3c541cebd2e632970e85876984c759c18 [file] [log] [blame]
Peter Stugecce26822008-07-21 17:48:40 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2008 Peter Stuge <peter@stuge.se>
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
Peter Stugecce26822008-07-21 17:48:40 +000021#include "flash.h"
Sean Nelson14ba6682010-02-26 05:48:29 +000022#include "chipdrivers.h"
Peter Stugecce26822008-07-21 17:48:40 +000023
Sean Nelson6e0b9122010-02-19 00:52:10 +000024int printlock_w39v040c(struct flashchip *flash)
25{
26 chipaddr bios = flash->virtual_memory;
27 uint8_t lock;
28
29 chip_writeb(0xAA, bios + 0x5555);
30 programmer_delay(10);
31 chip_writeb(0x55, bios + 0x2AAA);
32 programmer_delay(10);
33 chip_writeb(0x90, bios + 0x5555);
34 programmer_delay(10);
35
36 lock = chip_readb(bios + 0xfff2);
37
38 chip_writeb(0xAA, bios + 0x5555);
39 programmer_delay(10);
40 chip_writeb(0x55, bios + 0x2AAA);
41 programmer_delay(10);
42 chip_writeb(0xF0, bios + 0x5555);
43 programmer_delay(40);
44
Sean Nelsoned479d22010-03-24 23:14:32 +000045 msg_cdbg("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n",
Sean Nelson6e0b9122010-02-19 00:52:10 +000046 __func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un");
47 return 0;
48}