Flashrom

Flashrom Svn Source Tree

Root/trunk/sst49lfxxxc.c

1/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2000 Silicon Integrated System Corporation
5 * Copyright (C) 2005-2007 coresystems GmbH
6 * Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "flash.h"
24#include "chipdrivers.h"
25
26static int write_lockbits_block_49lfxxxc(struct flashctx *flash,
27 unsigned long address,
28 unsigned char bits)
29{
30unsigned long lock = flash->virtual_registers + address + 2;
31msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n", lock,
32 chip_readb(flash, lock));
33chip_writeb(flash, bits, lock);
34
35return 0;
36}
37
38static int write_lockbits_49lfxxxc(struct flashctx *flash, unsigned char bits)
39{
40chipaddr registers = flash->virtual_registers;
41unsigned int i, left = flash->total_size * 1024;
42unsigned long address;
43
44msg_cdbg("\nbios=0x%08lx\n", registers);
45for (i = 0; left > 65536; i++, left -= 65536) {
46write_lockbits_block_49lfxxxc(flash, i * 65536, bits);
47}
48address = i * 65536;
49write_lockbits_block_49lfxxxc(flash, address, bits);
50address += 32768;
51write_lockbits_block_49lfxxxc(flash, address, bits);
52address += 8192;
53write_lockbits_block_49lfxxxc(flash, address, bits);
54address += 8192;
55write_lockbits_block_49lfxxxc(flash, address, bits);
56
57return 0;
58}
59
60int unlock_49lfxxxc(struct flashctx *flash)
61{
62return write_lockbits_49lfxxxc(flash, 0);
63}
64
65int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address,
66 unsigned int sector_size)
67{
68uint8_t status;
69chipaddr bios = flash->virtual_memory;
70
71chip_writeb(flash, 0x30, bios);
72chip_writeb(flash, 0xD0, bios + address);
73
74status = wait_82802ab(flash);
75print_status_82802ab(status);
76
77/* FIXME: Check the status register for errors. */
78return 0;
79}
80

Archive Download this file

Revision: HEAD