blob: a85f98ddc1acaa4dbd31d2234fc5b9fb4d89847a [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 *
4 * Copyright 2000 Silicon Integrated System Corporation
5 *
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
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000021#include <stdio.h>
Andrew Ipf0126ce2002-10-16 06:58:05 +000022#include "flash.h"
Andrew Ipf0126ce2002-10-16 06:58:05 +000023
Ollie Lho184a4042005-11-26 21:55:36 +000024int write_49f002(struct flashchip *flash, uint8_t *buf)
Andrew Ipf0126ce2002-10-16 06:58:05 +000025{
Ollie Lhocec28792004-03-17 23:03:37 +000026 int i;
Uwe Hermann0b7afe62007-04-01 19:44:21 +000027 int total_size = flash->total_size * 1024;
28 int page_size = flash->page_size;
Stefan Reinauerce532972007-05-23 17:20:56 +000029 volatile uint8_t *bios = flash->virtual_memory;
Andrew Ipf0126ce2002-10-16 06:58:05 +000030
Ollie Lho761bf1b2004-03-20 16:46:10 +000031 erase_chip_jedec(flash);
Andrew Ipf0126ce2002-10-16 06:58:05 +000032
Ollie Lho761bf1b2004-03-20 16:46:10 +000033 printf("Programming Page: ");
Ollie Lho8a10d5a2005-08-03 15:04:53 +000034 for (i = 0; i < total_size / page_size; i++) {
Ollie Lhocec28792004-03-17 23:03:37 +000035 /* write to the sector */
Ollie Lhoefa28582004-12-08 20:10:01 +000036 printf("%04d at address: 0x%08x ", i, i * page_size);
37 write_sector_jedec(bios, buf + i * page_size,
38 bios + i * page_size, page_size);
39 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");
40 fflush(stdout);
Ollie Lhocec28792004-03-17 23:03:37 +000041 }
42 printf("\n");
43
Uwe Hermannffec5f32007-08-23 16:08:21 +000044 return 0;
Andrew Ipf0126ce2002-10-16 06:58:05 +000045}