52#define DESELECT_SLAVE SPI_MODE_SSPOL
65 unsigned int state ) {
69 DBGC2 ( spibit,
"SPIBIT %p setting slave %d select %s\n",
93 const void *data_out,
void *data_in,
94 unsigned int len,
int endianness ) {
99 unsigned int bit_offset;
100 unsigned int byte_offset;
101 unsigned int byte_mask;
105 DBGC2 ( spibit,
"SPIBIT %p transferring %d bits in mode %#x\n",
112 byte_offset = ( bit_offset / 8 );
113 byte_mask = ( 1 << ( bit_offset % 8 ) );
116 if ( sclk == cpha ) {
121 byte = ( data_out + byte_offset );
122 bit = ( *
byte & byte_mask );
123 DBGCP ( spibit,
"SPIBIT %p wrote bit %d\n",
124 spibit, (
bit ? 1 : 0 ) );
135 DBGCP ( spibit,
"SPIBIT %p read bit %d\n",
136 spibit, (
bit ? 1 : 0 ) );
137 byte = ( data_in + byte_offset );
139 *
byte |= (
bit & byte_mask );
164 const void *data_out,
void *data_in,
size_t len ) {
185 assert (
device->command_len <= ( 8 * sizeof ( tmp_command ) ) );
192 assert (
device->address_len <= ( 8 * sizeof ( tmp_address )));
199 DBGC ( spibit,
"SPIBIT %p autodetecting device "
200 "address length\n", spibit );
205 &tmp_address_detect, 1,
208 }
while (
le32_to_cpu ( tmp_address_detect ) & 1 );
209 DBGC ( spibit,
"SPIBIT %p autodetected device address "
210 "length %d\n", spibit,
device->address_len );
#define NULL
NULL pointer (VOID *)
#define assert(condition)
Assert a condition at run-time.
int read_bit(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
void write_bit(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
static void open_bit(struct bit_basher *basher)
Open bit-bashing interface.
static void close_bit(struct bit_basher *basher)
Close bit-bashing interface.
uint64_t address
Base address.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
#define le32_to_cpu(value)
#define cpu_to_le32(value)
static unsigned int unsigned int bit
void step(void)
Single-step a single process.
#define SPI_MODE_CPHA
Clock phase (CPHA) mode bit.
#define SPI_MODE_CPOL
Clock polarity (CPOL) mode bit.
#define SPI_MODE_SSPOL
Slave select polarity mode bit.
#define SPI_AUTODETECT_ADDRESS_LEN
SPI magic autodetection address length.
#define SELECT_SLAVE
Chip select line will be asserted.
static void spi_bit_delay(void)
Delay between SCLK changes and around SS changes.
static void spi_bit_set_slave_select(struct spi_bit_basher *spibit, unsigned int slave, unsigned int state)
Select/deselect slave.
void init_spi_bit_basher(struct spi_bit_basher *spibit)
Initialise SPI bit-bashing interface.
#define DESELECT_SLAVE
Chip select line will be deasserted.
static void spi_bit_transfer(struct spi_bit_basher *spibit, const void *data_out, void *data_in, unsigned int len, int endianness)
Transfer bits over SPI bit-bashing bus.
static int spi_bit_rw(struct spi_bus *bus, struct spi_device *device, unsigned int command, int address, const void *data_out, void *data_in, size_t len)
Read/write data via SPI bit-bashing bus.
SPI bit-bashing interface.
#define SPI_BIT_UDELAY
Delay between SCLK transitions.
@ SPI_BIT_MOSI
Master Out Slave In.
@ SPI_BIT_MISO
Master In Slave Out.
@ SPI_BIT_SCLK
Serial clock.
#define SPI_BIT_SS(slave)
Determine bit index for a particular slave.
#define SPI_BIT_BIG_ENDIAN
SPI bit basher treats data as big-endian.
#define container_of(ptr, type, field)
Get containing structure.
void(* write)(struct bit_basher *basher, unsigned int bit_id, unsigned long data)
Set/clear output bit.
int(* read)(struct bit_basher *basher, unsigned int bit_id)
Read input bit.
struct bit_basher_operations * op
Bit-bashing operations.
struct spi_bus bus
SPI bus.
int endianness
Endianness of data.
struct bit_basher basher
Bit-bashing interface.
int(* rw)(struct spi_bus *bus, struct spi_device *device, unsigned int command, int address, const void *data_out, void *data_in, size_t len)
Read/write data via SPI bus.
unsigned int mode
SPI interface mode.
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.