diff options
author | Patrice Chotard <patrice.chotard@foss.st.com> | 2022-05-18 08:46:46 +0200 |
---|---|---|
committer | Lokanathan, Raaj <raaj.lokanathan@intel.com> | 2022-08-12 09:09:09 +0800 |
commit | 134dc28fb41343ddf80888c8e99a029f3e8c558f (patch) | |
tree | 6f93cec8507d01af436aa8f69867dfdc37ee2941 | |
parent | 8918cd39f51317a27defd1bece3da08ab8709d6f (diff) | |
download | u-boot-socfpga-134dc28fb41343ddf80888c8e99a029f3e8c558f.tar.gz |
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>
-rw-r--r-- | drivers/mtd/spi/sf-uclass.c | 18 | ||||
-rw-r--r-- | test/dm/spi.c | 12 |
2 files changed, 10 insertions, 20 deletions
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index e6e650ef8c..2ee4c8d5a5 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -61,22 +61,8 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs, snprintf(name, sizeof(name), "spi_flash@%d:%d", busnum, cs); str = strdup(name); #endif - - if (_spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode, - "jedec_spi_nor", str, &bus, &slave)) - return NULL; - - return dev_get_uclass_priv(slave->dev); -} - -int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs, - struct udevice **devp) -{ - struct spi_slave *slave; - struct udevice *bus; - int ret; - - ret = spi_get_bus_and_cs(busnum, cs, &bus, &slave); + ret = _spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode, + "jedec_spi_nor", str, &bus, &slave); if (ret) return ret; diff --git a/test/dm/spi.c b/test/dm/spi.c index 325799bbf1..cda00e7257 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -46,7 +46,8 @@ 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, &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 @@ -145,9 +146,11 @@ static int dm_test_spi_claim_bus(struct unit_test_state *uts) const int busnum = 0, cs_a = 0, cs_b = 1; /* Get spi slave on CS0 */ - ut_assertok(spi_get_bus_and_cs(busnum, cs_a, &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, &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); @@ -180,7 +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, &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)); |