sst39sf020.c 1.45 KB
Newer Older
Ronald G. Minnich's avatar
Ronald G. Minnich committed
1
/*
2
 * This file is part of the flashrom project.
Ronald G. Minnich's avatar
Ronald G. Minnich committed
3
 *
4
 * Copyright (C) 2000 Silicon Integrated System Corporation
Ronald G. Minnich's avatar
Ronald G. Minnich committed
5
 *
6 7 8 9
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
Ronald G. Minnich's avatar
Ronald G. Minnich committed
10
 *
11 12 13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
15
 *
16 17 18
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
Ronald G. Minnich's avatar
Ronald G. Minnich committed
19 20
 */

Ronald G. Minnich's avatar
Ronald G. Minnich committed
21
#include <stdio.h>
22
#include <stdint.h>
Ronald G. Minnich's avatar
Ronald G. Minnich committed
23 24
#include "flash.h"

25
int write_39sf020(struct flashchip *flash, uint8_t *buf)
Ronald G. Minnich's avatar
Ronald G. Minnich committed
26 27
{
	int i;
Uwe Hermann's avatar
Uwe Hermann committed
28 29
	int total_size = flash->total_size * 1024;
	int page_size = flash->page_size;
30
	volatile uint8_t *bios = flash->virtual_memory;
Ronald G. Minnich's avatar
Ronald G. Minnich committed
31

32
	erase_chip_jedec(flash);
33

34
	printf("Programming page: ");
35
	for (i = 0; i < total_size / page_size; i++) {
Ronald G. Minnich's avatar
Ronald G. Minnich committed
36
		/* write to the sector */
37 38 39
		printf("%04d at address: 0x%08x", i, i * page_size);
		write_sector_jedec(bios, buf + i * page_size,
				   bios + i * page_size, page_size);
40
		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");
41
		fflush(stdout);
Ronald G. Minnich's avatar
Ronald G. Minnich committed
42 43 44
	}
	printf("\n");

Uwe Hermann's avatar
Uwe Hermann committed
45
	return 0;
Ronald G. Minnich's avatar
Ronald G. Minnich committed
46
}