threewire.h
Go to the documentation of this file.00001 #ifndef _GPXE_THREEWIRE_H
00002 #define _GPXE_THREEWIRE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 FILE_LICENCE ( GPL2_OR_LATER );
00014
00015 #include <gpxe/spi.h>
00016 #include <limits.h>
00017
00018
00019
00020
00021
00022
00023
00024 #define THREEWIRE_READ 0x6
00025
00026
00027 #define THREEWIRE_WRITE 0x5
00028
00029
00030 #define THREEWIRE_EWEN 0x4
00031
00032
00033 #define THREEWIRE_EWEN_ADDRESS INT_MAX
00034
00035
00036
00037
00038
00039
00040 #define THREEWIRE_WRITE_MDELAY 10
00041
00042
00043
00044 extern int threewire_read ( struct nvs_device *nvs, unsigned int address,
00045 void *data, size_t len );
00046 extern int threewire_write ( struct nvs_device *nvs, unsigned int address,
00047 const void *data, size_t len );
00048 extern int threewire_detect_address_len ( struct spi_device *device );
00049
00050
00051
00052
00053
00054
00055 static inline __attribute__ (( always_inline )) void
00056 init_at93cx6 ( struct spi_device *device, unsigned int organisation ) {
00057 device->nvs.word_len_log2 = ( ( organisation == 8 ) ? 0 : 1 );
00058 device->nvs.block_size = 1;
00059 device->command_len = 3,
00060 device->nvs.read = threewire_read;
00061 device->nvs.write = threewire_write;
00062 }
00063
00064
00065
00066
00067
00068
00069
00070 static inline __attribute__ (( always_inline )) void
00071 init_at93c46 ( struct spi_device *device, unsigned int organisation ) {
00072 device->nvs.size = ( 1024 / organisation );
00073 device->address_len = ( ( organisation == 8 ) ? 7 : 6 );
00074 init_at93cx6 ( device, organisation );
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 static inline __attribute__ (( always_inline )) void
00084 init_at93c56 ( struct spi_device *device, unsigned int organisation ) {
00085 device->nvs.size = ( 2048 / organisation );
00086 device->address_len = ( ( organisation == 8 ) ? 9 : 8 );
00087 init_at93cx6 ( device, organisation );
00088 }
00089
00090
00091
00092
00093
00094
00095
00096 static inline __attribute__ (( always_inline )) void
00097 init_at93c66 ( struct spi_device *device, unsigned int organisation ) {
00098 device->nvs.size = ( 4096 / organisation );
00099 device->address_len = ( ( organisation == 8 ) ? 9 : 8 );
00100 init_at93cx6 ( device, organisation );
00101 }
00102
00103
00104
00105 #endif