summaryrefslogtreecommitdiff
path: root/src/soc/mediatek/mt8173
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2016-12-01 01:02:44 -0800
committerFurquan Shaikh <furquan@google.com>2016-12-05 03:28:06 +0100
commit36b81af9e8ecea2bf58aae9a421720ed10f61b82 (patch)
tree05e7329c67bf009531c12052db105ac55ce015b8 /src/soc/mediatek/mt8173
parent0dba0254ea31eca41fdef88783f1dd192ac6fa56 (diff)
spi: Pass pointer to spi_slave structure in spi_setup_slave
For spi_setup_slave, instead of making the platform driver return a pointer to spi_slave structure, pass in a structure pointer that can be filled in by the driver as required. This removes the need for platform drivers to maintain a slave structure in data/CAR section. BUG=chrome-os-partner:59832 BRANCH=None TEST=Compiles successfully Change-Id: Ia15a4f88ef4dcfdf616bb1c22261e7cb642a7573 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17683 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/soc/mediatek/mt8173')
-rw-r--r--src/soc/mediatek/mt8173/spi.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c
index f60de6c32b..d6bcc0bd0a 100644
--- a/src/soc/mediatek/mt8173/spi.c
+++ b/src/soc/mediatek/mt8173/spi.c
@@ -47,9 +47,6 @@ enum {
static struct mtk_spi_bus spi_bus[1] = {
{
- .slave = {
- .bus = 0,
- },
.regs = (void *)SPI_BASE,
.state = MTK_SPI_IDLE,
}
@@ -57,7 +54,8 @@ static struct mtk_spi_bus spi_bus[1] = {
static inline struct mtk_spi_bus *to_mtk_spi(const struct spi_slave *slave)
{
- return container_of(slave, struct mtk_spi_bus, slave);
+ assert(slave->bus < ARRAY_SIZE(spi_bus));
+ return &spi_bus[slave->bus];
}
static void spi_sw_reset(struct mtk_spi_regs *regs)
@@ -162,24 +160,26 @@ static void mtk_spi_dump_data(const char *name, const uint8_t *data,
#endif
}
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
+int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
{
struct mtk_spi_bus *eslave;
- static struct spi_slave slave;
switch (bus) {
case CONFIG_EC_GOOGLE_CHROMEEC_SPI_BUS:
- eslave = &spi_bus[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 &eslave->slave;
+ return 0;
case CONFIG_BOOT_DEVICE_SPI_FLASH_BUS:
- slave.bus = bus;
- slave.cs = cs;
- return &slave;
+ slave->bus = bus;
+ slave->cs = cs;
+ return 0;
default:
die ("wrong bus number.\n");
};
+ return -1;
}
int spi_claim_bus(const struct spi_slave *slave)