1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-28 15:33:42 +02:00

Indent according to development guidelines

Corresponding to flashrom svn r277 and coreboot v2 svn r3392.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
This commit is contained in:
Stefan Reinauer 2008-06-27 15:18:20 +00:00 committed by Stefan Reinauer
parent 43b2281f51
commit 325b5d47d8

View File

@ -71,7 +71,6 @@
#define SPI_OPCODE_TYPE_READ_WITH_ADDRESS 2 #define SPI_OPCODE_TYPE_READ_WITH_ADDRESS 2
#define SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS 3 #define SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS 3
typedef struct _OPCODE { typedef struct _OPCODE {
uint8_t opcode; //This commands spi opcode uint8_t opcode; //This commands spi opcode
uint8_t spi_type; //This commands spi type uint8_t spi_type; //This commands spi type
@ -96,15 +95,13 @@ typedef struct _OPCODES {
OPCODE opcode[8]; OPCODE opcode[8];
} OPCODES; } OPCODES;
static OPCODES *curopcodes = NULL;
static OPCODES *curopcodes=NULL;
/* HW access functions */ /* HW access functions */
static inline uint32_t REGREAD32(int X) static inline uint32_t REGREAD32(int X)
{ {
volatile uint32_t regval; volatile uint32_t regval;
regval = *(volatile uint32_t *)((uint8_t *)ich_spibar + X); regval = *(volatile uint32_t *)((uint8_t *) ich_spibar + X);
return regval; return regval;
} }
@ -112,20 +109,20 @@ static inline uint32_t REGREAD32(int X)
#define REGWRITE16(X,Y) (*(uint16_t *)((uint8_t *)ich_spibar+X)=Y) #define REGWRITE16(X,Y) (*(uint16_t *)((uint8_t *)ich_spibar+X)=Y)
#define REGWRITE8(X,Y) (*(uint8_t *)((uint8_t *)ich_spibar+X)=Y) #define REGWRITE8(X,Y) (*(uint8_t *)((uint8_t *)ich_spibar+X)=Y)
/* Common SPI functions */ /* Common SPI functions */
static int program_opcodes(OPCODES * op); 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 run_opcode(uint8_t nr, OPCODE op, uint32_t offset,
static int ich_spi_read_page(struct flashchip *flash, uint8_t * buf, int Offset); uint8_t datalength, uint8_t * data);
static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes, int Offset); 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); static int ich_spi_erase_block(struct flashchip *flash, int offset);
OPCODES O_ST_M25P = { OPCODES O_ST_M25P = {
{ {
JEDEC_WREN, JEDEC_WREN,
0 0},
},
{ {
{JEDEC_BYTE_PROGRAM, SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 1}, // Write Byte {JEDEC_BYTE_PROGRAM, SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS, 1}, // Write Byte
{JEDEC_READ, SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 0}, // Read Data {JEDEC_READ, SPI_OPCODE_TYPE_READ_WITH_ADDRESS, 0}, // Read Data
@ -138,7 +135,6 @@ OPCODES O_ST_M25P = {
} }
}; };
int program_opcodes(OPCODES * op) int program_opcodes(OPCODES * op)
{ {
uint8_t a; uint8_t a;
@ -275,7 +271,6 @@ int run_opcode(uint8_t nr, OPCODE op, uint32_t offset, uint8_t datalength,
return 0; return 0;
} }
static int ich_spi_erase_block(struct flashchip *flash, int offset) static int ich_spi_erase_block(struct flashchip *flash, int offset)
{ {
printf_debug("Spi_Erase,Offset=%d,sectors=%d\n", offset, 1); printf_debug("Spi_Erase,Offset=%d,sectors=%d\n", offset, 1);
@ -296,7 +291,8 @@ static int ich_spi_read_page(struct flashchip *flash, uint8_t * buf, int Offset)
uint32_t remaining = flash->page_size; uint32_t remaining = flash->page_size;
int a; 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) { for (a = 0; a < page_size; a += MAXDATABYTES) {
if (remaining < MAXDATABYTES) { if (remaining < MAXDATABYTES) {
@ -331,8 +327,8 @@ static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
uint32_t remaining = page_size; uint32_t remaining = page_size;
int a; int a;
printf_debug("write_page_ichspi,Offset=%d,number=%d,buf=%p\n", Offset, page_size, printf_debug("write_page_ichspi,Offset=%d,number=%d,buf=%p\n", Offset,
bytes); page_size, bytes);
for (a = 0; a < page_size; a += MAXDATABYTES) { for (a = 0; a < page_size; a += MAXDATABYTES) {
if (remaining < MAXDATABYTES) { if (remaining < MAXDATABYTES) {
@ -359,7 +355,6 @@ static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
return 0; return 0;
} }
int ich_spi_read(struct flashchip *flash, uint8_t * buf) int ich_spi_read(struct flashchip *flash, uint8_t * buf)
{ {
int i, rc = 0; int i, rc = 0;
@ -374,7 +369,6 @@ int ich_spi_read(struct flashchip *flash, uint8_t * buf)
return rc; return rc;
} }
int ich_spi_write(struct flashchip *flash, uint8_t * buf) int ich_spi_write(struct flashchip *flash, uint8_t * buf)
{ {
int i, j, rc = 0; int i, j, rc = 0;
@ -404,7 +398,8 @@ int ich_spi_write(struct flashchip *flash, uint8_t * buf)
return rc; 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 a;
int opcode_index = -1; int opcode_index = -1;
@ -417,7 +412,7 @@ int ich_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned
/* program opcodes if not already done */ /* program opcodes if not already done */
if (curopcodes == NULL) { if (curopcodes == NULL) {
printf_debug("Programming OPCODES\n"); printf_debug("Programming OPCODES\n");
curopcodes=&O_ST_M25P; curopcodes = &O_ST_M25P;
program_opcodes(curopcodes); program_opcodes(curopcodes);
} }
@ -440,22 +435,19 @@ int ich_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned
/* if opcode-type requires an address */ /* if opcode-type requires an address */
if (opcode->spi_type == SPI_OPCODE_TYPE_READ_WITH_ADDRESS || if (opcode->spi_type == SPI_OPCODE_TYPE_READ_WITH_ADDRESS ||
opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) { opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) {
addr = (writearr[1]<<16) | addr = (writearr[1] << 16) |
(writearr[2]<<8) | (writearr[2] << 8) | (writearr[3] << 0);
(writearr[3]<<0);
} }
/* translate read/write array/count */ /* translate read/write array/count */
if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS) { if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS) {
data = (uint8_t*)(writearr+1); data = (uint8_t *) (writearr + 1);
count = writecnt-1; count = writecnt - 1;
} } else if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) {
else if (opcode->spi_type == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS) { data = (uint8_t *) (writearr + 4);
data = (uint8_t*)(writearr+4); count = writecnt - 4;
count = writecnt-4; } else {
} data = (uint8_t *) readarr;
else {
data = (uint8_t*)readarr;
count = readcnt; count = readcnt;
} }