consolidate more jedec standard code
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1457 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
6a1a1102ea
commit
fbf43ac5a6
|
@ -47,10 +47,10 @@ void print_82802ab_status(unsigned char status)
|
|||
printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
|
||||
}
|
||||
|
||||
int probe_82802ab (struct flashchip * flash)
|
||||
int probe_82802ab(struct flashchip *flash)
|
||||
{
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
|
||||
#if 0
|
||||
*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
|
||||
|
@ -74,18 +74,18 @@ int probe_82802ab (struct flashchip * flash)
|
|||
#endif
|
||||
myusec_delay(10);
|
||||
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id) {
|
||||
size_t size = flash->total_size * 1024;
|
||||
// we need to mmap the write-protect space.
|
||||
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||
flash->fd_mem, (off_t) (0 - 0x400000 - size));
|
||||
if (bios == MAP_FAILED) {
|
||||
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||
flash->fd_mem, (off_t) (0 - 0x400000 - size));
|
||||
if (bios == MAP_FAILED) {
|
||||
// it's this part but we can't map it ...
|
||||
perror("Error MMAP /dev/mem");
|
||||
exit(1);
|
||||
}
|
||||
perror("Error MMAP /dev/mem");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
flash->virt_addr_2 = bios;
|
||||
return 1;
|
||||
|
@ -94,39 +94,39 @@ int probe_82802ab (struct flashchip * flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned char wait_82802ab(volatile unsigned char * bios)
|
||||
unsigned char wait_82802ab(volatile unsigned char *bios)
|
||||
{
|
||||
|
||||
unsigned char status;
|
||||
unsigned char id1, id2;
|
||||
|
||||
*bios = 0x70;
|
||||
if ((*bios & 0x80) == 0) { // it's busy
|
||||
while ((*bios & 0x80) == 0)
|
||||
;
|
||||
if ((*bios & 0x80) == 0) { // it's busy
|
||||
while ((*bios & 0x80) == 0);
|
||||
}
|
||||
|
||||
status = *bios;
|
||||
|
||||
// put another command to get out of status register mode
|
||||
|
||||
|
||||
*bios = 0x90;
|
||||
myusec_delay(10);
|
||||
|
||||
id1 = *(volatile unsigned char *) bios;
|
||||
id2 = *(volatile unsigned char *) (bios + 0x01);
|
||||
|
||||
|
||||
// this is needed to jam it out of "read id" mode
|
||||
*(volatile unsigned char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile unsigned char *) (bios + 0x5555) = 0xF0;
|
||||
return status;
|
||||
|
||||
|
||||
}
|
||||
int erase_82802ab_block(struct flashchip *flash, int offset)
|
||||
{
|
||||
volatile unsigned char * bios = flash->virt_addr + offset;
|
||||
volatile unsigned char *wrprotect = flash->virt_addr_2 + offset + 2;
|
||||
volatile unsigned char *bios = flash->virt_addr + offset;
|
||||
volatile unsigned char *wrprotect =
|
||||
flash->virt_addr_2 + offset + 2;
|
||||
unsigned char status;
|
||||
|
||||
// clear status register
|
||||
|
@ -146,54 +146,56 @@ int erase_82802ab_block(struct flashchip *flash, int offset)
|
|||
status = wait_82802ab(flash->virt_addr);
|
||||
//print_82802ab_status(status);
|
||||
printf("DONE BLOCK 0x%x\n", offset);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
int erase_82802ab (struct flashchip * flash)
|
||||
int erase_82802ab(struct flashchip *flash)
|
||||
{
|
||||
int i;
|
||||
unsigned int total_size = flash->total_size * 1024;
|
||||
|
||||
printf("total_size is %d; flash->page_size is %d\n",
|
||||
total_size, flash->page_size);
|
||||
for(i = 0; i < total_size; i += flash->page_size)
|
||||
printf("total_size is %d; flash->page_size is %d\n",
|
||||
total_size, flash->page_size);
|
||||
for (i = 0; i < total_size; i += flash->page_size)
|
||||
erase_82802ab_block(flash, i);
|
||||
printf("DONE ERASE\n");
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void write_page_82802ab (volatile char * bios, char * src, volatile char * dst,
|
||||
int page_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
/* transfer data from source to destination */
|
||||
*dst = 0x40;
|
||||
*dst++ = *src++;
|
||||
wait_82802ab(bios);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int write_82802ab (struct flashchip * flash, unsigned char * buf)
|
||||
void write_page_82802ab(volatile char *bios, char *src, volatile char *dst,
|
||||
int page_size)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
|
||||
erase_82802ab (flash);
|
||||
for (i = 0; i < page_size; i++) {
|
||||
/* transfer data from source to destination */
|
||||
*dst = 0x40;
|
||||
*dst++ = *src++;
|
||||
wait_82802ab(bios);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int write_82802ab(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
|
||||
erase_82802ab(flash);
|
||||
if (*bios != 0xff) {
|
||||
printf("ERASE FAILED\n");
|
||||
return -1;
|
||||
}
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_page_82802ab(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_page_82802ab(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
}
|
||||
printf("\n");
|
||||
protect_82802ab (bios);
|
||||
return(0);
|
||||
protect_82802ab(bios);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef __82802AB_H__
|
||||
#define __82802AB_H__ 1
|
||||
|
||||
extern int probe_82802ab (struct flashchip * flash);
|
||||
extern int erase_82802ab (struct flashchip * flash);
|
||||
extern int write_82802ab (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_82802ab(struct flashchip *flash);
|
||||
extern int erase_82802ab(struct flashchip *flash);
|
||||
extern int write_82802ab(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
extern __inline__ void toggle_ready_82802ab (volatile char * dst)
|
||||
extern __inline__ void toggle_ready_82802ab(volatile char *dst)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp1, tmp2;
|
||||
|
@ -21,7 +21,7 @@ extern __inline__ void toggle_ready_82802ab (volatile char * dst)
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void data_polling_82802ab (volatile char * dst, char data)
|
||||
extern __inline__ void data_polling_82802ab(volatile char *dst, char data)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp;
|
||||
|
@ -36,7 +36,7 @@ extern __inline__ void data_polling_82802ab (volatile char * dst, char data)
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void protect_82802ab (volatile char * bios)
|
||||
extern __inline__ void protect_82802ab(volatile char *bios)
|
||||
{
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
|
@ -45,4 +45,4 @@ extern __inline__ void protect_82802ab (volatile char * bios)
|
|||
usleep(200);
|
||||
}
|
||||
|
||||
#endif /* !__82802AB_H__ */
|
||||
#endif /* !__82802AB_H__ */
|
||||
|
|
|
@ -28,13 +28,14 @@
|
|||
#include "flash.h"
|
||||
#include "jedec.h"
|
||||
|
||||
static __inline__ int erase_sector_29f040b (volatile char * bios, unsigned long address)
|
||||
static __inline__ int erase_sector_29f040b(volatile char *bios,
|
||||
unsigned long address)
|
||||
{
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + 0x555) = 0x80;
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + 0x555) = 0x80;
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + address) = 0x30;
|
||||
|
||||
sleep(2);
|
||||
|
@ -42,17 +43,20 @@ static __inline__ int erase_sector_29f040b (volatile char * bios, unsigned long
|
|||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios + address);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static __inline__ int write_sector_29f040b(volatile char * bios, unsigned char * src,
|
||||
volatile unsigned char * dst, unsigned int page_size)
|
||||
static __inline__ int write_sector_29f040b(volatile char *bios,
|
||||
unsigned char *src,
|
||||
volatile unsigned char *dst,
|
||||
unsigned int page_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
printf("0x%08lx", (unsigned long) dst - (unsigned long) bios);
|
||||
|
||||
printf("0x%08lx",
|
||||
(unsigned long) dst - (unsigned long) bios);
|
||||
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + 0x555) = 0xA0;
|
||||
|
@ -64,25 +68,25 @@ static __inline__ int write_sector_29f040b(volatile char * bios, unsigned char *
|
|||
printf("\b\b\b\b\b\b\b\b\b\b");
|
||||
}
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int probe_29f040b (struct flashchip * flash)
|
||||
int probe_29f040b(struct flashchip *flash)
|
||||
{
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
*(bios + 0x555) = 0x90;
|
||||
|
||||
id1 = * bios;
|
||||
id2 = * (bios + 0x01);
|
||||
|
||||
id1 = *bios;
|
||||
id2 = *(bios + 0x01);
|
||||
|
||||
*bios = 0xF0;
|
||||
|
||||
myusec_delay(10);
|
||||
|
||||
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||
return 1;
|
||||
|
@ -90,9 +94,9 @@ int probe_29f040b (struct flashchip * flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int erase_29f040b (struct flashchip * flash)
|
||||
int erase_29f040b(struct flashchip *flash)
|
||||
{
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
|
||||
*(bios + 0x555) = 0xAA;
|
||||
*(bios + 0x2AA) = 0x55;
|
||||
|
@ -104,27 +108,28 @@ int erase_29f040b (struct flashchip * flash)
|
|||
myusec_delay(10);
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_29f040b (struct flashchip * flash, unsigned char * buf)
|
||||
int write_29f040b(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
/* erase the page before programming */
|
||||
erase_sector_29f040b(bios, i * page_size);
|
||||
|
||||
/* write to the sector */
|
||||
printf ("%04d at address: ", i);
|
||||
write_sector_29f040b(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
printf("%04d at address: ", i);
|
||||
write_sector_29f040b(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __AM29F040B_H__
|
||||
#define __AM29F040B_H__ 1
|
||||
|
||||
extern int probe_29f040b (struct flashchip * flash);
|
||||
extern int erase_29f040b (struct flashchip * flash);
|
||||
extern int write_29f040b (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_29f040b(struct flashchip *flash);
|
||||
extern int erase_29f040b(struct flashchip *flash);
|
||||
extern int write_29f040b(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__AM29F040B_H__ */
|
||||
#endif /* !__AM29F040B_H__ */
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
#include <unistd.h>
|
||||
|
||||
struct flashchip {
|
||||
char * name;
|
||||
char *name;
|
||||
int manufacture_id;
|
||||
int model_id;
|
||||
|
||||
volatile char * virt_addr;
|
||||
volatile char *virt_addr;
|
||||
int total_size;
|
||||
int page_size;
|
||||
|
||||
int (*probe) (struct flashchip * flash);
|
||||
int (*erase) (struct flashchip * flash);
|
||||
int (*write) (struct flashchip * flash, unsigned char * buf);
|
||||
int (*read) (struct flashchip * flash, unsigned char * buf);
|
||||
int (*write) (struct flashchip * flash, unsigned char *buf);
|
||||
int (*read) (struct flashchip * flash, unsigned char *buf);
|
||||
|
||||
int fd_mem;
|
||||
volatile char *virt_addr_2;
|
||||
|
@ -25,41 +25,41 @@ struct flashchip {
|
|||
#define AMD_ID 0x01
|
||||
#define AM_29F040B 0xA4
|
||||
|
||||
#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
|
||||
#define AT_29C040A 0xA4 /* Winbond w29c020c device code*/
|
||||
#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
|
||||
#define AT_29C040A 0xA4 /* Winbond w29c020c device code */
|
||||
|
||||
#define MX_ID 0xC2
|
||||
#define MX_29F002 0xB0
|
||||
|
||||
#define SST_ID 0xBF /* SST Manufacturer ID[B code */
|
||||
#define SST_29EE020A 0x10 /* SST 29EE020 device code */
|
||||
#define SST_28SF040 0x04 /* SST 29EE040 device code */
|
||||
#define SST_39SF020 0xB6 /* SST 39SF020 device */
|
||||
#define SST_39VF020 0xD6 /* SST 39VF020 device */
|
||||
#define SST_ID 0xBF /* SST Manufacturer ID[B code */
|
||||
#define SST_29EE020A 0x10 /* SST 29EE020 device code */
|
||||
#define SST_28SF040 0x04 /* SST 29EE040 device code */
|
||||
#define SST_39SF020 0xB6 /* SST 39SF020 device */
|
||||
#define SST_39VF020 0xD6 /* SST 39VF020 device */
|
||||
#define SST_49LF040 0x51 /* SST 49LF040 device */
|
||||
#define SST_49LF080A 0x5B /* SST 48LF080A device */
|
||||
#define SST_49LF002A 0x57 /* SST 49LF002A device*/
|
||||
#define SST_49LF003A 0x1B /* SST 49LF003A device*/
|
||||
#define SST_49LF004A 0x60 /* SST 49LF004A device*/
|
||||
#define SST_49LF008A 0x5A /* SST 49LF008A device*/
|
||||
#define SST_49LF002A 0x57 /* SST 49LF002A device */
|
||||
#define SST_49LF003A 0x1B /* SST 49LF003A device */
|
||||
#define SST_49LF004A 0x60 /* SST 49LF004A device */
|
||||
#define SST_49LF008A 0x5A /* SST 49LF008A device */
|
||||
|
||||
#define PMC_ID 0x9D /* PMC Manufacturer ID[B code */
|
||||
#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
|
||||
#define PMC_ID 0x9D /* PMC Manufacturer ID[B code */
|
||||
#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
|
||||
|
||||
#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
|
||||
#define W_29C011 0xC1 /* Winbond w29c011 device code*/
|
||||
#define W_29C020C 0x45 /* Winbond w29c020c device code*/
|
||||
#define W_49F002U 0x0B /* Winbond w29c020c device code*/
|
||||
#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
|
||||
#define W_29C011 0xC1 /* Winbond w29c011 device code */
|
||||
#define W_29C020C 0x45 /* Winbond w29c020c device code */
|
||||
#define W_49F002U 0x0B /* Winbond w29c020c device code */
|
||||
|
||||
#define ST_ID 0x20
|
||||
#define ST_ID 0x20
|
||||
#define ST_M29F400BT 0xD5
|
||||
|
||||
#define MSYSTEMS_ID 0x156f
|
||||
#define MSYSTEMS_MD2200 0xdb /* ? */
|
||||
#define MSYSTEMS_MD2800 0x30 /* hmm -- both 0x30 */
|
||||
#define MSYSTEMS_MD2802 0x30 /* hmm -- both 0x30 */
|
||||
#define MSYSTEMS_MD2200 0xdb /* ? */
|
||||
#define MSYSTEMS_MD2800 0x30 /* hmm -- both 0x30 */
|
||||
#define MSYSTEMS_MD2802 0x30 /* hmm -- both 0x30 */
|
||||
|
||||
extern void myusec_delay(int time);
|
||||
extern void myusec_calibrate_delay();
|
||||
extern int enable_flash_write(void);
|
||||
#endif /* !__FLASH_H__ */
|
||||
#endif /* !__FLASH_H__ */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <pci/pci.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int enable_flash_sis630 (struct pci_dev *dev, char *name)
|
||||
static int enable_flash_sis630(struct pci_dev *dev, char *name)
|
||||
{
|
||||
char b;
|
||||
|
||||
|
@ -42,7 +42,7 @@ static int enable_flash_sis630 (struct pci_dev *dev, char *name)
|
|||
outb(0x24, 0x4e);
|
||||
outb(b, 0x4f);
|
||||
outb(0x02, 0x4e);
|
||||
outb(0x02, 0x4f);
|
||||
outb(0x02, 0x4f);
|
||||
}
|
||||
|
||||
outb(0x24, 0x2e);
|
||||
|
@ -64,7 +64,7 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
|
|||
/* if it fails, it fails. There are so many variations of broken mobos
|
||||
* that it is hard to argue that we should quit at this point.
|
||||
*/
|
||||
|
||||
|
||||
old = pci_read_byte(dev, 0x4e);
|
||||
|
||||
new = old | 1;
|
||||
|
@ -75,8 +75,9 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
|
|||
pci_write_byte(dev, 0x4e, new);
|
||||
|
||||
if (pci_read_byte(dev, 0x4e) != new) {
|
||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x4e, new, name);
|
||||
printf
|
||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x4e, new, name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -87,7 +88,7 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||
unsigned char old, new, val;
|
||||
unsigned int base;
|
||||
int ok;
|
||||
|
||||
|
||||
/* get io privilege access PCI configuration space */
|
||||
if (iopl(3) != 0) {
|
||||
perror("Can not set io priviliage");
|
||||
|
@ -103,12 +104,15 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||
|
||||
ok = pci_write_byte(dev, 0x40, new);
|
||||
if (ok != 0) {
|
||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
old, new, name);
|
||||
printf
|
||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
old, new, name);
|
||||
}
|
||||
|
||||
/* enable GPIO15 which is connected to write protect. */
|
||||
base = ((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89) << 8);
|
||||
base =
|
||||
((pci_read_byte(dev, 0x88) & 0x80) | pci_read_byte(dev, 0x89)
|
||||
<< 8);
|
||||
val = inb(base + 0x4d);
|
||||
val |= 0x80;
|
||||
outb(val, base + 0x4d);
|
||||
|
@ -123,14 +127,15 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||
static int enable_flash_vt8231(struct pci_dev *dev, char *name)
|
||||
{
|
||||
unsigned char val;
|
||||
|
||||
|
||||
val = pci_read_byte(dev, 0x40);
|
||||
val |= 0x10;
|
||||
pci_write_byte(dev, 0x40, val);
|
||||
|
||||
if (pci_read_byte(dev, 0x40) != val) {
|
||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x40, val, name);
|
||||
printf
|
||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x40, val, name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -139,14 +144,15 @@ static int enable_flash_vt8231(struct pci_dev *dev, char *name)
|
|||
static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
||||
{
|
||||
unsigned char new;
|
||||
|
||||
|
||||
pci_write_byte(dev, 0x52, 0xee);
|
||||
|
||||
new = pci_read_byte(dev, 0x52);
|
||||
|
||||
if (new != 0xee) {
|
||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x52, new, name);
|
||||
printf
|
||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x52, new, name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -155,14 +161,15 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
|||
static int enable_flash_sc1100(struct pci_dev *dev, char *name)
|
||||
{
|
||||
unsigned char new;
|
||||
|
||||
|
||||
pci_write_byte(dev, 0x52, 0xee);
|
||||
|
||||
new = pci_read_byte(dev, 0x52);
|
||||
|
||||
if (new != 0xee) {
|
||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x52, new, name);
|
||||
printf
|
||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x52, new, name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -171,11 +178,11 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name)
|
|||
static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
||||
{
|
||||
unsigned char new, newer;
|
||||
|
||||
|
||||
new = pci_read_byte(dev, 0x45);
|
||||
|
||||
/* clear bit 5 */
|
||||
new &= (~ 0x20);
|
||||
new &= (~0x20);
|
||||
/* set bit 2 */
|
||||
new |= 0x4;
|
||||
|
||||
|
@ -183,15 +190,17 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
|||
|
||||
newer = pci_read_byte(dev, 0x45);
|
||||
if (newer != new) {
|
||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x45, new, name);
|
||||
printf
|
||||
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x45, new, name);
|
||||
printf("Stuck at 0x%x\n", newer);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
|
||||
static int enable_flash_amd8111(struct pci_dev *dev, char *name)
|
||||
{
|
||||
/* register 4e.b gets or'ed with one */
|
||||
unsigned char old, new;
|
||||
/* if it fails, it fails. There are so many variations of broken mobos
|
||||
|
@ -205,42 +214,44 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
|
|||
if (new != old) {
|
||||
pci_write_byte(dev, 0x43, new);
|
||||
if (pci_read_byte(dev, 0x43) != new) {
|
||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x43, new, name);
|
||||
printf
|
||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x43, new, name);
|
||||
}
|
||||
}
|
||||
|
||||
old = pci_read_byte(dev, 0x40);
|
||||
old = pci_read_byte(dev, 0x40);
|
||||
new = old | 0x01;
|
||||
if (new == old)
|
||||
return 0;
|
||||
pci_write_byte(dev, 0x40, new);
|
||||
|
||||
if (pci_read_byte(dev, 0x40) != new) {
|
||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x40, new, name);
|
||||
printf
|
||||
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||
0x40, new, name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct penable {
|
||||
unsigned short vendor, device;
|
||||
unsigned short vendor, device;
|
||||
char *name;
|
||||
int (*doit)(struct pci_dev *dev, char *name);
|
||||
int (*doit) (struct pci_dev * dev, char *name);
|
||||
} FLASH_ENABLE;
|
||||
|
||||
static FLASH_ENABLE enables[] = {
|
||||
{0x1039, 0x0630, "sis630", enable_flash_sis630},
|
||||
{0x8086, 0x2480, "E7500", enable_flash_e7500},
|
||||
{0x1106, 0x8231, "VT8231", enable_flash_vt8231},
|
||||
{0x1106, 0x3177, "VT8235", enable_flash_vt8235},
|
||||
{0x1078, 0x0100, "CS5530", enable_flash_cs5530},
|
||||
{0x100b, 0x0510, "SC1100", enable_flash_sc1100},
|
||||
{0x1039, 0x0630, "sis630", enable_flash_sis630},
|
||||
{0x8086, 0x2480, "E7500", enable_flash_e7500},
|
||||
{0x1106, 0x8231, "VT8231", enable_flash_vt8231},
|
||||
{0x1106, 0x3177, "VT8235", enable_flash_vt8235},
|
||||
{0x1078, 0x0100, "CS5530", enable_flash_cs5530},
|
||||
{0x100b, 0x0510, "SC1100", enable_flash_sc1100},
|
||||
{0x1039, 0x0008, "SIS5595", enable_flash_sis5595},
|
||||
{0x1022, 0x7468, "AMD8111", enable_flash_amd8111},
|
||||
};
|
||||
|
||||
|
||||
int enable_flash_write()
|
||||
{
|
||||
int i;
|
||||
|
@ -248,20 +259,21 @@ int enable_flash_write()
|
|||
struct pci_dev *dev = 0;
|
||||
FLASH_ENABLE *enable = 0;
|
||||
|
||||
pacc = pci_alloc(); /* Get the pci_access structure */
|
||||
pacc = pci_alloc(); /* Get the pci_access structure */
|
||||
/* Set all options you want -- here we stick with the defaults */
|
||||
pci_init(pacc); /* Initialize the PCI library */
|
||||
pci_scan_bus(pacc); /* We want to get the list of devices */
|
||||
pci_init(pacc); /* Initialize the PCI library */
|
||||
pci_scan_bus(pacc); /* We want to get the list of devices */
|
||||
|
||||
/* now let's try to find the chipset we have ... */
|
||||
for (i = 0; i < sizeof(enables)/sizeof(enables[0]) && (! dev); i++) {
|
||||
for (i = 0; i < sizeof(enables) / sizeof(enables[0]) && (!dev);
|
||||
i++) {
|
||||
struct pci_filter f;
|
||||
struct pci_dev *z;
|
||||
/* the first param is unused. */
|
||||
pci_filter_init((struct pci_access *) 0, &f);
|
||||
f.vendor = enables[i].vendor;
|
||||
f.device = enables[i].device;
|
||||
for (z=pacc->devices; z; z=z->next)
|
||||
for (z = pacc->devices; z; z = z->next)
|
||||
if (pci_filter_match(&f, z)) {
|
||||
enable = &enables[i];
|
||||
dev = z;
|
||||
|
|
|
@ -73,5 +73,5 @@ int main()
|
|||
outb(0x02, 0x2e);
|
||||
outb(0x02, 0x2f);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -48,59 +48,60 @@
|
|||
#include "mx29f002.h"
|
||||
|
||||
struct flashchip flashchips[] = {
|
||||
{"Am29F040B", AMD_ID, AM_29F040B, NULL, 512, 64*1024,
|
||||
{"Am29F040B", AMD_ID, AM_29F040B, NULL, 512, 64 * 1024,
|
||||
probe_29f040b, erase_29f040b, write_29f040b, NULL},
|
||||
{"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256,
|
||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
||||
{"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64*1024,
|
||||
probe_29f002, erase_29f002, write_29f002, NULL},
|
||||
{"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128,
|
||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
||||
{"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256,
|
||||
{"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256,
|
||||
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||
{"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64 * 1024,
|
||||
probe_29f002, erase_29f002, write_29f002, NULL},
|
||||
{"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128,
|
||||
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||
{"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256,
|
||||
probe_28sf040, erase_28sf040, write_28sf040, NULL},
|
||||
{"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096,
|
||||
probe_jedec, erase_jedec, write_39sf020, NULL},
|
||||
{"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096,
|
||||
probe_jedec, erase_jedec, write_39sf020, NULL},
|
||||
{"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
|
||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
||||
{"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64*1024,
|
||||
probe_jedec, erase_jedec, write_49fl004, NULL},
|
||||
{"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128,
|
||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
||||
{"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128,
|
||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
||||
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
||||
probe_jedec, erase_jedec, write_49f002, NULL},
|
||||
{"M29F400BT", ST_ID, ST_M29F400BT ,NULL, 512, 64*1024,
|
||||
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL},
|
||||
{"82802ab", 137, 173 , NULL, 512, 64*1024,
|
||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||
{"82802ac", 137, 172 , NULL, 1024, 64*1024,
|
||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||
{"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_39sf020, NULL},
|
||||
{"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_39sf020, NULL},
|
||||
{"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
|
||||
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||
{"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64 * 1024,
|
||||
probe_jedec, erase_chip_jedec, write_49fl004, NULL},
|
||||
{"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128,
|
||||
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||
{"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128,
|
||||
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
||||
probe_jedec, erase_chip_jedec, write_49f002, NULL},
|
||||
{"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024,
|
||||
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt,
|
||||
NULL},
|
||||
{"82802ab", 137, 173, NULL, 512, 64 * 1024,
|
||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||
{"82802ac", 137, 172, NULL, 1024, 64 * 1024,
|
||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||
{"MD-2802 (M-Systems DiskOnChip Millennium Module)",
|
||||
MSYSTEMS_ID, MSYSTEMS_MD2802,
|
||||
NULL, 8, 8*1024,
|
||||
NULL, 8, 8 * 1024,
|
||||
probe_md2802, erase_md2802, write_md2802, read_md2802},
|
||||
{NULL,}
|
||||
};
|
||||
|
||||
char *chip_to_probe = NULL;
|
||||
|
||||
struct flashchip * probe_flash(struct flashchip * flash)
|
||||
struct flashchip *probe_flash(struct flashchip *flash)
|
||||
{
|
||||
int fd_mem;
|
||||
volatile char * bios;
|
||||
volatile char *bios;
|
||||
unsigned long size;
|
||||
|
||||
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
||||
|
@ -109,21 +110,24 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
|||
}
|
||||
|
||||
while (flash->name != NULL) {
|
||||
if (chip_to_probe && strcmp(flash->name, chip_to_probe) != 0) {
|
||||
if (chip_to_probe
|
||||
&& strcmp(flash->name, chip_to_probe) != 0) {
|
||||
flash++;
|
||||
continue;
|
||||
}
|
||||
printf("Trying %s, %d KB\n", flash->name, flash->total_size);
|
||||
printf("Trying %s, %d KB\n", flash->name,
|
||||
flash->total_size);
|
||||
size = flash->total_size * 1024;
|
||||
/* BUG? what happens if getpagesize() > size!?
|
||||
-> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
|
||||
if (getpagesize() > size) {
|
||||
size = getpagesize();
|
||||
printf("%s: warning: size: %d -> %ld\n", __FUNCTION__,
|
||||
flash->total_size * 1024, (unsigned long)size);
|
||||
printf("%s: warning: size: %d -> %ld\n",
|
||||
__FUNCTION__, flash->total_size * 1024,
|
||||
(unsigned long) size);
|
||||
}
|
||||
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||
fd_mem, (off_t) (0xffffffff - size + 1));
|
||||
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||
fd_mem, (off_t) (0xffffffff - size + 1));
|
||||
if (bios == MAP_FAILED) {
|
||||
perror("Error MMAP /dev/mem");
|
||||
exit(1);
|
||||
|
@ -132,31 +136,31 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
|||
flash->fd_mem = fd_mem;
|
||||
|
||||
if (flash->probe(flash) == 1) {
|
||||
printf ("%s found at physical address: 0x%lx\n",
|
||||
flash->name, (0xffffffff - size + 1));
|
||||
printf("%s found at physical address: 0x%lx\n",
|
||||
flash->name, (0xffffffff - size + 1));
|
||||
return flash;
|
||||
}
|
||||
munmap ((void *) bios, size);
|
||||
munmap((void *) bios, size);
|
||||
flash++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int verify_flash (struct flashchip * flash, char * buf, int verbose)
|
||||
int verify_flash(struct flashchip *flash, char *buf, int verbose)
|
||||
{
|
||||
int i = 0;
|
||||
int total_size = flash->total_size *1024;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
printf("Verifying address: ");
|
||||
while (i < total_size) {
|
||||
if (verbose)
|
||||
if (verbose)
|
||||
printf("0x%08x", i);
|
||||
if (*(bios+i) != *(buf+i)) {
|
||||
if (*(bios + i) != *(buf + i)) {
|
||||
printf("FAILED\n");
|
||||
return 0;
|
||||
}
|
||||
if (verbose)
|
||||
if (verbose)
|
||||
printf("\b\b\b\b\b\b\b\b\b\b");
|
||||
i++;
|
||||
}
|
||||
|
@ -180,12 +184,12 @@ void usage(const char *name)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
int main (int argc, char * argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char * buf;
|
||||
char *buf;
|
||||
unsigned long size;
|
||||
FILE * image;
|
||||
struct flashchip * flash;
|
||||
FILE *image;
|
||||
struct flashchip *flash;
|
||||
int opt;
|
||||
int read_it = 0, write_it = 0, verify_it = 0, verbose = 0;
|
||||
char *filename = NULL;
|
||||
|
@ -222,7 +226,8 @@ int main (int argc, char * argv[])
|
|||
if (optind < argc)
|
||||
filename = argv[optind++];
|
||||
|
||||
printf("Calibrating timer since microsleep sucks ... takes a second\n");
|
||||
printf
|
||||
("Calibrating timer since microsleep sucks ... takes a second\n");
|
||||
myusec_calibrate_delay();
|
||||
printf("OK, calibrated, now do the deed\n");
|
||||
|
||||
|
@ -230,22 +235,23 @@ int main (int argc, char * argv[])
|
|||
* really need this to be done, etc., etc. It sucks.
|
||||
*/
|
||||
(void) enable_flash_write();
|
||||
|
||||
if ((flash = probe_flash (flashchips)) == NULL) {
|
||||
|
||||
if ((flash = probe_flash(flashchips)) == NULL) {
|
||||
printf("EEPROM not found\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Part is %s\n", flash->name);
|
||||
if (!filename){
|
||||
printf("OK, only ENABLING flash write, but NOT FLASHING\n");
|
||||
if (!filename) {
|
||||
printf
|
||||
("OK, only ENABLING flash write, but NOT FLASHING\n");
|
||||
return 0;
|
||||
}
|
||||
size = flash->total_size * 1024;
|
||||
buf = (char *) calloc (size, sizeof(char));
|
||||
buf = (char *) calloc(size, sizeof(char));
|
||||
|
||||
if (read_it) {
|
||||
if ((image = fopen (filename, "w")) == NULL) {
|
||||
if ((image = fopen(filename, "w")) == NULL) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -253,22 +259,22 @@ int main (int argc, char * argv[])
|
|||
if (flash->read == NULL)
|
||||
memcpy(buf, (const char *) flash->virt_addr, size);
|
||||
else
|
||||
flash->read (flash, buf);
|
||||
flash->read(flash, buf);
|
||||
fwrite(buf, sizeof(char), size, image);
|
||||
fclose(image);
|
||||
printf("done\n");
|
||||
} else {
|
||||
if ((image = fopen (filename, "r")) == NULL) {
|
||||
if ((image = fopen(filename, "r")) == NULL) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
fread (buf, sizeof(char), size, image);
|
||||
fread(buf, sizeof(char), size, image);
|
||||
fclose(image);
|
||||
}
|
||||
|
||||
if (write_it || (!read_it && !verify_it))
|
||||
flash->write (flash, buf);
|
||||
flash->write(flash, buf);
|
||||
if (verify_it)
|
||||
verify_flash (flash, buf, verbose);
|
||||
verify_flash(flash, buf, verbose);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,116 +28,176 @@
|
|||
#include "flash.h"
|
||||
#include "jedec.h"
|
||||
|
||||
int probe_jedec (struct flashchip * flash)
|
||||
int probe_jedec(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x5555) = 0x90;
|
||||
myusec_delay(10);
|
||||
/* Issue JEDEC Product ID Entry command */
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x5555) = 0x90;
|
||||
myusec_delay(10);
|
||||
|
||||
id1 = *(volatile unsigned char *) bios;
|
||||
id2 = *(volatile unsigned char *) (bios + 0x01);
|
||||
/* Read product ID */
|
||||
id1 = *(volatile unsigned char *) bios;
|
||||
id2 = *(volatile unsigned char *) (bios + 0x01);
|
||||
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x5555) = 0xF0;
|
||||
myusec_delay(10);
|
||||
/* Issue JEDEC Product ID Exit command */
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
myusec_delay(10);
|
||||
*(volatile char *) (bios + 0x5555) = 0xF0;
|
||||
myusec_delay(10);
|
||||
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||
return 1;
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int erase_sector_jedec (volatile char * bios, unsigned int page)
|
||||
int erase_sector_jedec(volatile char *bios, unsigned int page)
|
||||
{
|
||||
/* Chip erase function does not exist for LPC mode on 49lf040.
|
||||
* Erase sector-by-sector instead. */
|
||||
volatile unsigned char *Temp;
|
||||
|
||||
/* Issue the Sector Erase command to 40LF040 */
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
/* Issue the Sector Erase command */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + page; /* set up address to be the current sector */
|
||||
*Temp = 0x30; /* write data 0x30 to the address */
|
||||
|
||||
Temp = bios + page; /* set up address to be the current sector */
|
||||
*Temp = 0x30; /* write data 0x30 to the address */
|
||||
myusec_delay(10);
|
||||
|
||||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int erase_jedec (struct flashchip * flash)
|
||||
int erase_chip_jedec(struct flashchip *flash)
|
||||
{
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
volatile unsigned char *Temp;
|
||||
|
||||
/* Issue the Sector Erase command to 39SF020 */
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
/* Issue the JEDEC Chip Erase command */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0x10; /* write data 0x55 to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be BASEy:5555h */
|
||||
*Temp = 0x10; /* write data 0x10 to the address */
|
||||
myusec_delay(10);
|
||||
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_jedec (struct flashchip * flash, unsigned char * buf)
|
||||
void write_page_jedec(volatile char *bios, char *src, volatile char *dst,
|
||||
int page_size)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
|
||||
erase_jedec (flash);
|
||||
if (*bios != (unsigned char ) 0xff) {
|
||||
/* Issue JEDEC Data Unprotect comand */
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0xA0;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
/* transfer data from source to destination */
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
||||
usleep(100);
|
||||
toggle_ready_jedec(dst - 1);
|
||||
}
|
||||
|
||||
int write_sector_jedec(volatile char *bios,
|
||||
unsigned char *src,
|
||||
volatile unsigned char *dst, unsigned int page_size)
|
||||
{
|
||||
int i;
|
||||
volatile char *Temp;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
if (*dst != 0xff) {
|
||||
printf("FATAL: dst %p not erased (val 0x%x\n", dst,
|
||||
*dst);
|
||||
return (-1);
|
||||
}
|
||||
/* transfer data from source to destination */
|
||||
if (*src == 0xFF) {
|
||||
dst++, src++;
|
||||
/* If the data is 0xFF, don't program it */
|
||||
continue;
|
||||
}
|
||||
/* Issue JEDEC Byte Program command */
|
||||
Temp = bios + 0x5555;
|
||||
*Temp = 0xAA;
|
||||
Temp = bios + 0x2AAA;
|
||||
*Temp = 0x55;
|
||||
Temp = bios + 0x5555;
|
||||
*Temp = 0xA0;
|
||||
*dst = *src;
|
||||
toggle_ready_jedec(bios);
|
||||
if (*dst != *src)
|
||||
printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
|
||||
(unsigned long) dst, *dst, *src);
|
||||
dst++, src++;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_jedec(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
|
||||
erase_chip_jedec(flash);
|
||||
if (*bios != (unsigned char) 0xff) {
|
||||
printf("ERASE FAILED\n");
|
||||
return -1;
|
||||
}
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_page_jedec(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_page_jedec(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
}
|
||||
printf("\n");
|
||||
protect_jedec (bios);
|
||||
protect_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
#ifndef __JEDEC_H__
|
||||
#define __JEDEC_H__ 1
|
||||
|
||||
extern int probe_jedec (struct flashchip * flash);
|
||||
extern int erase_jedec (struct flashchip * flash);
|
||||
extern int write_jedec (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_jedec(struct flashchip *flash);
|
||||
extern int erase_chip_jedec(struct flashchip *flash);
|
||||
extern int write_jedec(struct flashchip *flash, unsigned char *buf);
|
||||
extern int erase_sector_jedec(volatile char *bios, unsigned int page);
|
||||
extern int write_sector_jedec(volatile char *bios,
|
||||
unsigned char *src,
|
||||
volatile unsigned char *dst,
|
||||
unsigned int page_size);
|
||||
|
||||
extern __inline__ void toggle_ready_jedec (volatile char * dst)
|
||||
extern __inline__ void toggle_ready_jedec(volatile char *dst)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp1, tmp2;
|
||||
|
@ -21,7 +26,7 @@ extern __inline__ void toggle_ready_jedec (volatile char * dst)
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void data_polling_jedec (volatile char * dst, char data)
|
||||
extern __inline__ void data_polling_jedec(volatile char *dst, char data)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp;
|
||||
|
@ -36,7 +41,19 @@ extern __inline__ void data_polling_jedec (volatile char * dst, char data)
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void protect_jedec (volatile char * bios)
|
||||
extern __inline__ void unprotect_jedec(volatile char *bios)
|
||||
{
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0x80;
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0x20;
|
||||
|
||||
usleep(200);
|
||||
}
|
||||
|
||||
extern __inline__ void protect_jedec(volatile char *bios)
|
||||
{
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
|
@ -45,60 +62,5 @@ extern __inline__ void protect_jedec (volatile char * bios)
|
|||
usleep(200);
|
||||
}
|
||||
|
||||
extern int erase_sector_jedec (volatile char * bios, unsigned int page);
|
||||
|
||||
extern __inline__ void write_page_jedec (volatile char * bios, char * src, volatile char * dst,
|
||||
int page_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0xA0;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
/* transfer data from source to destination */
|
||||
*dst++ = *src++;
|
||||
}
|
||||
|
||||
usleep(100);
|
||||
toggle_ready_jedec(dst-1);
|
||||
}
|
||||
|
||||
static __inline__ int write_sector_jedec(volatile char * bios,
|
||||
unsigned char * src,
|
||||
volatile unsigned char * dst,
|
||||
unsigned int page_size)
|
||||
{
|
||||
int i;
|
||||
volatile char *Temp;
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
if (*dst != 0xff) {
|
||||
printf("FATAL: dst %p not erased (val 0x%x\n", dst, *dst);
|
||||
return(-1);
|
||||
}
|
||||
/* transfer data from source to destination */
|
||||
if (*src == 0xFF) {
|
||||
dst++, src++;
|
||||
/* If the data is 0xFF, don't program it */
|
||||
continue;
|
||||
}
|
||||
Temp = (bios + 0x5555);
|
||||
*Temp = 0xAA;
|
||||
Temp = bios + 0x2AAA;
|
||||
*Temp = 0x55;
|
||||
Temp = bios + 0x5555;
|
||||
*Temp = 0xA0;
|
||||
*dst = *src;
|
||||
toggle_ready_jedec(bios);
|
||||
if (*dst != *src)
|
||||
printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
|
||||
(unsigned long)dst, *dst, *src);
|
||||
dst++, src++;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
#endif /* !__JEDEC_H__ */
|
||||
#endif /* !__JEDEC_H__ */
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
#include "flash.h"
|
||||
#include "m29f400bt.h"
|
||||
|
||||
int probe_m29f400bt (struct flashchip * flash)
|
||||
int probe_m29f400bt(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
|
||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
*(volatile char *) (bios + 0x555) = 0x55;
|
||||
|
@ -47,7 +47,7 @@ int probe_m29f400bt (struct flashchip * flash)
|
|||
|
||||
myusec_delay(10);
|
||||
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
|
||||
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||
|
@ -56,9 +56,9 @@ int probe_m29f400bt (struct flashchip * flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int erase_m29f400bt (struct flashchip * flash)
|
||||
int erase_m29f400bt(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
*(volatile char *) (bios + 0x555) = 0x55;
|
||||
|
@ -71,10 +71,10 @@ int erase_m29f400bt (struct flashchip * flash)
|
|||
myusec_delay(10);
|
||||
toggle_ready_m29f400bt(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int block_erase_m29f400bt (volatile char * bios ,volatile char * dst)
|
||||
int block_erase_m29f400bt(volatile char *bios, volatile char *dst)
|
||||
{
|
||||
|
||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
|
@ -84,22 +84,23 @@ int block_erase_m29f400bt (volatile char * bios ,volatile char * dst)
|
|||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
*(volatile char *) (bios + 0x555) = 0x55;
|
||||
//*(volatile char *) (bios + 0xAAA) = 0x10;
|
||||
*dst = 0x30;
|
||||
*dst = 0x30;
|
||||
|
||||
myusec_delay(10);
|
||||
toggle_ready_m29f400bt(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
||||
int write_m29f400bt(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
//erase_m29f400bt (flash);
|
||||
printf ("Programming Page:\n ");
|
||||
printf("Programming Page:\n ");
|
||||
/*********************************
|
||||
*Pages for M29F400BT:
|
||||
* 16 0x7c000 0x7ffff TOP
|
||||
|
@ -115,42 +116,47 @@ int write_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
|||
* 64 0x10000 0x1ffff
|
||||
* 64 0x00000 0x0ffff BOTTOM
|
||||
*********************************/
|
||||
printf("total_size/page_size = %d\n",total_size/page_size);
|
||||
for (i = 0; i < (total_size/page_size)-1; i++) {
|
||||
printf("total_size/page_size = %d\n", total_size / page_size);
|
||||
for (i = 0; i < (total_size / page_size) - 1; i++) {
|
||||
printf("%04d at address: 0x%08x\n", i, i * page_size);
|
||||
block_erase_m29f400bt(bios, bios + i * page_size);
|
||||
write_page_m29f400bt(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
write_page_m29f400bt(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
}
|
||||
|
||||
printf("%04d at address: 0x%08x\n",7,0x70000);
|
||||
block_erase_m29f400bt(bios , bios + 0x70000);
|
||||
write_page_m29f400bt(bios,buf + 0x70000, bios + 0x70000, 32*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",8,0x78000);
|
||||
block_erase_m29f400bt(bios , bios + 0x78000);
|
||||
write_page_m29f400bt(bios,buf + 0x78000, bios + 0x78000, 8*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",9,0x7a000);
|
||||
block_erase_m29f400bt(bios , bios + 0x7a000);
|
||||
write_page_m29f400bt(bios,buf + 0x7a000, bios + 0x7a000, 8*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",10,0x7c000);
|
||||
block_erase_m29f400bt(bios , bios + 0x7c000);
|
||||
write_page_m29f400bt(bios,buf + 0x7c000, bios + 0x7c000, 16*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 7, 0x70000);
|
||||
block_erase_m29f400bt(bios, bios + 0x70000);
|
||||
write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000,
|
||||
32 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 8, 0x78000);
|
||||
block_erase_m29f400bt(bios, bios + 0x78000);
|
||||
write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000,
|
||||
8 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 9, 0x7a000);
|
||||
block_erase_m29f400bt(bios, bios + 0x7a000);
|
||||
write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000,
|
||||
8 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 10, 0x7c000);
|
||||
block_erase_m29f400bt(bios, bios + 0x7c000);
|
||||
write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000,
|
||||
16 * 1024);
|
||||
|
||||
printf("\n");
|
||||
//protect_m29f400bt (bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_linuxbios_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
||||
int write_linuxbios_m29f400bt(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
printf ("Programming Page:\n ");
|
||||
printf("Programming Page:\n ");
|
||||
/*********************************
|
||||
*Pages for M29F400BT:
|
||||
* 16 0x7c000 0x7ffff TOP
|
||||
|
@ -166,24 +172,28 @@ int write_linuxbios_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
|||
* 64 0x10000 0x1ffff
|
||||
* 64 0x00000 0x0ffff BOTTOM
|
||||
*********************************/
|
||||
printf("%04d at address: 0x%08x\n",7,0x00000);
|
||||
block_erase_m29f400bt(bios , bios + 0x00000);
|
||||
write_page_m29f400bt(bios,buf + 0x00000, bios + 0x00000, 64*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",7,0x10000);
|
||||
block_erase_m29f400bt(bios , bios + 0x10000);
|
||||
write_page_m29f400bt(bios,buf + 0x10000, bios + 0x10000, 64*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",7,0x20000);
|
||||
block_erase_m29f400bt(bios , bios + 0x20000);
|
||||
write_page_m29f400bt(bios,buf + 0x20000, bios + 0x20000, 64*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n",7,0x30000);
|
||||
block_erase_m29f400bt(bios , bios + 0x30000);
|
||||
write_page_m29f400bt(bios,buf + 0x30000, bios + 0x30000, 64*1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 7, 0x00000);
|
||||
block_erase_m29f400bt(bios, bios + 0x00000);
|
||||
write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000,
|
||||
64 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 7, 0x10000);
|
||||
block_erase_m29f400bt(bios, bios + 0x10000);
|
||||
write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000,
|
||||
64 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 7, 0x20000);
|
||||
block_erase_m29f400bt(bios, bios + 0x20000);
|
||||
write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000,
|
||||
64 * 1024);
|
||||
|
||||
printf("%04d at address: 0x%08x\n", 7, 0x30000);
|
||||
block_erase_m29f400bt(bios, bios + 0x30000);
|
||||
write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000,
|
||||
64 * 1024);
|
||||
|
||||
printf("\n");
|
||||
//protect_m29f400bt (bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
extern int probe_m29f400bt (struct flashchip * flash);
|
||||
extern int erase_m29f400bt (struct flashchip * flash);
|
||||
extern int block_erase_m29f400bt (volatile char * bios, volatile char * dst);
|
||||
extern int write_m29f400bt (struct flashchip * flash, unsigned char * buf);
|
||||
extern int write_linuxbios_m29f400bt (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_m29f400bt(struct flashchip *flash);
|
||||
extern int erase_m29f400bt(struct flashchip *flash);
|
||||
extern int block_erase_m29f400bt(volatile char *bios, volatile char *dst);
|
||||
extern int write_m29f400bt(struct flashchip *flash, unsigned char *buf);
|
||||
extern int write_linuxbios_m29f400bt(struct flashchip *flash,
|
||||
unsigned char *buf);
|
||||
|
||||
extern __inline__ void toggle_ready_m29f400bt (volatile char * dst)
|
||||
extern __inline__ void toggle_ready_m29f400bt(volatile char *dst)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp1, tmp2;
|
||||
|
@ -25,7 +26,8 @@ extern __inline__ void toggle_ready_m29f400bt (volatile char * dst)
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void data_polling_m29f400bt (volatile char * dst, unsigned char data)
|
||||
extern __inline__ void data_polling_m29f400bt(volatile char *dst,
|
||||
unsigned char data)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char tmp;
|
||||
|
@ -40,7 +42,7 @@ extern __inline__ void data_polling_m29f400bt (volatile char * dst, unsigned cha
|
|||
}
|
||||
}
|
||||
|
||||
extern __inline__ void protect_m29f400bt (volatile char * bios)
|
||||
extern __inline__ void protect_m29f400bt(volatile char *bios)
|
||||
{
|
||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
*(volatile char *) (bios + 0x555) = 0x55;
|
||||
|
@ -49,11 +51,12 @@ extern __inline__ void protect_m29f400bt (volatile char * bios)
|
|||
usleep(200);
|
||||
}
|
||||
|
||||
extern __inline__ void write_page_m29f400bt (volatile char * bios, char * src, volatile char * dst,
|
||||
int page_size)
|
||||
extern __inline__ void write_page_m29f400bt(volatile char *bios, char *src,
|
||||
volatile char *dst,
|
||||
int page_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||
*(volatile char *) (bios + 0x555) = 0x55;
|
||||
|
@ -64,11 +67,13 @@ extern __inline__ void write_page_m29f400bt (volatile char * bios, char * src, v
|
|||
//*(volatile char *) (bios) = 0xF0;
|
||||
//usleep(5);
|
||||
toggle_ready_m29f400bt(dst);
|
||||
printf("Value in the flash at address %p = %#x, want %#x\n",(char *)(dst-bios), *dst, *src);
|
||||
printf
|
||||
("Value in the flash at address %p = %#x, want %#x\n",
|
||||
(char *) (dst - bios), *dst, *src);
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* !__M29F400BT_H__ */
|
||||
#endif /* !__M29F400BT_H__ */
|
||||
|
|
|
@ -40,14 +40,13 @@ static void doc_write_cdsncontrol(volatile char *bios, unsigned char data);
|
|||
|
||||
|
||||
|
||||
int
|
||||
probe_md2802(struct flashchip * flash)
|
||||
int probe_md2802(struct flashchip *flash)
|
||||
{
|
||||
volatile char *bios = flash->virt_addr;
|
||||
unsigned char chipid;
|
||||
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
|
||||
unsigned char id_0x55, id_0xAA;
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
int i, toggle_a, toggle_b;
|
||||
|
||||
printf("%s:\n", __FUNCTION__);
|
||||
|
@ -66,14 +65,15 @@ probe_md2802(struct flashchip * flash)
|
|||
doc_write(0x85, bios, DOCControl);
|
||||
doc_write(0x85, bios, DOCControl);
|
||||
doc_read_4nop(bios);
|
||||
if(doc_wait(bios, 5000))
|
||||
return(-1);
|
||||
if (doc_wait(bios, 5000))
|
||||
return (-1);
|
||||
printf("%s: switching off reset mode ... done\n", __FUNCTION__);
|
||||
printf("%s:\n", __FUNCTION__);
|
||||
|
||||
printf("%s: switching off write protection ...\n", __FUNCTION__);
|
||||
doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios)&(~0x08));
|
||||
printf("%s: switching off write protection ... done\n", __FUNCTION__);
|
||||
doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios) & (~0x08));
|
||||
printf("%s: switching off write protection ... done\n",
|
||||
__FUNCTION__);
|
||||
printf("%s:\n", __FUNCTION__);
|
||||
|
||||
|
||||
|
@ -81,129 +81,128 @@ probe_md2802(struct flashchip * flash)
|
|||
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
|
||||
id_0x55 = doc_read(bios, IPL_0x0000);
|
||||
id_0xAA = doc_read(bios, IPL_0x0001);
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
printf("%s: IPL_0x0000: 0x%02x\n", __FUNCTION__, id_0x55);
|
||||
printf("%s: IPL_0x0001: 0x%02x\n", __FUNCTION__, id_0xAA);
|
||||
printf("%s: IPL_0x0002: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, IPL_0x0002));
|
||||
doc_read(bios, IPL_0x0002));
|
||||
printf("%s: IPL_0x0003: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, IPL_0x0003));
|
||||
doc_read(bios, IPL_0x0003));
|
||||
printf("%s:\n", __FUNCTION__);
|
||||
printf("%s: ChipID: 0x%02x\n", __FUNCTION__, chipid);
|
||||
printf("%s: DOCStatus: 0x%02x\n", __FUNCTION__,
|
||||
doc_read_docstatus(bios));
|
||||
doc_read_docstatus(bios));
|
||||
printf("%s: FloorSelect: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, FloorSelect));
|
||||
doc_read(bios, FloorSelect));
|
||||
printf("%s: CDSNControl: 0x%02x\n", __FUNCTION__,
|
||||
doc_read_cdsncontrol(bios));
|
||||
doc_read_cdsncontrol(bios));
|
||||
printf("%s: CDSNDeviceSelect: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, CDSNDeviceSelect));
|
||||
doc_read(bios, CDSNDeviceSelect));
|
||||
printf("%s: ECCConfiguration: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCConfiguration));
|
||||
doc_read(bios, ECCConfiguration));
|
||||
printf("%s: CDSNSlowIO: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, CDSNSlowIO));
|
||||
doc_read(bios, CDSNSlowIO));
|
||||
printf("%s: ECCSyndrome0: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome0));
|
||||
doc_read(bios, ECCSyndrome0));
|
||||
printf("%s: ECCSyndrome1: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome1));
|
||||
doc_read(bios, ECCSyndrome1));
|
||||
printf("%s: ECCSyndrome2: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome2));
|
||||
doc_read(bios, ECCSyndrome2));
|
||||
printf("%s: ECCSyndrome3: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome3));
|
||||
doc_read(bios, ECCSyndrome3));
|
||||
printf("%s: ECCSyndrome4: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome4));
|
||||
doc_read(bios, ECCSyndrome4));
|
||||
printf("%s: ECCSyndrome5: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ECCSyndrome5));
|
||||
doc_read(bios, ECCSyndrome5));
|
||||
printf("%s: AliasResolution: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, AliasResolution));
|
||||
doc_read(bios, AliasResolution));
|
||||
printf("%s: ConfigurationInput: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ConfigurationInput));
|
||||
doc_read(bios, ConfigurationInput));
|
||||
printf("%s: ReadPipelineInitialization: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, ReadPipelineInitialization));
|
||||
doc_read(bios, ReadPipelineInitialization));
|
||||
printf("%s: LastDataRead: 0x%02x\n", __FUNCTION__,
|
||||
doc_read(bios, LastDataRead));
|
||||
doc_read(bios, LastDataRead));
|
||||
printf("%s:\n", __FUNCTION__);
|
||||
|
||||
printf("%s: checking ECCConfiguration toggle bit\n", __FUNCTION__);
|
||||
printf("%s:", __FUNCTION__);
|
||||
toggle_a = toggle_b = 0;
|
||||
for(i=0; i<10; i++)
|
||||
{
|
||||
for (i = 0; i < 10; i++) {
|
||||
unsigned char toggle = doc_toggle(bios);
|
||||
|
||||
printf(" 0x%02x", toggle);
|
||||
|
||||
if(i%2)
|
||||
if (i % 2)
|
||||
toggle_a += toggle;
|
||||
else
|
||||
toggle_b += toggle;
|
||||
} /* for(i=0; i<10; i++) */
|
||||
printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a, toggle_b);
|
||||
} /* for(i=0; i<10; i++) */
|
||||
printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a,
|
||||
toggle_b);
|
||||
|
||||
if(chipid == flash->model_id
|
||||
&& ((toggle_a==5 && toggle_b==0)||(toggle_a==0 && toggle_b==5))
|
||||
if (chipid == flash->model_id
|
||||
&& ((toggle_a == 5 && toggle_b == 0)
|
||||
|| (toggle_a == 0 && toggle_b == 5))
|
||||
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
|
||||
&& id_0x55 == 0x55 && id_0xAA == 0xaa
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
)
|
||||
{
|
||||
return(1);
|
||||
&& id_0x55 == 0x55 && id_0xAA == 0xaa
|
||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||
) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
} /* int probe_md2802(struct flashchip *flash) */
|
||||
return (0);
|
||||
} /* int probe_md2802(struct flashchip *flash) */
|
||||
|
||||
|
||||
|
||||
int
|
||||
read_md2802(struct flashchip *flash, unsigned char *buf)
|
||||
int read_md2802(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
|
||||
return(0);
|
||||
} /* int read_md2802(struct flashchip *flash, unsigned char *buf) */
|
||||
|
||||
return (0);
|
||||
} /* int read_md2802(struct flashchip *flash, unsigned char *buf) */
|
||||
|
||||
|
||||
|
||||
int
|
||||
erase_md2802(struct flashchip *flash)
|
||||
int erase_md2802(struct flashchip *flash)
|
||||
{
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
return(1);
|
||||
*(volatile char *)(bios + 0x5555) = 0xAA;
|
||||
*(volatile char *)(bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *)(bios + 0x5555) = 0x80;
|
||||
return (1);
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0x80;
|
||||
|
||||
*(volatile char *)(bios + 0x5555) = 0xAA;
|
||||
*(volatile char *)(bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *)(bios + 0x5555) = 0x10;
|
||||
} /* int erase_md2802(struct flashchip *flash) */
|
||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||
*(volatile char *) (bios + 0x5555) = 0x10;
|
||||
} /* int erase_md2802(struct flashchip *flash) */
|
||||
|
||||
|
||||
|
||||
int
|
||||
write_md2802(struct flashchip *flash, unsigned char *buf)
|
||||
int write_md2802(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
||||
volatile unsigned char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile unsigned char *bios = flash->virt_addr;
|
||||
|
||||
return(1);
|
||||
erase_md2802 (flash);
|
||||
if (*bios != (unsigned char ) 0xff) {
|
||||
return (1);
|
||||
erase_md2802(flash);
|
||||
if (*bios != (unsigned char) 0xff) {
|
||||
printf("ERASE FAILED\n");
|
||||
return -1;
|
||||
}
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
//write_page_md2802(bios, buf + i * page_size, bios + i * page_size, page_size);
|
||||
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");
|
||||
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");
|
||||
}
|
||||
printf("\n");
|
||||
//protect_md2802(bios);
|
||||
|
||||
} /* int write_md2802(struct flashchip *flash, char *buf) */
|
||||
} /* int write_md2802(struct flashchip *flash, char *buf) */
|
||||
|
||||
|
||||
|
||||
|
@ -216,74 +215,67 @@ write_md2802(struct flashchip *flash, unsigned char *buf)
|
|||
0: ready
|
||||
-1: timeout expired
|
||||
*/
|
||||
static int
|
||||
doc_wait(volatile char *bios, int timeout)
|
||||
static int doc_wait(volatile char *bios, int timeout)
|
||||
{
|
||||
int i = 20;
|
||||
|
||||
doc_read_4nop(bios);
|
||||
|
||||
while(_doc_busy(bios) && (i != 0))
|
||||
{
|
||||
usleep(timeout*1000/20);
|
||||
while (_doc_busy(bios) && (i != 0)) {
|
||||
usleep(timeout * 1000 / 20);
|
||||
i--;
|
||||
}
|
||||
|
||||
doc_read_2nop(bios);
|
||||
|
||||
if(_doc_busy(bios))
|
||||
{
|
||||
if (_doc_busy(bios)) {
|
||||
doc_read_2nop(bios);
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
} /* static int doc_wait(volatile char *bios, int timeout) */
|
||||
return (0);
|
||||
} /* static int doc_wait(volatile char *bios, int timeout) */
|
||||
|
||||
|
||||
|
||||
static unsigned char
|
||||
doc_read_docstatus(volatile char *bios)
|
||||
static unsigned char doc_read_docstatus(volatile char *bios)
|
||||
{
|
||||
doc_read(bios, CDSNSlowIO);
|
||||
doc_read_2nop(bios);
|
||||
|
||||
return(doc_read(bios, _DOCStatus));
|
||||
} /* static unsigned char doc_read_docstatus(volatile char *bios) */
|
||||
return (doc_read(bios, _DOCStatus));
|
||||
} /* static unsigned char doc_read_docstatus(volatile char *bios) */
|
||||
|
||||
|
||||
|
||||
static unsigned char
|
||||
doc_read_chipid(volatile char *bios)
|
||||
static unsigned char doc_read_chipid(volatile char *bios)
|
||||
{
|
||||
doc_read(bios, CDSNSlowIO);
|
||||
doc_read_2nop(bios);
|
||||
|
||||
return(doc_read(bios, _ChipID));
|
||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||
return (doc_read(bios, _ChipID));
|
||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||
|
||||
|
||||
|
||||
static unsigned char
|
||||
doc_read_cdsncontrol(volatile char *bios)
|
||||
static unsigned char doc_read_cdsncontrol(volatile char *bios)
|
||||
{
|
||||
unsigned char value;
|
||||
|
||||
/* the delays might be necessary when reading the busy bit,
|
||||
but because a read to this reg reads the busy bit
|
||||
anyway we better do this delays... */
|
||||
but because a read to this reg reads the busy bit
|
||||
anyway we better do this delays... */
|
||||
doc_read_4nop(bios);
|
||||
value = doc_read(bios, _CDSNControl);
|
||||
doc_read_2nop(bios);
|
||||
|
||||
return(value);
|
||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||
return (value);
|
||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||
|
||||
|
||||
|
||||
static void
|
||||
doc_write_cdsncontrol(volatile char *bios, unsigned char data)
|
||||
static void doc_write_cdsncontrol(volatile char *bios, unsigned char data)
|
||||
{
|
||||
doc_write(data, bios, _CDSNControl);
|
||||
doc_read_4nop(bios);
|
||||
} /* static void doc_write_chipid(volatile char *bios, unsigned char data) */
|
||||
} /* static void doc_write_chipid(volatile char *bios, unsigned char data) */
|
||||
|
|
|
@ -107,4 +107,4 @@ extern int write_md2802(struct flashchip *flash, unsigned char *buf);
|
|||
|
||||
|
||||
|
||||
#endif /* !__MSYS_DOC_H__ */
|
||||
#endif /* !__MSYS_DOC_H__ */
|
||||
|
|
|
@ -30,18 +30,18 @@
|
|||
#include "jedec.h"
|
||||
#include "mx29f002.h"
|
||||
|
||||
int probe_29f002 (struct flashchip * flash)
|
||||
int probe_29f002(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2;
|
||||
|
||||
*(bios + 0x5555) = 0xAA;
|
||||
*(bios + 0x2AAA) = 0x55;
|
||||
*(bios + 0x5555) = 0x90;
|
||||
|
||||
|
||||
id1 = *(volatile unsigned char *) bios;
|
||||
id2 = *(volatile unsigned char *) (bios + 0x01);
|
||||
|
||||
|
||||
*bios = 0xF0;
|
||||
|
||||
myusec_delay(10);
|
||||
|
@ -53,9 +53,9 @@ int probe_29f002 (struct flashchip * flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int erase_29f002 (struct flashchip * flash)
|
||||
int erase_29f002(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
*(bios + 0x555) = 0xF0;
|
||||
*(bios + 0x555) = 0xAA;
|
||||
|
@ -81,39 +81,39 @@ int erase_29f002 (struct flashchip * flash)
|
|||
*(bios + 0x3bfff) = 0x30;
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_29f002 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_29f002(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char * dst = bios;
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
volatile char *dst = bios;
|
||||
|
||||
*bios = 0xF0;
|
||||
myusec_delay(10);
|
||||
erase_29f002(flash);
|
||||
//*bios = 0xF0;
|
||||
*bios = 0xF0;
|
||||
myusec_delay(10);
|
||||
erase_29f002(flash);
|
||||
//*bios = 0xF0;
|
||||
#if 1
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size; i++) {
|
||||
/* write to the sector */
|
||||
if ((i & 0xfff) == 0)
|
||||
printf ("address: 0x%08lx", (unsigned long)i);
|
||||
*(bios + 0x5555) = 0xAA;
|
||||
*(bios + 0x2AAA) = 0x55;
|
||||
*(bios + 0x5555) = 0xA0;
|
||||
*dst++ = *buf++;
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size; i++) {
|
||||
/* write to the sector */
|
||||
if ((i & 0xfff) == 0)
|
||||
printf("address: 0x%08lx", (unsigned long) i);
|
||||
*(bios + 0x5555) = 0xAA;
|
||||
*(bios + 0x2AAA) = 0x55;
|
||||
*(bios + 0x5555) = 0xA0;
|
||||
*dst++ = *buf++;
|
||||
|
||||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(dst);
|
||||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(dst);
|
||||
|
||||
if ((i & 0xfff) == 0)
|
||||
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
}
|
||||
if ((i & 0xfff) == 0)
|
||||
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
}
|
||||
#endif
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __MX29F002_H__
|
||||
#define __MX29F002_H__ 1
|
||||
|
||||
extern int probe_29f002 (struct flashchip * flash);
|
||||
extern int erase_29f002 (struct flashchip * flash);
|
||||
extern int write_29f002 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_29f002(struct flashchip *flash);
|
||||
extern int erase_29f002(struct flashchip *flash);
|
||||
extern int write_29f002(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__MX29F002_H__ */
|
||||
#endif /* !__MX29F002_H__ */
|
||||
|
|
|
@ -31,37 +31,38 @@
|
|||
#define RESET 0xFF
|
||||
#define READ_ID 0x90
|
||||
|
||||
static __inline__ int erase_block_49fl004 ( volatile unsigned char * bios ,unsigned long address)
|
||||
static __inline__ int erase_block_49fl004(volatile unsigned char *bios,
|
||||
unsigned long address)
|
||||
{
|
||||
volatile unsigned char *Temp;
|
||||
volatile unsigned char *Temp;
|
||||
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + address; /* set up address to be C000:5555h */
|
||||
*Temp = 0x50; /* write data 0x50 to the address */
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0x80; /* write data 0x80 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
||||
*Temp = 0x55; /* write data 0x55 to the address */
|
||||
myusec_delay(10);
|
||||
Temp = bios + address; /* set up address to be C000:5555h */
|
||||
*Temp = 0x50; /* write data 0x50 to the address */
|
||||
|
||||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios);
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static __inline__ int write_block_49fl004(volatile char * bios,
|
||||
unsigned char * src,
|
||||
volatile unsigned char * dst,
|
||||
static __inline__ int write_block_49fl004(volatile char *bios,
|
||||
unsigned char *src,
|
||||
volatile unsigned char *dst,
|
||||
unsigned int page_size)
|
||||
{
|
||||
int i;
|
||||
|
@ -69,8 +70,9 @@ static __inline__ int write_block_49fl004(volatile char * bios,
|
|||
|
||||
for (i = 0; i < page_size; i++) {
|
||||
if (*dst != 0xff) {
|
||||
printf("FATAL: dst %p not erased (val 0x%x\n", dst, *dst);
|
||||
return(-1);
|
||||
printf("FATAL: dst %p not erased (val 0x%x\n", dst,
|
||||
*dst);
|
||||
return (-1);
|
||||
}
|
||||
/* transfer data from source to destination */
|
||||
if (*src == 0xFF) {
|
||||
|
@ -78,42 +80,44 @@ static __inline__ int write_block_49fl004(volatile char * bios,
|
|||
/* If the data is 0xFF, don't program it */
|
||||
continue;
|
||||
}
|
||||
Temp = (bios + 0x5555);
|
||||
*Temp = 0xAA;
|
||||
Temp = bios + 0x2AAA;
|
||||
*Temp = 0x55;
|
||||
Temp = bios + 0x5555;
|
||||
*Temp = 0xA0;
|
||||
Temp = (bios + 0x5555);
|
||||
*Temp = 0xAA;
|
||||
Temp = bios + 0x2AAA;
|
||||
*Temp = 0x55;
|
||||
Temp = bios + 0x5555;
|
||||
*Temp = 0xA0;
|
||||
*dst = *src;
|
||||
toggle_ready_jedec(bios);
|
||||
if (*dst != *src)
|
||||
printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
|
||||
(unsigned long)dst, *dst, *src);
|
||||
(unsigned long) dst, *dst, *src);
|
||||
dst++, src++;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_49fl004 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_49fl004(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
/* erase the page before programming */
|
||||
erase_block_49fl004(bios, i * page_size);
|
||||
|
||||
/* write to the sector */
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_block_49fl004(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
fflush(stdout);
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_block_49fl004(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
fflush(stdout);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __PM49FL004_H__
|
||||
#define __PM49FL004_H__ 1
|
||||
|
||||
extern int probe_49fl004 (struct flashchip * flash);
|
||||
extern int erase_49fl004 (struct flashchip * flash);
|
||||
extern int write_49fl004 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_49fl004(struct flashchip *flash);
|
||||
extern int erase_49fl004(struct flashchip *flash);
|
||||
extern int write_49fl004(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define RESET 0xFF
|
||||
#define READ_ID 0x90
|
||||
|
||||
static __inline__ void protect_28sf040 (volatile char * bios)
|
||||
static __inline__ void protect_28sf040(volatile char *bios)
|
||||
{
|
||||
/* ask compiler not to optimize this */
|
||||
volatile unsigned char tmp;
|
||||
|
@ -50,7 +50,7 @@ static __inline__ void protect_28sf040 (volatile char * bios)
|
|||
tmp = *(volatile unsigned char *) (bios + 0x040A);
|
||||
}
|
||||
|
||||
static __inline__ void unprotect_28sf040 (volatile char * bios)
|
||||
static __inline__ void unprotect_28sf040(volatile char *bios)
|
||||
{
|
||||
/* ask compiler not to optimize this */
|
||||
volatile unsigned char tmp;
|
||||
|
@ -64,7 +64,8 @@ static __inline__ void unprotect_28sf040 (volatile char * bios)
|
|||
tmp = *(volatile unsigned char *) (bios + 0x041A);
|
||||
}
|
||||
|
||||
static __inline__ int erase_sector_28sf040 (volatile char * bios, unsigned long address)
|
||||
static __inline__ int erase_sector_28sf040(volatile char *bios,
|
||||
unsigned long address)
|
||||
{
|
||||
*bios = AUTO_PG_ERASE1;
|
||||
*(bios + address) = AUTO_PG_ERASE2;
|
||||
|
@ -72,11 +73,13 @@ static __inline__ int erase_sector_28sf040 (volatile char * bios, unsigned long
|
|||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static __inline__ int write_sector_28sf040(volatile char * bios, unsigned char * src,
|
||||
volatile unsigned char * dst, unsigned int page_size)
|
||||
static __inline__ int write_sector_28sf040(volatile char *bios,
|
||||
unsigned char *src,
|
||||
volatile unsigned char *dst,
|
||||
unsigned int page_size)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -88,20 +91,20 @@ static __inline__ int write_sector_28sf040(volatile char * bios, unsigned char *
|
|||
continue;
|
||||
}
|
||||
/*issue AUTO PROGRAM command */
|
||||
*dst = AUTO_PGRM;
|
||||
*dst = AUTO_PGRM;
|
||||
*dst++ = *src++;
|
||||
|
||||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int probe_28sf040 (struct flashchip * flash)
|
||||
int probe_28sf040(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
unsigned char id1, id2, tmp;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
unsigned char id1, id2, tmp;
|
||||
|
||||
/* save the value at the beginning of the Flash */
|
||||
tmp = *bios;
|
||||
|
@ -118,7 +121,7 @@ int probe_28sf040 (struct flashchip * flash)
|
|||
*bios = RESET;
|
||||
myusec_delay(10);
|
||||
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__ , id1, id2);
|
||||
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
|
||||
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||
return 1;
|
||||
|
||||
|
@ -127,43 +130,45 @@ int probe_28sf040 (struct flashchip * flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int erase_28sf040 (struct flashchip * flash)
|
||||
int erase_28sf040(struct flashchip *flash)
|
||||
{
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
unprotect_28sf040 (bios);
|
||||
unprotect_28sf040(bios);
|
||||
*bios = CHIP_ERASE;
|
||||
*bios = CHIP_ERASE;
|
||||
protect_28sf040 (bios);
|
||||
protect_28sf040(bios);
|
||||
|
||||
myusec_delay(10);
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_28sf040 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_28sf040(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
unprotect_28sf040 (bios);
|
||||
unprotect_28sf040(bios);
|
||||
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
/* erase the page before programming */
|
||||
erase_sector_28sf040(bios, i * page_size);
|
||||
|
||||
/* write to the sector */
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_sector_28sf040(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_sector_28sf040(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
protect_28sf040 (bios);
|
||||
protect_28sf040(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __SST28SF040_H__
|
||||
#define __SST28SF040_H__
|
||||
|
||||
extern int probe_28sf040 (struct flashchip * flash);
|
||||
extern int erase_28sf040 (struct flashchip * flash);
|
||||
extern int write_28sf040 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_28sf040(struct flashchip *flash);
|
||||
extern int erase_28sf040(struct flashchip *flash);
|
||||
extern int write_28sf040(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__SST28SF040_H__ */
|
||||
#endif /* !__SST28SF040_H__ */
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
#define RESET 0xFF
|
||||
#define READ_ID 0x90
|
||||
|
||||
static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long address)
|
||||
static __inline__ int erase_sector_39sf020(volatile char *bios,
|
||||
unsigned long address)
|
||||
{
|
||||
*bios = AUTO_PG_ERASE1;
|
||||
*(bios + address) = AUTO_PG_ERASE2;
|
||||
|
@ -47,30 +48,32 @@ static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long
|
|||
/* wait for Toggle bit ready */
|
||||
toggle_ready_jedec(bios);
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int write_39sf020 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_39sf020(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
erase_jedec(flash);
|
||||
erase_chip_jedec(flash);
|
||||
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
/* erase the page before programming */
|
||||
//erase_sector_39sf020(bios, i * page_size);
|
||||
|
||||
/* write to the sector */
|
||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_sector_jedec(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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");
|
||||
fflush(stdout);
|
||||
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||
write_sector_jedec(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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");
|
||||
fflush(stdout);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __SST39SF020_H__
|
||||
#define __SST39SF020_H__ 1
|
||||
|
||||
extern int probe_39sf020 (struct flashchip * flash);
|
||||
extern int write_39sf020 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_39sf020(struct flashchip *flash);
|
||||
extern int write_39sf020(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__SST39SF020_H__ */
|
||||
#endif /* !__SST39SF020_H__ */
|
||||
|
|
|
@ -38,27 +38,29 @@
|
|||
#define READ_ID 0x90
|
||||
|
||||
|
||||
int write_49lf040 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_49lf040(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
int total_size = flash->total_size * 1024, page_size =
|
||||
flash->page_size;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
|
||||
printf ("Programming Page: ");
|
||||
for (i = 0; i < total_size/page_size; i++) {
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size / page_size; i++) {
|
||||
/* erase the page before programming
|
||||
* Chip erase only works in parallel programming mode for the 49lf040.
|
||||
* Use sector-erase instead */
|
||||
erase_sector_jedec(bios, i * page_size);
|
||||
|
||||
/* write to the sector */
|
||||
printf ("%04d at address: 0x%08x ", i, i * page_size);
|
||||
write_sector_jedec(bios, buf + i * page_size, bios + i * page_size,
|
||||
page_size);
|
||||
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\b");
|
||||
fflush(stdout);
|
||||
printf("%04d at address: 0x%08x ", i, i * page_size);
|
||||
write_sector_jedec(bios, buf + i * page_size,
|
||||
bios + i * page_size, page_size);
|
||||
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\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __SST49LF040_H__
|
||||
#define __SST49LF040_H__ 1
|
||||
|
||||
extern int probe_49lf040 (struct flashchip * flash);
|
||||
extern int erase_49lf040 (struct flashchip * flash);
|
||||
extern int write_49lf040 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_49lf040(struct flashchip *flash);
|
||||
extern int erase_49lf040(struct flashchip *flash);
|
||||
extern int write_49lf040(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__SST49LF040_H__ */
|
||||
#endif /* !__SST49LF040_H__ */
|
||||
|
|
|
@ -7,8 +7,7 @@ unsigned long micro = 1;
|
|||
void myusec_delay(int time)
|
||||
{
|
||||
volatile unsigned long i;
|
||||
for (i = 0; i < time * micro; i++)
|
||||
;
|
||||
for (i = 0; i < time * micro; i++);
|
||||
}
|
||||
|
||||
void myusec_calibrate_delay()
|
||||
|
@ -23,10 +22,10 @@ void myusec_calibrate_delay()
|
|||
gettimeofday(&start, 0);
|
||||
myusec_delay(count);
|
||||
gettimeofday(&end, 0);
|
||||
timeusec = 1000000 * (end.tv_sec - start.tv_sec ) +
|
||||
(end.tv_usec - start.tv_usec);
|
||||
timeusec = 1000000 * (end.tv_sec - start.tv_sec) +
|
||||
(end.tv_usec - start.tv_usec);
|
||||
count *= 2;
|
||||
if (timeusec < 1000000/4)
|
||||
if (timeusec < 1000000 / 4)
|
||||
continue;
|
||||
ok = 1;
|
||||
}
|
||||
|
@ -34,5 +33,5 @@ void myusec_calibrate_delay()
|
|||
// compute one microsecond. That will be count / time
|
||||
micro = count / timeusec;
|
||||
|
||||
fprintf(stderr, "%ldM loops per second\n", (unsigned long)micro);
|
||||
fprintf(stderr, "%ldM loops per second\n", (unsigned long) micro);
|
||||
}
|
||||
|
|
|
@ -32,20 +32,20 @@
|
|||
#include "jedec.h"
|
||||
#include "w49f002u.h"
|
||||
|
||||
int write_49f002 (struct flashchip * flash, unsigned char * buf)
|
||||
int write_49f002(struct flashchip *flash, unsigned char *buf)
|
||||
{
|
||||
int i;
|
||||
int total_size = flash->total_size * 1024;
|
||||
volatile char * bios = flash->virt_addr;
|
||||
volatile char * dst = bios;
|
||||
volatile char *bios = flash->virt_addr;
|
||||
volatile char *dst = bios;
|
||||
|
||||
erase_jedec(flash);
|
||||
erase_chip_jedec(flash);
|
||||
|
||||
printf ("Programming Page: ");
|
||||
printf("Programming Page: ");
|
||||
for (i = 0; i < total_size; i++) {
|
||||
/* write to the sector */
|
||||
if ((i & 0xfff) == 0)
|
||||
printf ("address: 0x%08lx", (unsigned long)i);
|
||||
printf("address: 0x%08lx", (unsigned long) i);
|
||||
*(bios + 0x5555) = 0xAA;
|
||||
*(bios + 0x2AAA) = 0x55;
|
||||
*(bios + 0x5555) = 0xA0;
|
||||
|
@ -55,9 +55,9 @@ int write_49f002 (struct flashchip * flash, unsigned char * buf)
|
|||
toggle_ready_jedec(dst);
|
||||
|
||||
if ((i & 0xfff) == 0)
|
||||
printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef __W49F002U_H__
|
||||
#define __W49F002U_H__ 1
|
||||
|
||||
extern int probe_49f002 (struct flashchip * flash);
|
||||
extern int erase_49f002 (struct flashchip * flash);
|
||||
extern int write_49f002 (struct flashchip * flash, unsigned char * buf);
|
||||
extern int probe_49f002(struct flashchip *flash);
|
||||
extern int erase_49f002(struct flashchip *flash);
|
||||
extern int write_49f002(struct flashchip *flash, unsigned char *buf);
|
||||
|
||||
#endif /* !__W49F002U_H__ */
|
||||
#endif /* !__W49F002U_H__ */
|
||||
|
|
Loading…
Reference in New Issue