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,9 +47,9 @@ void print_82802ab_status(unsigned char status)
|
|||||||
printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:");
|
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;
|
volatile unsigned char *bios = flash->virt_addr;
|
||||||
unsigned char id1, id2;
|
unsigned char id1, id2;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -79,7 +79,7 @@ int probe_82802ab (struct flashchip * flash)
|
|||||||
if (id1 == flash->manufacture_id && id2 == flash->model_id) {
|
if (id1 == flash->manufacture_id && id2 == flash->model_id) {
|
||||||
size_t size = flash->total_size * 1024;
|
size_t size = flash->total_size * 1024;
|
||||||
// we need to mmap the write-protect space.
|
// we need to mmap the write-protect space.
|
||||||
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||||
flash->fd_mem, (off_t) (0 - 0x400000 - size));
|
flash->fd_mem, (off_t) (0 - 0x400000 - size));
|
||||||
if (bios == MAP_FAILED) {
|
if (bios == MAP_FAILED) {
|
||||||
// it's this part but we can't map it ...
|
// it's this part but we can't map it ...
|
||||||
@ -94,7 +94,7 @@ int probe_82802ab (struct flashchip * flash)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char wait_82802ab(volatile unsigned char * bios)
|
unsigned char wait_82802ab(volatile unsigned char *bios)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char status;
|
unsigned char status;
|
||||||
@ -102,8 +102,7 @@ unsigned char wait_82802ab(volatile unsigned char * bios)
|
|||||||
|
|
||||||
*bios = 0x70;
|
*bios = 0x70;
|
||||||
if ((*bios & 0x80) == 0) { // it's busy
|
if ((*bios & 0x80) == 0) { // it's busy
|
||||||
while ((*bios & 0x80) == 0)
|
while ((*bios & 0x80) == 0);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = *bios;
|
status = *bios;
|
||||||
@ -125,8 +124,9 @@ unsigned char wait_82802ab(volatile unsigned char * bios)
|
|||||||
}
|
}
|
||||||
int erase_82802ab_block(struct flashchip *flash, int offset)
|
int erase_82802ab_block(struct flashchip *flash, int offset)
|
||||||
{
|
{
|
||||||
volatile unsigned char * bios = flash->virt_addr + offset;
|
volatile unsigned char *bios = flash->virt_addr + offset;
|
||||||
volatile unsigned char *wrprotect = flash->virt_addr_2 + offset + 2;
|
volatile unsigned char *wrprotect =
|
||||||
|
flash->virt_addr_2 + offset + 2;
|
||||||
unsigned char status;
|
unsigned char status;
|
||||||
|
|
||||||
// clear status register
|
// clear status register
|
||||||
@ -146,22 +146,22 @@ int erase_82802ab_block(struct flashchip *flash, int offset)
|
|||||||
status = wait_82802ab(flash->virt_addr);
|
status = wait_82802ab(flash->virt_addr);
|
||||||
//print_82802ab_status(status);
|
//print_82802ab_status(status);
|
||||||
printf("DONE BLOCK 0x%x\n", offset);
|
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;
|
int i;
|
||||||
unsigned int total_size = flash->total_size * 1024;
|
unsigned int total_size = flash->total_size * 1024;
|
||||||
|
|
||||||
printf("total_size is %d; flash->page_size is %d\n",
|
printf("total_size is %d; flash->page_size is %d\n",
|
||||||
total_size, flash->page_size);
|
total_size, flash->page_size);
|
||||||
for(i = 0; i < total_size; i += flash->page_size)
|
for (i = 0; i < total_size; i += flash->page_size)
|
||||||
erase_82802ab_block(flash, i);
|
erase_82802ab_block(flash, i);
|
||||||
printf("DONE ERASE\n");
|
printf("DONE ERASE\n");
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_page_82802ab (volatile char * bios, char * src, volatile char * dst,
|
void write_page_82802ab(volatile char *bios, char *src, volatile char *dst,
|
||||||
int page_size)
|
int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -175,25 +175,27 @@ void write_page_82802ab (volatile char * bios, char * src, volatile char * dst,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_82802ab (struct flashchip * flash, unsigned char * buf)
|
int write_82802ab(struct flashchip *flash, unsigned char *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile unsigned char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile unsigned char *bios = flash->virt_addr;
|
||||||
|
|
||||||
erase_82802ab (flash);
|
erase_82802ab(flash);
|
||||||
if (*bios != 0xff) {
|
if (*bios != 0xff) {
|
||||||
printf("ERASE FAILED\n");
|
printf("ERASE FAILED\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_page_82802ab(bios, buf + i * page_size, bios + i * page_size,
|
write_page_82802ab(bios, buf + i * page_size,
|
||||||
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");
|
printf("\n");
|
||||||
protect_82802ab (bios);
|
protect_82802ab(bios);
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef __82802AB_H__
|
#ifndef __82802AB_H__
|
||||||
#define __82802AB_H__ 1
|
#define __82802AB_H__ 1
|
||||||
|
|
||||||
extern int probe_82802ab (struct flashchip * flash);
|
extern int probe_82802ab(struct flashchip *flash);
|
||||||
extern int erase_82802ab (struct flashchip * flash);
|
extern int erase_82802ab(struct flashchip *flash);
|
||||||
extern int write_82802ab (struct flashchip * flash, unsigned char * buf);
|
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;
|
unsigned int i = 0;
|
||||||
char tmp1, tmp2;
|
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;
|
unsigned int i = 0;
|
||||||
char tmp;
|
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 + 0x5555) = 0xAA;
|
||||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "jedec.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 + 0x555) = 0xAA;
|
||||||
*(bios + 0x2AA) = 0x55;
|
*(bios + 0x2AA) = 0x55;
|
||||||
@ -42,16 +43,19 @@ static __inline__ int erase_sector_29f040b (volatile char * bios, unsigned long
|
|||||||
/* wait for Toggle bit ready */
|
/* wait for Toggle bit ready */
|
||||||
toggle_ready_jedec(bios + address);
|
toggle_ready_jedec(bios + address);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int write_sector_29f040b(volatile char * bios, unsigned char * src,
|
static __inline__ int write_sector_29f040b(volatile char *bios,
|
||||||
volatile unsigned char * dst, unsigned int page_size)
|
unsigned char *src,
|
||||||
|
volatile unsigned char *dst,
|
||||||
|
unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < page_size; 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 + 0x555) = 0xAA;
|
||||||
*(bios + 0x2AA) = 0x55;
|
*(bios + 0x2AA) = 0x55;
|
||||||
@ -64,20 +68,20 @@ static __inline__ int write_sector_29f040b(volatile char * bios, unsigned char *
|
|||||||
printf("\b\b\b\b\b\b\b\b\b\b");
|
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;
|
unsigned char id1, id2;
|
||||||
|
|
||||||
*(bios + 0x555) = 0xAA;
|
*(bios + 0x555) = 0xAA;
|
||||||
*(bios + 0x2AA) = 0x55;
|
*(bios + 0x2AA) = 0x55;
|
||||||
*(bios + 0x555) = 0x90;
|
*(bios + 0x555) = 0x90;
|
||||||
|
|
||||||
id1 = * bios;
|
id1 = *bios;
|
||||||
id2 = * (bios + 0x01);
|
id2 = *(bios + 0x01);
|
||||||
|
|
||||||
*bios = 0xF0;
|
*bios = 0xF0;
|
||||||
|
|
||||||
@ -90,9 +94,9 @@ int probe_29f040b (struct flashchip * flash)
|
|||||||
return 0;
|
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 + 0x555) = 0xAA;
|
||||||
*(bios + 0x2AA) = 0x55;
|
*(bios + 0x2AA) = 0x55;
|
||||||
@ -104,27 +108,28 @@ int erase_29f040b (struct flashchip * flash)
|
|||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
toggle_ready_jedec(bios);
|
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 i;
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
erase_sector_29f040b(bios, i * page_size);
|
erase_sector_29f040b(bios, i * page_size);
|
||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf ("%04d at address: ", i);
|
printf("%04d at address: ", i);
|
||||||
write_sector_29f040b(bios, buf + i * page_size, bios + i * page_size,
|
write_sector_29f040b(bios, buf + i * page_size,
|
||||||
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("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __AM29F040B_H__
|
#ifndef __AM29F040B_H__
|
||||||
#define __AM29F040B_H__ 1
|
#define __AM29F040B_H__ 1
|
||||||
|
|
||||||
extern int probe_29f040b (struct flashchip * flash);
|
extern int probe_29f040b(struct flashchip *flash);
|
||||||
extern int erase_29f040b (struct flashchip * flash);
|
extern int erase_29f040b(struct flashchip *flash);
|
||||||
extern int write_29f040b (struct flashchip * flash, unsigned char * buf);
|
extern int write_29f040b(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif /* !__AM29F040B_H__ */
|
#endif /* !__AM29F040B_H__ */
|
||||||
|
@ -5,18 +5,18 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
struct flashchip {
|
struct flashchip {
|
||||||
char * name;
|
char *name;
|
||||||
int manufacture_id;
|
int manufacture_id;
|
||||||
int model_id;
|
int model_id;
|
||||||
|
|
||||||
volatile char * virt_addr;
|
volatile char *virt_addr;
|
||||||
int total_size;
|
int total_size;
|
||||||
int page_size;
|
int page_size;
|
||||||
|
|
||||||
int (*probe) (struct flashchip * flash);
|
int (*probe) (struct flashchip * flash);
|
||||||
int (*erase) (struct flashchip * flash);
|
int (*erase) (struct flashchip * flash);
|
||||||
int (*write) (struct flashchip * flash, unsigned char * buf);
|
int (*write) (struct flashchip * flash, unsigned char *buf);
|
||||||
int (*read) (struct flashchip * flash, unsigned char * buf);
|
int (*read) (struct flashchip * flash, unsigned char *buf);
|
||||||
|
|
||||||
int fd_mem;
|
int fd_mem;
|
||||||
volatile char *virt_addr_2;
|
volatile char *virt_addr_2;
|
||||||
@ -26,7 +26,7 @@ struct flashchip {
|
|||||||
#define AM_29F040B 0xA4
|
#define AM_29F040B 0xA4
|
||||||
|
|
||||||
#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
|
#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
|
||||||
#define AT_29C040A 0xA4 /* Winbond w29c020c device code*/
|
#define AT_29C040A 0xA4 /* Winbond w29c020c device code */
|
||||||
|
|
||||||
#define MX_ID 0xC2
|
#define MX_ID 0xC2
|
||||||
#define MX_29F002 0xB0
|
#define MX_29F002 0xB0
|
||||||
@ -38,18 +38,18 @@ struct flashchip {
|
|||||||
#define SST_39VF020 0xD6 /* SST 39VF020 device */
|
#define SST_39VF020 0xD6 /* SST 39VF020 device */
|
||||||
#define SST_49LF040 0x51 /* SST 49LF040 device */
|
#define SST_49LF040 0x51 /* SST 49LF040 device */
|
||||||
#define SST_49LF080A 0x5B /* SST 48LF080A device */
|
#define SST_49LF080A 0x5B /* SST 48LF080A device */
|
||||||
#define SST_49LF002A 0x57 /* SST 49LF002A device*/
|
#define SST_49LF002A 0x57 /* SST 49LF002A device */
|
||||||
#define SST_49LF003A 0x1B /* SST 49LF003A device*/
|
#define SST_49LF003A 0x1B /* SST 49LF003A device */
|
||||||
#define SST_49LF004A 0x60 /* SST 49LF004A device*/
|
#define SST_49LF004A 0x60 /* SST 49LF004A device */
|
||||||
#define SST_49LF008A 0x5A /* SST 49LF008A device*/
|
#define SST_49LF008A 0x5A /* SST 49LF008A device */
|
||||||
|
|
||||||
#define PMC_ID 0x9D /* PMC Manufacturer ID[B code */
|
#define PMC_ID 0x9D /* PMC Manufacturer ID[B code */
|
||||||
#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
|
#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
|
||||||
|
|
||||||
#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
|
#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
|
||||||
#define W_29C011 0xC1 /* Winbond w29c011 device code*/
|
#define W_29C011 0xC1 /* Winbond w29c011 device code */
|
||||||
#define W_29C020C 0x45 /* Winbond w29c020c device code*/
|
#define W_29C020C 0x45 /* Winbond w29c020c device code */
|
||||||
#define W_49F002U 0x0B /* 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 ST_M29F400BT 0xD5
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
#include <stdlib.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;
|
char b;
|
||||||
|
|
||||||
@ -75,7 +75,8 @@ static int enable_flash_e7500(struct pci_dev *dev, char *name)
|
|||||||
pci_write_byte(dev, 0x4e, new);
|
pci_write_byte(dev, 0x4e, new);
|
||||||
|
|
||||||
if (pci_read_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",
|
printf
|
||||||
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x4e, new, name);
|
0x4e, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -103,12 +104,15 @@ static int enable_flash_vt8235(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
ok = pci_write_byte(dev, 0x40, new);
|
ok = pci_write_byte(dev, 0x40, new);
|
||||||
if (ok != 0) {
|
if (ok != 0) {
|
||||||
printf("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
printf
|
||||||
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
old, new, name);
|
old, new, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable GPIO15 which is connected to write protect. */
|
/* 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 = inb(base + 0x4d);
|
||||||
val |= 0x80;
|
val |= 0x80;
|
||||||
outb(val, base + 0x4d);
|
outb(val, base + 0x4d);
|
||||||
@ -129,7 +133,8 @@ static int enable_flash_vt8231(struct pci_dev *dev, char *name)
|
|||||||
pci_write_byte(dev, 0x40, val);
|
pci_write_byte(dev, 0x40, val);
|
||||||
|
|
||||||
if (pci_read_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",
|
printf
|
||||||
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x40, val, name);
|
0x40, val, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -145,7 +150,8 @@ static int enable_flash_cs5530(struct pci_dev *dev, char *name)
|
|||||||
new = pci_read_byte(dev, 0x52);
|
new = pci_read_byte(dev, 0x52);
|
||||||
|
|
||||||
if (new != 0xee) {
|
if (new != 0xee) {
|
||||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
printf
|
||||||
|
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x52, new, name);
|
0x52, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -161,7 +167,8 @@ static int enable_flash_sc1100(struct pci_dev *dev, char *name)
|
|||||||
new = pci_read_byte(dev, 0x52);
|
new = pci_read_byte(dev, 0x52);
|
||||||
|
|
||||||
if (new != 0xee) {
|
if (new != 0xee) {
|
||||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
printf
|
||||||
|
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x52, new, name);
|
0x52, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -175,7 +182,7 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
|||||||
new = pci_read_byte(dev, 0x45);
|
new = pci_read_byte(dev, 0x45);
|
||||||
|
|
||||||
/* clear bit 5 */
|
/* clear bit 5 */
|
||||||
new &= (~ 0x20);
|
new &= (~0x20);
|
||||||
/* set bit 2 */
|
/* set bit 2 */
|
||||||
new |= 0x4;
|
new |= 0x4;
|
||||||
|
|
||||||
@ -183,7 +190,8 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
|||||||
|
|
||||||
newer = pci_read_byte(dev, 0x45);
|
newer = pci_read_byte(dev, 0x45);
|
||||||
if (newer != new) {
|
if (newer != new) {
|
||||||
printf("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
printf
|
||||||
|
("tried to set register 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x45, new, name);
|
0x45, new, name);
|
||||||
printf("Stuck at 0x%x\n", newer);
|
printf("Stuck at 0x%x\n", newer);
|
||||||
return -1;
|
return -1;
|
||||||
@ -191,7 +199,8 @@ static int enable_flash_sis5595(struct pci_dev *dev, char *name)
|
|||||||
return 0;
|
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 */
|
/* register 4e.b gets or'ed with one */
|
||||||
unsigned char old, new;
|
unsigned char old, new;
|
||||||
/* if it fails, it fails. There are so many variations of broken mobos
|
/* if it fails, it fails. There are so many variations of broken mobos
|
||||||
@ -205,7 +214,8 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
|
|||||||
if (new != old) {
|
if (new != old) {
|
||||||
pci_write_byte(dev, 0x43, new);
|
pci_write_byte(dev, 0x43, new);
|
||||||
if (pci_read_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",
|
printf
|
||||||
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x43, new, name);
|
0x43, new, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,7 +227,8 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
|
|||||||
pci_write_byte(dev, 0x40, new);
|
pci_write_byte(dev, 0x40, new);
|
||||||
|
|
||||||
if (pci_read_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",
|
printf
|
||||||
|
("tried to set 0x%x to 0x%x on %s failed (WARNING ONLY)\n",
|
||||||
0x40, new, name);
|
0x40, new, name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -227,7 +238,7 @@ static int enable_flash_amd8111(struct pci_dev *dev, char *name) {
|
|||||||
typedef struct penable {
|
typedef struct penable {
|
||||||
unsigned short vendor, device;
|
unsigned short vendor, device;
|
||||||
char *name;
|
char *name;
|
||||||
int (*doit)(struct pci_dev *dev, char *name);
|
int (*doit) (struct pci_dev * dev, char *name);
|
||||||
} FLASH_ENABLE;
|
} FLASH_ENABLE;
|
||||||
|
|
||||||
static FLASH_ENABLE enables[] = {
|
static FLASH_ENABLE enables[] = {
|
||||||
@ -254,14 +265,15 @@ int enable_flash_write()
|
|||||||
pci_scan_bus(pacc); /* We want to get the list of devices */
|
pci_scan_bus(pacc); /* We want to get the list of devices */
|
||||||
|
|
||||||
/* now let's try to find the chipset we have ... */
|
/* 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_filter f;
|
||||||
struct pci_dev *z;
|
struct pci_dev *z;
|
||||||
/* the first param is unused. */
|
/* the first param is unused. */
|
||||||
pci_filter_init((struct pci_access *) 0, &f);
|
pci_filter_init((struct pci_access *) 0, &f);
|
||||||
f.vendor = enables[i].vendor;
|
f.vendor = enables[i].vendor;
|
||||||
f.device = enables[i].device;
|
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)) {
|
if (pci_filter_match(&f, z)) {
|
||||||
enable = &enables[i];
|
enable = &enables[i];
|
||||||
dev = z;
|
dev = z;
|
||||||
|
@ -73,5 +73,5 @@ int main()
|
|||||||
outb(0x02, 0x2e);
|
outb(0x02, 0x2e);
|
||||||
outb(0x02, 0x2f);
|
outb(0x02, 0x2f);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -48,59 +48,60 @@
|
|||||||
#include "mx29f002.h"
|
#include "mx29f002.h"
|
||||||
|
|
||||||
struct flashchip flashchips[] = {
|
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},
|
probe_29f040b, erase_29f040b, write_29f040b, NULL},
|
||||||
{"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256,
|
{"At29C040A", ATMEL_ID, AT_29C040A, NULL, 512, 256,
|
||||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||||
{"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64*1024,
|
{"Mx29f002", MX_ID, MX_29F002, NULL, 256, 64 * 1024,
|
||||||
probe_29f002, erase_29f002, write_29f002, NULL},
|
probe_29f002, erase_29f002, write_29f002, NULL},
|
||||||
{"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128,
|
{"SST29EE020A", SST_ID, SST_29EE020A, NULL, 256, 128,
|
||||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||||
{"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256,
|
{"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256,
|
||||||
probe_28sf040, erase_28sf040, write_28sf040, NULL},
|
probe_28sf040, erase_28sf040, write_28sf040, NULL},
|
||||||
{"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096,
|
{"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096,
|
||||||
probe_jedec, erase_jedec, write_39sf020, NULL},
|
probe_jedec, erase_chip_jedec, write_39sf020, NULL},
|
||||||
{"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096,
|
{"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096,
|
||||||
probe_jedec, erase_jedec, write_39sf020, NULL},
|
probe_jedec, erase_chip_jedec, write_39sf020, NULL},
|
||||||
{"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096,
|
{"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
|
{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
|
{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
|
{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
|
{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
|
{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
|
||||||
probe_jedec, erase_jedec, write_49lf040, NULL},
|
probe_jedec, erase_chip_jedec, write_49lf040, NULL},
|
||||||
{"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64*1024,
|
{"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64 * 1024,
|
||||||
probe_jedec, erase_jedec, write_49fl004, NULL},
|
probe_jedec, erase_chip_jedec, write_49fl004, NULL},
|
||||||
{"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128,
|
{"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128,
|
||||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||||
{"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128,
|
{"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128,
|
||||||
probe_jedec, erase_jedec, write_jedec, NULL},
|
probe_jedec, erase_chip_jedec, write_jedec, NULL},
|
||||||
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
{"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128,
|
||||||
probe_jedec, erase_jedec, write_49f002, NULL},
|
probe_jedec, erase_chip_jedec, write_49f002, NULL},
|
||||||
{"M29F400BT", ST_ID, ST_M29F400BT ,NULL, 512, 64*1024,
|
{"M29F400BT", ST_ID, ST_M29F400BT, NULL, 512, 64 * 1024,
|
||||||
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL},
|
probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt,
|
||||||
{"82802ab", 137, 173 , NULL, 512, 64*1024,
|
NULL},
|
||||||
|
{"82802ab", 137, 173, NULL, 512, 64 * 1024,
|
||||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||||
{"82802ac", 137, 172 , NULL, 1024, 64*1024,
|
{"82802ac", 137, 172, NULL, 1024, 64 * 1024,
|
||||||
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
probe_82802ab, erase_82802ab, write_82802ab, NULL},
|
||||||
{"MD-2802 (M-Systems DiskOnChip Millennium Module)",
|
{"MD-2802 (M-Systems DiskOnChip Millennium Module)",
|
||||||
MSYSTEMS_ID, MSYSTEMS_MD2802,
|
MSYSTEMS_ID, MSYSTEMS_MD2802,
|
||||||
NULL, 8, 8*1024,
|
NULL, 8, 8 * 1024,
|
||||||
probe_md2802, erase_md2802, write_md2802, read_md2802},
|
probe_md2802, erase_md2802, write_md2802, read_md2802},
|
||||||
{NULL,}
|
{NULL,}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *chip_to_probe = NULL;
|
char *chip_to_probe = NULL;
|
||||||
|
|
||||||
struct flashchip * probe_flash(struct flashchip * flash)
|
struct flashchip *probe_flash(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
int fd_mem;
|
int fd_mem;
|
||||||
volatile char * bios;
|
volatile char *bios;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
|
||||||
@ -109,20 +110,23 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (flash->name != NULL) {
|
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++;
|
flash++;
|
||||||
continue;
|
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;
|
size = flash->total_size * 1024;
|
||||||
/* BUG? what happens if getpagesize() > size!?
|
/* BUG? what happens if getpagesize() > size!?
|
||||||
-> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
|
-> ``Error MMAP /dev/mem: Invalid argument'' NIKI */
|
||||||
if (getpagesize() > size) {
|
if (getpagesize() > size) {
|
||||||
size = getpagesize();
|
size = getpagesize();
|
||||||
printf("%s: warning: size: %d -> %ld\n", __FUNCTION__,
|
printf("%s: warning: size: %d -> %ld\n",
|
||||||
flash->total_size * 1024, (unsigned long)size);
|
__FUNCTION__, flash->total_size * 1024,
|
||||||
|
(unsigned long) size);
|
||||||
}
|
}
|
||||||
bios = mmap (0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||||
fd_mem, (off_t) (0xffffffff - size + 1));
|
fd_mem, (off_t) (0xffffffff - size + 1));
|
||||||
if (bios == MAP_FAILED) {
|
if (bios == MAP_FAILED) {
|
||||||
perror("Error MMAP /dev/mem");
|
perror("Error MMAP /dev/mem");
|
||||||
@ -132,27 +136,27 @@ struct flashchip * probe_flash(struct flashchip * flash)
|
|||||||
flash->fd_mem = fd_mem;
|
flash->fd_mem = fd_mem;
|
||||||
|
|
||||||
if (flash->probe(flash) == 1) {
|
if (flash->probe(flash) == 1) {
|
||||||
printf ("%s found at physical address: 0x%lx\n",
|
printf("%s found at physical address: 0x%lx\n",
|
||||||
flash->name, (0xffffffff - size + 1));
|
flash->name, (0xffffffff - size + 1));
|
||||||
return flash;
|
return flash;
|
||||||
}
|
}
|
||||||
munmap ((void *) bios, size);
|
munmap((void *) bios, size);
|
||||||
flash++;
|
flash++;
|
||||||
}
|
}
|
||||||
return NULL;
|
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 i = 0;
|
||||||
int total_size = flash->total_size *1024;
|
int total_size = flash->total_size * 1024;
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
printf("Verifying address: ");
|
printf("Verifying address: ");
|
||||||
while (i < total_size) {
|
while (i < total_size) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printf("0x%08x", i);
|
printf("0x%08x", i);
|
||||||
if (*(bios+i) != *(buf+i)) {
|
if (*(bios + i) != *(buf + i)) {
|
||||||
printf("FAILED\n");
|
printf("FAILED\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -180,12 +184,12 @@ void usage(const char *name)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char * argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char * buf;
|
char *buf;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
FILE * image;
|
FILE *image;
|
||||||
struct flashchip * flash;
|
struct flashchip *flash;
|
||||||
int opt;
|
int opt;
|
||||||
int read_it = 0, write_it = 0, verify_it = 0, verbose = 0;
|
int read_it = 0, write_it = 0, verify_it = 0, verbose = 0;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
@ -222,7 +226,8 @@ int main (int argc, char * argv[])
|
|||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
filename = argv[optind++];
|
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();
|
myusec_calibrate_delay();
|
||||||
printf("OK, calibrated, now do the deed\n");
|
printf("OK, calibrated, now do the deed\n");
|
||||||
|
|
||||||
@ -231,21 +236,22 @@ int main (int argc, char * argv[])
|
|||||||
*/
|
*/
|
||||||
(void) enable_flash_write();
|
(void) enable_flash_write();
|
||||||
|
|
||||||
if ((flash = probe_flash (flashchips)) == NULL) {
|
if ((flash = probe_flash(flashchips)) == NULL) {
|
||||||
printf("EEPROM not found\n");
|
printf("EEPROM not found\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Part is %s\n", flash->name);
|
printf("Part is %s\n", flash->name);
|
||||||
if (!filename){
|
if (!filename) {
|
||||||
printf("OK, only ENABLING flash write, but NOT FLASHING\n");
|
printf
|
||||||
|
("OK, only ENABLING flash write, but NOT FLASHING\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
size = flash->total_size * 1024;
|
size = flash->total_size * 1024;
|
||||||
buf = (char *) calloc (size, sizeof(char));
|
buf = (char *) calloc(size, sizeof(char));
|
||||||
|
|
||||||
if (read_it) {
|
if (read_it) {
|
||||||
if ((image = fopen (filename, "w")) == NULL) {
|
if ((image = fopen(filename, "w")) == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -253,22 +259,22 @@ int main (int argc, char * argv[])
|
|||||||
if (flash->read == NULL)
|
if (flash->read == NULL)
|
||||||
memcpy(buf, (const char *) flash->virt_addr, size);
|
memcpy(buf, (const char *) flash->virt_addr, size);
|
||||||
else
|
else
|
||||||
flash->read (flash, buf);
|
flash->read(flash, buf);
|
||||||
fwrite(buf, sizeof(char), size, image);
|
fwrite(buf, sizeof(char), size, image);
|
||||||
fclose(image);
|
fclose(image);
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
} else {
|
} else {
|
||||||
if ((image = fopen (filename, "r")) == NULL) {
|
if ((image = fopen(filename, "r")) == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fread (buf, sizeof(char), size, image);
|
fread(buf, sizeof(char), size, image);
|
||||||
fclose(image);
|
fclose(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write_it || (!read_it && !verify_it))
|
if (write_it || (!read_it && !verify_it))
|
||||||
flash->write (flash, buf);
|
flash->write(flash, buf);
|
||||||
if (verify_it)
|
if (verify_it)
|
||||||
verify_flash (flash, buf, verbose);
|
verify_flash(flash, buf, verbose);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,12 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "jedec.h"
|
#include "jedec.h"
|
||||||
|
|
||||||
int probe_jedec (struct flashchip * flash)
|
int probe_jedec(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
unsigned char id1, id2;
|
unsigned char id1, id2;
|
||||||
|
|
||||||
|
/* Issue JEDEC Product ID Entry command */
|
||||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
@ -40,9 +41,11 @@ int probe_jedec (struct flashchip * flash)
|
|||||||
*(volatile char *) (bios + 0x5555) = 0x90;
|
*(volatile char *) (bios + 0x5555) = 0x90;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
|
/* Read product ID */
|
||||||
id1 = *(volatile unsigned char *) bios;
|
id1 = *(volatile unsigned char *) bios;
|
||||||
id2 = *(volatile unsigned char *) (bios + 0x01);
|
id2 = *(volatile unsigned char *) (bios + 0x01);
|
||||||
|
|
||||||
|
/* Issue JEDEC Product ID Exit command */
|
||||||
*(volatile char *) (bios + 0x5555) = 0xAA;
|
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
@ -57,87 +60,144 @@ int probe_jedec (struct flashchip * flash)
|
|||||||
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;
|
volatile unsigned char *Temp;
|
||||||
|
|
||||||
/* Issue the Sector Erase command to 40LF040 */
|
/* Issue the Sector Erase command */
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||||
*Temp = 0x55; /* write data 0x55 to the address */
|
*Temp = 0x55; /* write data 0x55 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0x80; /* write data 0x80 to the address */
|
*Temp = 0x80; /* write data 0x80 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||||
*Temp = 0x55; /* write data 0x55 to the address */
|
*Temp = 0x55; /* write data 0x55 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + page; /* set up address to be the current sector */
|
Temp = bios + page; /* set up address to be the current sector */
|
||||||
*Temp = 0x30; /* write data 0x30 to the address */
|
*Temp = 0x30; /* write data 0x30 to the address */
|
||||||
|
myusec_delay(10);
|
||||||
|
|
||||||
/* wait for Toggle bit ready */
|
/* wait for Toggle bit ready */
|
||||||
toggle_ready_jedec(bios);
|
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;
|
volatile unsigned char *Temp;
|
||||||
|
|
||||||
/* Issue the Sector Erase command to 39SF020 */
|
/* Issue the JEDEC Chip Erase command */
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||||
*Temp = 0x55; /* write data 0x55 to the address */
|
*Temp = 0x55; /* write data 0x55 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0x80; /* write data 0x80 to the address */
|
*Temp = 0x80; /* write data 0x80 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASE:5555h */
|
||||||
*Temp = 0xAA; /* write data 0xAA to the address */
|
*Temp = 0xAA; /* write data 0xAA to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */
|
Temp = bios + 0x2AAA; /* set up address to be BASE:2AAAh */
|
||||||
*Temp = 0x55; /* write data 0x55 to the address */
|
*Temp = 0x55; /* write data 0x55 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
Temp = bios + 0x5555; /* set up address to be C000:5555h */
|
Temp = bios + 0x5555; /* set up address to be BASEy:5555h */
|
||||||
*Temp = 0x10; /* write data 0x55 to the address */
|
*Temp = 0x10; /* write data 0x10 to the address */
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
|
|
||||||
toggle_ready_jedec(bios);
|
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 i;
|
||||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
|
||||||
volatile unsigned char * bios = flash->virt_addr;
|
|
||||||
|
|
||||||
erase_jedec (flash);
|
/* Issue JEDEC Data Unprotect comand */
|
||||||
if (*bios != (unsigned char ) 0xff) {
|
*(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");
|
printf("ERASE FAILED\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_page_jedec(bios, buf + i * page_size, bios + i * page_size,
|
write_page_jedec(bios, buf + i * page_size,
|
||||||
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");
|
printf("\n");
|
||||||
protect_jedec (bios);
|
protect_jedec(bios);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
#ifndef __JEDEC_H__
|
#ifndef __JEDEC_H__
|
||||||
#define __JEDEC_H__ 1
|
#define __JEDEC_H__ 1
|
||||||
|
|
||||||
extern int probe_jedec (struct flashchip * flash);
|
extern int probe_jedec(struct flashchip *flash);
|
||||||
extern int erase_jedec (struct flashchip * flash);
|
extern int erase_chip_jedec(struct flashchip *flash);
|
||||||
extern int write_jedec (struct flashchip * flash, unsigned char * buf);
|
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;
|
unsigned int i = 0;
|
||||||
char tmp1, tmp2;
|
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;
|
unsigned int i = 0;
|
||||||
char tmp;
|
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 + 0x5555) = 0xAA;
|
||||||
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
@ -45,60 +62,5 @@ extern __inline__ void protect_jedec (volatile char * bios)
|
|||||||
usleep(200);
|
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,9 +27,9 @@
|
|||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "m29f400bt.h"
|
#include "m29f400bt.h"
|
||||||
|
|
||||||
int probe_m29f400bt (struct flashchip * flash)
|
int probe_m29f400bt(struct flashchip *flash)
|
||||||
{
|
{
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
unsigned char id1, id2;
|
unsigned char id1, id2;
|
||||||
|
|
||||||
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||||
@ -56,9 +56,9 @@ int probe_m29f400bt (struct flashchip * flash)
|
|||||||
return 0;
|
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 + 0xAAA) = 0xAA;
|
||||||
*(volatile char *) (bios + 0x555) = 0x55;
|
*(volatile char *) (bios + 0x555) = 0x55;
|
||||||
@ -71,10 +71,10 @@ int erase_m29f400bt (struct flashchip * flash)
|
|||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
toggle_ready_m29f400bt(bios);
|
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;
|
*(volatile char *) (bios + 0xAAA) = 0xAA;
|
||||||
@ -89,17 +89,18 @@ int block_erase_m29f400bt (volatile char * bios ,volatile char * dst)
|
|||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
toggle_ready_m29f400bt(bios);
|
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 i;
|
||||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
//erase_m29f400bt (flash);
|
//erase_m29f400bt (flash);
|
||||||
printf ("Programming Page:\n ");
|
printf("Programming Page:\n ");
|
||||||
/*********************************
|
/*********************************
|
||||||
*Pages for M29F400BT:
|
*Pages for M29F400BT:
|
||||||
* 16 0x7c000 0x7ffff TOP
|
* 16 0x7c000 0x7ffff TOP
|
||||||
@ -115,42 +116,47 @@ int write_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
|||||||
* 64 0x10000 0x1ffff
|
* 64 0x10000 0x1ffff
|
||||||
* 64 0x00000 0x0ffff BOTTOM
|
* 64 0x00000 0x0ffff BOTTOM
|
||||||
*********************************/
|
*********************************/
|
||||||
printf("total_size/page_size = %d\n",total_size/page_size);
|
printf("total_size/page_size = %d\n", total_size / page_size);
|
||||||
for (i = 0; i < (total_size/page_size)-1; i++) {
|
for (i = 0; i < (total_size / page_size) - 1; i++) {
|
||||||
printf("%04d at address: 0x%08x\n", i, i * page_size);
|
printf("%04d at address: 0x%08x\n", i, i * page_size);
|
||||||
block_erase_m29f400bt(bios, bios + i * page_size);
|
block_erase_m29f400bt(bios, bios + i * page_size);
|
||||||
write_page_m29f400bt(bios, buf + i * page_size, bios + i * page_size,
|
write_page_m29f400bt(bios, buf + i * page_size,
|
||||||
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("%04d at address: 0x%08x\n",7,0x70000);
|
printf("%04d at address: 0x%08x\n", 7, 0x70000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x70000);
|
block_erase_m29f400bt(bios, bios + 0x70000);
|
||||||
write_page_m29f400bt(bios,buf + 0x70000, bios + 0x70000, 32*1024);
|
write_page_m29f400bt(bios, buf + 0x70000, bios + 0x70000,
|
||||||
|
32 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",8,0x78000);
|
printf("%04d at address: 0x%08x\n", 8, 0x78000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x78000);
|
block_erase_m29f400bt(bios, bios + 0x78000);
|
||||||
write_page_m29f400bt(bios,buf + 0x78000, bios + 0x78000, 8*1024);
|
write_page_m29f400bt(bios, buf + 0x78000, bios + 0x78000,
|
||||||
|
8 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",9,0x7a000);
|
printf("%04d at address: 0x%08x\n", 9, 0x7a000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x7a000);
|
block_erase_m29f400bt(bios, bios + 0x7a000);
|
||||||
write_page_m29f400bt(bios,buf + 0x7a000, bios + 0x7a000, 8*1024);
|
write_page_m29f400bt(bios, buf + 0x7a000, bios + 0x7a000,
|
||||||
|
8 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",10,0x7c000);
|
printf("%04d at address: 0x%08x\n", 10, 0x7c000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x7c000);
|
block_erase_m29f400bt(bios, bios + 0x7c000);
|
||||||
write_page_m29f400bt(bios,buf + 0x7c000, bios + 0x7c000, 16*1024);
|
write_page_m29f400bt(bios, buf + 0x7c000, bios + 0x7c000,
|
||||||
|
16 * 1024);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
//protect_m29f400bt (bios);
|
//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:
|
*Pages for M29F400BT:
|
||||||
* 16 0x7c000 0x7ffff TOP
|
* 16 0x7c000 0x7ffff TOP
|
||||||
@ -166,24 +172,28 @@ int write_linuxbios_m29f400bt (struct flashchip * flash, unsigned char * buf)
|
|||||||
* 64 0x10000 0x1ffff
|
* 64 0x10000 0x1ffff
|
||||||
* 64 0x00000 0x0ffff BOTTOM
|
* 64 0x00000 0x0ffff BOTTOM
|
||||||
*********************************/
|
*********************************/
|
||||||
printf("%04d at address: 0x%08x\n",7,0x00000);
|
printf("%04d at address: 0x%08x\n", 7, 0x00000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x00000);
|
block_erase_m29f400bt(bios, bios + 0x00000);
|
||||||
write_page_m29f400bt(bios,buf + 0x00000, bios + 0x00000, 64*1024);
|
write_page_m29f400bt(bios, buf + 0x00000, bios + 0x00000,
|
||||||
|
64 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",7,0x10000);
|
printf("%04d at address: 0x%08x\n", 7, 0x10000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x10000);
|
block_erase_m29f400bt(bios, bios + 0x10000);
|
||||||
write_page_m29f400bt(bios,buf + 0x10000, bios + 0x10000, 64*1024);
|
write_page_m29f400bt(bios, buf + 0x10000, bios + 0x10000,
|
||||||
|
64 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",7,0x20000);
|
printf("%04d at address: 0x%08x\n", 7, 0x20000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x20000);
|
block_erase_m29f400bt(bios, bios + 0x20000);
|
||||||
write_page_m29f400bt(bios,buf + 0x20000, bios + 0x20000, 64*1024);
|
write_page_m29f400bt(bios, buf + 0x20000, bios + 0x20000,
|
||||||
|
64 * 1024);
|
||||||
|
|
||||||
printf("%04d at address: 0x%08x\n",7,0x30000);
|
printf("%04d at address: 0x%08x\n", 7, 0x30000);
|
||||||
block_erase_m29f400bt(bios , bios + 0x30000);
|
block_erase_m29f400bt(bios, bios + 0x30000);
|
||||||
write_page_m29f400bt(bios,buf + 0x30000, bios + 0x30000, 64*1024);
|
write_page_m29f400bt(bios, buf + 0x30000, bios + 0x30000,
|
||||||
|
64 * 1024);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
//protect_m29f400bt (bios);
|
//protect_m29f400bt (bios);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int probe_m29f400bt (struct flashchip * flash);
|
extern int probe_m29f400bt(struct flashchip *flash);
|
||||||
extern int erase_m29f400bt (struct flashchip * flash);
|
extern int erase_m29f400bt(struct flashchip *flash);
|
||||||
extern int block_erase_m29f400bt (volatile char * bios, volatile char * dst);
|
extern int block_erase_m29f400bt(volatile char *bios, volatile char *dst);
|
||||||
extern int write_m29f400bt (struct flashchip * flash, unsigned char * buf);
|
extern int write_m29f400bt(struct flashchip *flash, unsigned char *buf);
|
||||||
extern int write_linuxbios_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;
|
unsigned int i = 0;
|
||||||
char tmp1, tmp2;
|
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;
|
unsigned int i = 0;
|
||||||
char tmp;
|
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 + 0xAAA) = 0xAA;
|
||||||
*(volatile char *) (bios + 0x555) = 0x55;
|
*(volatile char *) (bios + 0x555) = 0x55;
|
||||||
@ -49,7 +51,8 @@ extern __inline__ void protect_m29f400bt (volatile char * bios)
|
|||||||
usleep(200);
|
usleep(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern __inline__ void write_page_m29f400bt (volatile char * bios, char * src, volatile char * dst,
|
extern __inline__ void write_page_m29f400bt(volatile char *bios, char *src,
|
||||||
|
volatile char *dst,
|
||||||
int page_size)
|
int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -64,7 +67,9 @@ extern __inline__ void write_page_m29f400bt (volatile char * bios, char * src, v
|
|||||||
//*(volatile char *) (bios) = 0xF0;
|
//*(volatile char *) (bios) = 0xF0;
|
||||||
//usleep(5);
|
//usleep(5);
|
||||||
toggle_ready_m29f400bt(dst);
|
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++;
|
dst++;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,7 @@ static void doc_write_cdsncontrol(volatile char *bios, unsigned char data);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int probe_md2802(struct flashchip *flash)
|
||||||
probe_md2802(struct flashchip * flash)
|
|
||||||
{
|
{
|
||||||
volatile char *bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
unsigned char chipid;
|
unsigned char chipid;
|
||||||
@ -66,14 +65,15 @@ probe_md2802(struct flashchip * flash)
|
|||||||
doc_write(0x85, bios, DOCControl);
|
doc_write(0x85, bios, DOCControl);
|
||||||
doc_write(0x85, bios, DOCControl);
|
doc_write(0x85, bios, DOCControl);
|
||||||
doc_read_4nop(bios);
|
doc_read_4nop(bios);
|
||||||
if(doc_wait(bios, 5000))
|
if (doc_wait(bios, 5000))
|
||||||
return(-1);
|
return (-1);
|
||||||
printf("%s: switching off reset mode ... done\n", __FUNCTION__);
|
printf("%s: switching off reset mode ... done\n", __FUNCTION__);
|
||||||
printf("%s:\n", __FUNCTION__);
|
printf("%s:\n", __FUNCTION__);
|
||||||
|
|
||||||
printf("%s: switching off write protection ...\n", __FUNCTION__);
|
printf("%s: switching off write protection ...\n", __FUNCTION__);
|
||||||
doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios)&(~0x08));
|
doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios) & (~0x08));
|
||||||
printf("%s: switching off write protection ... done\n", __FUNCTION__);
|
printf("%s: switching off write protection ... done\n",
|
||||||
|
__FUNCTION__);
|
||||||
printf("%s:\n", __FUNCTION__);
|
printf("%s:\n", __FUNCTION__);
|
||||||
|
|
||||||
|
|
||||||
@ -127,78 +127,77 @@ probe_md2802(struct flashchip * flash)
|
|||||||
printf("%s: checking ECCConfiguration toggle bit\n", __FUNCTION__);
|
printf("%s: checking ECCConfiguration toggle bit\n", __FUNCTION__);
|
||||||
printf("%s:", __FUNCTION__);
|
printf("%s:", __FUNCTION__);
|
||||||
toggle_a = toggle_b = 0;
|
toggle_a = toggle_b = 0;
|
||||||
for(i=0; i<10; i++)
|
for (i = 0; i < 10; i++) {
|
||||||
{
|
|
||||||
unsigned char toggle = doc_toggle(bios);
|
unsigned char toggle = doc_toggle(bios);
|
||||||
|
|
||||||
printf(" 0x%02x", toggle);
|
printf(" 0x%02x", toggle);
|
||||||
|
|
||||||
if(i%2)
|
if (i % 2)
|
||||||
toggle_a += toggle;
|
toggle_a += toggle;
|
||||||
else
|
else
|
||||||
toggle_b += toggle;
|
toggle_b += toggle;
|
||||||
} /* for(i=0; i<10; i++) */
|
} /* for(i=0; i<10; i++) */
|
||||||
printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a, toggle_b);
|
printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a,
|
||||||
|
toggle_b);
|
||||||
|
|
||||||
if(chipid == flash->model_id
|
if (chipid == flash->model_id
|
||||||
&& ((toggle_a==5 && toggle_b==0)||(toggle_a==0 && toggle_b==5))
|
&& ((toggle_a == 5 && toggle_b == 0)
|
||||||
|
|| (toggle_a == 0 && toggle_b == 5))
|
||||||
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
|
#ifndef MSYSTEMS_DOC_NO_55AA_CHECKING
|
||||||
&& id_0x55 == 0x55 && id_0xAA == 0xaa
|
&& id_0x55 == 0x55 && id_0xAA == 0xaa
|
||||||
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
#endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */
|
||||||
)
|
) {
|
||||||
{
|
return (1);
|
||||||
return(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
} /* int probe_md2802(struct flashchip *flash) */
|
} /* int probe_md2802(struct flashchip *flash) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int read_md2802(struct flashchip *flash, unsigned char *buf)
|
||||||
read_md2802(struct flashchip *flash, unsigned char *buf)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
} /* int read_md2802(struct flashchip *flash, unsigned char *buf) */
|
} /* int read_md2802(struct flashchip *flash, unsigned char *buf) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int erase_md2802(struct flashchip *flash)
|
||||||
erase_md2802(struct flashchip *flash)
|
|
||||||
{
|
{
|
||||||
volatile char *bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
*(volatile char *)(bios + 0x5555) = 0xAA;
|
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||||
*(volatile char *)(bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
*(volatile char *)(bios + 0x5555) = 0x80;
|
*(volatile char *) (bios + 0x5555) = 0x80;
|
||||||
|
|
||||||
*(volatile char *)(bios + 0x5555) = 0xAA;
|
*(volatile char *) (bios + 0x5555) = 0xAA;
|
||||||
*(volatile char *)(bios + 0x2AAA) = 0x55;
|
*(volatile char *) (bios + 0x2AAA) = 0x55;
|
||||||
*(volatile char *)(bios + 0x5555) = 0x10;
|
*(volatile char *) (bios + 0x5555) = 0x10;
|
||||||
} /* int erase_md2802(struct flashchip *flash) */
|
} /* int erase_md2802(struct flashchip *flash) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int write_md2802(struct flashchip *flash, unsigned char *buf)
|
||||||
write_md2802(struct flashchip *flash, unsigned char *buf)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int total_size = flash->total_size *1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile unsigned char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile unsigned char *bios = flash->virt_addr;
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
erase_md2802 (flash);
|
erase_md2802(flash);
|
||||||
if (*bios != (unsigned char ) 0xff) {
|
if (*bios != (unsigned char) 0xff) {
|
||||||
printf("ERASE FAILED\n");
|
printf("ERASE FAILED\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
//write_page_md2802(bios, buf + i * page_size, bios + i * page_size, 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");
|
printf("\n");
|
||||||
//protect_md2802(bios);
|
//protect_md2802(bios);
|
||||||
@ -216,56 +215,50 @@ write_md2802(struct flashchip *flash, unsigned char *buf)
|
|||||||
0: ready
|
0: ready
|
||||||
-1: timeout expired
|
-1: timeout expired
|
||||||
*/
|
*/
|
||||||
static int
|
static int doc_wait(volatile char *bios, int timeout)
|
||||||
doc_wait(volatile char *bios, int timeout)
|
|
||||||
{
|
{
|
||||||
int i = 20;
|
int i = 20;
|
||||||
|
|
||||||
doc_read_4nop(bios);
|
doc_read_4nop(bios);
|
||||||
|
|
||||||
while(_doc_busy(bios) && (i != 0))
|
while (_doc_busy(bios) && (i != 0)) {
|
||||||
{
|
usleep(timeout * 1000 / 20);
|
||||||
usleep(timeout*1000/20);
|
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc_read_2nop(bios);
|
doc_read_2nop(bios);
|
||||||
|
|
||||||
if(_doc_busy(bios))
|
if (_doc_busy(bios)) {
|
||||||
{
|
|
||||||
doc_read_2nop(bios);
|
doc_read_2nop(bios);
|
||||||
return(-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
} /* static int doc_wait(volatile char *bios, int timeout) */
|
} /* static int doc_wait(volatile char *bios, int timeout) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char
|
static unsigned char doc_read_docstatus(volatile char *bios)
|
||||||
doc_read_docstatus(volatile char *bios)
|
|
||||||
{
|
{
|
||||||
doc_read(bios, CDSNSlowIO);
|
doc_read(bios, CDSNSlowIO);
|
||||||
doc_read_2nop(bios);
|
doc_read_2nop(bios);
|
||||||
|
|
||||||
return(doc_read(bios, _DOCStatus));
|
return (doc_read(bios, _DOCStatus));
|
||||||
} /* static unsigned char doc_read_docstatus(volatile char *bios) */
|
} /* static unsigned char doc_read_docstatus(volatile char *bios) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char
|
static unsigned char doc_read_chipid(volatile char *bios)
|
||||||
doc_read_chipid(volatile char *bios)
|
|
||||||
{
|
{
|
||||||
doc_read(bios, CDSNSlowIO);
|
doc_read(bios, CDSNSlowIO);
|
||||||
doc_read_2nop(bios);
|
doc_read_2nop(bios);
|
||||||
|
|
||||||
return(doc_read(bios, _ChipID));
|
return (doc_read(bios, _ChipID));
|
||||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char
|
static unsigned char doc_read_cdsncontrol(volatile char *bios)
|
||||||
doc_read_cdsncontrol(volatile char *bios)
|
|
||||||
{
|
{
|
||||||
unsigned char value;
|
unsigned char value;
|
||||||
|
|
||||||
@ -276,13 +269,12 @@ doc_read_cdsncontrol(volatile char *bios)
|
|||||||
value = doc_read(bios, _CDSNControl);
|
value = doc_read(bios, _CDSNControl);
|
||||||
doc_read_2nop(bios);
|
doc_read_2nop(bios);
|
||||||
|
|
||||||
return(value);
|
return (value);
|
||||||
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
} /* static unsigned char doc_read_chipid(volatile char *bios) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void doc_write_cdsncontrol(volatile char *bios, unsigned char data)
|
||||||
doc_write_cdsncontrol(volatile char *bios, unsigned char data)
|
|
||||||
{
|
{
|
||||||
doc_write(data, bios, _CDSNControl);
|
doc_write(data, bios, _CDSNControl);
|
||||||
doc_read_4nop(bios);
|
doc_read_4nop(bios);
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
#include "jedec.h"
|
#include "jedec.h"
|
||||||
#include "mx29f002.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;
|
unsigned char id1, id2;
|
||||||
|
|
||||||
*(bios + 0x5555) = 0xAA;
|
*(bios + 0x5555) = 0xAA;
|
||||||
@ -53,9 +53,9 @@ int probe_29f002 (struct flashchip * flash)
|
|||||||
return 0;
|
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) = 0xF0;
|
||||||
*(bios + 0x555) = 0xAA;
|
*(bios + 0x555) = 0xAA;
|
||||||
@ -81,26 +81,26 @@ int erase_29f002 (struct flashchip * flash)
|
|||||||
*(bios + 0x3bfff) = 0x30;
|
*(bios + 0x3bfff) = 0x30;
|
||||||
#endif
|
#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 i;
|
||||||
int total_size = flash->total_size * 1024;
|
int total_size = flash->total_size * 1024;
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
volatile char * dst = bios;
|
volatile char *dst = bios;
|
||||||
|
|
||||||
*bios = 0xF0;
|
*bios = 0xF0;
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
erase_29f002(flash);
|
erase_29f002(flash);
|
||||||
//*bios = 0xF0;
|
//*bios = 0xF0;
|
||||||
#if 1
|
#if 1
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size; i++) {
|
for (i = 0; i < total_size; i++) {
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
if ((i & 0xfff) == 0)
|
if ((i & 0xfff) == 0)
|
||||||
printf ("address: 0x%08lx", (unsigned long)i);
|
printf("address: 0x%08lx", (unsigned long) i);
|
||||||
*(bios + 0x5555) = 0xAA;
|
*(bios + 0x5555) = 0xAA;
|
||||||
*(bios + 0x2AAA) = 0x55;
|
*(bios + 0x2AAA) = 0x55;
|
||||||
*(bios + 0x5555) = 0xA0;
|
*(bios + 0x5555) = 0xA0;
|
||||||
@ -110,10 +110,10 @@ int write_29f002 (struct flashchip * flash, unsigned char * buf)
|
|||||||
toggle_ready_jedec(dst);
|
toggle_ready_jedec(dst);
|
||||||
|
|
||||||
if ((i & 0xfff) == 0)
|
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");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __MX29F002_H__
|
#ifndef __MX29F002_H__
|
||||||
#define __MX29F002_H__ 1
|
#define __MX29F002_H__ 1
|
||||||
|
|
||||||
extern int probe_29f002 (struct flashchip * flash);
|
extern int probe_29f002(struct flashchip *flash);
|
||||||
extern int erase_29f002 (struct flashchip * flash);
|
extern int erase_29f002(struct flashchip *flash);
|
||||||
extern int write_29f002 (struct flashchip * flash, unsigned char * buf);
|
extern int write_29f002(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif /* !__MX29F002_H__ */
|
#endif /* !__MX29F002_H__ */
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
#define RESET 0xFF
|
#define RESET 0xFF
|
||||||
#define READ_ID 0x90
|
#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;
|
||||||
|
|
||||||
@ -56,12 +57,12 @@ static __inline__ int erase_block_49fl004 ( volatile unsigned char * bios ,unsig
|
|||||||
/* wait for Toggle bit ready */
|
/* 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,
|
static __inline__ int write_block_49fl004(volatile char *bios,
|
||||||
unsigned char * src,
|
unsigned char *src,
|
||||||
volatile unsigned char * dst,
|
volatile unsigned char *dst,
|
||||||
unsigned int page_size)
|
unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -69,8 +70,9 @@ static __inline__ int write_block_49fl004(volatile char * bios,
|
|||||||
|
|
||||||
for (i = 0; i < page_size; i++) {
|
for (i = 0; i < page_size; i++) {
|
||||||
if (*dst != 0xff) {
|
if (*dst != 0xff) {
|
||||||
printf("FATAL: dst %p not erased (val 0x%x\n", dst, *dst);
|
printf("FATAL: dst %p not erased (val 0x%x\n", dst,
|
||||||
return(-1);
|
*dst);
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
/* transfer data from source to destination */
|
/* transfer data from source to destination */
|
||||||
if (*src == 0xFF) {
|
if (*src == 0xFF) {
|
||||||
@ -88,32 +90,34 @@ static __inline__ int write_block_49fl004(volatile char * bios,
|
|||||||
toggle_ready_jedec(bios);
|
toggle_ready_jedec(bios);
|
||||||
if (*dst != *src)
|
if (*dst != *src)
|
||||||
printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
|
printf("BAD! dst 0x%lx val 0x%x src 0x%x\n",
|
||||||
(unsigned long)dst, *dst, *src);
|
(unsigned long) dst, *dst, *src);
|
||||||
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 i;
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
erase_block_49fl004(bios, i * page_size);
|
erase_block_49fl004(bios, i * page_size);
|
||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_block_49fl004(bios, buf + i * page_size, bios + i * page_size,
|
write_block_49fl004(bios, buf + i * page_size,
|
||||||
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");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __PM49FL004_H__
|
#ifndef __PM49FL004_H__
|
||||||
#define __PM49FL004_H__ 1
|
#define __PM49FL004_H__ 1
|
||||||
|
|
||||||
extern int probe_49fl004 (struct flashchip * flash);
|
extern int probe_49fl004(struct flashchip *flash);
|
||||||
extern int erase_49fl004 (struct flashchip * flash);
|
extern int erase_49fl004(struct flashchip *flash);
|
||||||
extern int write_49fl004 (struct flashchip * flash, unsigned char * buf);
|
extern int write_49fl004(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#define RESET 0xFF
|
#define RESET 0xFF
|
||||||
#define READ_ID 0x90
|
#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 */
|
/* ask compiler not to optimize this */
|
||||||
volatile unsigned char tmp;
|
volatile unsigned char tmp;
|
||||||
@ -50,7 +50,7 @@ static __inline__ void protect_28sf040 (volatile char * bios)
|
|||||||
tmp = *(volatile unsigned char *) (bios + 0x040A);
|
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 */
|
/* ask compiler not to optimize this */
|
||||||
volatile unsigned char tmp;
|
volatile unsigned char tmp;
|
||||||
@ -64,7 +64,8 @@ static __inline__ void unprotect_28sf040 (volatile char * bios)
|
|||||||
tmp = *(volatile unsigned char *) (bios + 0x041A);
|
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 = AUTO_PG_ERASE1;
|
||||||
*(bios + address) = AUTO_PG_ERASE2;
|
*(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 */
|
/* wait for Toggle bit ready */
|
||||||
toggle_ready_jedec(bios);
|
toggle_ready_jedec(bios);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int write_sector_28sf040(volatile char * bios, unsigned char * src,
|
static __inline__ int write_sector_28sf040(volatile char *bios,
|
||||||
volatile unsigned char * dst, unsigned int page_size)
|
unsigned char *src,
|
||||||
|
volatile unsigned char *dst,
|
||||||
|
unsigned int page_size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -95,12 +98,12 @@ static __inline__ int write_sector_28sf040(volatile char * bios, unsigned char *
|
|||||||
toggle_ready_jedec(bios);
|
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;
|
volatile char *bios = flash->virt_addr;
|
||||||
unsigned char id1, id2, tmp;
|
unsigned char id1, id2, tmp;
|
||||||
|
|
||||||
/* save the value at the beginning of the Flash */
|
/* save the value at the beginning of the Flash */
|
||||||
@ -118,7 +121,7 @@ int probe_28sf040 (struct flashchip * flash)
|
|||||||
*bios = RESET;
|
*bios = RESET;
|
||||||
myusec_delay(10);
|
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)
|
if (id1 == flash->manufacture_id && id2 == flash->model_id)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -127,43 +130,45 @@ int probe_28sf040 (struct flashchip * flash)
|
|||||||
return 0;
|
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;
|
||||||
*bios = CHIP_ERASE;
|
*bios = CHIP_ERASE;
|
||||||
protect_28sf040 (bios);
|
protect_28sf040(bios);
|
||||||
|
|
||||||
myusec_delay(10);
|
myusec_delay(10);
|
||||||
toggle_ready_jedec(bios);
|
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 i;
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
unprotect_28sf040 (bios);
|
unprotect_28sf040(bios);
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
erase_sector_28sf040(bios, i * page_size);
|
erase_sector_28sf040(bios, i * page_size);
|
||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_28sf040(bios, buf + i * page_size, bios + i * page_size,
|
write_sector_28sf040(bios, buf + i * page_size,
|
||||||
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");
|
printf("\n");
|
||||||
|
|
||||||
protect_28sf040 (bios);
|
protect_28sf040(bios);
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __SST28SF040_H__
|
#ifndef __SST28SF040_H__
|
||||||
#define __SST28SF040_H__
|
#define __SST28SF040_H__
|
||||||
|
|
||||||
extern int probe_28sf040 (struct flashchip * flash);
|
extern int probe_28sf040(struct flashchip *flash);
|
||||||
extern int erase_28sf040 (struct flashchip * flash);
|
extern int erase_28sf040(struct flashchip *flash);
|
||||||
extern int write_28sf040 (struct flashchip * flash, unsigned char * buf);
|
extern int write_28sf040(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif /* !__SST28SF040_H__ */
|
#endif /* !__SST28SF040_H__ */
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
#define RESET 0xFF
|
#define RESET 0xFF
|
||||||
#define READ_ID 0x90
|
#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 = AUTO_PG_ERASE1;
|
||||||
*(bios + address) = AUTO_PG_ERASE2;
|
*(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 */
|
/* wait for Toggle bit ready */
|
||||||
toggle_ready_jedec(bios);
|
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 i;
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
erase_jedec(flash);
|
erase_chip_jedec(flash);
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
/* erase the page before programming */
|
/* erase the page before programming */
|
||||||
//erase_sector_39sf020(bios, i * page_size);
|
//erase_sector_39sf020(bios, i * page_size);
|
||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf ("%04d at address: 0x%08x", i, i * page_size);
|
printf("%04d at address: 0x%08x", i, i * page_size);
|
||||||
write_sector_jedec(bios, buf + i * page_size, bios + i * page_size,
|
write_sector_jedec(bios, buf + i * page_size,
|
||||||
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");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __SST39SF020_H__
|
#ifndef __SST39SF020_H__
|
||||||
#define __SST39SF020_H__ 1
|
#define __SST39SF020_H__ 1
|
||||||
|
|
||||||
extern int probe_39sf020 (struct flashchip * flash);
|
extern int probe_39sf020(struct flashchip *flash);
|
||||||
extern int write_39sf020 (struct flashchip * flash, unsigned char * buf);
|
extern int write_39sf020(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif /* !__SST39SF020_H__ */
|
#endif /* !__SST39SF020_H__ */
|
||||||
|
@ -38,27 +38,29 @@
|
|||||||
#define READ_ID 0x90
|
#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 i;
|
||||||
int total_size = flash->total_size * 1024, page_size = flash->page_size;
|
int total_size = flash->total_size * 1024, page_size =
|
||||||
volatile char * bios = flash->virt_addr;
|
flash->page_size;
|
||||||
|
volatile char *bios = flash->virt_addr;
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size/page_size; i++) {
|
for (i = 0; i < total_size / page_size; i++) {
|
||||||
/* erase the page before programming
|
/* erase the page before programming
|
||||||
* Chip erase only works in parallel programming mode for the 49lf040.
|
* Chip erase only works in parallel programming mode for the 49lf040.
|
||||||
* Use sector-erase instead */
|
* Use sector-erase instead */
|
||||||
erase_sector_jedec(bios, i * page_size);
|
erase_sector_jedec(bios, i * page_size);
|
||||||
|
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
printf ("%04d at address: 0x%08x ", i, i * page_size);
|
printf("%04d at address: 0x%08x ", i, i * page_size);
|
||||||
write_sector_jedec(bios, buf + i * page_size, bios + i * page_size,
|
write_sector_jedec(bios, buf + i * page_size,
|
||||||
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");
|
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);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __SST49LF040_H__
|
#ifndef __SST49LF040_H__
|
||||||
#define __SST49LF040_H__ 1
|
#define __SST49LF040_H__ 1
|
||||||
|
|
||||||
extern int probe_49lf040 (struct flashchip * flash);
|
extern int probe_49lf040(struct flashchip *flash);
|
||||||
extern int erase_49lf040 (struct flashchip * flash);
|
extern int erase_49lf040(struct flashchip *flash);
|
||||||
extern int write_49lf040 (struct flashchip * flash, unsigned char * buf);
|
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)
|
void myusec_delay(int time)
|
||||||
{
|
{
|
||||||
volatile unsigned long i;
|
volatile unsigned long i;
|
||||||
for (i = 0; i < time * micro; i++)
|
for (i = 0; i < time * micro; i++);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void myusec_calibrate_delay()
|
void myusec_calibrate_delay()
|
||||||
@ -23,10 +22,10 @@ void myusec_calibrate_delay()
|
|||||||
gettimeofday(&start, 0);
|
gettimeofday(&start, 0);
|
||||||
myusec_delay(count);
|
myusec_delay(count);
|
||||||
gettimeofday(&end, 0);
|
gettimeofday(&end, 0);
|
||||||
timeusec = 1000000 * (end.tv_sec - start.tv_sec ) +
|
timeusec = 1000000 * (end.tv_sec - start.tv_sec) +
|
||||||
(end.tv_usec - start.tv_usec);
|
(end.tv_usec - start.tv_usec);
|
||||||
count *= 2;
|
count *= 2;
|
||||||
if (timeusec < 1000000/4)
|
if (timeusec < 1000000 / 4)
|
||||||
continue;
|
continue;
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
@ -34,5 +33,5 @@ void myusec_calibrate_delay()
|
|||||||
// compute one microsecond. That will be count / time
|
// compute one microsecond. That will be count / time
|
||||||
micro = count / timeusec;
|
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 "jedec.h"
|
||||||
#include "w49f002u.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 i;
|
||||||
int total_size = flash->total_size * 1024;
|
int total_size = flash->total_size * 1024;
|
||||||
volatile char * bios = flash->virt_addr;
|
volatile char *bios = flash->virt_addr;
|
||||||
volatile char * dst = bios;
|
volatile char *dst = bios;
|
||||||
|
|
||||||
erase_jedec(flash);
|
erase_chip_jedec(flash);
|
||||||
|
|
||||||
printf ("Programming Page: ");
|
printf("Programming Page: ");
|
||||||
for (i = 0; i < total_size; i++) {
|
for (i = 0; i < total_size; i++) {
|
||||||
/* write to the sector */
|
/* write to the sector */
|
||||||
if ((i & 0xfff) == 0)
|
if ((i & 0xfff) == 0)
|
||||||
printf ("address: 0x%08lx", (unsigned long)i);
|
printf("address: 0x%08lx", (unsigned long) i);
|
||||||
*(bios + 0x5555) = 0xAA;
|
*(bios + 0x5555) = 0xAA;
|
||||||
*(bios + 0x2AAA) = 0x55;
|
*(bios + 0x2AAA) = 0x55;
|
||||||
*(bios + 0x5555) = 0xA0;
|
*(bios + 0x5555) = 0xA0;
|
||||||
@ -55,9 +55,9 @@ int write_49f002 (struct flashchip * flash, unsigned char * buf)
|
|||||||
toggle_ready_jedec(dst);
|
toggle_ready_jedec(dst);
|
||||||
|
|
||||||
if ((i & 0xfff) == 0)
|
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");
|
printf("\n");
|
||||||
|
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __W49F002U_H__
|
#ifndef __W49F002U_H__
|
||||||
#define __W49F002U_H__ 1
|
#define __W49F002U_H__ 1
|
||||||
|
|
||||||
extern int probe_49f002 (struct flashchip * flash);
|
extern int probe_49f002(struct flashchip *flash);
|
||||||
extern int erase_49f002 (struct flashchip * flash);
|
extern int erase_49f002(struct flashchip *flash);
|
||||||
extern int write_49f002 (struct flashchip * flash, unsigned char * buf);
|
extern int write_49f002(struct flashchip *flash, unsigned char *buf);
|
||||||
|
|
||||||
#endif /* !__W49F002U_H__ */
|
#endif /* !__W49F002U_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user