Abstracted out part of the concept of an SPI device to a generalised NVS

device.

Separated the mechanisms of non-volatile storage access and non-volatile
stored options.
This commit is contained in:
Michael Brown
2006-12-04 18:23:06 +00:00
parent dc06c895fc
commit 946967f09c
12 changed files with 275 additions and 240 deletions

View File

@@ -2388,11 +2388,6 @@ static int falcon_write_nvs ( struct nvs_device *nvs, unsigned int offset,
return 0;
}
static struct nvs_operations falcon_nvs_operations = {
.read = falcon_read_nvs,
.write = falcon_write_nvs,
};
/** RX descriptor */
typedef efab_qword_t falcon_rx_desc_t;
@@ -3046,10 +3041,12 @@ static int falcon_init_nic ( struct efab_nic *efab ) {
/* Register non-volatile storage */
if ( efab->has_eeprom ) {
/*
efab->nvs.op = &falcon_nvs_operations;
efab->nvs.len = 0x100;
if ( nvs_register ( &efab->nvs ) != 0 )
return 0;
*/
}
return 1;

View File

@@ -240,15 +240,12 @@ static struct bit_basher_operations rtl_basher_ops = {
.write = rtl_spi_write_bit,
};
static struct spi_device_type rtl_ee9346 = AT93C46 ( 16 );
static struct spi_device_type rtl_ee9356 = AT93C56 ( 16 );
/**
* Set up for EEPROM access
*
* @v rtl RTL8139 NIC
*/
static void rtl_init_eeprom ( struct rtl8139_nic *rtl ) {
void rtl_init_eeprom ( struct rtl8139_nic *rtl ) {
int ee9356;
/* Initialise three-wire bus */
@@ -258,8 +255,13 @@ static void rtl_init_eeprom ( struct rtl8139_nic *rtl ) {
/* Detect EEPROM type and initialise three-wire device */
ee9356 = ( inw ( rtl->ioaddr + RxConfig ) & Eeprom9356 );
DBG ( "EEPROM is an %s\n", ( ee9356 ? "AT93C56" : "AT93C46" ) );
rtl->eeprom.type = ( ee9356 ? &rtl_ee9356 : &rtl_ee9346 );
if ( ee9356 ) {
DBG ( "EEPROM is an AT93C56\n" );
init_at93c56 ( &rtl->eeprom, 16 );
} else {
DBG ( "EEPROM is an AT93C46\n" );
init_at93c46 ( &rtl->eeprom, 16 );
}
rtl->eeprom.bus = &rtl->spibit.bus;
}
@@ -271,12 +273,12 @@ static void rtl_init_eeprom ( struct rtl8139_nic *rtl ) {
*/
static void rtl_read_mac ( struct rtl8139_nic *rtl, uint8_t *mac_addr ) {
struct spi_device *device = &rtl->eeprom;
struct nvs_device *nvs = &rtl->eeprom.nvs;
int i;
DBG ( "MAC address is " );
for ( i = EE_MAC ; i < ( EE_MAC + ( ETH_ALEN / 2 ) ) ; i++ ) {
device->type->read ( device, i, mac_addr, 2 );
nvs_read ( nvs, i, mac_addr, 2 );
DBG ( "%02x%02x", mac_addr[0], mac_addr[1] );
mac_addr += 2;
}