Changed length parameter in SPI methods to be a byte length, rather than
[people/xl0/gpxe.git] / src / include / gpxe / threewire.h
1 #ifndef _GPXE_THREEWIRE_H
2 #define _GPXE_THREEWIRE_H
3
4 /** @file
5  *
6  * Three-wire serial interface
7  *
8  * The Atmel three-wire interface is a subset of the (newer) SPI
9  * interface, and is implemented here as a layer on top of the SPI
10  * support.
11  */
12
13 #include <gpxe/spi.h>
14
15 /**
16  * @defgroup tcmds Three-wire commands
17  * @{
18  */
19
20 /** Read data from memory array */
21 #define THREEWIRE_READ 0x6
22
23 /** @} */
24
25 /**
26  * @defgroup spidevs SPI device types
27  * @{
28  */
29
30 /** Atmel AT93C46 serial EEPROM
31  *
32  * @v org       Word size (8 or 16)
33  */
34 #define AT93C46( org ) {                                \
35         .word_len = (org),                              \
36         .size = ( 1024 / (org) ),                       \
37         .block_size = 1,                                \
38         .command_len = 3,                               \
39         .address_len = ( ( (org) == 8 ) ? 7 : 6 ),      \
40         .read = threewire_read,                         \
41         }
42
43 /** Atmel AT93C56 serial EEPROM
44  *
45  * @v org       Word size (8 or 16)
46  */
47 #define AT93C56( org ) {                                \
48         .word_len = (org),                              \
49         .size = ( 2048 / (org) ),                       \
50         .block_size = 1,                                \
51         .command_len = 3,                               \
52         .address_len = ( ( (org) == 8 ) ? 9 : 8 ),      \
53         .read = threewire_read,                         \
54         }
55
56 /** @} */
57
58 extern int threewire_read ( struct spi_device *device, unsigned int address,
59                             void *data, size_t len );
60
61 #endif /* _GPXE_THREEWIRE_H */