arm-trusted-firmware/include/drivers/gpio_spi.h
Abhi Singh 3c54570afc feat(io): add generic gpio spi bit-bang driver
When using a tpm breakout board with rpi3, we elected to bit-bang
gpio pins to emulate a spi interface, this implementation required a
driver to interface with the platform specific pins and emulate spi
functionality. The generic driver provides the ability to pass in a
gpio_spi_data structure that contains the necessary gpio pins in
order to simulate spi operations (get_access, start, stop, xfer).

Change-Id: I88919e8a294c05e0cabb8224e35ae5c1ba5f2413
Signed-off-by: Tushar Khandelwal <tushar.khandelwal@arm.com>
Signed-off-by: Abhi Singh <abhi.singh@arm.com>
2025-03-18 19:56:16 +01:00

32 lines
639 B
C

/*
* Copyright (c) 2025, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef GPIO_SPI_H
#define GPIO_SPI_H
#include <stdint.h>
struct gpio_spi_data {
uint8_t cs_gpio, sclk_gpio, mosi_gpio, miso_gpio, reset_gpio;
uint32_t spi_delay_us;
unsigned int spi_mode;
};
struct spi_ops {
void (*get_access)(void);
void (*start)(void);
void (*stop)(void);
int (*xfer)(unsigned int bitlen, const void *dout, void *din);
};
struct spi_plat {
struct gpio_spi_data gpio_data;
const struct spi_ops *ops;
};
struct spi_plat *gpio_spi_init(struct gpio_spi_data *gpio_spi_data);
#endif /* GPIO_SPI_H */