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... */ |
| 30 | erase_29f040b(flash); |
| 31 | |
| 32 | printf("Programming page: "); |
| 33 | for (i = 0; i < total_size; i++) { |
| 34 | if ((i & 0xfff) == 0) |
| 35 | printf("address: 0x%08lx", (unsigned long)i); |
| 36 | |
| 37 | /* Pm29F002T/B only support byte-wise programming. */ |
| 38 | chip_writeb(0xAA, bios + 0x555); |
| 39 | chip_writeb(0x55, bios + 0x2AA); |
| 40 | chip_writeb(0xA0, bios + 0x555); |
| 41 | chip_writeb(*buf++, dst++); |
| 42 | |
| 43 | /* Wait for Toggle bit ready. */ |
| 44 | toggle_ready_jedec(dst); |
| 45 | |
| 46 | if ((i & 0xfff) == 0) |
| 47 | printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); |
| 48 | } |
| 49 | |
| 50 | printf("\n"); |
| 51 | |
| 52 | return 0; |
| 53 | } |