summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8173
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-05-18 10:57:10 -0700
committerFurquan Shaikh <furquan@google.com>2017-05-24 04:38:33 +0200
commit02c0743a24b26315b964a6aa99f6ada310c5c114 (patch)
tree1e365490e23e52527764629ba4af7604da411d14 /src/soc/mediatek/mt8173
parentb46e9f602939c7cddf17bb38541fc5a59f2fe6c8 (diff)
downloadcoreboot-02c0743a24b26315b964a6aa99f6ada310c5c114.tar.xz
soc/mediatek/mt8173: 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: Ib0d6e4e8185ce1285b671af5ebcead1d42e049bc Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19770 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/soc/mediatek/mt8173')
-rw-r--r--src/soc/mediatek/mt8173/spi.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c
index b8ee4231b9..ae6dc3b911 100644
--- a/src/soc/mediatek/mt8173/spi.c
+++ b/src/soc/mediatek/mt8173/spi.c
@@ -289,35 +289,39 @@ static void spi_ctrlr_release_bus(const struct spi_slave *slave)
mtk_slave->state = MTK_SPI_IDLE;
}
+static int spi_ctrlr_setup(const struct spi_slave *slave)
+{
+ struct mtk_spi_bus *eslave = to_mtk_spi(slave);
+ assert(read32(&eslave->regs->spi_cfg0_reg) != 0);
+ spi_sw_reset(eslave->regs);
+ return 0;
+}
+
+static const struct spi_ctrlr spi_flash_ctrlr = {
+ .max_xfer_size = 65535,
+ .flash_probe = mtk_spi_flash_probe,
+};
+
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 = 65535,
- .flash_probe = mtk_spi_flash_probe,
};
-int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
-{
- struct mtk_spi_bus *eslave;
-
- slave->ctrlr = &spi_ctrlr;
-
- switch (bus) {
- case CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS:
- slave->bus = bus;
- slave->cs = cs;
- eslave = to_mtk_spi(slave);
- assert(read32(&eslave->regs->spi_cfg0_reg) != 0);
- spi_sw_reset(eslave->regs);
- return 0;
- case CONFIG_BOOT_DEVICE_SPI_FLASH_BUS:
- slave->bus = bus;
- slave->cs = cs;
- return 0;
- default:
- die ("wrong bus number.\n");
- };
- return -1;
-}
+const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = {
+ {
+ .ctrlr = &spi_ctrlr,
+ .bus_start = 0,
+ .bus_end = 0,
+ },
+ {
+ .ctrlr = &spi_flash_ctrlr,
+ .bus_start = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
+ .bus_end = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS,
+ },
+};
+
+const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map);