]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: spi: Add sandbox_spi_get_{speed, mode} interface
authorOvidiu Panait <ovidiu.panait@windriver.com>
Mon, 14 Dec 2020 17:06:49 +0000 (19:06 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 23 Dec 2020 03:39:26 +0000 (20:39 -0700)
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/include/asm/test.h
drivers/spi/sandbox_spi.c

index 7f99d07c47fcf95ccf1ddf427d8dbf0b570548ff..05f66f700ca364bfac804c7dd39e3bcf07c94b88 100644 (file)
@@ -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
  *
index be516d5aa62df35e9e9edac1454b63fb198d171f..0564d8b55e70b336c3c91d7febee6c45e7feb6f6 100644 (file)
@@ -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)
 {