blob: 87ce0009a1627565187826b5569155857ae3ae69 [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
Carl-Daniel Hailfinger30f7cb22009-06-15 17:23:36 +000030 if (erase_chip_jedec(flash)) {
31 fprintf(stderr, "ERASE FAILED!\n");
32 return -1;
33 }
Andrew Ipf0126ce2002-10-16 06:58:05 +000034
Uwe Hermanna502dce2007-10-17 23:55:15 +000035 printf("Programming page: ");
Ollie Lho8a10d5a2005-08-03 15:04:53 +000036 for (i = 0; i < total_size / page_size; i++) {
Ollie Lhoefa28582004-12-08 20:10:01 +000037 printf("%04d at address: 0x%08x ", i, i * page_size);
Uwe Hermann24f9fbe2009-05-12 14:06:04 +000038 /* Byte-wise writing of 'page_size' bytes. */
Sean Nelsonc57a9202010-01-04 17:15:23 +000039 write_sector_jedec_common(flash, buf + i * page_size,
40 bios + i * page_size, page_size, 0xffff);
Ollie Lhoefa28582004-12-08 20:10:01 +000041 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");
42 fflush(stdout);
Ollie Lhocec28792004-03-17 23:03:37 +000043 }
44 printf("\n");
45
Uwe Hermannffec5f32007-08-23 16:08:21 +000046 return 0;
Andrew Ipf0126ce2002-10-16 06:58:05 +000047}