summaryrefslogtreecommitdiffstats
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/bitbash/spi_bit.c9
-rw-r--r--src/drivers/net/etherfabric.c7
-rw-r--r--src/drivers/net/rtl8139.c18
-rw-r--r--src/drivers/nvs/nvs.c31
-rw-r--r--src/drivers/nvs/threewire.c5
5 files changed, 50 insertions, 20 deletions
diff --git a/src/drivers/bitbash/spi_bit.c b/src/drivers/bitbash/spi_bit.c
index ef1d8ff7..8b89f01d 100644
--- a/src/drivers/bitbash/spi_bit.c
+++ b/src/drivers/bitbash/spi_bit.c
@@ -147,22 +147,21 @@ static int spi_bit_rw ( struct spi_bus *bus, struct spi_device *device,
const void *data_out, void *data_in, size_t len ) {
struct spi_bit_basher *spibit
= container_of ( bus, struct spi_bit_basher, bus );
- struct spi_device_type *devtype = device->type;
uint32_t tmp;
/* Assert chip select on specified slave */
spi_bit_set_slave_select ( spibit, device->slave, SELECT_SLAVE );
/* Transmit command */
- assert ( devtype->command_len <= ( 8 * sizeof ( tmp ) ) );
+ assert ( device->command_len <= ( 8 * sizeof ( tmp ) ) );
tmp = cpu_to_le32 ( command );
- spi_bit_transfer ( spibit, &tmp, NULL, devtype->command_len );
+ spi_bit_transfer ( spibit, &tmp, NULL, device->command_len );
/* Transmit address, if present */
if ( address >= 0 ) {
- assert ( devtype->address_len <= ( 8 * sizeof ( tmp ) ) );
+ assert ( device->address_len <= ( 8 * sizeof ( tmp ) ) );
tmp = cpu_to_le32 ( address );
- spi_bit_transfer ( spibit, &tmp, NULL, devtype->address_len );
+ spi_bit_transfer ( spibit, &tmp, NULL, device->address_len );
}
/* Transmit/receive data */
diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c
index 9afe65df..790bfb54 100644
--- a/src/drivers/net/etherfabric.c
+++ b/src/drivers/net/etherfabric.c
@@ -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;
diff --git a/src/drivers/net/rtl8139.c b/src/drivers/net/rtl8139.c
index 34d6572a..503cee25 100644
--- a/src/drivers/net/rtl8139.c
+++ b/src/drivers/net/rtl8139.c
@@ -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;
}
diff --git a/src/drivers/nvs/nvs.c b/src/drivers/nvs/nvs.c
new file mode 100644
index 00000000..55cd8283
--- /dev/null
+++ b/src/drivers/nvs/nvs.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * 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 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 <stdint.h>
+#include <gpxe/nvs.h>
+
+/** @file
+ *
+ * Non-volatile storage
+ *
+ */
+
+int nvs_read ( struct nvs_device *nvs, unsigned int address,
+ void *data, size_t len ) {
+ return nvs->read ( nvs, address, data, len );
+}
diff --git a/src/drivers/nvs/threewire.c b/src/drivers/nvs/threewire.c
index 552c3b46..043cc8fc 100644
--- a/src/drivers/nvs/threewire.c
+++ b/src/drivers/nvs/threewire.c
@@ -28,14 +28,15 @@
/** Read data from three-wire device
*
- * @v device SPI device
+ * @v nvs NVS device
* @v address Address from which to read
* @v data Data buffer
* @v len Length of data buffer
* @ret rc Return status code
*/
-int threewire_read ( struct spi_device *device, unsigned int address,
+int threewire_read ( struct nvs_device *nvs, unsigned int address,
void *data, size_t len ) {
+ struct spi_device *device = nvs_to_spi ( nvs );
struct spi_bus *bus = device->bus;
assert ( bus->mode == SPI_MODE_THREEWIRE );