2 * jedec.c: driver for programming JEDEC standard flash parts
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.
31 int probe_jedec (struct flashchip * flash)
33 volatile char * bios = flash->virt_addr;
34 unsigned char id1, id2;
36 *(volatile char *) (bios + 0x5555) = 0xAA;
37 *(volatile char *) (bios + 0x2AAA) = 0x55;
38 *(volatile char *) (bios + 0x5555) = 0x90;
42 id1 = *(volatile unsigned char *) bios;
43 id2 = *(volatile unsigned char *) (bios + 0x01);
45 *(volatile char *) (bios + 0x5555) = 0xAA;
46 *(volatile char *) (bios + 0x2AAA) = 0x55;
47 *(volatile char *) (bios + 0x5555) = 0xF0;
51 printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
52 if (id1 == flash->manufacture_id && id2 == flash->model_id)
58 int erase_jedec (struct flashchip * flash)
60 volatile char * bios = flash->virt_addr;
62 *(volatile char *) (bios + 0x5555) = 0xAA;
63 *(volatile char *) (bios + 0x2AAA) = 0x55;
64 *(volatile char *) (bios + 0x5555) = 0x80;
66 *(volatile char *) (bios + 0x5555) = 0xAA;
67 *(volatile char *) (bios + 0x2AAA) = 0x55;
68 *(volatile char *) (bios + 0x5555) = 0x10;
71 toggle_ready_jedec(bios);
76 int write_jedec (struct flashchip * flash, unsigned char * buf)
79 int total_size = flash->total_size *1024, page_size = flash->page_size;
80 volatile unsigned char * bios = flash->virt_addr;
83 if (*bios != (unsigned char ) 0xff) {
84 printf("ERASE FAILED\n");
87 printf ("Programming Page: ");
88 for (i = 0; i < total_size/page_size; i++) {
89 printf ("%04d at address: 0x%08x", i, i * page_size);
90 write_page_jedec(bios, buf + i * page_size, bios + i * page_size,
92 printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");