mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 07:23:43 +02:00
Generify jedec functions by introducing an address mask
The patch converts jedec functions into mask-based generics which can be used for many chip provided the only changes are the addresses are converted from 0x5555/0x2AAA to 0x555/0x2AA or similar. The patch mostly changes jedec.c, but a few other files are changed because they use the jedec functions within their own functions. The patch also adds a copyright line to flashchips.c because of my recent work in converting AMD and Atmel chips to use struct erase_block. Corresponding to flashrom svn r828. Signed-off-by: Sean Nelson <audiohacked@gmail.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
parent
009c51b062
commit
c57a920f34
@ -76,7 +76,6 @@ int write_en29f002a(struct flashchip *flash, uint8_t *buf);
|
|||||||
uint8_t oddparity(uint8_t val);
|
uint8_t oddparity(uint8_t val);
|
||||||
void toggle_ready_jedec(chipaddr dst);
|
void toggle_ready_jedec(chipaddr dst);
|
||||||
void data_polling_jedec(chipaddr dst, uint8_t data);
|
void data_polling_jedec(chipaddr dst, uint8_t data);
|
||||||
void start_program_jedec(chipaddr bios);
|
|
||||||
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
|
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
|
||||||
chipaddr dst);
|
chipaddr dst);
|
||||||
int probe_jedec(struct flashchip *flash);
|
int probe_jedec(struct flashchip *flash);
|
||||||
@ -86,8 +85,7 @@ int write_jedec_1(struct flashchip *flash, uint8_t *buf);
|
|||||||
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
|
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
|
||||||
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
|
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
|
||||||
int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
|
int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
|
||||||
int write_sector_jedec(chipaddr bios, uint8_t *src,
|
int write_sector_jedec_common(struct flashchip *flash, uint8_t *src, chipaddr dst, unsigned int page_size, unsigned int mask);
|
||||||
chipaddr dst, unsigned int page_size);
|
|
||||||
|
|
||||||
/* m29f002.c */
|
/* m29f002.c */
|
||||||
int erase_m29f002(struct flashchip *flash);
|
int erase_m29f002(struct flashchip *flash);
|
||||||
|
4
flash.h
4
flash.h
@ -144,6 +144,9 @@ enum chipbustype {
|
|||||||
*/
|
*/
|
||||||
#define NUM_ERASEFUNCTIONS 5
|
#define NUM_ERASEFUNCTIONS 5
|
||||||
|
|
||||||
|
#define FEATURE_REGISTERMAP (1 << 0)
|
||||||
|
#define FEATURE_BYTEWRITES (1 << 1)
|
||||||
|
|
||||||
struct flashchip {
|
struct flashchip {
|
||||||
const char *vendor;
|
const char *vendor;
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -160,6 +163,7 @@ struct flashchip {
|
|||||||
|
|
||||||
int total_size;
|
int total_size;
|
||||||
int page_size;
|
int page_size;
|
||||||
|
int feature_bits;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicate if flashrom has been tested with this flash chip and if
|
* Indicate if flashrom has been tested with this flash chip and if
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
* Copyright (C) 2004 Tyan Corp
|
* Copyright (C) 2004 Tyan Corp
|
||||||
* Copyright (C) 2005-2008 coresystems GmbH <stepan@openbios.org>
|
* Copyright (C) 2005-2008 coresystems GmbH <stepan@openbios.org>
|
||||||
* Copyright (C) 2006-2009 Carl-Daniel Hailfinger
|
* Copyright (C) 2006-2009 Carl-Daniel Hailfinger
|
||||||
|
* Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
223
jedec.c
223
jedec.c
@ -5,6 +5,7 @@
|
|||||||
* Copyright (C) 2006 Giampiero Giancipoli <gianci@email.it>
|
* Copyright (C) 2006 Giampiero Giancipoli <gianci@email.it>
|
||||||
* Copyright (C) 2006 coresystems GmbH <info@coresystems.de>
|
* Copyright (C) 2006 coresystems GmbH <info@coresystems.de>
|
||||||
* Copyright (C) 2007 Carl-Daniel Hailfinger
|
* Copyright (C) 2007 Carl-Daniel Hailfinger
|
||||||
|
* Copyright (C) 2009 Sean Nelson <audiohacked@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -24,6 +25,8 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
#define MAX_REFLASH_TRIES 0x10
|
#define MAX_REFLASH_TRIES 0x10
|
||||||
|
#define MASK_FULL 0xffff
|
||||||
|
#define MASK_2AA 0x7ff
|
||||||
|
|
||||||
/* Check one byte for odd parity */
|
/* Check one byte for odd parity */
|
||||||
uint8_t oddparity(uint8_t val)
|
uint8_t oddparity(uint8_t val)
|
||||||
@ -87,14 +90,16 @@ void data_polling_jedec(chipaddr dst, uint8_t data)
|
|||||||
printf_debug("%s: excessive loops, i=0x%x\n", __func__, i);
|
printf_debug("%s: excessive loops, i=0x%x\n", __func__, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_program_jedec(chipaddr bios)
|
void start_program_jedec_common(struct flashchip *flash, unsigned int mask)
|
||||||
{
|
{
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chipaddr bios = flash->virtual_memory;
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
chip_writeb(0xA0, bios + 0x5555);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
|
chip_writeb(0xA0, bios + (0x5555 & mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
int probe_jedec(struct flashchip *flash)
|
int probe_jedec_common(struct flashchip *flash,
|
||||||
|
unsigned int mask, int long_reset)
|
||||||
{
|
{
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
uint8_t id1, id2;
|
uint8_t id1, id2;
|
||||||
@ -118,13 +123,13 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Issue JEDEC Product ID Entry command */
|
/* Issue JEDEC Product ID Entry command */
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
if (probe_timing_enter)
|
if (probe_timing_enter)
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
if (probe_timing_enter)
|
if (probe_timing_enter)
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x90, bios + 0x5555);
|
chip_writeb(0x90, bios + (0x5555 & mask));
|
||||||
if (probe_timing_enter)
|
if (probe_timing_enter)
|
||||||
programmer_delay(probe_timing_enter);
|
programmer_delay(probe_timing_enter);
|
||||||
|
|
||||||
@ -147,13 +152,16 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Issue JEDEC Product ID Exit command */
|
/* Issue JEDEC Product ID Exit command */
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
if (long_reset)
|
||||||
|
{
|
||||||
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
if (probe_timing_exit)
|
if (probe_timing_exit)
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
if (probe_timing_exit)
|
if (probe_timing_exit)
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0xF0, bios + 0x5555);
|
}
|
||||||
|
chip_writeb(0xF0, bios + (0x5555 & mask));
|
||||||
if (probe_timing_exit)
|
if (probe_timing_exit)
|
||||||
programmer_delay(probe_timing_exit);
|
programmer_delay(probe_timing_exit);
|
||||||
|
|
||||||
@ -184,24 +192,28 @@ int probe_jedec(struct flashchip *flash)
|
|||||||
if (largeid1 == flash->manufacture_id && largeid2 == flash->model_id)
|
if (largeid1 == flash->manufacture_id && largeid2 == flash->model_id)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (flash->feature_bits & FEATURE_REGISTERMAP)
|
||||||
|
map_flash_registers(flash);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize)
|
int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
|
||||||
|
unsigned int pagesize, unsigned int mask)
|
||||||
{
|
{
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
|
||||||
/* Issue the Sector Erase command */
|
/* Issue the Sector Erase command */
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x80, bios + 0x5555);
|
chip_writeb(0x80, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
|
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x30, bios + page);
|
chip_writeb(0x30, bios + page);
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
@ -216,21 +228,22 @@ int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int erase_block_jedec(struct flashchip *flash, unsigned int block, unsigned int blocksize)
|
int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
|
||||||
|
unsigned int blocksize, unsigned int mask)
|
||||||
{
|
{
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
|
||||||
/* Issue the Sector Erase command */
|
/* Issue the Sector Erase command */
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x80, bios + 0x5555);
|
chip_writeb(0x80, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
|
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x50, bios + block);
|
chip_writeb(0x50, bios + block);
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
@ -245,35 +258,24 @@ int erase_block_jedec(struct flashchip *flash, unsigned int block, unsigned int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* erase chip with block_erase() prototype */
|
int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
|
||||||
int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr, unsigned int blocksize)
|
|
||||||
{
|
|
||||||
if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
|
|
||||||
fprintf(stderr, "%s called with incorrect arguments\n",
|
|
||||||
__func__);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return erase_chip_jedec(flash);
|
|
||||||
}
|
|
||||||
|
|
||||||
int erase_chip_jedec(struct flashchip *flash)
|
|
||||||
{
|
{
|
||||||
int total_size = flash->total_size * 1024;
|
int total_size = flash->total_size * 1024;
|
||||||
chipaddr bios = flash->virtual_memory;
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
|
||||||
/* Issue the JEDEC Chip Erase command */
|
/* Issue the JEDEC Chip Erase command */
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x80, bios + 0x5555);
|
chip_writeb(0x80, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
|
|
||||||
chip_writeb(0xAA, bios + 0x5555);
|
chip_writeb(0xAA, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x55, bios + 0x2AAA);
|
chip_writeb(0x55, bios + (0x2AAA & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
chip_writeb(0x10, bios + 0x5555);
|
chip_writeb(0x10, bios + (0x5555 & mask));
|
||||||
programmer_delay(10);
|
programmer_delay(10);
|
||||||
|
|
||||||
toggle_ready_jedec_slow(bios);
|
toggle_ready_jedec_slow(bios);
|
||||||
@ -285,8 +287,55 @@ int erase_chip_jedec(struct flashchip *flash)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_page_write_jedec(struct flashchip *flash, uint8_t *src,
|
int write_byte_program_jedec_common(struct flashchip *flash, uint8_t *src,
|
||||||
int start, int page_size)
|
chipaddr dst, unsigned int mask)
|
||||||
|
{
|
||||||
|
int tried = 0, failed = 0;
|
||||||
|
chipaddr bios = flash->virtual_memory;
|
||||||
|
|
||||||
|
/* If the data is 0xFF, don't program it and don't complain. */
|
||||||
|
if (*src == 0xFF) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
retry:
|
||||||
|
/* Issue JEDEC Byte Program command */
|
||||||
|
start_program_jedec_common(flash, mask);
|
||||||
|
|
||||||
|
/* transfer data from source to destination */
|
||||||
|
chip_writeb(*src, dst);
|
||||||
|
toggle_ready_jedec(bios);
|
||||||
|
|
||||||
|
if (chip_readb(dst) != *src && tried++ < MAX_REFLASH_TRIES) {
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tried >= MAX_REFLASH_TRIES)
|
||||||
|
failed = 1;
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int write_sector_jedec_common(struct flashchip *flash, uint8_t *src,
|
||||||
|
chipaddr dst, unsigned int page_size, unsigned int mask)
|
||||||
|
{
|
||||||
|
int i, failed = 0;
|
||||||
|
chipaddr olddst;
|
||||||
|
|
||||||
|
olddst = dst;
|
||||||
|
for (i = 0; i < page_size; i++) {
|
||||||
|
if (write_byte_program_jedec_common(flash, src, dst, mask))
|
||||||
|
failed = 1;
|
||||||
|
dst++, src++;
|
||||||
|
}
|
||||||
|
if (failed)
|
||||||
|
fprintf(stderr, " writing sector at 0x%lx failed!\n", olddst);
|
||||||
|
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src,
|
||||||
|
int start, int page_size, unsigned int mask)
|
||||||
{
|
{
|
||||||
int i, tried = 0, failed;
|
int i, tried = 0, failed;
|
||||||
uint8_t *s = src;
|
uint8_t *s = src;
|
||||||
@ -295,8 +344,8 @@ int write_page_write_jedec(struct flashchip *flash, uint8_t *src,
|
|||||||
chipaddr d = dst;
|
chipaddr d = dst;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
/* Issue JEDEC Data Unprotect comand */
|
/* Issue JEDEC Start Program comand */
|
||||||
start_program_jedec(bios);
|
start_program_jedec_common(flash, mask);
|
||||||
|
|
||||||
/* transfer data from source to destination */
|
/* transfer data from source to destination */
|
||||||
for (i = 0; i < page_size; i++) {
|
for (i = 0; i < page_size; i++) {
|
||||||
@ -324,52 +373,6 @@ retry:
|
|||||||
return failed;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_byte_program_jedec(chipaddr bios, uint8_t *src,
|
|
||||||
chipaddr dst)
|
|
||||||
{
|
|
||||||
int tried = 0, failed = 0;
|
|
||||||
|
|
||||||
/* If the data is 0xFF, don't program it and don't complain. */
|
|
||||||
if (*src == 0xFF) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
retry:
|
|
||||||
/* Issue JEDEC Byte Program command */
|
|
||||||
start_program_jedec(bios);
|
|
||||||
|
|
||||||
/* transfer data from source to destination */
|
|
||||||
chip_writeb(*src, dst);
|
|
||||||
toggle_ready_jedec(bios);
|
|
||||||
|
|
||||||
if (chip_readb(dst) != *src && tried++ < MAX_REFLASH_TRIES) {
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tried >= MAX_REFLASH_TRIES)
|
|
||||||
failed = 1;
|
|
||||||
|
|
||||||
return failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_sector_jedec(chipaddr bios, uint8_t *src,
|
|
||||||
chipaddr dst, unsigned int page_size)
|
|
||||||
{
|
|
||||||
int i, failed = 0;
|
|
||||||
chipaddr olddst;
|
|
||||||
|
|
||||||
olddst = dst;
|
|
||||||
for (i = 0; i < page_size; i++) {
|
|
||||||
if (write_byte_program_jedec(bios, src, dst))
|
|
||||||
failed = 1;
|
|
||||||
dst++, src++;
|
|
||||||
}
|
|
||||||
if (failed)
|
|
||||||
fprintf(stderr, " writing sector at 0x%lx failed!\n", olddst);
|
|
||||||
|
|
||||||
return failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_jedec(struct flashchip *flash, uint8_t *buf)
|
int write_jedec(struct flashchip *flash, uint8_t *buf)
|
||||||
{
|
{
|
||||||
int i, failed = 0;
|
int i, failed = 0;
|
||||||
@ -384,8 +387,8 @@ int write_jedec(struct flashchip *flash, uint8_t *buf)
|
|||||||
printf("Programming page: ");
|
printf("Programming page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
if (write_page_write_jedec(flash, buf + i * page_size,
|
if (write_page_write_jedec_common(flash, buf + i * page_size,
|
||||||
i * page_size, page_size))
|
i * page_size, page_size, MASK_FULL))
|
||||||
failed = 1;
|
failed = 1;
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
@ -411,7 +414,7 @@ int write_jedec_1(struct flashchip *flash, uint8_t * buf)
|
|||||||
if ((i & 0x3) == 0)
|
if ((i & 0x3) == 0)
|
||||||
printf("address: 0x%08lx", (unsigned long)i * 1024);
|
printf("address: 0x%08lx", (unsigned long)i * 1024);
|
||||||
|
|
||||||
write_sector_jedec(bios, buf + i * 1024, dst + i * 1024, 1024);
|
write_sector_jedec_common(flash, buf + i * 1024, dst + i * 1024, 1024, MASK_FULL);
|
||||||
|
|
||||||
if ((i & 0x3) == 0)
|
if ((i & 0x3) == 0)
|
||||||
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||||
@ -420,3 +423,35 @@ int write_jedec_1(struct flashchip *flash, uint8_t * buf)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* erase chip with block_erase() prototype */
|
||||||
|
int erase_chip_block_jedec(struct flashchip *flash, unsigned int addr,
|
||||||
|
unsigned int blocksize)
|
||||||
|
{
|
||||||
|
if ((addr != 0) || (blocksize != flash->total_size * 1024)) {
|
||||||
|
fprintf(stderr, "%s called with incorrect arguments\n",
|
||||||
|
__func__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return erase_chip_jedec_common(flash, MASK_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int probe_jedec(struct flashchip *flash)
|
||||||
|
{
|
||||||
|
return probe_jedec_common(flash, MASK_FULL, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
||||||
|
{
|
||||||
|
return erase_sector_jedec_common(flash, page, size, MASK_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int size)
|
||||||
|
{
|
||||||
|
return erase_block_jedec_common(flash, page, size, MASK_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int erase_chip_jedec(struct flashchip *flash)
|
||||||
|
{
|
||||||
|
return erase_chip_jedec_common(flash, MASK_FULL);
|
||||||
|
}
|
||||||
|
@ -101,8 +101,8 @@ int write_49fl00x(struct flashchip *flash, uint8_t *buf)
|
|||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec_common(flash, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size, 0xffff);
|
||||||
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");
|
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");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ int write_49lf040(struct flashchip *flash, uint8_t *buf)
|
|||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
printf("%04d at address: 0x%08x ", i, i * page_size);
|
printf("%04d at address: 0x%08x ", i, i * page_size);
|
||||||
|
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec_common(flash, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size, 0xffff);
|
||||||
|
|
||||||
if (i % 10 == 0)
|
if (i % 10 == 0)
|
||||||
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");
|
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");
|
||||||
|
@ -157,8 +157,8 @@ int write_sst_fwhub(struct flashchip *flash, uint8_t *buf)
|
|||||||
page_size);
|
page_size);
|
||||||
if (rc)
|
if (rc)
|
||||||
return 1;
|
return 1;
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec_common(flash, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size, 0xffff);
|
||||||
}
|
}
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ int write_w39v040c(struct flashchip *flash, uint8_t *buf)
|
|||||||
printf("Programming page: ");
|
printf("Programming page: ");
|
||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec_common(flash, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size, 0xffff);
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -182,7 +182,7 @@ int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf)
|
|||||||
printf("Programming: ");
|
printf("Programming: ");
|
||||||
for (i = 0; i < total_size; i += flash->page_size) {
|
for (i = 0; i < total_size; i += flash->page_size) {
|
||||||
printf("0x%08x\b\b\b\b\b\b\b\b\b\b", i);
|
printf("0x%08x\b\b\b\b\b\b\b\b\b\b", i);
|
||||||
write_sector_jedec(bios, buf + i, bios + i, flash->page_size);
|
write_sector_jedec_common(flash, buf + i, bios + i, flash->page_size, 0xffff);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ int write_49f002(struct flashchip *flash, uint8_t *buf)
|
|||||||
for (i = 0; i < total_size / page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf("%04d at address: 0x%08x ", i, i * page_size);
|
printf("%04d at address: 0x%08x ", i, i * page_size);
|
||||||
/* Byte-wise writing of 'page_size' bytes. */
|
/* Byte-wise writing of 'page_size' bytes. */
|
||||||
write_sector_jedec(bios, buf + i * page_size,
|
write_sector_jedec_common(flash, buf + i * page_size,
|
||||||
bios + i * page_size, page_size);
|
bios + i * page_size, page_size, 0xffff);
|
||||||
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");
|
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");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user