2 * mx29f002.c: driver for MXIC MX29F002 flash models
5 * Copyright 2000 Silicon Integrated System Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * MX29F002/002N data sheet
33 int probe_29f002(struct flashchip *flash)
35 volatile char *bios = flash->virt_addr;
36 unsigned char id1, id2;
38 *(bios + 0x5555) = 0xAA;
39 *(bios + 0x2AAA) = 0x55;
40 *(bios + 0x5555) = 0x90;
42 id1 = *(volatile unsigned char *) bios;
43 id2 = *(volatile unsigned char *) (bios + 0x01);
49 printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
50 if (id1 == flash->manufacture_id && id2 == flash->model_id)
56 int erase_29f002(struct flashchip *flash)
58 volatile char *bios = flash->virt_addr;
60 *(bios + 0x555) = 0xF0;
61 *(bios + 0x555) = 0xAA;
62 *(bios + 0x2AA) = 0x55;
63 *(bios + 0x555) = 0x80;
64 *(bios + 0x555) = 0xAA;
65 *(bios + 0x2AA) = 0x55;
66 *(bios + 0x555) = 0x10;
69 toggle_ready_jedec(bios);
71 // while ((*bios & 0x40) != 0x40)
75 toggle_ready_jedec(bios);
76 *(bios + 0x0ffff) = 0x30;
77 *(bios + 0x1ffff) = 0x30;
78 *(bios + 0x2ffff) = 0x30;
79 *(bios + 0x37fff) = 0x30;
80 *(bios + 0x39fff) = 0x30;
81 *(bios + 0x3bfff) = 0x30;
87 int write_29f002(struct flashchip *flash, unsigned char *buf)
90 int total_size = flash->total_size * 1024;
91 volatile char *bios = flash->virt_addr;
92 volatile char *dst = bios;
99 printf("Programming Page: ");
100 for (i = 0; i < total_size; i++) {
101 /* write to the sector */
102 if ((i & 0xfff) == 0)
103 printf("address: 0x%08lx", (unsigned long) i);
104 *(bios + 0x5555) = 0xAA;
105 *(bios + 0x2AAA) = 0x55;
106 *(bios + 0x5555) = 0xA0;
109 /* wait for Toggle bit ready */
110 toggle_ready_jedec(dst);
112 if ((i & 0xfff) == 0)
113 printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");