aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@foss.st.com>2022-03-30 09:33:13 +0200
committerTom Rini <trini@konsulko.com>2022-05-23 09:33:10 -0400
commit61708bb0a24caad99b0e79de52077dafb59688d6 (patch)
tree92509d695141d0455f7fe329a870ad57e39a6a34 /test
parent827a232623e9b00e7d1b4b62b46e803d7168bbf5 (diff)
downloadu-boot-61708bb0a24caad99b0e79de52077dafb59688d6.zip
u-boot-61708bb0a24caad99b0e79de52077dafb59688d6.tar.gz
u-boot-61708bb0a24caad99b0e79de52077dafb59688d6.tar.bz2
spi: spi-uclass: Add new spi_get_bus_and_cs() implementation
Move legacy spi_get_bus_and_cs() code to _spi_get_bus_and_cs(). Add new spi_get_bus_and_cs() implementation which rely on DT for speed and mode and don't need any drv_name nor dev_name parameters. This will prepare the ground for next patch. Update all callers to use _spi_get_bus_and_cs() to keep the same behavior. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Cc: Marek Behun <marek.behun@nic.cz> Cc: Jagan Teki <jagan@amarulasolutions.com> Cc: Vignesh R <vigneshr@ti.com> Cc: Joe Hershberger <joe.hershberger@ni.com> Cc: Ramon Fried <rfried.dev@gmail.com> Cc: Lukasz Majewski <lukma@denx.de> Cc: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: Simon Glass <sjg@chromium.org> Cc: Stefan Roese <sr@denx.de> Cc: "Pali Rohár" <pali@kernel.org> Cc: Konstantin Porotchkin <kostap@marvell.com> Cc: Igal Liberman <igall@marvell.com> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Pratyush Yadav <p.yadav@ti.com> Cc: Sean Anderson <seanga2@gmail.com> Cc: Anji J <anji.jagarlmudi@nxp.com> Cc: Biwen Li <biwen.li@nxp.com> Cc: Priyanka Jain <priyanka.jain@nxp.com> Cc: Chaitanya Sakinam <chaitanya.sakinam@nxp.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/spi.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/test/dm/spi.c b/test/dm/spi.c
index ee4ad3a..7ab0820 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -46,19 +46,19 @@ static int dm_test_spi_find(struct unit_test_state *uts)
/* This finds nothing because we removed the device */
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
- ut_asserteq(-ENODEV, spi_get_bus_and_cs(busnum, cs, speed, mode,
- NULL, 0, &bus, &slave));
+ ut_asserteq(-ENODEV, _spi_get_bus_and_cs(busnum, cs, speed, mode,
+ NULL, 0, &bus, &slave));
/*
* This forces the device to be re-added, but there is no emulation
* connected so the probe will fail. We require that bus is left
- * alone on failure, and that the spi_get_bus_and_cs() does not add
+ * alone on failure, and that the _spi_get_bus_and_cs() does not add
* a 'partially-inited' device.
*/
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
- ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
- "jedec_spi_nor", "name", &bus,
- &slave));
+ ut_asserteq(-ENOENT, _spi_get_bus_and_cs(busnum, cs, speed, mode,
+ "jedec_spi_nor", "name", &bus,
+ &slave));
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(NULL, info.dev);
@@ -67,8 +67,8 @@ static int dm_test_spi_find(struct unit_test_state *uts)
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, node,
"name"));
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
- ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
- "jedec_spi_nor", "name", &bus, &slave));
+ ut_assertok(_spi_get_bus_and_cs(busnum, cs, speed, mode,
+ "jedec_spi_nor", "name", &bus, &slave));
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(info.dev, slave->dev);
@@ -76,8 +76,9 @@ static int dm_test_spi_find(struct unit_test_state *uts)
/* We should be able to add something to another chip select */
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
"name"));
- ut_asserteq(-EINVAL, spi_get_bus_and_cs(busnum, cs_b, speed, mode,
- "jedec_spi_nor", "name", &bus, &slave));
+ ut_asserteq(-EINVAL, _spi_get_bus_and_cs(busnum, cs_b, speed, mode,
+ "jedec_spi_nor", "name", &bus,
+ &slave));
ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info));
ut_asserteq_ptr(NULL, info.dev);
@@ -145,11 +146,11 @@ static int dm_test_spi_claim_bus(struct unit_test_state *uts)
const int busnum = 0, cs_a = 0, cs_b = 1, mode = 0;
/* Get spi slave on CS0 */
- ut_assertok(spi_get_bus_and_cs(busnum, cs_a, 1000000, mode, NULL, 0,
- &bus, &slave_a));
+ ut_assertok(_spi_get_bus_and_cs(busnum, cs_a, 1000000, mode, NULL, 0,
+ &bus, &slave_a));
/* Get spi slave on CS1 */
- ut_assertok(spi_get_bus_and_cs(busnum, cs_b, 1000000, mode, NULL, 0,
- &bus, &slave_b));
+ ut_assertok(_spi_get_bus_and_cs(busnum, cs_b, 1000000, mode, NULL, 0,
+ &bus, &slave_b));
/* Different max_hz, different mode. */
ut_assert(slave_a->max_hz != slave_b->max_hz);
@@ -182,8 +183,8 @@ static int dm_test_spi_xfer(struct unit_test_state *uts)
const char dout[5] = {0x9f};
unsigned char din[5];
- ut_assertok(spi_get_bus_and_cs(busnum, cs, 1000000, mode, NULL, 0,
- &bus, &slave));
+ ut_assertok(_spi_get_bus_and_cs(busnum, cs, 1000000, mode, NULL, 0,
+ &bus, &slave));
ut_assertok(spi_claim_bus(slave));
ut_assertok(spi_xfer(slave, 40, dout, din,
SPI_XFER_BEGIN | SPI_XFER_END));