diff mbox series

[4/6] test: spi: Add sandbox_spi_get_{speed, mode} interface

Message ID 20201206212128.21233-5-ovidiu.panait@windriver.com
State Superseded
Delegated to: Simon Glass
Headers show
Series spi: spi-uclass: Fix spi_claim_bus() speed/mode setup logic | expand

Commit Message

Ovidiu Panait Dec. 6, 2020, 9:21 p.m. UTC
Introduce sandbox_spi_get_{speed, mode} public interface to retrieve the
sandbox spi bus internal state. They are meant to be used in sandbox spi
testcases.

Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---

 arch/sandbox/include/asm/test.h | 16 ++++++++++++++++
 drivers/spi/sandbox_spi.c       | 14 ++++++++++++++
 2 files changed, 30 insertions(+)

Comments

Simon Glass Dec. 12, 2020, 3:39 p.m. UTC | #1
On Sun, 6 Dec 2020 at 14:23, Ovidiu Panait <ovidiu.panait@windriver.com> wrote:
>
> Introduce sandbox_spi_get_{speed, mode} public interface to retrieve the
> sandbox spi bus internal state. They are meant to be used in sandbox spi
> testcases.
>
> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
> ---
>
>  arch/sandbox/include/asm/test.h | 16 ++++++++++++++++
>  drivers/spi/sandbox_spi.c       | 14 ++++++++++++++
>  2 files changed, 30 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 7f99d07c47..05f66f700c 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -202,6 +202,22 @@  void sandbox_set_allow_beep(struct udevice *dev, bool allow);
  */
 int sandbox_get_beep_frequency(struct udevice *dev);
 
+/**
+ * sandbox_spi_get_speed() - Get current speed setting of a sandbox spi bus
+ *
+ * @dev: Device to check
+ * @return current bus speed
+ */
+uint sandbox_spi_get_speed(struct udevice *dev);
+
+/**
+ * sandbox_spi_get_mode() - Get current mode setting of a sandbox spi bus
+ *
+ * @dev: Device to check
+ * @return current mode
+ */
+uint sandbox_spi_get_mode(struct udevice *dev);
+
 /**
  * sandbox_get_pch_spi_protect() - Get the PCI SPI protection status
  *
diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c
index 72f22d066f..cbe8d62681 100644
--- a/drivers/spi/sandbox_spi.c
+++ b/drivers/spi/sandbox_spi.c
@@ -52,6 +52,20 @@  __weak int sandbox_spi_get_emul(struct sandbox_state *state,
 	return -ENOENT;
 }
 
+uint sandbox_spi_get_speed(struct udevice *dev)
+{
+	struct sandbox_spi_priv *priv = dev_get_priv(dev);
+
+	return priv->speed;
+}
+
+uint sandbox_spi_get_mode(struct udevice *dev)
+{
+	struct sandbox_spi_priv *priv = dev_get_priv(dev);
+
+	return priv->mode;
+}
+
 static int sandbox_spi_xfer(struct udevice *slave, unsigned int bitlen,
 			    const void *dout, void *din, unsigned long flags)
 {