From e173ee8f01dae8d645235347f80b6c0ec4aacf0d Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Thu, 18 May 2017 11:10:20 -0700 Subject: 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 Reviewed-on: https://review.coreboot.org/19772 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/soc/imgtec/pistachio/spi.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/soc/imgtec/pistachio') 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); -- cgit v1.2.3