[coreboot] r3392 - trunk/util/flashrom

svn at coreboot.org svn at coreboot.org
Fri Jun 27 17:18:20 CEST 2008


Author: stepan
Date: 2008-06-27 17:18:20 +0200 (Fri, 27 Jun 2008)
New Revision: 3392

Modified:
   trunk/util/flashrom/ichspi.c
Log:
indent according to development guidelines (trivial)
Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Stefan Reinauer <stepan at coresystems.de>


Modified: trunk/util/flashrom/ichspi.c
===================================================================
--- trunk/util/flashrom/ichspi.c	2008-06-26 19:42:25 UTC (rev 3391)
+++ trunk/util/flashrom/ichspi.c	2008-06-27 15:18:20 UTC (rev 3392)
@@ -71,7 +71,6 @@
 #define SPI_OPCODE_TYPE_READ_WITH_ADDRESS   2
 #define SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS  3
 
-
 typedef struct _OPCODE {
 	uint8_t opcode;		//This commands spi opcode
 	uint8_t spi_type;	//This commands spi type
@@ -96,15 +95,13 @@
 	OPCODE opcode[8];
 } OPCODES;
 
+static OPCODES *curopcodes = NULL;
 
-static OPCODES *curopcodes=NULL;
-
-
 /* HW access functions */
 static inline uint32_t REGREAD32(int X)
 {
 	volatile uint32_t regval;
-	regval = *(volatile uint32_t *)((uint8_t *)ich_spibar + X);
+	regval = *(volatile uint32_t *)((uint8_t *) ich_spibar + X);
 	return regval;
 }
 
@@ -112,33 +109,32 @@
 #define REGWRITE16(X,Y) (*(uint16_t *)((uint8_t *)ich_spibar+X)=Y)
 #define REGWRITE8(X,Y)  (*(uint8_t *)((uint8_t *)ich_spibar+X)=Y)
 
-
 /* Common SPI functions */
 static int program_opcodes(OPCODES * op);
-static int run_opcode(uint8_t nr, OPCODE op, uint32_t offset, uint8_t datalength, uint8_t * data);
-static int ich_spi_read_page(struct flashchip *flash, uint8_t * buf, int Offset);
-static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes, int Offset);
+static int run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
+		      uint8_t datalength, uint8_t * data);
+static int ich_spi_read_page(struct flashchip *flash, uint8_t * buf,
+			     int Offset);
+static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
+			      int Offset);
 static int ich_spi_erase_block(struct flashchip *flash, int offset);
 
-
 OPCODES O_ST_M25P = {
 	{
 	 JEDEC_WREN,
-	 0
-	},
+	 0},
 	{
-	 {JEDEC_BYTE_PROGRAM, 	SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 	1},	// Write Byte
-	 {JEDEC_READ, 		SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 	0},	// Read Data
-	 {JEDEC_BE_D8, 		SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 	1},	// Erase Sector
-	 {JEDEC_RDSR, 		SPI_OPCODE_TYPE_READ_NO_ADDRESS, 	0},	// Read Device Status Reg
-	 {JEDEC_RES, 		SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 	0},	// Resume Deep Power-Down
-	 {JEDEC_WRSR, 		SPI_OPCODE_TYPE_WRITE_NO_ADDRESS, 	1},	// Write Status Register
-	 {JEDEC_RDID, 		SPI_OPCODE_TYPE_READ_NO_ADDRESS, 	0},	// Read JDEC ID
-	 {JEDEC_CE_C7, 		SPI_OPCODE_TYPE_WRITE_NO_ADDRESS, 	1},	// Bulk erase
-	}
+	 {JEDEC_BYTE_PROGRAM, SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 1},	// Write Byte
+	 {JEDEC_READ, SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 0},	// Read Data
+	 {JEDEC_BE_D8, SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 1},	// Erase Sector
+	 {JEDEC_RDSR, SPI_OPCODE_TYPE_READ_NO_ADDRESS, 0},	// Read Device Status Reg
+	 {JEDEC_RES, SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 0},	// Resume Deep Power-Down
+	 {JEDEC_WRSR, SPI_OPCODE_TYPE_WRITE_NO_ADDRESS, 1},	// Write Status Register
+	 {JEDEC_RDID, SPI_OPCODE_TYPE_READ_NO_ADDRESS, 0},	// Read JDEC ID
+	 {JEDEC_CE_C7, SPI_OPCODE_TYPE_WRITE_NO_ADDRESS, 1},	// Bulk erase
+	 }
 };
 
-
 int program_opcodes(OPCODES * op)
 {
 	uint8_t a;
@@ -178,7 +174,7 @@
 }
 
 int run_opcode(uint8_t nr, OPCODE op, uint32_t offset, uint8_t datalength,
-	      uint8_t * data)
+	       uint8_t * data)
 {
 	int write_cmd = 0;
 	uint32_t temp32;
@@ -275,7 +271,6 @@
 	return 0;
 }
 
-
 static int ich_spi_erase_block(struct flashchip *flash, int offset)
 {
 	printf_debug("Spi_Erase,Offset=%d,sectors=%d\n", offset, 1);
@@ -296,7 +291,8 @@
 	uint32_t remaining = flash->page_size;
 	int a;
 
-	printf_debug("Spi_Read,Offset=%d,number=%d,buf=%p\n", Offset, page_size, buf);
+	printf_debug("Spi_Read,Offset=%d,number=%d,buf=%p\n", Offset, page_size,
+		     buf);
 
 	for (a = 0; a < page_size; a += MAXDATABYTES) {
 		if (remaining < MAXDATABYTES) {
@@ -325,14 +321,14 @@
 }
 
 static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
-			     int Offset)
+			      int Offset)
 {
 	int page_size = flash->page_size;
 	uint32_t remaining = page_size;
 	int a;
 
-	printf_debug("write_page_ichspi,Offset=%d,number=%d,buf=%p\n", Offset, page_size,
-	       bytes);
+	printf_debug("write_page_ichspi,Offset=%d,number=%d,buf=%p\n", Offset,
+		     page_size, bytes);
 
 	for (a = 0; a < page_size; a += MAXDATABYTES) {
 		if (remaining < MAXDATABYTES) {
@@ -359,7 +355,6 @@
 	return 0;
 }
 
-
 int ich_spi_read(struct flashchip *flash, uint8_t * buf)
 {
 	int i, rc = 0;
@@ -368,13 +363,12 @@
 
 	for (i = 0; (i < total_size / page_size) && (rc == 0); i++) {
 		rc = ich_spi_read_page(flash, (void *)(buf + i * page_size),
-				      i * page_size);
+				       i * page_size);
 	}
 
 	return rc;
 }
 
-
 int ich_spi_write(struct flashchip *flash, uint8_t * buf)
 {
 	int i, j, rc = 0;
@@ -392,7 +386,7 @@
 			printf("Error erasing block at 0x%x\n", i);
 			break;
 		}
-		
+
 		for (j = 0; j < erase_size / page_size; j++) {
 			ich_spi_write_page(flash, (void *)(buf + (i * erase_size) + (j * page_size)),
 					   (i * erase_size) + (j * page_size));
@@ -404,7 +398,8 @@
 	return rc;
 }
 
-int ich_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr)
+int ich_spi_command(unsigned int writecnt, unsigned int readcnt,
+		    const unsigned char *writearr, unsigned char *readarr)
 {
 	int a;
 	int opcode_index = -1;
@@ -417,7 +412,7 @@
 	/* program opcodes if not already done */
 	if (curopcodes == NULL) {
 		printf_debug("Programming OPCODES\n");
-		curopcodes=&O_ST_M25P;
+		curopcodes = &O_ST_M25P;
 		program_opcodes(curopcodes);
 	}
 
@@ -440,25 +435,22 @@
 	/* if opcode-type requires an address */
 	if (opcode->spi_type == SPI_OPCODE_TYPE_READ_WITH_ADDRESS ||
 	    opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) {
-		addr = (writearr[1]<<16) |
-		       (writearr[2]<<8)  |
-		       (writearr[3]<<0);
+		addr = (writearr[1] << 16) |
+		    (writearr[2] << 8) | (writearr[3] << 0);
 	}
-	
+
 	/* translate read/write array/count */
 	if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS) {
-		data = (uint8_t*)(writearr+1);
-		count = writecnt-1;
-	}
-	else if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) {
-		data = (uint8_t*)(writearr+4);
-		count = writecnt-4;
-	}
-	else {
-		data = (uint8_t*)readarr;
+		data = (uint8_t *) (writearr + 1);
+		count = writecnt - 1;
+	} else if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) {
+		data = (uint8_t *) (writearr + 4);
+		count = writecnt - 4;
+	} else {
+		data = (uint8_t *) readarr;
 		count = readcnt;
 	}
-	
+
 	if (run_opcode(opcode_index, *opcode, addr, count, data) != 0) {
 		printf_debug("run OPCODE 0x%02x failed\n", opcode->opcode);
 		return 1;





More information about the coreboot mailing list