5 * 24LC02 EEPROM driver in conjunction with NetUP Dual DVB-S2 CI card
7 * Copyright (C) 2009 NetUP Inc.
8 * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "netup-eeprom.h"
30 #define EEPROM_I2C_ADDR 0x50
32 int netup_eeprom_read(struct i2c_adapter
*i2c_adap
, u8 addr
)
37 /* Read from EEPROM */
38 struct i2c_msg msg
[] = {
40 .addr
= EEPROM_I2C_ADDR
,
45 .addr
= EEPROM_I2C_ADDR
,
56 ret
= i2c_transfer(i2c_adap
, msg
, 2);
59 printk(KERN_ERR
"eeprom i2c read error, status=%d\n", ret
);
66 int netup_eeprom_write(struct i2c_adapter
*i2c_adap
, u8 addr
, u8 data
)
69 unsigned char bufw
[2];
71 /* Write into EEPROM */
72 struct i2c_msg msg
[] = {
74 .addr
= EEPROM_I2C_ADDR
,
84 ret
= i2c_transfer(i2c_adap
, msg
, 1);
87 printk(KERN_ERR
"eeprom i2c write error, status=%d\n", ret
);
91 mdelay(10); /* prophylactic delay, datasheet write cycle time = 5 ms */
95 void netup_get_card_info(struct i2c_adapter
*i2c_adap
,
96 struct netup_card_info
*cinfo
)
100 cinfo
->rev
= netup_eeprom_read(i2c_adap
, 63);
102 for (i
= 64, j
= 0; i
< 70; i
++, j
++)
103 cinfo
->port
[0].mac
[j
] = netup_eeprom_read(i2c_adap
, i
);
105 for (i
= 70, j
= 0; i
< 76; i
++, j
++)
106 cinfo
->port
[1].mac
[j
] = netup_eeprom_read(i2c_adap
, i
);