Reset Pm49fl002/4's lockbits for write and erasing. Signed-off-by: Nikolay Petukhov <[EMAIL PROTECTED]>
-- Nikolay
diff -Nru flashrom-2978/flashchips.c flashrom-2978-pm49fl00x/flashchips.c --- flashrom-2978/flashchips.c 2007-10-30 05:56:50.000000000 +0500 +++ flashrom-2978-pm49fl00x/flashchips.c 2007-11-24 15:52:50.000000000 +0500 @@ -83,9 +83,9 @@ {"SST49LF160C", SST_ID, SST_49LF160C, 2048, 4 * 1024 , probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc}, {"Pm49FL002", PMC_ID, PMC_49FL002, 256, 16 * 1024, - probe_jedec, erase_chip_jedec, write_49fl004}, + probe_49fl00x, erase_49fl00x, write_49fl00x}, {"Pm49FL004", PMC_ID, PMC_49FL004, 512, 64 * 1024, - probe_jedec, erase_chip_jedec, write_49fl004}, + probe_49fl00x, erase_49fl00x, write_49fl00x}, {"W29C011", WINBOND_ID, W_29C011, 128, 128, probe_jedec, erase_chip_jedec, write_jedec}, {"W29C040P", WINBOND_ID, W_29C040P, 512, 256, diff -Nru flashrom-2978/flash.h flashrom-2978-pm49fl00x/flash.h --- flashrom-2978/flash.h 2007-10-30 05:56:50.000000000 +0500 +++ flashrom-2978-pm49fl00x/flash.h 2007-11-24 15:53:37.000000000 +0500 @@ -290,9 +290,9 @@ int write_29f002(struct flashchip *flash, uint8_t *buf); /* pm49fl004.c */ -int probe_49fl004(struct flashchip *flash); -int erase_49fl004(struct flashchip *flash); -int write_49fl004(struct flashchip *flash, uint8_t *buf); +int probe_49fl00x(struct flashchip *flash); +int erase_49fl00x(struct flashchip *flash); +int write_49fl00x(struct flashchip *flash, uint8_t *buf); /* sharplhf00l04.c */ int probe_lhf00l04(struct flashchip *flash); diff -Nru flashrom-2978/pm49fl004.c flashrom-2978-pm49fl00x/pm49fl004.c --- flashrom-2978/pm49fl004.c 2007-10-18 05:55:15.000000000 +0600 +++ flashrom-2978-pm49fl00x/pm49fl004.c 2007-11-24 16:13:06.000000000 +0500 @@ -2,6 +2,7 @@ * This file is part of the flashrom project. * * Copyright (C) 2004 Tyan Corporation + * Copyright (C) 2007 Nikolay Petukhov <[EMAIL PROTECTED]> * * 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 @@ -23,13 +24,58 @@ extern int exclude_start_page, exclude_end_page; -int write_49fl004(struct flashchip *flash, uint8_t *buf) +void write_lockbits_49fl00x(volatile uint8_t *bios, int size, + unsigned char bits, int block_size) +{ + int i, left = size; + + for (i = 0; left >= block_size; i++, left -= block_size) { + + /* pm49fl002 */ + if (block_size == 16384 && i%2) + continue; + + *(bios + (i * block_size) + 2) = bits; + } +} + +int probe_49fl00x(struct flashchip *flash) +{ + int ret = probe_jedec(flash); + + if (ret == 1) + map_flash_registers(flash); + + return ret; +} + +int erase_49fl00x(struct flashchip *flash) +{ + int total_size = flash->total_size * 1024; + int page_size = flash->page_size; + int ret; + + /* unprotected */ + write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, page_size); + + ret = erase_chip_jedec(flash); + + /* protected */ + write_lockbits_49fl00x(flash->virtual_registers, total_size, 1, page_size); + + return ret; +} + +int write_49fl00x(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024; int page_size = flash->page_size; volatile uint8_t *bios = flash->virtual_memory; + /* unprotected */ + write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, page_size); + printf("Programming page: "); for (i = 0; i < total_size / page_size; i++) { if ((i >= exclude_start_page) && (i < exclude_end_page)) @@ -46,6 +92,9 @@ fflush(stdout); } printf("\n"); + + /* protected */ + write_lockbits_49fl00x(flash->virtual_registers, total_size, 1, page_size); return 0; }
-- linuxbios mailing list linuxbios@linuxbios.org http://www.linuxbios.org/mailman/listinfo/linuxbios