diff mbox series

[2/6] sandbox: test: Add a second SPI slave on sandbox_spi bus

Message ID 20201206212128.21233-3-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
Place a second spi slave on the sandbox_spi bus, to be used by the
spi_claim_bus() testcase we are about to introduce. We need to make sure
that jumping between slaves calling spi_claim_bus() sets the bus speed and
mode appropriately. Use different max-hz and mode properties for this new
slave.

Also, update sandbox_spi cs_info call to allow activity on CS0/CS1 and
adapt dm_test_spi_find() testcase for this new setup.

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

 arch/sandbox/dts/test.dts | 10 +++++++++-
 drivers/spi/sandbox_spi.c |  4 ++--
 test/dm/spi.c             |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

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:
>
> Place a second spi slave on the sandbox_spi bus, to be used by the
> spi_claim_bus() testcase we are about to introduce. We need to make sure
> that jumping between slaves calling spi_claim_bus() sets the bus speed and
> mode appropriately. Use different max-hz and mode properties for this new
> slave.
>
> Also, update sandbox_spi cs_info call to allow activity on CS0/CS1 and
> adapt dm_test_spi_find() testcase for this new setup.
>
> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
> ---
>
>  arch/sandbox/dts/test.dts | 10 +++++++++-
>  drivers/spi/sandbox_spi.c |  4 ++--
>  test/dm/spi.c             |  2 +-
>  3 files changed, 12 insertions(+), 4 deletions(-)

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

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index f3b766271d..3eca1a73de 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -864,13 +864,21 @@ 
 		#size-cells = <0>;
 		reg = <0 1>;
 		compatible = "sandbox,spi";
-		cs-gpios = <0>, <&gpio_a 0>;
+		cs-gpios = <0>, <0>, <&gpio_a 0>;
 		spi.bin@0 {
 			reg = <0>;
 			compatible = "spansion,m25p16", "jedec,spi-nor";
 			spi-max-frequency = <40000000>;
 			sandbox,filename = "spi.bin";
 		};
+		spi.bin@1 {
+			reg = <1>;
+			compatible = "spansion,m25p16", "jedec,spi-nor";
+			spi-max-frequency = <50000000>;
+			sandbox,filename = "spi.bin";
+			spi-cpol;
+			spi-cpha;
+		};
 	};
 
 	syscon0: syscon@0 {
diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c
index 3640ddeeb6..412756aa4b 100644
--- a/drivers/spi/sandbox_spi.c
+++ b/drivers/spi/sandbox_spi.c
@@ -101,8 +101,8 @@  static int sandbox_spi_set_mode(struct udevice *bus, uint mode)
 static int sandbox_cs_info(struct udevice *bus, uint cs,
 			   struct spi_cs_info *info)
 {
-	/* Always allow activity on CS 0 */
-	if (cs >= 1)
+	/* Always allow activity on CS 0, CS 1 */
+	if (cs >= 2)
 		return -EINVAL;
 
 	return 0;
diff --git a/test/dm/spi.c b/test/dm/spi.c
index fb180aed1f..6db680edd2 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -22,7 +22,7 @@  static int dm_test_spi_find(struct unit_test_state *uts)
 	struct sandbox_state *state = state_get_current();
 	struct spi_slave *slave;
 	struct udevice *bus, *dev;
-	const int busnum = 0, cs = 0, mode = 0, speed = 1000000, cs_b = 1;
+	const int busnum = 0, cs = 0, mode = 0, speed = 1000000, cs_b = 2;
 	struct spi_cs_info info;
 	ofnode node;