summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-05-18 11:10:20 -0700
committerFurquan Shaikh <furquan@google.com>2017-05-24 04:39:07 +0200
commite173ee8f01dae8d645235347f80b6c0ec4aacf0d (patch)
treed0f68f4855aec43192b57da3579112dd6115ac05
parent23d5d99098a61b90cb4bea07a357531f74e7be38 (diff)
soc/imgtec/pistachio: Move spi driver to use spi_bus_map
This is in preparation to get rid of the strong spi_setup_slave implemented by different platforms. BUG=b:38430839 Change-Id: Ie4ec74fccaf25900537ccd5c146bb0a333a2754c Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19772 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--src/soc/imgtec/pistachio/spi.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/soc/imgtec/pistachio/spi.c b/src/soc/imgtec/pistachio/spi.c
index 30e14fab10..bfd982cf62 100644
--- a/src/soc/imgtec/pistachio/spi.c
+++ b/src/soc/imgtec/pistachio/spi.c
@@ -533,22 +533,13 @@ static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
return SPIM_OK;
}
-static const struct spi_ctrlr spi_ctrlr = {
- .claim_bus = spi_ctrlr_claim_bus,
- .release_bus = spi_ctrlr_release_bus,
- .xfer = spi_ctrlr_xfer,
- .xfer_vector = spi_xfer_two_vectors,
- .max_xfer_size = IMGTEC_SPI_MAX_TRANSFER_SIZE,
-};
-
-/* Set up communications parameters for a SPI slave. */
-int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
+static int spi_ctrlr_setup(const struct spi_slave *slave)
{
struct img_spi_slave *img_slave = NULL;
struct spim_device_parameters *device_parameters;
u32 base;
- switch (bus) {
+ switch (slave->bus) {
case 0:
base = IMG_SPIM0_BASE_ADDRESS;
break;
@@ -560,16 +551,12 @@ int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
__func__);
return -1;
}
- if (cs > SPIM_DEVICE4) {
+ if (slave->cs > SPIM_DEVICE4) {
printk(BIOS_ERR, "%s: Error: unsupported chipselect.\n",
__func__);
return -1;
}
- slave->bus = bus;
- slave->cs = cs;
- slave->ctrlr = &spi_ctrlr;
-
img_slave = get_img_slave(slave);
device_parameters = &(img_slave->device_parameters);
@@ -586,3 +573,22 @@ int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
return 0;
}
+
+static const struct spi_ctrlr spi_ctrlr = {
+ .setup = spi_ctrlr_setup,
+ .claim_bus = spi_ctrlr_claim_bus,
+ .release_bus = spi_ctrlr_release_bus,
+ .xfer = spi_ctrlr_xfer,
+ .xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = IMGTEC_SPI_MAX_TRANSFER_SIZE,
+};
+
+const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = {
+ {
+ .ctrlr = &spi_ctrlr,
+ .bus_start = 0,
+ .bus_end = 1,
+ },
+};
+
+const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map);