Commit 50fd8b1f authored by Michael Welling's avatar Michael Welling Committed by Greg Kroah-Hartman

STAGING: cxt1e1: Indentation fixes

Indentation fixes using Lindent.
Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9200b4da
...@@ -44,10 +44,9 @@ ...@@ -44,10 +44,9 @@
* using. * using.
*/ */
#define EE_MFG (long)0 /* Index to manufacturing record */ #define EE_MFG (long)0 /* Index to manufacturing record */
#define EE_FIRST 0x28 /* Index to start testing at */ #define EE_FIRST 0x28 /* Index to start testing at */
#define EE_LIMIT 128 /* Index to end testing at */ #define EE_LIMIT 128 /* Index to end testing at */
/* Bit Ordering for Instructions /* Bit Ordering for Instructions
** **
...@@ -55,27 +54,25 @@ ...@@ -55,27 +54,25 @@
** **
*/ */
#define EPROM_EWEN 0x0019 /* Erase/Write enable (reversed) */ #define EPROM_EWEN 0x0019 /* Erase/Write enable (reversed) */
#define EPROM_EWDS 0x0001 /* Erase/Write disable (reversed) */ #define EPROM_EWDS 0x0001 /* Erase/Write disable (reversed) */
#define EPROM_READ 0x0003 /* Read (reversed) */ #define EPROM_READ 0x0003 /* Read (reversed) */
#define EPROM_WRITE 0x0005 /* Write (reversed) */ #define EPROM_WRITE 0x0005 /* Write (reversed) */
#define EPROM_ERASE 0x0007 /* Erase (reversed) */ #define EPROM_ERASE 0x0007 /* Erase (reversed) */
#define EPROM_ERAL 0x0009 /* Erase All (reversed) */ #define EPROM_ERAL 0x0009 /* Erase All (reversed) */
#define EPROM_WRAL 0x0011 /* Write All (reversed) */ #define EPROM_WRAL 0x0011 /* Write All (reversed) */
#define EPROM_ADR_SZ 7 /* Number of bits in offset address */ #define EPROM_ADR_SZ 7 /* Number of bits in offset address */
#define EPROM_OP_SZ 3 /* Number of bits in command */ #define EPROM_OP_SZ 3 /* Number of bits in command */
#define SIZE_ADDR_OP (EPROM_ADR_SZ + EPROM_OP_SZ) #define SIZE_ADDR_OP (EPROM_ADR_SZ + EPROM_OP_SZ)
#define LC46A_MAX_OPS 10 /* Number of bits in Instruction */ #define LC46A_MAX_OPS 10 /* Number of bits in Instruction */
#define NUM_OF_BITS 8 /* Number of bits in data */ #define NUM_OF_BITS 8 /* Number of bits in data */
/* EEPROM signal bits */ /* EEPROM signal bits */
#define EPROM_ACTIVE_OUT_BIT 0x0001 /* Out data bit */ #define EPROM_ACTIVE_OUT_BIT 0x0001 /* Out data bit */
#define EPROM_ACTIVE_IN_BIT 0x0002 /* In data bit */ #define EPROM_ACTIVE_IN_BIT 0x0002 /* In data bit */
#define ACTIVE_IN_BIT_SHIFT 0x0001 /* Shift In data bit to LSB */ #define ACTIVE_IN_BIT_SHIFT 0x0001 /* Shift In data bit to LSB */
#define EPROM_ENCS 0x0004 /* Set EEPROM CS during operation */ #define EPROM_ENCS 0x0004 /* Set EEPROM CS during operation */
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* The ByteReverse table is used to reverses the 8 bits within a byte * The ByteReverse table is used to reverses the 8 bits within a byte
...@@ -83,29 +80,26 @@ ...@@ -83,29 +80,26 @@
*/ */
static unsigned char ByteReverse[256]; static unsigned char ByteReverse[256];
static int ByteReverseBuilt = FALSE; static int ByteReverseBuilt = FALSE;
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* mfg_template - initial serial EEPROM data structure * mfg_template - initial serial EEPROM data structure
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
static u8 mfg_template[sizeof(FLD_TYPE2)] = static u8 mfg_template[sizeof(FLD_TYPE2)] = {
{ PROM_FORMAT_TYPE2, /* type; */
PROM_FORMAT_TYPE2, /* type; */ 0x00, 0x1A, /* length[2]; */
0x00, 0x1A, /* length[2]; */ 0x00, 0x00, 0x00, 0x00, /* Crc32[4]; */
0x00, 0x00, 0x00, 0x00, /* Crc32[4]; */ 0x11, 0x76, /* Id[2]; */
0x11, 0x76, /* Id[2]; */ 0x07, 0x05, /* SubId[2] E1; */
0x07, 0x05, /* SubId[2] E1; */ 0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00, /* Serial[6]; */
0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00, /* Serial[6]; */ 0x00, 0x00, 0x00, 0x00, /* CreateTime[4]; */
0x00, 0x00, 0x00, 0x00, /* CreateTime[4]; */ 0x00, 0x00, 0x00, 0x00, /* HeatRunTime[4]; */
0x00, 0x00, 0x00, 0x00, /* HeatRunTime[4]; */ 0x00, 0x00, 0x00, 0x00, /* HeatRunIterations[4]; */
0x00, 0x00, 0x00, 0x00, /* HeatRunIterations[4]; */ 0x00, 0x00, 0x00, 0x00, /* HeatRunErrors[4]; */
0x00, 0x00, 0x00, 0x00, /* HeatRunErrors[4]; */
}; };
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* BuildByteReverse - build the 8-bit reverse table * BuildByteReverse - build the 8-bit reverse table
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -114,39 +108,35 @@ static u8 mfg_template[sizeof(FLD_TYPE2)] = ...@@ -114,39 +108,35 @@ static u8 mfg_template[sizeof(FLD_TYPE2)] =
* (the MSB becomes the LSB etc.). * (the MSB becomes the LSB etc.).
*/ */
static void static void BuildByteReverse(void)
BuildByteReverse (void)
{ {
long half; /* Used to build by powers to 2 */ long half; /* Used to build by powers to 2 */
int i; int i;
ByteReverse[0] = 0; ByteReverse[0] = 0;
for (half = 1; half < sizeof (ByteReverse); half <<= 1) for (half = 1; half < sizeof(ByteReverse); half <<= 1)
for (i = 0; i < half; i++) for (i = 0; i < half; i++)
ByteReverse[half + i] = (char) (ByteReverse[i] | (0x80 / half)); ByteReverse[half + i] =
(char)(ByteReverse[i] | (0x80 / half));
ByteReverseBuilt = TRUE; ByteReverseBuilt = TRUE;
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* eeprom_delay - small delay for EEPROM timing * eeprom_delay - small delay for EEPROM timing
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
static void static void eeprom_delay(void)
eeprom_delay (void)
{ {
int timeout; int timeout;
for (timeout = 20; timeout; --timeout) for (timeout = 20; timeout; --timeout) {
{ OS_uwait_dummy();
OS_uwait_dummy (); }
}
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* eeprom_put_byte - Send a byte to the EEPROM serially * eeprom_put_byte - Send a byte to the EEPROM serially
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -155,23 +145,20 @@ eeprom_delay (void) ...@@ -155,23 +145,20 @@ eeprom_delay (void)
* the data to the EEPROM. * the data to the EEPROM.
*/ */
static void static void eeprom_put_byte(long addr, long data, int count)
eeprom_put_byte (long addr, long data, int count)
{ {
u_int32_t output; u_int32_t output;
while (--count >= 0) while (--count >= 0) {
{ output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0; /* Get next data bit */
output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0; /* Get next data bit */ output |= EPROM_ENCS; /* Add Chip Select */
output |= EPROM_ENCS; /* Add Chip Select */ data >>= 1;
data >>= 1;
eeprom_delay (); eeprom_delay();
pci_write_32 ((u_int32_t *) addr, output); /* Output it */ pci_write_32((u_int32_t *) addr, output); /* Output it */
} }
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* eeprom_get_byte - Receive a byte from the EEPROM serially * eeprom_get_byte - Receive a byte from the EEPROM serially
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -180,12 +167,11 @@ eeprom_put_byte (long addr, long data, int count) ...@@ -180,12 +167,11 @@ eeprom_put_byte (long addr, long data, int count)
* from the EEPROM. * from the EEPROM.
*/ */
static u_int32_t static u_int32_t eeprom_get_byte(long addr)
eeprom_get_byte (long addr)
{ {
u_int32_t input; u_int32_t input;
u_int32_t data; u_int32_t data;
int count; int count;
/* Start the Reading of DATA /* Start the Reading of DATA
** **
...@@ -193,24 +179,22 @@ eeprom_get_byte (long addr) ...@@ -193,24 +179,22 @@ eeprom_get_byte (long addr)
** EPLD and read on the next read access to the EEPROM. ** EPLD and read on the next read access to the EEPROM.
*/ */
input = pci_read_32 ((u_int32_t *) addr); input = pci_read_32((u_int32_t *) addr);
data = 0; data = 0;
count = NUM_OF_BITS; count = NUM_OF_BITS;
while (--count >= 0) while (--count >= 0) {
{ eeprom_delay();
eeprom_delay (); input = pci_read_32((u_int32_t *) addr);
input = pci_read_32 ((u_int32_t *) addr);
data <<= 1; /* Shift data over */ data <<= 1; /* Shift data over */
data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0; data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0;
} }
return data; return data;
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* disable_pmc_eeprom - Disable writes to the EEPROM * disable_pmc_eeprom - Disable writes to the EEPROM
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -218,16 +202,14 @@ eeprom_get_byte (long addr) ...@@ -218,16 +202,14 @@ eeprom_get_byte (long addr)
* Issue the EEPROM command to disable writes. * Issue the EEPROM command to disable writes.
*/ */
static void static void disable_pmc_eeprom(long addr)
disable_pmc_eeprom (long addr)
{ {
eeprom_put_byte (addr, EPROM_EWDS, SIZE_ADDR_OP); eeprom_put_byte(addr, EPROM_EWDS, SIZE_ADDR_OP);
pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select pci_write_32((u_int32_t *) addr, 0); /* this removes Chip Select
* from EEPROM */ * from EEPROM */
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* enable_pmc_eeprom - Enable writes to the EEPROM * enable_pmc_eeprom - Enable writes to the EEPROM
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -235,16 +217,14 @@ disable_pmc_eeprom (long addr) ...@@ -235,16 +217,14 @@ disable_pmc_eeprom (long addr)
* Issue the EEPROM command to enable writes. * Issue the EEPROM command to enable writes.
*/ */
static void static void enable_pmc_eeprom(long addr)
enable_pmc_eeprom (long addr)
{ {
eeprom_put_byte (addr, EPROM_EWEN, SIZE_ADDR_OP); eeprom_put_byte(addr, EPROM_EWEN, SIZE_ADDR_OP);
pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select pci_write_32((u_int32_t *) addr, 0); /* this removes Chip Select
* from EEPROM */ * from EEPROM */
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmc_eeprom_read - EEPROM location read * pmc_eeprom_read - EEPROM location read
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -253,35 +233,33 @@ enable_pmc_eeprom (long addr) ...@@ -253,35 +233,33 @@ enable_pmc_eeprom (long addr)
* the contents of the specified location to the calling routine. * the contents of the specified location to the calling routine.
*/ */
static u_int32_t static u_int32_t pmc_eeprom_read(long addr, long mem_offset)
pmc_eeprom_read (long addr, long mem_offset)
{ {
u_int32_t data; /* Data from chip */ u_int32_t data; /* Data from chip */
if (!ByteReverseBuilt) if (!ByteReverseBuilt)
BuildByteReverse (); BuildByteReverse();
mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */
/* /*
* NOTE: The max offset address is 128 or half the reversal table. So the * NOTE: The max offset address is 128 or half the reversal table. So the
* LSB is always zero and counts as a built in shift of one bit. So even * LSB is always zero and counts as a built in shift of one bit. So even
* though we need to shift 3 bits to make room for the command, we only * though we need to shift 3 bits to make room for the command, we only
* need to shift twice more because of the built in shift. * need to shift twice more because of the built in shift.
*/ */
mem_offset <<= 2; /* Shift for command */ mem_offset <<= 2; /* Shift for command */
mem_offset |= EPROM_READ; /* Add command */ mem_offset |= EPROM_READ; /* Add command */
eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */ eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */
data = eeprom_get_byte (addr); /* Read chip data */ data = eeprom_get_byte(addr); /* Read chip data */
pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select from pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select from
* EEPROM */ * EEPROM */
return (data & 0x000000FF); return (data & 0x000000FF);
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmc_eeprom_write - EEPROM location write * pmc_eeprom_write - EEPROM location write
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -293,32 +271,31 @@ pmc_eeprom_read (long addr, long mem_offset) ...@@ -293,32 +271,31 @@ pmc_eeprom_read (long addr, long mem_offset)
* operation succeeded. * operation succeeded.
*/ */
static int static int pmc_eeprom_write(long addr, long mem_offset, u_int32_t data)
pmc_eeprom_write (long addr, long mem_offset, u_int32_t data)
{ {
volatile u_int32_t temp; volatile u_int32_t temp;
int count; int count;
if (!ByteReverseBuilt) if (!ByteReverseBuilt)
BuildByteReverse (); BuildByteReverse();
mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */
/* /*
* NOTE: The max offset address is 128 or half the reversal table. So the * NOTE: The max offset address is 128 or half the reversal table. So the
* LSB is always zero and counts as a built in shift of one bit. So even * LSB is always zero and counts as a built in shift of one bit. So even
* though we need to shift 3 bits to make room for the command, we only * though we need to shift 3 bits to make room for the command, we only
* need to shift twice more because of the built in shift. * need to shift twice more because of the built in shift.
*/ */
mem_offset <<= 2; /* Shift for command */ mem_offset <<= 2; /* Shift for command */
mem_offset |= EPROM_WRITE; /* Add command */ mem_offset |= EPROM_WRITE; /* Add command */
eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */ eeprom_put_byte(addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */
data = ByteReverse[0xFF & data];/* Reverse data */ data = ByteReverse[0xFF & data]; /* Reverse data */
eeprom_put_byte (addr, data, NUM_OF_BITS); /* Output chip data */ eeprom_put_byte(addr, data, NUM_OF_BITS); /* Output chip data */
pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select from pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select from
* EEPROM */ * EEPROM */
/* /*
** Must see Data In at a low state before completing this transaction. ** Must see Data In at a low state before completing this transaction.
...@@ -326,156 +303,135 @@ pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) ...@@ -326,156 +303,135 @@ pmc_eeprom_write (long addr, long mem_offset, u_int32_t data)
** Afterwards, the data bit will return to a high state, ~6 ms, terminating ** Afterwards, the data bit will return to a high state, ~6 ms, terminating
** the operation. ** the operation.
*/ */
pci_write_32 ((u_int32_t *) addr, EPROM_ENCS); /* Re-enable Chip Select */ pci_write_32((u_int32_t *) addr, EPROM_ENCS); /* Re-enable Chip Select */
temp = pci_read_32 ((u_int32_t *) addr); /* discard first read */ temp = pci_read_32((u_int32_t *) addr); /* discard first read */
temp = pci_read_32 ((u_int32_t *) addr); temp = pci_read_32((u_int32_t *) addr);
if (temp & EPROM_ACTIVE_IN_BIT) if (temp & EPROM_ACTIVE_IN_BIT) {
{ temp = pci_read_32((u_int32_t *) addr);
temp = pci_read_32 ((u_int32_t *) addr); if (temp & EPROM_ACTIVE_IN_BIT) {
if (temp & EPROM_ACTIVE_IN_BIT) pci_write_32((u_int32_t *) addr, 0); /* Remove Chip Select
{ * from EEPROM */
pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select return (1);
* from EEPROM */ }
return (1); }
} count = 1000;
} while (count--) {
count = 1000; for (temp = 0; temp < 0x10; temp++)
while (count--) OS_uwait_dummy();
{
for (temp = 0; temp < 0x10; temp++) if (pci_read_32((u_int32_t *) addr) & EPROM_ACTIVE_IN_BIT)
OS_uwait_dummy (); break;
}
if (pci_read_32 ((u_int32_t *) addr) & EPROM_ACTIVE_IN_BIT)
break; if (count == -1)
} return (2);
if (count == -1) return (0);
return (2);
return (0);
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmcGetBuffValue - read the specified value from buffer * pmcGetBuffValue - read the specified value from buffer
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
static long static long pmcGetBuffValue(char *ptr, int size)
pmcGetBuffValue (char *ptr, int size)
{ {
long value = 0; long value = 0;
int index; int index;
for (index = 0; index < size; ++index) for (index = 0; index < size; ++index) {
{ value <<= 8;
value <<= 8; value |= ptr[index] & 0xFF;
value |= ptr[index] & 0xFF; }
}
return value; return value;
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmcSetBuffValue - save the specified value to buffer * pmcSetBuffValue - save the specified value to buffer
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
static void static void pmcSetBuffValue(char *ptr, long value, int size)
pmcSetBuffValue (char *ptr, long value, int size)
{ {
int index = size; int index = size;
while (--index >= 0) while (--index >= 0) {
{ ptr[index] = (char)(value & 0xFF);
ptr[index] = (char) (value & 0xFF); value >>= 8;
value >>= 8; }
}
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmc_eeprom_read_buffer - read EEPROM data into specified buffer * pmc_eeprom_read_buffer - read EEPROM data into specified buffer
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
void void
pmc_eeprom_read_buffer (long addr, long mem_offset, char *dest_ptr, int size) pmc_eeprom_read_buffer(long addr, long mem_offset, char *dest_ptr, int size)
{ {
while (--size >= 0) while (--size >= 0)
*dest_ptr++ = (char) pmc_eeprom_read (addr, mem_offset++); *dest_ptr++ = (char)pmc_eeprom_read(addr, mem_offset++);
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmc_eeprom_write_buffer - write EEPROM data from specified buffer * pmc_eeprom_write_buffer - write EEPROM data from specified buffer
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
void void
pmc_eeprom_write_buffer (long addr, long mem_offset, char *dest_ptr, int size) pmc_eeprom_write_buffer(long addr, long mem_offset, char *dest_ptr, int size)
{ {
enable_pmc_eeprom (addr); enable_pmc_eeprom(addr);
while (--size >= 0) while (--size >= 0)
pmc_eeprom_write (addr, mem_offset++, *dest_ptr++); pmc_eeprom_write(addr, mem_offset++, *dest_ptr++);
disable_pmc_eeprom (addr); disable_pmc_eeprom(addr);
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmcCalcCrc - calculate the CRC for the serial EEPROM structure * pmcCalcCrc - calculate the CRC for the serial EEPROM structure
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
static u_int32_t static u_int32_t pmcCalcCrc_T01(void *bufp)
pmcCalcCrc_T01 (void *bufp)
{ {
FLD_TYPE2 *buf = bufp; FLD_TYPE2 *buf = bufp;
u_int32_t crc; /* CRC of the structure */ u_int32_t crc; /* CRC of the structure */
/* Calc CRC for type and length fields */ /* Calc CRC for type and length fields */
sbeCrc ( sbeCrc((u_int8_t *) & buf->type,
(u_int8_t *) &buf->type, (u_int32_t) STRUCT_OFFSET(FLD_TYPE1, Crc32),
(u_int32_t) STRUCT_OFFSET (FLD_TYPE1, Crc32), (u_int32_t) 0, (u_int32_t *) & crc);
(u_int32_t) 0,
(u_int32_t *) &crc);
#ifdef EEPROM_TYPE_DEBUG #ifdef EEPROM_TYPE_DEBUG
pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */ pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */
#endif #endif
return ~crc; return ~crc;
} }
static u_int32_t static u_int32_t pmcCalcCrc_T02(void *bufp)
pmcCalcCrc_T02 (void *bufp)
{ {
FLD_TYPE2 *buf = bufp; FLD_TYPE2 *buf = bufp;
u_int32_t crc; /* CRC of the structure */ u_int32_t crc; /* CRC of the structure */
/* Calc CRC for type and length fields */ /* Calc CRC for type and length fields */
sbeCrc ( sbeCrc((u_int8_t *) & buf->type,
(u_int8_t *) &buf->type, (u_int32_t) STRUCT_OFFSET(FLD_TYPE2, Crc32),
(u_int32_t) STRUCT_OFFSET (FLD_TYPE2, Crc32), (u_int32_t) 0, (u_int32_t *) & crc);
(u_int32_t) 0,
(u_int32_t *) &crc); /* Calc CRC for remaining fields */
sbeCrc((u_int8_t *) & buf->Id[0],
/* Calc CRC for remaining fields */ (u_int32_t) (sizeof(FLD_TYPE2) - STRUCT_OFFSET(FLD_TYPE2, Id)),
sbeCrc ( (u_int32_t) crc, (u_int32_t *) & crc);
(u_int8_t *) &buf->Id[0],
(u_int32_t) (sizeof (FLD_TYPE2) - STRUCT_OFFSET (FLD_TYPE2, Id)),
(u_int32_t) crc,
(u_int32_t *) &crc);
#ifdef EEPROM_TYPE_DEBUG #ifdef EEPROM_TYPE_DEBUG
pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */ pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */
#endif #endif
return crc; return crc;
} }
/*------------------------------------------------------------------------ /*------------------------------------------------------------------------
* pmc_init_seeprom - initialize the serial EEPROM structure * pmc_init_seeprom - initialize the serial EEPROM structure
*------------------------------------------------------------------------ *------------------------------------------------------------------------
...@@ -486,64 +442,61 @@ pmcCalcCrc_T02 (void *bufp) ...@@ -486,64 +442,61 @@ pmcCalcCrc_T02 (void *bufp)
* serial number field. * serial number field.
*/ */
void void pmc_init_seeprom(u_int32_t addr, u_int32_t serialNum)
pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum)
{ {
PROMFORMAT buffer; /* Memory image of structure */ PROMFORMAT buffer; /* Memory image of structure */
u_int32_t crc; /* CRC of structure */ u_int32_t crc; /* CRC of structure */
time_t createTime; time_t createTime;
createTime = get_seconds (); createTime = get_seconds();
/* use template data */ /* use template data */
memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2)); memcpy(&buffer.fldType2, mfg_template, sizeof(buffer.fldType2));
/* Update serial number field in buffer */ /* Update serial number field in buffer */
pmcSetBuffValue (&buffer.fldType2.Serial[3], serialNum, 3); pmcSetBuffValue(&buffer.fldType2.Serial[3], serialNum, 3);
/* Update create time field in buffer */ /* Update create time field in buffer */
pmcSetBuffValue (&buffer.fldType2.CreateTime[0], createTime, 4); pmcSetBuffValue(&buffer.fldType2.CreateTime[0], createTime, 4);
/* Update CRC field in buffer */ /* Update CRC field in buffer */
crc = pmcCalcCrc_T02 (&buffer); crc = pmcCalcCrc_T02(&buffer);
pmcSetBuffValue (&buffer.fldType2.Crc32[0], crc, 4); pmcSetBuffValue(&buffer.fldType2.Crc32[0], crc, 4);
#ifdef DEBUG #ifdef DEBUG
for (i = 0; i < sizeof (FLD_TYPE2); ++i) for (i = 0; i < sizeof(FLD_TYPE2); ++i)
pr_info("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF); pr_info("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF);
#endif #endif
/* Write structure to serial EEPROM */ /* Write structure to serial EEPROM */
pmc_eeprom_write_buffer (addr, EE_MFG, (char *) &buffer, sizeof (FLD_TYPE2)); pmc_eeprom_write_buffer(addr, EE_MFG, (char *)&buffer,
sizeof(FLD_TYPE2));
} }
char pmc_verify_cksum(void *bufp)
char
pmc_verify_cksum (void *bufp)
{ {
FLD_TYPE1 *buf1 = bufp; FLD_TYPE1 *buf1 = bufp;
FLD_TYPE2 *buf2 = bufp; FLD_TYPE2 *buf2 = bufp;
u_int32_t crc1, crc2; /* CRC read from EEPROM */ u_int32_t crc1, crc2; /* CRC read from EEPROM */
/* Retrieve contents of CRC field */ /* Retrieve contents of CRC field */
crc1 = pmcGetBuffValue (&buf1->Crc32[0], sizeof (buf1->Crc32)); crc1 = pmcGetBuffValue(&buf1->Crc32[0], sizeof(buf1->Crc32));
#ifdef EEPROM_TYPE_DEBUG #ifdef EEPROM_TYPE_DEBUG
pr_info("EEPROM: chksum 1 reads as %08x\n", crc1); /* RLD DEBUG */ pr_info("EEPROM: chksum 1 reads as %08x\n", crc1); /* RLD DEBUG */
#endif #endif
if ((buf1->type == PROM_FORMAT_TYPE1) && if ((buf1->type == PROM_FORMAT_TYPE1) &&
(pmcCalcCrc_T01 ((void *) buf1) == crc1)) (pmcCalcCrc_T01((void *)buf1) == crc1))
return PROM_FORMAT_TYPE1; /* checksum type 1 verified */ return PROM_FORMAT_TYPE1; /* checksum type 1 verified */
crc2 = pmcGetBuffValue (&buf2->Crc32[0], sizeof (buf2->Crc32)); crc2 = pmcGetBuffValue(&buf2->Crc32[0], sizeof(buf2->Crc32));
#ifdef EEPROM_TYPE_DEBUG #ifdef EEPROM_TYPE_DEBUG
pr_info("EEPROM: chksum 2 reads as %08x\n", crc2); /* RLD DEBUG */ pr_info("EEPROM: chksum 2 reads as %08x\n", crc2); /* RLD DEBUG */
#endif #endif
if ((buf2->type == PROM_FORMAT_TYPE2) && if ((buf2->type == PROM_FORMAT_TYPE2) &&
(pmcCalcCrc_T02 ((void *) buf2) == crc2)) (pmcCalcCrc_T02((void *)buf2) == crc2))
return PROM_FORMAT_TYPE2; /* checksum type 2 verified */ return PROM_FORMAT_TYPE2; /* checksum type 2 verified */
return PROM_FORMAT_Unk; /* failed to validate */ return PROM_FORMAT_Unk; /* failed to validate */
} }
/*** End-of-File ***/ /*** End-of-File ***/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment