blob: 3144ebd395a2cc64548a5464a7c57f8e12a4ecd1 [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
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
Uwe Hermanna502dce2007-10-17 23:55:15 +000033 printf("Programming page: ");
Ollie Lho8a10d5a2005-08-03 15:04:53 +000034 for (i = 0; i < total_size / page_size; i++) {
Ollie Lhoefa28582004-12-08 20:10:01 +000035 printf("%04d at address: 0x%08x ", i, i * page_size);
Uwe Hermann24f9fbe2009-05-12 14:06:04 +000036 /* Byte-wise writing of 'page_size' bytes. */
Ollie Lhoefa28582004-12-08 20:10:01 +000037 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}