2 * OpenBIOS - free your system!
3 * ( firmware/flash device driver for Linux )
5 * programming.h - prototypes for flash device programming
7 * This program is part of a free implementation of the IEEE 1275-1994
8 * Standard for Boot (Initialization Configuration) Firmware.
10 * Copyright (C) 1998-2004 Stefan Reinauer, <stepan@openbios.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2 of the License.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
28 #define ADDR_MANUFACTURER 0x0000
29 #define ADDR_DEVICE_ID 0x0001
30 #define ADDR_SECTOR_LOCK 0x0002
31 #define ADDR_HANDSHAKE 0x0003
33 #define ADDR_UNLOCK_1 0x5555
34 #define ADDR_UNLOCK_2 0x2AAA
35 #define ADDR_COMMAND 0x5555
38 #define CMD_UNLOCK_DATA_1 0xAA
39 #define CMD_UNLOCK_DATA_2 0x55
40 #define CMD_MANUFACTURER_UNLOCK_DATA 0x90
41 #define CMD_UNLOCK_BYPASS_MODE 0x20
42 #define CMD_PROGRAM_UNLOCK_DATA 0xA0
43 #define CMD_RESET_DATA 0xF0
44 #define CMD_SECTOR_ERASE_UNLOCK_DATA 0x80
45 #define CMD_SECTOR_ERASE_UNLOCK_DATA_2 0x30
46 #define CMD_ERASE_DATA 0x10
47 #define CMD_UNLOCK_SECTOR 0x60
49 extern int flashcount;
51 void flash_command(unsigned char *addr, unsigned char command);
53 void flash_program (unsigned char *addr);
54 void flash_program_atmel (unsigned char *addr);
56 int flash_ready_toggle (unsigned char *addr, unsigned int offset);
57 int flash_ready_poll (unsigned char *addr, unsigned int offset, unsigned char data);
59 int flash_erase (unsigned char *addr, unsigned int flashnum);
60 int flash_erase_sectors (unsigned char *addr, unsigned int flashnum,
61 unsigned int startsec, unsigned int endsec);
63 void iflash_program_byte (unsigned char *addr, unsigned int offset, unsigned char data);
64 int iflash_erase_sectors (unsigned char *addr, unsigned int flashnum, unsigned int startsec, unsigned int endsec);
66 unsigned char flash_readb(unsigned char *addr, unsigned int offset);
67 void flash_writeb(unsigned char *addr, unsigned int offset, unsigned char data);
70 int flash_probe_address(void *address);
71 void flash_probe_area(unsigned long romaddr, unsigned long romsize,