spi: mediatek: add SPI_CS_HIGH support

Change to use SPI_CS_HIGH to support spi CS polarity setting
for chips support enhance_timing.

Signed-off-by: Luhua Xu <luhua.xu@mediatek.com>
Link: https://lore.kernel.org/r/1574053037-26721-2-git-send-email-luhua.xu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Luhua Xu 2019-11-18 12:57:16 +08:00 committed by Mark Brown
parent cd050abeba
commit ae7c2d342a
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0
2 changed files with 10 additions and 3 deletions

View file

@ -139,7 +139,6 @@ static const struct mtk_spi_compatible mt8183_compat = {
* supplies it. * supplies it.
*/ */
static const struct mtk_chip_config mtk_default_chip_info = { static const struct mtk_chip_config mtk_default_chip_info = {
.cs_pol = 0,
.sample_sel = 0, .sample_sel = 0,
}; };
@ -230,10 +229,12 @@ static int mtk_spi_prepare_message(struct spi_master *master,
#endif #endif
if (mdata->dev_comp->enhance_timing) { if (mdata->dev_comp->enhance_timing) {
if (chip_config->cs_pol) /* set CS polarity */
if (spi->mode & SPI_CS_HIGH)
reg_val |= SPI_CMD_CS_POL; reg_val |= SPI_CMD_CS_POL;
else else
reg_val &= ~SPI_CMD_CS_POL; reg_val &= ~SPI_CMD_CS_POL;
if (chip_config->sample_sel) if (chip_config->sample_sel)
reg_val |= SPI_CMD_SAMPLE_SEL; reg_val |= SPI_CMD_SAMPLE_SEL;
else else
@ -264,6 +265,9 @@ static void mtk_spi_set_cs(struct spi_device *spi, bool enable)
u32 reg_val; u32 reg_val;
struct mtk_spi *mdata = spi_master_get_devdata(spi->master); struct mtk_spi *mdata = spi_master_get_devdata(spi->master);
if (spi->mode & SPI_CS_HIGH)
enable = !enable;
reg_val = readl(mdata->base + SPI_CMD_REG); reg_val = readl(mdata->base + SPI_CMD_REG);
if (!enable) { if (!enable) {
reg_val |= SPI_CMD_PAUSE_EN; reg_val |= SPI_CMD_PAUSE_EN;
@ -646,6 +650,10 @@ static int mtk_spi_probe(struct platform_device *pdev)
mdata = spi_master_get_devdata(master); mdata = spi_master_get_devdata(master);
mdata->dev_comp = of_id->data; mdata->dev_comp = of_id->data;
if (mdata->dev_comp->enhance_timing)
master->mode_bits |= SPI_CS_HIGH;
if (mdata->dev_comp->must_tx) if (mdata->dev_comp->must_tx)
master->flags = SPI_MASTER_MUST_TX; master->flags = SPI_MASTER_MUST_TX;

View file

@ -11,7 +11,6 @@
/* Board specific platform_data */ /* Board specific platform_data */
struct mtk_chip_config { struct mtk_chip_config {
u32 cs_pol;
u32 sample_sel; u32 sample_sel;
}; };
#endif #endif