[coreboot-gerrit] Change in coreboot[master]: soc/imgtec/pistachio: Move spi driver to use spi_bus_map

Furquan Shaikh (Code Review) gerrit at coreboot.org
Wed May 24 04:39:12 CEST 2017


Furquan Shaikh has submitted this change and it was merged. ( https://review.coreboot.org/19772 )

Change subject: soc/imgtec/pistachio: Move spi driver to use spi_bus_map
......................................................................


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 at chromium.org>
Reviewed-on: https://review.coreboot.org/19772
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
Reviewed-by: Aaron Durbin <adurbin at chromium.org>
---
M src/soc/imgtec/pistachio/spi.c
1 file changed, 22 insertions(+), 16 deletions(-)

Approvals:
  Aaron Durbin: Looks good to me, approved
  build bot (Jenkins): Verified



diff --git a/src/soc/imgtec/pistachio/spi.c b/src/soc/imgtec/pistachio/spi.c
index 30e14fa..bfd982c 100644
--- a/src/soc/imgtec/pistachio/spi.c
+++ b/src/soc/imgtec/pistachio/spi.c
@@ -533,22 +533,13 @@
 	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,15 +551,11 @@
 				__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 @@
 
 	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);

-- 
To view, visit https://review.coreboot.org/19772
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4ec74fccaf25900537ccd5c146bb0a333a2754c
Gerrit-PatchSet: 6
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Aaron Durbin <adurbin at chromium.org>
Gerrit-Reviewer: Duncan Laurie <dlaurie at chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>



More information about the coreboot-gerrit mailing list