From 15ad0d0480f558633ba9ca822ec24191542bc8c4 Mon Sep 17 00:00:00 2001 From: Kyungwoo_Kang_System Date: Thu, 7 Sep 2017 18:06:42 +0900 Subject: [PATCH] [COMMON] spi: s3c64xx: Fix Code sequece by architectual guide. The guide of SPI PACKET CNT SFR setting is like below. [Disable the channel] -> [Change PACKET CNT SFR] -> [Enable the channel] Previously our SPI driver code sequece is differ from architectual guide. To prevent SPI malfunction, we change the code sequence. Change-Id: I8c105b97f1e36912064ac1c9cfb8f5c43f079927 Signed-off-by: Kyungwoo_Kang_System --- drivers/spi/spi-s3c64xx.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 695d37e66e56..e893912152b3 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -269,12 +269,12 @@ static void flush_fifo(struct s3c64xx_spi_driver_data *sdd) unsigned long loops; u32 val; - writel(0, regs + S3C64XX_SPI_PACKET_CNT); - val = readl(regs + S3C64XX_SPI_CH_CFG); val &= ~(S3C64XX_SPI_CH_RXCH_ON | S3C64XX_SPI_CH_TXCH_ON); writel(val, regs + S3C64XX_SPI_CH_CFG); + writel(0, regs + S3C64XX_SPI_PACKET_CNT); + val = readl(regs + S3C64XX_SPI_CH_CFG); val |= S3C64XX_SPI_CH_SW_RST; val &= ~S3C64XX_SPI_CH_HS_EN; @@ -520,7 +520,7 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, struct spi_transfer *xfer, int dma_mode) { void __iomem *regs = sdd->regs; - u32 modecfg, chcfg, dma_burst_len; + u32 modecfg, chcfg, dma_burst_len, packet_cnt_en; chcfg = readl(regs + S3C64XX_SPI_CH_CFG); chcfg &= ~S3C64XX_SPI_CH_TXCH_ON; @@ -540,9 +540,17 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd, * as exactly needed. */ chcfg |= S3C64XX_SPI_CH_RXCH_ON; - writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff) - | S3C64XX_SPI_PACKET_CNT_EN, - regs + S3C64XX_SPI_PACKET_CNT); + + packet_cnt_en = readl(regs + S3C64XX_SPI_PACKET_CNT); + packet_cnt_en &= ~S3C64XX_SPI_PACKET_CNT_EN; + writel(packet_cnt_en, regs + S3C64XX_SPI_PACKET_CNT); + + writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff), + regs + S3C64XX_SPI_PACKET_CNT); + + packet_cnt_en = readl(regs + S3C64XX_SPI_PACKET_CNT); + packet_cnt_en |= S3C64XX_SPI_PACKET_CNT_EN; + writel(packet_cnt_en, regs + S3C64XX_SPI_PACKET_CNT); } writel(modecfg, regs + S3C64XX_SPI_MODE_CFG); -- 2.20.1