mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
spi: sandbox_spi: Implement speed/mode setup
Implement sandbox_spi_set_{speed, mode} routines, to be able to keep track of the current bus speed/mode. This will help determine whether the values passed from dm_spi_claim_bus() are valid. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
This commit is contained in:
parent
1dc53ce71d
commit
2da1800456
1 changed files with 26 additions and 0 deletions
|
@ -28,6 +28,23 @@
|
||||||
# define CONFIG_SPI_IDLE_VAL 0xFF
|
# define CONFIG_SPI_IDLE_VAL 0xFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct sandbox_spi_priv - Sandbox SPI private data
|
||||||
|
*
|
||||||
|
* Helper struct to keep track of the sandbox SPI bus internal state. It is
|
||||||
|
* used in unit tests to verify that dm spi functions update the bus
|
||||||
|
* speed/mode properly (for instance, when jumping back and forth between spi
|
||||||
|
* slaves claiming the bus, we need to make sure that the bus speed is updated
|
||||||
|
* accordingly for each slave).
|
||||||
|
*
|
||||||
|
* @speed: Current bus speed.
|
||||||
|
* @mode: Current bus mode.
|
||||||
|
*/
|
||||||
|
struct sandbox_spi_priv {
|
||||||
|
uint speed;
|
||||||
|
uint mode;
|
||||||
|
};
|
||||||
|
|
||||||
__weak int sandbox_spi_get_emul(struct sandbox_state *state,
|
__weak int sandbox_spi_get_emul(struct sandbox_state *state,
|
||||||
struct udevice *bus, struct udevice *slave,
|
struct udevice *bus, struct udevice *slave,
|
||||||
struct udevice **emulp)
|
struct udevice **emulp)
|
||||||
|
@ -90,11 +107,19 @@ static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,
|
||||||
|
|
||||||
static int sandbox_spi_set_speed(struct udevice *bus, uint speed)
|
static int sandbox_spi_set_speed(struct udevice *bus, uint speed)
|
||||||
{
|
{
|
||||||
|
struct sandbox_spi_priv *priv = dev_get_priv(bus);
|
||||||
|
|
||||||
|
priv->speed = speed;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sandbox_spi_set_mode(struct udevice *bus, uint mode)
|
static int sandbox_spi_set_mode(struct udevice *bus, uint mode)
|
||||||
{
|
{
|
||||||
|
struct sandbox_spi_priv *priv = dev_get_priv(bus);
|
||||||
|
|
||||||
|
priv->mode = mode;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,4 +161,5 @@ U_BOOT_DRIVER(sandbox_spi) = {
|
||||||
.id = UCLASS_SPI,
|
.id = UCLASS_SPI,
|
||||||
.of_match = sandbox_spi_ids,
|
.of_match = sandbox_spi_ids,
|
||||||
.ops = &sandbox_spi_ops,
|
.ops = &sandbox_spi_ops,
|
||||||
|
.priv_auto = sizeof(struct sandbox_spi_priv),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue