24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/types.h>
37 #ifdef SBE_INCLUDE_SYMBOLS
53 #define EE_MFG (long)0
64 #define EPROM_EWEN 0x0019
65 #define EPROM_EWDS 0x0001
66 #define EPROM_READ 0x0003
67 #define EPROM_WRITE 0x0005
68 #define EPROM_ERASE 0x0007
69 #define EPROM_ERAL 0x0009
70 #define EPROM_WRAL 0x0011
72 #define EPROM_ADR_SZ 7
74 #define SIZE_ADDR_OP (EPROM_ADR_SZ + EPROM_OP_SZ)
75 #define LC46A_MAX_OPS 10
80 #define EPROM_ACTIVE_OUT_BIT 0x0001
81 #define EPROM_ACTIVE_IN_BIT 0x0002
82 #define ACTIVE_IN_BIT_SHIFT 0x0001
83 #define EPROM_ENCS 0x0004
91 static unsigned char ByteReverse[256];
92 static int ByteReverseBuilt =
FALSE;
104 0x00, 0x00, 0x00, 0x00,
107 0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00,
131 for (half = 1; half <
sizeof (ByteReverse); half <<= 1)
132 for (i = 0; i <
half; i++)
133 ByteReverse[half + i] = (
char) (ByteReverse[
i] | (0x80 /
half));
135 ByteReverseBuilt =
TRUE;
149 for (timeout = 20; timeout; --timeout)
267 if (!ByteReverseBuilt)
270 mem_offset = ByteReverse[0x7F & mem_offset];
287 return (data & 0x000000FF);
308 if (!ByteReverseBuilt)
311 mem_offset = ByteReverse[0x7F & mem_offset];
323 data = ByteReverse[0xFF &
data];
341 if (temp & EPROM_ACTIVE_IN_BIT)
351 for (temp = 0; temp < 0x10; temp++)
379 value |= ptr[
index] & 0xFF;
452 #ifdef EEPROM_TYPE_DEBUG
453 pr_info(
"sbeCrc: crc 1 calculated as %08x\n", crc);
478 #ifdef EEPROM_TYPE_DEBUG
479 pr_info(
"sbeCrc: crc 2 calculated as %08x\n", crc);
538 #ifdef EEPROM_TYPE_DEBUG
539 pr_info(
"EEPROM: chksum 1 reads as %08x\n", crc1);
546 #ifdef EEPROM_TYPE_DEBUG
547 pr_info(
"EEPROM: chksum 2 reads as %08x\n", crc2);