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 | |
Michael Karcher | 1c296ca | 2009-11-27 17:49:42 +0000 | [diff] [blame] | 23 | /* if write_sector_jedec is used, |
| 24 | this is write_jedec_1 */ |
Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 25 | int write_pm29f002(struct flashchip *flash, uint8_t *buf) |
| 26 | { |
| 27 | int i, total_size = flash->total_size * 1024; |
| 28 | chipaddr bios = flash->virtual_memory; |
| 29 | chipaddr dst = bios; |
| 30 | |
Michael Karcher | 1c296ca | 2009-11-27 17:49:42 +0000 | [diff] [blame] | 31 | if (erase_flash(flash)) { |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 32 | fprintf(stderr, "ERASE FAILED!\n"); |
| 33 | return -1; |
| 34 | } |
Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 35 | |
Michael Karcher | 1c296ca | 2009-11-27 17:49:42 +0000 | [diff] [blame] | 36 | /* FIXME: use write_sector_jedec? */ |
Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 37 | printf("Programming page: "); |
| 38 | for (i = 0; i < total_size; i++) { |
| 39 | if ((i & 0xfff) == 0) |
| 40 | printf("address: 0x%08lx", (unsigned long)i); |
| 41 | |
| 42 | /* Pm29F002T/B only support byte-wise programming. */ |
| 43 | chip_writeb(0xAA, bios + 0x555); |
| 44 | chip_writeb(0x55, bios + 0x2AA); |
| 45 | chip_writeb(0xA0, bios + 0x555); |
| 46 | chip_writeb(*buf++, dst++); |
| 47 | |
| 48 | /* Wait for Toggle bit ready. */ |
| 49 | toggle_ready_jedec(dst); |
| 50 | |
| 51 | if ((i & 0xfff) == 0) |
| 52 | printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); |
| 53 | } |
| 54 | |
| 55 | printf("\n"); |
| 56 | |
| 57 | return 0; |
| 58 | } |