Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | * |
| 6 | * 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. |
| 10 | * |
| 11 | * 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. |
| 15 | * |
| 16 | * 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 |
| 19 | */ |
| 20 | |
| 21 | #include "flash.h" |
| 22 | |
| 23 | int write_pm29f002(struct flashchip *flash, uint8_t *buf) |
| 24 | { |
| 25 | int i, total_size = flash->total_size * 1024; |
| 26 | chipaddr bios = flash->virtual_memory; |
| 27 | chipaddr dst = bios; |
| 28 | |
| 29 | /* Pm29F002T/B use the same erase method... */ |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 30 | if (erase_29f040b(flash)) { |
| 31 | fprintf(stderr, "ERASE FAILED!\n"); |
| 32 | return -1; |
| 33 | } |
Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 34 | |
| 35 | printf("Programming page: "); |
| 36 | for (i = 0; i < total_size; i++) { |
| 37 | if ((i & 0xfff) == 0) |
| 38 | printf("address: 0x%08lx", (unsigned long)i); |
| 39 | |
| 40 | /* Pm29F002T/B only support byte-wise programming. */ |
| 41 | chip_writeb(0xAA, bios + 0x555); |
| 42 | chip_writeb(0x55, bios + 0x2AA); |
| 43 | chip_writeb(0xA0, bios + 0x555); |
| 44 | chip_writeb(*buf++, dst++); |
| 45 | |
| 46 | /* Wait for Toggle bit ready. */ |
| 47 | toggle_ready_jedec(dst); |
| 48 | |
| 49 | if ((i & 0xfff) == 0) |
| 50 | printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); |
| 51 | } |
| 52 | |
| 53 | printf("\n"); |
| 54 | |
| 55 | return 0; |
| 56 | } |