blob: 1c4177a0867a20e199a5956bf8305cdb53e5cbc4 [file] [log] [blame]
Andrew Ipf0126ce2002-10-16 06:58:05 +00001/*
Uwe Hermannd1107642007-08-29 17:52:32 +00002 * This file is part of the flashrom project.
Andrew Ipf0126ce2002-10-16 06:58:05 +00003 *
Uwe Hermannd22a1d42007-09-09 20:21:05 +00004 * Copyright (C) 2000 Silicon Integrated System Corporation
Andrew Ipf0126ce2002-10-16 06:58:05 +00005 *
Uwe Hermannd1107642007-08-29 17:52:32 +00006 * 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.
Andrew Ipf0126ce2002-10-16 06:58:05 +000010 *
Uwe Hermannd1107642007-08-29 17:52:32 +000011 * 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.
Andrew Ipf0126ce2002-10-16 06:58:05 +000015 *
Uwe Hermannd1107642007-08-29 17:52:32 +000016 * 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
Andrew Ipf0126ce2002-10-16 06:58:05 +000019 */
20
21#include "flash.h"
Andrew Ipf0126ce2002-10-16 06:58:05 +000022
Ollie Lho184a4042005-11-26 21:55:36 +000023int write_49f002(struct flashchip *flash, uint8_t *buf)
Andrew Ipf0126ce2002-10-16 06:58:05 +000024{
Ollie Lhocec28792004-03-17 23:03:37 +000025 int i;
Uwe Hermann0b7afe62007-04-01 19:44:21 +000026 int total_size = flash->total_size * 1024;
27 int page_size = flash->page_size;
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000028 chipaddr bios = flash->virtual_memory;
Andrew Ipf0126ce2002-10-16 06:58:05 +000029
Ollie Lho761bf1b2004-03-20 16:46:10 +000030 erase_chip_jedec(flash);
Andrew Ipf0126ce2002-10-16 06:58:05 +000031
Uwe Hermanna502dce2007-10-17 23:55:15 +000032 printf("Programming page: ");
Ollie Lho8a10d5a2005-08-03 15:04:53 +000033 for (i = 0; i < total_size / page_size; i++) {
Ollie Lhoefa28582004-12-08 20:10:01 +000034 printf("%04d at address: 0x%08x ", i, i * page_size);
Uwe Hermann24f9fbe2009-05-12 14:06:04 +000035 /* Byte-wise writing of 'page_size' bytes. */
Ollie Lhoefa28582004-12-08 20:10:01 +000036 write_sector_jedec(bios, buf + i * page_size,
37 bios + i * page_size, page_size);
38 printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
39 fflush(stdout);
Ollie Lhocec28792004-03-17 23:03:37 +000040 }
41 printf("\n");
42
Uwe Hermannffec5f32007-08-23 16:08:21 +000043 return 0;
Andrew Ipf0126ce2002-10-16 06:58:05 +000044}