mediatek: Use GPIO based SPI CS
Some boards (e.g., Kukui) need GPIO based CS for SPI0. This patch changes the pinmux and binds the pins to the correponding SPIs. When using GPIO based SPI CS, we need to manually make CS log/high before/after SPI transactions. BUG=b:132311067 BRANCH=none TEST=Verified that b/132311067 is irreproducible Change-Id: I61653fb19242b6ee6be9a45545a8b66e5c9c7cad Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33165 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
committed by
Patrick Georgi
parent
7fc006f745
commit
4b3047833f
@@ -16,6 +16,7 @@
|
||||
#ifndef MTK_COMMON_SPI_H
|
||||
#define MTK_COMMON_SPI_H
|
||||
|
||||
#include <soc/gpio_base.h>
|
||||
#include <spi-generic.h>
|
||||
|
||||
enum {
|
||||
@@ -77,6 +78,7 @@ struct mtk_spi_bus {
|
||||
struct mtk_spi_regs *regs;
|
||||
int initialized;
|
||||
int state;
|
||||
gpio_t cs_gpio;
|
||||
};
|
||||
|
||||
extern const struct spi_ctrlr spi_ctrlr;
|
||||
|
@@ -17,6 +17,8 @@
|
||||
#include <assert.h>
|
||||
#include <console/console.h>
|
||||
#include <endian.h>
|
||||
#include <gpio.h>
|
||||
#include <stdlib.h>
|
||||
#include <soc/pll.h>
|
||||
#include <soc/spi.h>
|
||||
#include <timer.h>
|
||||
@@ -87,6 +89,8 @@ void mtk_spi_init(unsigned int bus, enum spi_pad_mask pad_select,
|
||||
|
||||
clrsetbits_le32(®s->spi_pad_macro_sel_reg, SPI_PAD_SEL_MASK,
|
||||
pad_select);
|
||||
|
||||
gpio_output(slave->cs_gpio, 1);
|
||||
}
|
||||
|
||||
static void mtk_spi_dump_data(const char *name, const uint8_t *data, int size)
|
||||
@@ -109,6 +113,8 @@ static int spi_ctrlr_claim_bus(const struct spi_slave *slave)
|
||||
setbits_le32(®s->spi_cmd_reg, 1 << SPI_CMD_PAUSE_EN_SHIFT);
|
||||
mtk_slave->state = MTK_SPI_IDLE;
|
||||
|
||||
gpio_output(mtk_slave->cs_gpio, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -243,6 +249,8 @@ static void spi_ctrlr_release_bus(const struct spi_slave *slave)
|
||||
clrbits_le32(®s->spi_cmd_reg, SPI_CMD_PAUSE_EN);
|
||||
spi_sw_reset(regs);
|
||||
mtk_slave->state = MTK_SPI_IDLE;
|
||||
|
||||
gpio_output(mtk_slave->cs_gpio, 1);
|
||||
}
|
||||
|
||||
static int spi_ctrlr_setup(const struct spi_slave *slave)
|
||||
|
Reference in New Issue
Block a user