34 #include <asm/errno.h>
36 #include <linux/module.h>
37 #include <linux/string.h>
38 #include <linux/i2c.h>
43 #define dprintk(x...) do { printk(x); } while (0)
45 #define dprintk(x...) do { } while (0)
49 static int check_mac_tt(
u8 *
buf)
54 for (i = 0; i < 8; i++) {
55 tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]);
56 tmp ^= (tmp >> 4) & 0x0f;
57 tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5);
60 return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9]));
63 static int getmac_tt(
u8 * decodedMAC,
u8 * encodedMAC)
65 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c,
66 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6,
67 0x1d, 0x36, 0x64, 0x78};
72 memcpy(data, encodedMAC, 20);
74 for (i = 0; i < 20; i++)
76 for (i = 0; i < 10; i++)
77 data[i] = ((data[2 * i + 1] << 8) | data[2 * i])
78 >> ((data[2 * i + 1] >> 6) & 3);
80 if (check_mac_tt(data))
83 decodedMAC[0] = data[2]; decodedMAC[1] = data[1]; decodedMAC[2] = data[0];
84 decodedMAC[3] = data[6]; decodedMAC[4] = data[5]; decodedMAC[5] = data[4];
90 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c,
91 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6,
92 0x1d, 0x36, 0x64, 0x78};
96 memcpy(data, encodedMAC, 20);
98 for (i = 0; i < 20; i++)
100 for (i = 0; i < 10; i++)
101 data[i] = ((data[2 * i + 1] << 8) | data[2 * i])
102 >> ((data[2 * i + 1] >> 6) & 3);
104 if (check_mac_tt(data))
107 decodedMAC[0] = data[2];
108 decodedMAC[1] = data[1];
109 decodedMAC[2] = data[0];
110 decodedMAC[3] = data[6];
111 decodedMAC[4] = data[5];
112 decodedMAC[5] = data[4];
123 { .addr = 0x50, .flags = 0, .buf = b0, .len = 1 },
124 { .addr = 0x50, .flags =
I2C_M_RD, .buf = encodedMAC, .len = 20 }
144 ret = ttpci_eeprom_read_encodedMAC(adapter, encodedMAC);
147 dprintk(
"Couldn't read from EEPROM: not there?\n");
148 memset(proposed_mac, 0, 6);
152 ret = getmac_tt(decodedMAC, encodedMAC);
154 dprintk(
"adapter failed MAC signature check\n");
155 dprintk(
"encoded MAC from EEPROM was " );
156 for(i=0; i<19; i++) {
157 dprintk(
"%.2x:", encodedMAC[i]);
159 dprintk(
"%.2x\n", encodedMAC[19]);
160 memset(proposed_mac, 0, 6);
164 memcpy(proposed_mac, decodedMAC, 6);
165 dprintk(
"adapter has MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
166 decodedMAC[0], decodedMAC[1], decodedMAC[2],
167 decodedMAC[3], decodedMAC[4], decodedMAC[5]);
176 "made by Siemens, Technotrend, Hauppauge");