aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/b2c2/flexcop-eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/b2c2/flexcop-eeprom.c')
-rw-r--r--drivers/media/dvb/b2c2/flexcop-eeprom.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-eeprom.c b/drivers/media/dvb/b2c2/flexcop-eeprom.c
index 8a8ae8a3e6ba..a25373a9bd84 100644
--- a/drivers/media/dvb/b2c2/flexcop-eeprom.c
+++ b/drivers/media/dvb/b2c2/flexcop-eeprom.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading)
4 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading is used) 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
@@ -14,17 +12,17 @@ static int eeprom_write(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
14 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len); 12 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len);
15} 13}
16 14
17static int eeprom_lrc_write(struct adapter *adapter, u32 addr, u32 len, u8 *wbuf, u8 *rbuf, int retries) 15static int eeprom_lrc_write(struct adapter *adapter, u32 addr,
16 u32 len, u8 *wbuf, u8 *rbuf, int retries)
18{ 17{
19 int i; 18int i;
20 19
21 for (i = 0; i < retries; i++) { 20for (i = 0; i < retries; i++) {
22 if (eeprom_write(adapter, addr, wbuf, len) == len) { 21 if (eeprom_write(adapter, addr, wbuf, len) == len) {
23 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1) 22 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1)
24 return 1; 23 return 1;
25 } 24 }
26 } 25 }
27
28 return 0; 26 return 0;
29} 27}
30 28
@@ -39,12 +37,10 @@ static int eeprom_writeKey(struct adapter *adapter, u8 *key, u32 len)
39 return 0; 37 return 0;
40 38
41 memcpy(wbuf, key, len); 39 memcpy(wbuf, key, len);
42
43 wbuf[16] = 0; 40 wbuf[16] = 0;
44 wbuf[17] = 0; 41 wbuf[17] = 0;
45 wbuf[18] = 0; 42 wbuf[18] = 0;
46 wbuf[19] = calc_lrc(wbuf, 19); 43 wbuf[19] = calc_lrc(wbuf, 19);
47
48 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4); 44 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4);
49} 45}
50 46
@@ -59,7 +55,6 @@ static int eeprom_readKey(struct adapter *adapter, u8 *key, u32 len)
59 return 0; 55 return 0;
60 56
61 memcpy(key, buf, len); 57 memcpy(key, buf, len);
62
63 return 1; 58 return 1;
64} 59}
65 60
@@ -74,9 +69,7 @@ static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
74 tmp[3] = mac[5]; 69 tmp[3] = mac[5];
75 tmp[4] = mac[6]; 70 tmp[4] = mac[6];
76 tmp[5] = mac[7]; 71 tmp[5] = mac[7];
77
78 } else { 72 } else {
79
80 tmp[0] = mac[0]; 73 tmp[0] = mac[0];
81 tmp[1] = mac[1]; 74 tmp[1] = mac[1];
82 tmp[2] = mac[2]; 75 tmp[2] = mac[2];
@@ -90,11 +83,11 @@ static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
90 83
91 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8) 84 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8)
92 return 1; 85 return 1;
93
94 return 0; 86 return 0;
95} 87}
96 88
97static int flexcop_eeprom_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len) 89static int flexcop_eeprom_read(struct flexcop_device *fc,
90 u16 addr, u8 *buf, u16 len)
98{ 91{
99 return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len); 92 return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len);
100} 93}
@@ -110,7 +103,8 @@ static u8 calc_lrc(u8 *buf, int len)
110 return sum; 103 return sum;
111} 104}
112 105
113static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries) 106static int flexcop_eeprom_request(struct flexcop_device *fc,
107 flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries)
114{ 108{
115 int i,ret = 0; 109 int i,ret = 0;
116 u8 chipaddr = 0x50 | ((addr >> 8) & 3); 110 u8 chipaddr = 0x50 | ((addr >> 8) & 3);
@@ -123,7 +117,8 @@ static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t
123 return ret; 117 return ret;
124} 118}
125 119
126static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries) 120static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr,
121 u8 *buf, u16 len, int retries)
127{ 122{
128 int ret = flexcop_eeprom_request(fc, FC_READ, addr, buf, len, retries); 123 int ret = flexcop_eeprom_request(fc, FC_READ, addr, buf, len, retries);
129 if (ret == 0) 124 if (ret == 0)
@@ -133,8 +128,7 @@ static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf,
133} 128}
134 129
135/* JJ's comment about extended == 1: it is not presently used anywhere but was 130/* JJ's comment about extended == 1: it is not presently used anywhere but was
136 * added to the low-level functions for possible support of EUI64 131 * added to the low-level functions for possible support of EUI64 */
137 */
138int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended) 132int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
139{ 133{
140 u8 buf[8]; 134 u8 buf[8];
@@ -142,12 +136,9 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
142 136
143 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) { 137 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
144 if (extended != 0) { 138 if (extended != 0) {
145 err("TODO: extended (EUI64) MAC addresses aren't completely supported yet"); 139 err("TODO: extended (EUI64) MAC addresses aren't "
140 "completely supported yet");
146 ret = -EINVAL; 141 ret = -EINVAL;
147/* memcpy(fc->dvb_adapter.proposed_mac,buf,3);
148 mac[3] = 0xfe;
149 mac[4] = 0xff;
150 memcpy(&fc->dvb_adapter.proposed_mac[3],&buf[5],3); */
151 } else 142 } else
152 memcpy(fc->dvb_adapter.proposed_mac,buf,6); 143 memcpy(fc->dvb_adapter.proposed_mac,buf,6);
153 } 144 }