summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--82802ab.h9
-rw-r--r--am29f040b.c12
-rw-r--r--flash.h143
-rw-r--r--jedec.h21
-rw-r--r--layout.h1
-rw-r--r--msys_doc.h10
-rw-r--r--mx29f002.c6
-rw-r--r--pm49fl004.c10
-rw-r--r--sharplhf00l04.h9
-rw-r--r--sst39sf020.c4
-rw-r--r--sst49lf040.c14
-rw-r--r--sst_fwhub.c8
-rw-r--r--udelay.c4
-rw-r--r--w49f002u.c4
14 files changed, 122 insertions, 133 deletions
diff --git a/82802ab.h b/82802ab.h
index 7836f36..f71f180 100644
--- a/82802ab.h
+++ b/82802ab.h
@@ -21,7 +21,8 @@ extern __inline__ void toggle_ready_82802ab(volatile uint8_t *dst)
}
}
-extern __inline__ void data_polling_82802ab(volatile uint8_t *dst, uint8_t data)
+extern __inline__ void data_polling_82802ab(volatile uint8_t *dst,
+ uint8_t data)
{
unsigned int i = 0;
uint8_t tmp;
@@ -38,9 +39,9 @@ extern __inline__ void data_polling_82802ab(volatile uint8_t *dst, uint8_t data)
extern __inline__ void protect_82802ab(volatile uint8_t *bios)
{
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0xA0;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xA0;
usleep(200);
}
diff --git a/am29f040b.c b/am29f040b.c
index 7b82331..ae9fb07 100644
--- a/am29f040b.c
+++ b/am29f040b.c
@@ -54,9 +54,9 @@ static __inline__ int write_sector_29f040b(volatile uint8_t *bios,
int i;
for (i = 0; i < page_size; i++) {
- if( (i & 0xfff) == 0xfff )
- printf("0x%08lx", (unsigned long) dst -
- (unsigned long) bios);
+ if ((i & 0xfff) == 0xfff)
+ printf("0x%08lx", (unsigned long)dst -
+ (unsigned long)bios);
*(bios + 0x555) = 0xAA;
*(bios + 0x2AA) = 0x55;
@@ -66,7 +66,7 @@ static __inline__ int write_sector_29f040b(volatile uint8_t *bios,
/* wait for Toggle bit ready */
toggle_ready_jedec(bios);
- if( (i & 0xfff) == 0xfff )
+ if ((i & 0xfff) == 0xfff)
printf("\b\b\b\b\b\b\b\b\b\b");
}
@@ -116,8 +116,8 @@ int erase_29f040b(struct flashchip *flash)
int write_29f040b(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
printf("Programming page ");
diff --git a/flash.h b/flash.h
index 9f2da65..aa24cac 100644
--- a/flash.h
+++ b/flash.h
@@ -21,7 +21,6 @@
*
*/
-
#ifndef __FLASH_H__
#define __FLASH_H__ 1
@@ -41,10 +40,10 @@ struct flashchip {
int total_size;
int page_size;
- int (*probe) (struct flashchip * flash);
- int (*erase) (struct flashchip * flash);
- int (*write) (struct flashchip * flash, uint8_t *buf);
- int (*read) (struct flashchip * flash, uint8_t *buf);
+ int (*probe) (struct flashchip *flash);
+ int (*erase) (struct flashchip *flash);
+ int (*write) (struct flashchip *flash, uint8_t *buf);
+ int (*read) (struct flashchip *flash, uint8_t *buf);
int fd_mem;
volatile uint8_t *virt_addr_2;
@@ -52,73 +51,73 @@ struct flashchip {
extern struct flashchip flashchips[];
-#define AMD_ID 0x01
-#define AM_29F040B 0xA4
-#define AM_29F016D 0xAD
-
-#define ASD_ID 0x25
-#define ASD_AE49F2008 0x52
-
-#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
-#define AT_29C040A 0xA4 /* Winbond w29c020c device code */
-
-#define MX_ID 0xC2
-#define MX_29F002 0xB0
-
-#define SHARP_ID 0xB0
-#define SHARP_LHF00L04 0xCF
-
-#define SST_ID 0xBF /* SST Manufacturer ID code */
-#define SST_29EE020A 0x10 /* SST 29EE020 device */
-#define SST_28SF040 0x04 /* SST 29EE040 device */
-#define SST_39SF010 0xB5 /* SST 39SF010A device */
-#define SST_39SF020 0xB6 /* SST 39SF020A device */
-#define SST_39SF040 0xB7 /* SST 39SF040 device */
-#define SST_39VF020 0xD6 /* SST 39VF020 device */
-#define SST_49LF040B 0x50 /* SST 49LF040B device */
-#define SST_49LF040 0x51 /* SST 49LF040 device */
-#define SST_49LF020A 0x52 /* SST 49LF020A device */
-#define SST_49LF080A 0x5B /* SST 48LF080A device */
-#define SST_49LF002A 0x57 /* SST 49LF002A device */
-#define SST_49LF003A 0x1B /* SST 49LF003A device */
-#define SST_49LF004A 0x60 /* SST 49LF004A device */
-#define SST_49LF008A 0x5A /* SST 49LF008A device */
-#define SST_49LF004C 0x54 /* SST 49LF004C device */
-#define SST_49LF008C 0x59 /* SST 49LF008C device */
-#define SST_49LF016C 0x5C /* SST 49LF016C device */
-#define SST_49LF160C 0x4C /* SST 49LF160C device */
-
-#define PMC_ID 0x9D /* PMC Manufacturer ID code */
-#define PMC_49FL002 0x6D /* PMC 49FL002 device code */
-#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
-
-#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
-#define W_29C011 0xC1 /* Winbond w29c011 device code */
-#define W_29C020C 0x45 /* Winbond w29c020c device code */
-#define W_39V040A 0x3D /* Winbond w39v040a device code */
-#define W_39V040B 0x54 /* Winbond w39v040b device code */
-#define W_39V080A 0xD0 /* Winbond w39v080a device code */
-#define W_49F002U 0x0B /* Winbond w49F002u device code */
-#define W_49V002A 0xB0 /* Winbond W49V002A device code */
-#define W_49V002FA 0x32 /* Winbond W49V002FA device code */
-
-#define ST_ID 0x20
-#define ST_M29F040B 0xE2
-#define ST_M29F400BT 0xD5
-
-#define EMST_ID 0x8c /* EMST - Elite Flash Storage Inc. Manufacturer ID code */
-#define EMST_F49B002UA 0x00 /* EMST F49B002UA device code */
-
-#define MSYSTEMS_ID 0x156f
-#define MSYSTEMS_MD2200 0xdb /* ? */
-#define MSYSTEMS_MD2800 0x30 /* hmm -- both 0x30 */
-#define MSYSTEMS_MD2802 0x30 /* hmm -- both 0x30 */
-
-#define SYNCMOS_ID 0x40 /* SyncMOS ID */
-#define S29C51001T 0x01 /* SyncMOS S29C51001T/B */
-#define S29C51002T 0x02 /* SyncMOS S29C51002T/B */
-#define S29C51004T 0x03 /* SyncMOS S29C51004T/B */
-#define S29C31004T 0x63 /* SyncMOS S29C31004T */
+#define AMD_ID 0x01
+#define AM_29F040B 0xA4
+#define AM_29F016D 0xAD
+
+#define ASD_ID 0x25
+#define ASD_AE49F2008 0x52
+
+#define ATMEL_ID 0x1F /* Winbond Manufacture ID code */
+#define AT_29C040A 0xA4 /* Winbond w29c020c device code */
+
+#define MX_ID 0xC2
+#define MX_29F002 0xB0
+
+#define SHARP_ID 0xB0
+#define SHARP_LHF00L04 0xCF
+
+#define SST_ID 0xBF /* SST Manufacturer ID code */
+#define SST_29EE020A 0x10 /* SST 29EE020 device */
+#define SST_28SF040 0x04 /* SST 29EE040 device */
+#define SST_39SF010 0xB5 /* SST 39SF010A device */
+#define SST_39SF020 0xB6 /* SST 39SF020A device */
+#define SST_39SF040 0xB7 /* SST 39SF040 device */
+#define SST_39VF020 0xD6 /* SST 39VF020 device */
+#define SST_49LF040B 0x50 /* SST 49LF040B device */
+#define SST_49LF040 0x51 /* SST 49LF040 device */
+#define SST_49LF020A 0x52 /* SST 49LF020A device */
+#define SST_49LF080A 0x5B /* SST 48LF080A device */
+#define SST_49LF002A 0x57 /* SST 49LF002A device */
+#define SST_49LF003A 0x1B /* SST 49LF003A device */
+#define SST_49LF004A 0x60 /* SST 49LF004A device */
+#define SST_49LF008A 0x5A /* SST 49LF008A device */
+#define SST_49LF004C 0x54 /* SST 49LF004C device */
+#define SST_49LF008C 0x59 /* SST 49LF008C device */
+#define SST_49LF016C 0x5C /* SST 49LF016C device */
+#define SST_49LF160C 0x4C /* SST 49LF160C device */
+
+#define PMC_ID 0x9D /* PMC Manufacturer ID code */
+#define PMC_49FL002 0x6D /* PMC 49FL002 device code */
+#define PMC_49FL004 0x6E /* PMC 49FL004 device code */
+
+#define WINBOND_ID 0xDA /* Winbond Manufacture ID code */
+#define W_29C011 0xC1 /* Winbond w29c011 device code */
+#define W_29C020C 0x45 /* Winbond w29c020c device code */
+#define W_39V040A 0x3D /* Winbond w39v040a device code */
+#define W_39V040B 0x54 /* Winbond w39v040b device code */
+#define W_39V080A 0xD0 /* Winbond w39v080a device code */
+#define W_49F002U 0x0B /* Winbond w49F002u device code */
+#define W_49V002A 0xB0 /* Winbond W49V002A device code */
+#define W_49V002FA 0x32 /* Winbond W49V002FA device code */
+
+#define ST_ID 0x20
+#define ST_M29F040B 0xE2
+#define ST_M29F400BT 0xD5
+
+#define EMST_ID 0x8c /* EMST - Elite Flash Storage Inc. Manufacturer ID code */
+#define EMST_F49B002UA 0x00 /* EMST F49B002UA device code */
+
+#define MSYSTEMS_ID 0x156f
+#define MSYSTEMS_MD2200 0xdb /* ? */
+#define MSYSTEMS_MD2800 0x30 /* hmm -- both 0x30 */
+#define MSYSTEMS_MD2802 0x30 /* hmm -- both 0x30 */
+
+#define SYNCMOS_ID 0x40 /* SyncMOS ID */
+#define S29C51001T 0x01 /* SyncMOS S29C51001T/B */
+#define S29C51002T 0x02 /* SyncMOS S29C51002T/B */
+#define S29C51004T 0x03 /* SyncMOS S29C51004T/B */
+#define S29C31004T 0x63 /* SyncMOS S29C31004T */
/* function prototypes from udelay.h */
diff --git a/jedec.h b/jedec.h
index 210f9f9..c5c5c64 100644
--- a/jedec.h
+++ b/jedec.h
@@ -9,8 +9,7 @@ extern int write_jedec(struct flashchip *flash, uint8_t *buf);
extern int erase_sector_jedec(volatile uint8_t *bios, unsigned int page);
extern int erase_block_jedec(volatile uint8_t *bios, unsigned int page);
extern int write_sector_jedec(volatile uint8_t *bios, uint8_t *src,
- volatile uint8_t *dst,
- unsigned int page_size);
+ volatile uint8_t *dst, unsigned int page_size);
extern __inline__ void toggle_ready_jedec(volatile uint8_t *dst)
{
@@ -45,21 +44,21 @@ extern __inline__ void data_polling_jedec(volatile uint8_t *dst, uint8_t data)
extern __inline__ void unprotect_jedec(volatile uint8_t *bios)
{
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0x80;
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0x20;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x80;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x20;
usleep(200);
}
extern __inline__ void protect_jedec(volatile uint8_t *bios)
{
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0xA0;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xA0;
usleep(200);
}
diff --git a/layout.h b/layout.h
index ec1fd1b..b717d34 100644
--- a/layout.h
+++ b/layout.h
@@ -6,5 +6,4 @@ int read_romlayout(char *name);
int find_romentry(char *name);
int handle_romentries(uint8_t *buffer, uint8_t *content);
-
#endif /* !__LAYOUT_H__ */
diff --git a/msys_doc.h b/msys_doc.h
index 02da23c..1d79e13 100644
--- a/msys_doc.h
+++ b/msys_doc.h
@@ -19,13 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
-
#ifndef __MSYS_DOC_H__
#define __MSYS_DOC_H__ 1
-
-
/* idea from include/linux/mtd/doc2000.h */
/* registers with __ should not be read/written directly */
#define MSYSTEMS_DOC_R__ChipID 0x1000
@@ -66,8 +62,6 @@
#define MSYSTEMS_DOC_R_CDSNIO_BASE 0x0800
#define MSYSTEMS_DOC_W_CDSNIO_BASE 0x0800
-
-
#define doc_read(base,reg) \
(*(volatile uint8_t *)(base + MSYSTEMS_DOC_R_##reg))
@@ -98,13 +92,9 @@
#define doc_toggle(base) /* 0, 1, 0, 1, 0, 1, ... if a doc is present */ \
( (doc_read(base, ECCConfiguration) & 0x04) >> 2 )
-
-
extern int probe_md2802(struct flashchip *flash);
extern int read_md2802(struct flashchip *flash, uint8_t *buf);
extern int erase_md2802(struct flashchip *flash);
extern int write_md2802(struct flashchip *flash, uint8_t *buf);
-
-
#endif /* !__MSYS_DOC_H__ */
diff --git a/mx29f002.c b/mx29f002.c
index 769e944..8535474 100644
--- a/mx29f002.c
+++ b/mx29f002.c
@@ -40,8 +40,8 @@ int probe_29f002(struct flashchip *flash)
*(bios + 0x2AAA) = 0x55;
*(bios + 0x5555) = 0x90;
- id1 = *(volatile uint8_t *) bios;
- id2 = *(volatile uint8_t *) (bios + 0x01);
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
*bios = 0xF0;
@@ -101,7 +101,7 @@ int write_29f002(struct flashchip *flash, uint8_t *buf)
for (i = 0; i < total_size; i++) {
/* write to the sector */
if ((i & 0xfff) == 0)
- printf("address: 0x%08lx", (unsigned long) i);
+ printf("address: 0x%08lx", (unsigned long)i);
*(bios + 0x5555) = 0xAA;
*(bios + 0x2AAA) = 0x55;
*(bios + 0x5555) = 0xA0;
diff --git a/pm49fl004.c b/pm49fl004.c
index baa80a8..9995177 100644
--- a/pm49fl004.c
+++ b/pm49fl004.c
@@ -32,15 +32,15 @@ extern int exclude_start_page, exclude_end_page;
int write_49fl004(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
-
+
printf("Programming Page: ");
for (i = 0; i < total_size / page_size; i++) {
- if( (i>=exclude_start_page) && (i<exclude_end_page))
+ if ((i >= exclude_start_page) && (i < exclude_end_page))
continue;
-
+
/* erase the page before programming */
erase_block_jedec(bios, i * page_size);
diff --git a/sharplhf00l04.h b/sharplhf00l04.h
index 3b8852a..e2352a0 100644
--- a/sharplhf00l04.h
+++ b/sharplhf00l04.h
@@ -20,7 +20,8 @@ extern __inline__ void toggle_ready_lhf00l04(volatile uint8_t *dst)
}
}
-extern __inline__ void data_polling_lhf00l04(volatile uint8_t *dst, uint8_t data)
+extern __inline__ void data_polling_lhf00l04(volatile uint8_t *dst,
+ uint8_t data)
{
unsigned int i = 0;
uint8_t tmp;
@@ -37,9 +38,9 @@ extern __inline__ void data_polling_lhf00l04(volatile uint8_t *dst, uint8_t data
extern __inline__ void protect_lhf00l04(volatile uint8_t *bios)
{
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0xA0;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xA0;
usleep(200);
}
diff --git a/sst39sf020.c b/sst39sf020.c
index 30433f5..9c71659 100644
--- a/sst39sf020.c
+++ b/sst39sf020.c
@@ -50,8 +50,8 @@ static __inline__ int erase_sector_39sf020(volatile uint8_t *bios,
int write_39sf020(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
erase_chip_jedec(flash);
diff --git a/sst49lf040.c b/sst49lf040.c
index 36537f2..0d31d82 100644
--- a/sst49lf040.c
+++ b/sst49lf040.c
@@ -31,16 +31,16 @@
int erase_49lf040(struct flashchip *flash)
{
- int i;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
- volatile uint8_t *bios = flash->virt_addr;
+ int i;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
+ volatile uint8_t *bios = flash->virt_addr;
- for (i = 0; i < total_size / page_size; i++) {
+ for (i = 0; i < total_size / page_size; i++) {
/* Chip erase only works in parallel programming mode
* for the 49lf040. Use sector-erase instead */
erase_sector_jedec(bios, i * page_size);
- }
+ }
return 0;
}
@@ -60,7 +60,7 @@ int write_49lf040(struct flashchip *flash, uint8_t *buf)
/* write to the sector */
printf("%04d at address: 0x%08x ", i, i * page_size);
-
+
write_sector_jedec(bios, buf + i * page_size,
bios + i * page_size, page_size);
diff --git a/sst_fwhub.c b/sst_fwhub.c
index 34a59da..5d811a6 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -90,15 +90,15 @@ int erase_sst_fwhub(struct flashchip *flash)
int write_sst_fwhub(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
// FIXME: We want block wide erase instead of ironing the whole chip
erase_sst_fwhub(flash);
-
+
// dumb check if erase was successful.
- for (i=0; i < total_size; i++) {
+ for (i = 0; i < total_size; i++) {
if (bios[i] != 0xff) {
printf("ERASE FAILED\n");
return -1;
diff --git a/udelay.c b/udelay.c
index e2fd310..91c3c6d 100644
--- a/udelay.c
+++ b/udelay.c
@@ -8,7 +8,7 @@ unsigned long micro = 1;
void myusec_delay(int time)
{
volatile unsigned long i;
- for (i = 0; i < time * micro; i++);
+ for (i = 0; i < time * micro; i++) ;
}
void myusec_calibrate_delay()
@@ -34,5 +34,5 @@ void myusec_calibrate_delay()
// compute one microsecond. That will be count / time
micro = count / timeusec;
- printf_debug("%ldM loops per second\n", (unsigned long) micro);
+ printf_debug("%ldM loops per second\n", (unsigned long)micro);
}
diff --git a/w49f002u.c b/w49f002u.c
index e37e179..9a698ae 100644
--- a/w49f002u.c
+++ b/w49f002u.c
@@ -34,8 +34,8 @@
int write_49f002(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
erase_chip_jedec(flash);
OpenPOWER on IntegriCloud