-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V4L/DVB (10797): Add EEPROM code for NetUP Dual DVB-S2 CI card.
Signed-off-by: Abylay Ospan <aospan@netup.ru> Signed-off-by: Igor M. Liplianin <liplianin@netup.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
- Loading branch information
Abylay Ospan
authored and
Mauro Carvalho Chehab
committed
Mar 30, 2009
1 parent
c253a17
commit b45c055
Showing
2 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
|
||
/* | ||
* netup-eeprom.c | ||
* | ||
* 24LC02 EEPROM driver in conjunction with NetUP Dual DVB-S2 CI card | ||
* | ||
* Copyright (C) 2009 NetUP Inc. | ||
* Copyright (C) 2009 Abylay Ospan <aospan@netup.ru> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
# | ||
#include "cx23885.h" | ||
#include "netup-eeprom.h" | ||
|
||
#define EEPROM_I2C_ADDR 0x50 | ||
|
||
int netup_eeprom_read(struct i2c_adapter *i2c_adap, u8 addr) | ||
{ | ||
int ret; | ||
unsigned char buf[2]; | ||
|
||
/* Read from EEPROM */ | ||
struct i2c_msg msg[] = { | ||
{ | ||
.addr = EEPROM_I2C_ADDR, | ||
.flags = 0, | ||
.buf = &buf[0], | ||
.len = 1 | ||
}, { | ||
.addr = EEPROM_I2C_ADDR, | ||
.flags = I2C_M_RD, | ||
.buf = &buf[1], | ||
.len = 1 | ||
} | ||
|
||
}; | ||
|
||
buf[0] = addr; | ||
buf[1] = 0x0; | ||
|
||
ret = i2c_transfer(i2c_adap, msg, 2); | ||
|
||
if (ret != 2) { | ||
printk(KERN_ERR "eeprom i2c read error, status=%d\n", ret); | ||
return -1; | ||
} | ||
|
||
return buf[1]; | ||
}; | ||
|
||
int netup_eeprom_write(struct i2c_adapter *i2c_adap, u8 addr, u8 data) | ||
{ | ||
int ret; | ||
unsigned char bufw[2]; | ||
|
||
/* Write into EEPROM */ | ||
struct i2c_msg msg[] = { | ||
{ | ||
.addr = EEPROM_I2C_ADDR, | ||
.flags = 0, | ||
.buf = &bufw[0], | ||
.len = 2 | ||
} | ||
}; | ||
|
||
bufw[0] = addr; | ||
bufw[1] = data; | ||
|
||
ret = i2c_transfer(i2c_adap, msg, 1); | ||
|
||
if (ret != 1) { | ||
printk(KERN_ERR "eeprom i2c write error, status=%d\n", ret); | ||
return -1; | ||
} | ||
|
||
mdelay(10); /* prophylactic delay, datasheet write cycle time = 5 ms */ | ||
return 0; | ||
}; | ||
|
||
void netup_get_card_info(struct i2c_adapter *i2c_adap, | ||
struct netup_card_info *cinfo) | ||
{ | ||
int i, j; | ||
|
||
cinfo->rev = netup_eeprom_read(i2c_adap, 13); | ||
|
||
for (i = 0, j = 0; i < 6; i++, j++) | ||
cinfo->port[0].mac[j] = netup_eeprom_read(i2c_adap, i); | ||
|
||
for (i = 6, j = 0; i < 12; i++, j++) | ||
cinfo->port[1].mac[j] = netup_eeprom_read(i2c_adap, i); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* netup-eeprom.h | ||
* | ||
* 24LC02 EEPROM driver in conjunction with NetUP Dual DVB-S2 CI card | ||
* | ||
* Copyright (C) 2009 NetUP Inc. | ||
* Copyright (C) 2009 Abylay Ospan <aospan@netup.ru> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
|
||
#ifndef NETUP_EEPROM_H | ||
#define NETUP_EEPROM_H | ||
|
||
struct netup_port_info { | ||
u8 mac[6];/* card MAC address */ | ||
}; | ||
|
||
struct netup_card_info { | ||
struct netup_port_info port[2];/* ports - 1,2 */ | ||
u8 rev;/* card revision */ | ||
}; | ||
|
||
extern int netup_eeprom_read(struct i2c_adapter *i2c_adap, u8 addr); | ||
extern int netup_eeprom_write(struct i2c_adapter *i2c_adap, u8 addr, u8 data); | ||
extern void netup_get_card_info(struct i2c_adapter *i2c_adap, | ||
struct netup_card_info *cinfo); | ||
|
||
#endif |