2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading)
4 * see flexcop.c for copyright information
9 static u8
calc_lrc(u8
*buf
, int len
)
13 for (i
= 0; i
< len
; i
++)
18 static int flexcop_eeprom_request(struct flexcop_device
*fc
,
19 flexcop_access_op_t op
, u16 addr
, u8
*buf
, u16 len
, int retries
)
22 u8 chipaddr
= 0x50 | ((addr
>> 8) & 3);
23 for (i
= 0; i
< retries
; i
++) {
24 ret
= fc
->i2c_request(&fc
->fc_i2c_adap
[1], op
, chipaddr
,
25 addr
& 0xff, buf
, len
);
32 static int flexcop_eeprom_lrc_read(struct flexcop_device
*fc
, u16 addr
,
33 u8
*buf
, u16 len
, int retries
)
35 int ret
= flexcop_eeprom_request(fc
, FC_READ
, addr
, buf
, len
, retries
);
37 if (calc_lrc(buf
, len
- 1) != buf
[len
- 1])
42 /* JJ's comment about extended == 1: it is not presently used anywhere but was
43 * added to the low-level functions for possible support of EUI64 */
44 int flexcop_eeprom_check_mac_addr(struct flexcop_device
*fc
, int extended
)
49 if ((ret
= flexcop_eeprom_lrc_read(fc
,0x3f8,buf
,8,4)) == 0) {
51 err("TODO: extended (EUI64) MAC addresses aren't "
52 "completely supported yet");
55 memcpy(fc
->dvb_adapter
.proposed_mac
,buf
,6);
59 EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr
);