summaryrefslogtreecommitdiffstats
path: root/src/include/gpxe/threewire.h
blob: 4277d8abd270cff2324d347d46f09af92e64435c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _GPXE_THREEWIRE_H
#define _GPXE_THREEWIRE_H

/** @file
 *
 * Three-wire serial interface
 *
 * The Atmel three-wire interface is a subset of the (newer) SPI
 * interface, and is implemented here as a layer on top of the SPI
 * support.
 */

#include <gpxe/spi.h>

/**
 * @defgroup tcmds Three-wire commands
 * @{
 */

/** Read data from memory array */
#define THREEWIRE_READ 0x6

/** @} */

/**
 * @defgroup spidevs SPI device types
 * @{
 */

/** Atmel AT93C46 serial EEPROM
 *
 * @v org	Word size (8 or 16)
 */
#define AT93C46( org ) {				\
	.word_len = (org),				\
	.size = ( 1024 / (org) ),			\
	.block_size = 1,				\
	.command_len = 3,				\
	.address_len = ( ( (org) == 8 ) ? 7 : 6 ),	\
	.read = threewire_read,				\
	}

/** Atmel AT93C56 serial EEPROM
 *
 * @v org	Word size (8 or 16)
 */
#define AT93C56( org ) {				\
	.word_len = (org),				\
	.size = ( 2048 / (org) ),			\
	.block_size = 1,				\
	.command_len = 3,				\
	.address_len = ( ( (org) == 8 ) ? 9 : 8 ),	\
	.read = threewire_read,				\
	}

/** @} */

extern int threewire_read ( struct spi_device *device, unsigned int address,
			    void *data, size_t len );

#endif /* _GPXE_THREEWIRE_H */