1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * 24LC02 EEPROM driver in conjunction with NetUP Dual DVB-S2 CI card
8 * Copyright (C) 2009 NetUP Inc.
9 * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru>
14 #include "netup-eeprom.h"
16 #define EEPROM_I2C_ADDR 0x50
18 int netup_eeprom_read(struct i2c_adapter
*i2c_adap
, u8 addr
)
23 /* Read from EEPROM */
24 struct i2c_msg msg
[] = {
26 .addr
= EEPROM_I2C_ADDR
,
31 .addr
= EEPROM_I2C_ADDR
,
42 ret
= i2c_transfer(i2c_adap
, msg
, 2);
45 pr_err("eeprom i2c read error, status=%d\n", ret
);
52 int netup_eeprom_write(struct i2c_adapter
*i2c_adap
, u8 addr
, u8 data
)
55 unsigned char bufw
[2];
57 /* Write into EEPROM */
58 struct i2c_msg msg
[] = {
60 .addr
= EEPROM_I2C_ADDR
,
70 ret
= i2c_transfer(i2c_adap
, msg
, 1);
73 pr_err("eeprom i2c write error, status=%d\n", ret
);
77 mdelay(10); /* prophylactic delay, datasheet write cycle time = 5 ms */
81 void netup_get_card_info(struct i2c_adapter
*i2c_adap
,
82 struct netup_card_info
*cinfo
)
86 cinfo
->rev
= netup_eeprom_read(i2c_adap
, 63);
88 for (i
= 64, j
= 0; i
< 70; i
++, j
++)
89 cinfo
->port
[0].mac
[j
] = netup_eeprom_read(i2c_adap
, i
);
91 for (i
= 70, j
= 0; i
< 76; i
++, j
++)
92 cinfo
->port
[1].mac
[j
] = netup_eeprom_read(i2c_adap
, i
);