summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe
diff options
context:
space:
mode:
authorMichael Brown2009-05-28 15:45:32 +0200
committerMichael Brown2009-05-28 20:32:03 +0200
commit92a9978b4403628345ca03ba4edc7641352460fa (patch)
tree02626e7d3a3970b7b14cb4dd6f76211c447057cf /src/include/gpxe
parent[build] Add -fno-dwarf2-cfi-asm to CFLAGS if supported by the gcc in use (diff)
downloadipxe-92a9978b4403628345ca03ba4edc7641352460fa.tar.gz
ipxe-92a9978b4403628345ca03ba4edc7641352460fa.tar.xz
ipxe-92a9978b4403628345ca03ba4edc7641352460fa.zip
[spi] Add address-length autodetection to the SPI bit-bashing code
Several SPI chips will respond to an SPI read command with a dummy zero bit immediately prior to the first real data bit. This can be used to autodetect the address length, provided that the command length and data length are already known, and that the MISO data line is tied high. Tested-by: Thomas Miletich <thomas.miletich@gmail.com> Debugged-by: Thomas Miletich <thomas.miletich@gmail.com>
Diffstat (limited to 'src/include/gpxe')
-rw-r--r--src/include/gpxe/spi.h8
-rw-r--r--src/include/gpxe/threewire.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/include/gpxe/spi.h b/src/include/gpxe/spi.h
index ebfc3226b..8e4a6763b 100644
--- a/src/include/gpxe/spi.h
+++ b/src/include/gpxe/spi.h
@@ -104,6 +104,14 @@ struct spi_device {
unsigned int munge_address : 1;
};
+/**
+ * SPI magic autodetection address length
+ *
+ * Set @c spi_device::address_len to @c SPI_AUTODETECT_ADDRESS_LEN if
+ * the address length should be autodetected.
+ */
+#define SPI_AUTODETECT_ADDRESS_LEN 0
+
static inline __attribute__ (( always_inline )) struct spi_device *
nvs_to_spi ( struct nvs_device *nvs ) {
return container_of ( nvs, struct spi_device, nvs );
diff --git a/src/include/gpxe/threewire.h b/src/include/gpxe/threewire.h
index 4dc755c2e..2db672603 100644
--- a/src/include/gpxe/threewire.h
+++ b/src/include/gpxe/threewire.h
@@ -45,6 +45,7 @@ extern int threewire_read ( struct nvs_device *nvs, unsigned int address,
void *data, size_t len );
extern int threewire_write ( struct nvs_device *nvs, unsigned int address,
const void *data, size_t len );
+extern int threewire_detect_address_len ( struct spi_device *device );
/**
* @defgroup tdevs Three-wire device types