]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: test: Add a second SPI slave on sandbox_spi bus
authorOvidiu Panait <ovidiu.panait@windriver.com>
Mon, 14 Dec 2020 17:06:47 +0000 (19:06 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 23 Dec 2020 03:39:25 +0000 (20:39 -0700)
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>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
drivers/spi/sandbox_spi.c
test/dm/spi.c

index d49bee43aaef23f86d37589753ccdbdb73b5c59f..c9b9b7b75eaf7ec5f62662ecc3c1539af43f0b78 100644 (file)
                #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 {
index 6adddd77b87e72e91a9a55425e3c7ad973fc2e74..58f80c60ac30dd75d85240b3092563db50c7b6d4 100644 (file)
@@ -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;
index b767cf9c4a024277eff7625e50135243e10d37e8..59bcedf2937380e8147491bd13eff2bebc8e0c31 100644 (file)
@@ -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;