1f62ca4e2SLi-hao Kuo // SPDX-License-Identifier: GPL-2.0-only 2f62ca4e2SLi-hao Kuo // Copyright (c) 2021 Sunplus Inc. 3f62ca4e2SLi-hao Kuo // Author: Li-hao Kuo <lhjeff911@gmail.com> 4f62ca4e2SLi-hao Kuo 5f62ca4e2SLi-hao Kuo #include <linux/bitfield.h> 6f62ca4e2SLi-hao Kuo #include <linux/clk.h> 7f62ca4e2SLi-hao Kuo #include <linux/delay.h> 8f62ca4e2SLi-hao Kuo #include <linux/dma-mapping.h> 9f62ca4e2SLi-hao Kuo #include <linux/interrupt.h> 10f62ca4e2SLi-hao Kuo #include <linux/module.h> 11f62ca4e2SLi-hao Kuo #include <linux/of.h> 12f62ca4e2SLi-hao Kuo #include <linux/platform_device.h> 13f62ca4e2SLi-hao Kuo #include <linux/pm_runtime.h> 14f62ca4e2SLi-hao Kuo #include <linux/reset.h> 15f62ca4e2SLi-hao Kuo #include <linux/spi/spi.h> 16f62ca4e2SLi-hao Kuo 17f62ca4e2SLi-hao Kuo #define SP7021_DATA_RDY_REG 0x0044 18f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_CTRL_REG 0x0048 19f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_LENGTH_REG 0x004c 20f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_ADDR_REG 0x004c 21f62ca4e2SLi-hao Kuo 22f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DATA_RDY BIT(0) 23f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_SW_RST BIT(1) 24f62ca4e2SLi-hao Kuo #define SP7021_SLA_DMA_W_INT BIT(8) 25f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_CLR_INT BIT(8) 26f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_EN BIT(0) 27f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_RW BIT(6) 28f62ca4e2SLi-hao Kuo #define SP7021_SLAVE_DMA_CMD GENMASK(3, 2) 29f62ca4e2SLi-hao Kuo 30f62ca4e2SLi-hao Kuo #define SP7021_FIFO_REG 0x0034 31f62ca4e2SLi-hao Kuo #define SP7021_SPI_STATUS_REG 0x0038 32f62ca4e2SLi-hao Kuo #define SP7021_SPI_CONFIG_REG 0x003c 33f62ca4e2SLi-hao Kuo #define SP7021_INT_BUSY_REG 0x004c 34f62ca4e2SLi-hao Kuo #define SP7021_DMA_CTRL_REG 0x0050 35f62ca4e2SLi-hao Kuo 36f62ca4e2SLi-hao Kuo #define SP7021_SPI_START_FD BIT(0) 37f62ca4e2SLi-hao Kuo #define SP7021_FD_SW_RST BIT(1) 38f62ca4e2SLi-hao Kuo #define SP7021_TX_EMP_FLAG BIT(2) 39f62ca4e2SLi-hao Kuo #define SP7021_RX_EMP_FLAG BIT(4) 40f62ca4e2SLi-hao Kuo #define SP7021_RX_FULL_FLAG BIT(5) 41f62ca4e2SLi-hao Kuo #define SP7021_FINISH_FLAG BIT(6) 42f62ca4e2SLi-hao Kuo 43f62ca4e2SLi-hao Kuo #define SP7021_TX_CNT_MASK GENMASK(11, 8) 44f62ca4e2SLi-hao Kuo #define SP7021_RX_CNT_MASK GENMASK(15, 12) 45f62ca4e2SLi-hao Kuo #define SP7021_TX_LEN_MASK GENMASK(23, 16) 46f62ca4e2SLi-hao Kuo #define SP7021_GET_LEN_MASK GENMASK(31, 24) 47f62ca4e2SLi-hao Kuo #define SP7021_SET_TX_LEN GENMASK(23, 16) 48f62ca4e2SLi-hao Kuo #define SP7021_SET_XFER_LEN GENMASK(31, 24) 49f62ca4e2SLi-hao Kuo 50f62ca4e2SLi-hao Kuo #define SP7021_CPOL_FD BIT(0) 51f62ca4e2SLi-hao Kuo #define SP7021_CPHA_R BIT(1) 52f62ca4e2SLi-hao Kuo #define SP7021_CPHA_W BIT(2) 53f62ca4e2SLi-hao Kuo #define SP7021_LSB_SEL BIT(4) 54f62ca4e2SLi-hao Kuo #define SP7021_CS_POR BIT(5) 55f62ca4e2SLi-hao Kuo #define SP7021_FD_SEL BIT(6) 56f62ca4e2SLi-hao Kuo 57f62ca4e2SLi-hao Kuo #define SP7021_RX_UNIT GENMASK(8, 7) 58f62ca4e2SLi-hao Kuo #define SP7021_TX_UNIT GENMASK(10, 9) 59f62ca4e2SLi-hao Kuo #define SP7021_TX_EMP_FLAG_MASK BIT(11) 60f62ca4e2SLi-hao Kuo #define SP7021_RX_FULL_FLAG_MASK BIT(14) 61f62ca4e2SLi-hao Kuo #define SP7021_FINISH_FLAG_MASK BIT(15) 62f62ca4e2SLi-hao Kuo #define SP7021_CLEAN_RW_BYTE GENMASK(10, 7) 63f62ca4e2SLi-hao Kuo #define SP7021_CLEAN_FLUG_MASK GENMASK(15, 11) 64f62ca4e2SLi-hao Kuo #define SP7021_CLK_MASK GENMASK(31, 16) 65f62ca4e2SLi-hao Kuo 66f62ca4e2SLi-hao Kuo #define SP7021_INT_BYPASS BIT(3) 67f62ca4e2SLi-hao Kuo #define SP7021_CLR_MASTER_INT BIT(6) 68f62ca4e2SLi-hao Kuo 69f62ca4e2SLi-hao Kuo #define SP7021_SPI_DATA_SIZE (255) 70f62ca4e2SLi-hao Kuo #define SP7021_FIFO_DATA_LEN (16) 71f62ca4e2SLi-hao Kuo 72f62ca4e2SLi-hao Kuo enum { 73f62ca4e2SLi-hao Kuo SP7021_MASTER_MODE = 0, 74f62ca4e2SLi-hao Kuo SP7021_SLAVE_MODE = 1, 75f62ca4e2SLi-hao Kuo }; 76f62ca4e2SLi-hao Kuo 77f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr { 78f62ca4e2SLi-hao Kuo struct device *dev; 79f62ca4e2SLi-hao Kuo struct spi_controller *ctlr; 80f62ca4e2SLi-hao Kuo void __iomem *m_base; 81f62ca4e2SLi-hao Kuo void __iomem *s_base; 82f62ca4e2SLi-hao Kuo u32 xfer_conf; 83f62ca4e2SLi-hao Kuo int mode; 84f62ca4e2SLi-hao Kuo int m_irq; 85f62ca4e2SLi-hao Kuo int s_irq; 86f62ca4e2SLi-hao Kuo struct clk *spi_clk; 87f62ca4e2SLi-hao Kuo struct reset_control *rstc; 88f62ca4e2SLi-hao Kuo // irq spin lock 89f62ca4e2SLi-hao Kuo spinlock_t lock; 90f62ca4e2SLi-hao Kuo // data xfer lock 91f62ca4e2SLi-hao Kuo struct mutex buf_lock; 92f62ca4e2SLi-hao Kuo struct completion isr_done; 93f62ca4e2SLi-hao Kuo struct completion slave_isr; 94f62ca4e2SLi-hao Kuo unsigned int rx_cur_len; 95f62ca4e2SLi-hao Kuo unsigned int tx_cur_len; 96f62ca4e2SLi-hao Kuo unsigned int data_unit; 97f62ca4e2SLi-hao Kuo const u8 *tx_buf; 98f62ca4e2SLi-hao Kuo u8 *rx_buf; 99f62ca4e2SLi-hao Kuo }; 100f62ca4e2SLi-hao Kuo 101f62ca4e2SLi-hao Kuo static irqreturn_t sp7021_spi_slave_irq(int irq, void *dev) 102f62ca4e2SLi-hao Kuo { 103f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = dev; 104f62ca4e2SLi-hao Kuo unsigned int data_status; 105f62ca4e2SLi-hao Kuo 106f62ca4e2SLi-hao Kuo data_status = readl(pspim->s_base + SP7021_DATA_RDY_REG); 10747e8fe57SLi-hao Kuo data_status |= SP7021_SLAVE_CLR_INT; 10847e8fe57SLi-hao Kuo writel(data_status , pspim->s_base + SP7021_DATA_RDY_REG); 109f62ca4e2SLi-hao Kuo complete(&pspim->slave_isr); 110f62ca4e2SLi-hao Kuo return IRQ_HANDLED; 111f62ca4e2SLi-hao Kuo } 112f62ca4e2SLi-hao Kuo 113f62ca4e2SLi-hao Kuo static int sp7021_spi_slave_abort(struct spi_controller *ctlr) 114f62ca4e2SLi-hao Kuo { 115f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 116f62ca4e2SLi-hao Kuo 117f62ca4e2SLi-hao Kuo complete(&pspim->slave_isr); 118f62ca4e2SLi-hao Kuo complete(&pspim->isr_done); 119f62ca4e2SLi-hao Kuo return 0; 120f62ca4e2SLi-hao Kuo } 121f62ca4e2SLi-hao Kuo 1226938e02fS郭力豪 static int sp7021_spi_slave_tx(struct spi_device *spi, struct spi_transfer *xfer) 123f62ca4e2SLi-hao Kuo { 124f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_controller_get_devdata(spi->controller); 12547e8fe57SLi-hao Kuo u32 value; 126f62ca4e2SLi-hao Kuo 127f62ca4e2SLi-hao Kuo reinit_completion(&pspim->slave_isr); 12847e8fe57SLi-hao Kuo value = SP7021_SLAVE_DMA_EN | SP7021_SLAVE_DMA_RW | FIELD_PREP(SP7021_SLAVE_DMA_CMD, 3); 12947e8fe57SLi-hao Kuo writel(value, pspim->s_base + SP7021_SLAVE_DMA_CTRL_REG); 130f62ca4e2SLi-hao Kuo writel(xfer->len, pspim->s_base + SP7021_SLAVE_DMA_LENGTH_REG); 131f62ca4e2SLi-hao Kuo writel(xfer->tx_dma, pspim->s_base + SP7021_SLAVE_DMA_ADDR_REG); 13247e8fe57SLi-hao Kuo value = readl(pspim->s_base + SP7021_DATA_RDY_REG); 13347e8fe57SLi-hao Kuo value |= SP7021_SLAVE_DATA_RDY; 13447e8fe57SLi-hao Kuo writel(value, pspim->s_base + SP7021_DATA_RDY_REG); 135f62ca4e2SLi-hao Kuo if (wait_for_completion_interruptible(&pspim->isr_done)) { 136f62ca4e2SLi-hao Kuo dev_err(&spi->dev, "%s() wait_for_completion err\n", __func__); 137f62ca4e2SLi-hao Kuo return -EINTR; 138f62ca4e2SLi-hao Kuo } 139f62ca4e2SLi-hao Kuo return 0; 140f62ca4e2SLi-hao Kuo } 141f62ca4e2SLi-hao Kuo 1426938e02fS郭力豪 static int sp7021_spi_slave_rx(struct spi_device *spi, struct spi_transfer *xfer) 143f62ca4e2SLi-hao Kuo { 144f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_controller_get_devdata(spi->controller); 14547e8fe57SLi-hao Kuo u32 value; 146f62ca4e2SLi-hao Kuo 147f62ca4e2SLi-hao Kuo reinit_completion(&pspim->isr_done); 14847e8fe57SLi-hao Kuo value = SP7021_SLAVE_DMA_EN | FIELD_PREP(SP7021_SLAVE_DMA_CMD, 3); 14947e8fe57SLi-hao Kuo writel(value, pspim->s_base + SP7021_SLAVE_DMA_CTRL_REG); 150f62ca4e2SLi-hao Kuo writel(xfer->len, pspim->s_base + SP7021_SLAVE_DMA_LENGTH_REG); 151f62ca4e2SLi-hao Kuo writel(xfer->rx_dma, pspim->s_base + SP7021_SLAVE_DMA_ADDR_REG); 152f62ca4e2SLi-hao Kuo if (wait_for_completion_interruptible(&pspim->isr_done)) { 153f62ca4e2SLi-hao Kuo dev_err(&spi->dev, "%s() wait_for_completion err\n", __func__); 154f62ca4e2SLi-hao Kuo return -EINTR; 155f62ca4e2SLi-hao Kuo } 156f62ca4e2SLi-hao Kuo writel(SP7021_SLAVE_SW_RST, pspim->s_base + SP7021_SLAVE_DMA_CTRL_REG); 15747e8fe57SLi-hao Kuo return 0; 158f62ca4e2SLi-hao Kuo } 159f62ca4e2SLi-hao Kuo 1606938e02fS郭力豪 static void sp7021_spi_master_rb(struct sp7021_spi_ctlr *pspim, unsigned int len) 161f62ca4e2SLi-hao Kuo { 162f62ca4e2SLi-hao Kuo int i; 163f62ca4e2SLi-hao Kuo 164f62ca4e2SLi-hao Kuo for (i = 0; i < len; i++) { 165f62ca4e2SLi-hao Kuo pspim->rx_buf[pspim->rx_cur_len] = 166f62ca4e2SLi-hao Kuo readl(pspim->m_base + SP7021_FIFO_REG); 167f62ca4e2SLi-hao Kuo pspim->rx_cur_len++; 168f62ca4e2SLi-hao Kuo } 169f62ca4e2SLi-hao Kuo } 170f62ca4e2SLi-hao Kuo 1716938e02fS郭力豪 static void sp7021_spi_master_wb(struct sp7021_spi_ctlr *pspim, unsigned int len) 172f62ca4e2SLi-hao Kuo { 173f62ca4e2SLi-hao Kuo int i; 174f62ca4e2SLi-hao Kuo 175f62ca4e2SLi-hao Kuo for (i = 0; i < len; i++) { 176f62ca4e2SLi-hao Kuo writel(pspim->tx_buf[pspim->tx_cur_len], 177f62ca4e2SLi-hao Kuo pspim->m_base + SP7021_FIFO_REG); 178f62ca4e2SLi-hao Kuo pspim->tx_cur_len++; 179f62ca4e2SLi-hao Kuo } 180f62ca4e2SLi-hao Kuo } 181f62ca4e2SLi-hao Kuo 182f62ca4e2SLi-hao Kuo static irqreturn_t sp7021_spi_master_irq(int irq, void *dev) 183f62ca4e2SLi-hao Kuo { 184f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = dev; 185f62ca4e2SLi-hao Kuo unsigned int tx_cnt, total_len; 186f62ca4e2SLi-hao Kuo unsigned int tx_len, rx_cnt; 187f62ca4e2SLi-hao Kuo unsigned int fd_status; 188f62ca4e2SLi-hao Kuo bool isrdone = false; 189f62ca4e2SLi-hao Kuo u32 value; 190f62ca4e2SLi-hao Kuo 191f62ca4e2SLi-hao Kuo fd_status = readl(pspim->m_base + SP7021_SPI_STATUS_REG); 192f62ca4e2SLi-hao Kuo tx_cnt = FIELD_GET(SP7021_TX_CNT_MASK, fd_status); 193f62ca4e2SLi-hao Kuo tx_len = FIELD_GET(SP7021_TX_LEN_MASK, fd_status); 194f62ca4e2SLi-hao Kuo total_len = FIELD_GET(SP7021_GET_LEN_MASK, fd_status); 195f62ca4e2SLi-hao Kuo 196f62ca4e2SLi-hao Kuo if ((fd_status & SP7021_TX_EMP_FLAG) && (fd_status & SP7021_RX_EMP_FLAG) && total_len == 0) 197f62ca4e2SLi-hao Kuo return IRQ_NONE; 198f62ca4e2SLi-hao Kuo 199f62ca4e2SLi-hao Kuo if (tx_len == 0 && total_len == 0) 200f62ca4e2SLi-hao Kuo return IRQ_NONE; 201f62ca4e2SLi-hao Kuo 20247e8fe57SLi-hao Kuo spin_lock_irq(&pspim->lock); 203f62ca4e2SLi-hao Kuo 204f62ca4e2SLi-hao Kuo rx_cnt = FIELD_GET(SP7021_RX_CNT_MASK, fd_status); 205f62ca4e2SLi-hao Kuo if (fd_status & SP7021_RX_FULL_FLAG) 206f62ca4e2SLi-hao Kuo rx_cnt = pspim->data_unit; 207f62ca4e2SLi-hao Kuo 208f62ca4e2SLi-hao Kuo tx_cnt = min(tx_len - pspim->tx_cur_len, pspim->data_unit - tx_cnt); 209f62ca4e2SLi-hao Kuo dev_dbg(pspim->dev, "fd_st=0x%x rx_c:%d tx_c:%d tx_l:%d", 210f62ca4e2SLi-hao Kuo fd_status, rx_cnt, tx_cnt, tx_len); 211f62ca4e2SLi-hao Kuo 212f62ca4e2SLi-hao Kuo if (rx_cnt > 0) 213f62ca4e2SLi-hao Kuo sp7021_spi_master_rb(pspim, rx_cnt); 214f62ca4e2SLi-hao Kuo if (tx_cnt > 0) 215f62ca4e2SLi-hao Kuo sp7021_spi_master_wb(pspim, tx_cnt); 216f62ca4e2SLi-hao Kuo 217f62ca4e2SLi-hao Kuo fd_status = readl(pspim->m_base + SP7021_SPI_STATUS_REG); 218f62ca4e2SLi-hao Kuo tx_len = FIELD_GET(SP7021_TX_LEN_MASK, fd_status); 219f62ca4e2SLi-hao Kuo total_len = FIELD_GET(SP7021_GET_LEN_MASK, fd_status); 220f62ca4e2SLi-hao Kuo 221f62ca4e2SLi-hao Kuo if (fd_status & SP7021_FINISH_FLAG || tx_len == pspim->tx_cur_len) { 222f62ca4e2SLi-hao Kuo while (total_len != pspim->rx_cur_len) { 223f62ca4e2SLi-hao Kuo fd_status = readl(pspim->m_base + SP7021_SPI_STATUS_REG); 224f62ca4e2SLi-hao Kuo total_len = FIELD_GET(SP7021_GET_LEN_MASK, fd_status); 225f62ca4e2SLi-hao Kuo if (fd_status & SP7021_RX_FULL_FLAG) 226f62ca4e2SLi-hao Kuo rx_cnt = pspim->data_unit; 227f62ca4e2SLi-hao Kuo else 228f62ca4e2SLi-hao Kuo rx_cnt = FIELD_GET(SP7021_RX_CNT_MASK, fd_status); 229f62ca4e2SLi-hao Kuo 230f62ca4e2SLi-hao Kuo if (rx_cnt > 0) 231f62ca4e2SLi-hao Kuo sp7021_spi_master_rb(pspim, rx_cnt); 232f62ca4e2SLi-hao Kuo } 233f62ca4e2SLi-hao Kuo value = readl(pspim->m_base + SP7021_INT_BUSY_REG); 234f62ca4e2SLi-hao Kuo value |= SP7021_CLR_MASTER_INT; 235f62ca4e2SLi-hao Kuo writel(value, pspim->m_base + SP7021_INT_BUSY_REG); 236f62ca4e2SLi-hao Kuo writel(SP7021_FINISH_FLAG, pspim->m_base + SP7021_SPI_STATUS_REG); 237f62ca4e2SLi-hao Kuo isrdone = true; 238f62ca4e2SLi-hao Kuo } 239f62ca4e2SLi-hao Kuo 240f62ca4e2SLi-hao Kuo if (isrdone) 241f62ca4e2SLi-hao Kuo complete(&pspim->isr_done); 24247e8fe57SLi-hao Kuo spin_unlock_irq(&pspim->lock); 243f62ca4e2SLi-hao Kuo return IRQ_HANDLED; 244f62ca4e2SLi-hao Kuo } 245f62ca4e2SLi-hao Kuo 246f62ca4e2SLi-hao Kuo static void sp7021_prep_transfer(struct spi_controller *ctlr, struct spi_device *spi) 247f62ca4e2SLi-hao Kuo { 248f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 249f62ca4e2SLi-hao Kuo 250f62ca4e2SLi-hao Kuo pspim->tx_cur_len = 0; 251f62ca4e2SLi-hao Kuo pspim->rx_cur_len = 0; 252f62ca4e2SLi-hao Kuo pspim->data_unit = SP7021_FIFO_DATA_LEN; 253f62ca4e2SLi-hao Kuo } 254f62ca4e2SLi-hao Kuo 255f62ca4e2SLi-hao Kuo // preliminary set CS, CPOL, CPHA and LSB 256f62ca4e2SLi-hao Kuo static int sp7021_spi_controller_prepare_message(struct spi_controller *ctlr, 257f62ca4e2SLi-hao Kuo struct spi_message *msg) 258f62ca4e2SLi-hao Kuo { 259f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 260f62ca4e2SLi-hao Kuo struct spi_device *s = msg->spi; 261f62ca4e2SLi-hao Kuo u32 valus, rs = 0; 262f62ca4e2SLi-hao Kuo 263f62ca4e2SLi-hao Kuo valus = readl(pspim->m_base + SP7021_SPI_STATUS_REG); 264f62ca4e2SLi-hao Kuo valus |= SP7021_FD_SW_RST; 265f62ca4e2SLi-hao Kuo writel(valus, pspim->m_base + SP7021_SPI_STATUS_REG); 266f62ca4e2SLi-hao Kuo rs |= SP7021_FD_SEL; 267f62ca4e2SLi-hao Kuo if (s->mode & SPI_CPOL) 268f62ca4e2SLi-hao Kuo rs |= SP7021_CPOL_FD; 269f62ca4e2SLi-hao Kuo 270f62ca4e2SLi-hao Kuo if (s->mode & SPI_LSB_FIRST) 271f62ca4e2SLi-hao Kuo rs |= SP7021_LSB_SEL; 272f62ca4e2SLi-hao Kuo 273f62ca4e2SLi-hao Kuo if (s->mode & SPI_CS_HIGH) 274f62ca4e2SLi-hao Kuo rs |= SP7021_CS_POR; 275f62ca4e2SLi-hao Kuo 276f62ca4e2SLi-hao Kuo if (s->mode & SPI_CPHA) 277f62ca4e2SLi-hao Kuo rs |= SP7021_CPHA_R; 278f62ca4e2SLi-hao Kuo else 279f62ca4e2SLi-hao Kuo rs |= SP7021_CPHA_W; 280f62ca4e2SLi-hao Kuo 281f62ca4e2SLi-hao Kuo rs |= FIELD_PREP(SP7021_TX_UNIT, 0) | FIELD_PREP(SP7021_RX_UNIT, 0); 282f62ca4e2SLi-hao Kuo pspim->xfer_conf = rs; 283f62ca4e2SLi-hao Kuo if (pspim->xfer_conf & SP7021_CPOL_FD) 284f62ca4e2SLi-hao Kuo writel(pspim->xfer_conf, pspim->m_base + SP7021_SPI_CONFIG_REG); 285f62ca4e2SLi-hao Kuo 286f62ca4e2SLi-hao Kuo return 0; 287f62ca4e2SLi-hao Kuo } 288f62ca4e2SLi-hao Kuo 289f62ca4e2SLi-hao Kuo static void sp7021_spi_setup_clk(struct spi_controller *ctlr, struct spi_transfer *xfer) 290f62ca4e2SLi-hao Kuo { 291f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 292f62ca4e2SLi-hao Kuo u32 clk_rate, clk_sel, div; 293f62ca4e2SLi-hao Kuo 294f62ca4e2SLi-hao Kuo clk_rate = clk_get_rate(pspim->spi_clk); 29547e8fe57SLi-hao Kuo div = max(2U, clk_rate / xfer->speed_hz); 29647e8fe57SLi-hao Kuo 297f62ca4e2SLi-hao Kuo clk_sel = (div / 2) - 1; 29847e8fe57SLi-hao Kuo pspim->xfer_conf &= ~SP7021_CLK_MASK; 299f62ca4e2SLi-hao Kuo pspim->xfer_conf |= FIELD_PREP(SP7021_CLK_MASK, clk_sel); 300f62ca4e2SLi-hao Kuo writel(pspim->xfer_conf, pspim->m_base + SP7021_SPI_CONFIG_REG); 301f62ca4e2SLi-hao Kuo } 302f62ca4e2SLi-hao Kuo 303f62ca4e2SLi-hao Kuo static int sp7021_spi_master_transfer_one(struct spi_controller *ctlr, struct spi_device *spi, 304f62ca4e2SLi-hao Kuo struct spi_transfer *xfer) 305f62ca4e2SLi-hao Kuo { 306f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 307f62ca4e2SLi-hao Kuo unsigned long timeout = msecs_to_jiffies(1000); 308f62ca4e2SLi-hao Kuo unsigned int xfer_cnt, xfer_len, last_len; 309f62ca4e2SLi-hao Kuo unsigned int i, len_temp; 310f62ca4e2SLi-hao Kuo u32 reg_temp; 311f62ca4e2SLi-hao Kuo 312f62ca4e2SLi-hao Kuo xfer_cnt = xfer->len / SP7021_SPI_DATA_SIZE; 313f62ca4e2SLi-hao Kuo last_len = xfer->len % SP7021_SPI_DATA_SIZE; 314f62ca4e2SLi-hao Kuo 315f62ca4e2SLi-hao Kuo for (i = 0; i <= xfer_cnt; i++) { 316f62ca4e2SLi-hao Kuo mutex_lock(&pspim->buf_lock); 317f62ca4e2SLi-hao Kuo sp7021_prep_transfer(ctlr, spi); 318f62ca4e2SLi-hao Kuo sp7021_spi_setup_clk(ctlr, xfer); 319f62ca4e2SLi-hao Kuo reinit_completion(&pspim->isr_done); 320f62ca4e2SLi-hao Kuo 321f62ca4e2SLi-hao Kuo if (i == xfer_cnt) 322f62ca4e2SLi-hao Kuo xfer_len = last_len; 323f62ca4e2SLi-hao Kuo else 324f62ca4e2SLi-hao Kuo xfer_len = SP7021_SPI_DATA_SIZE; 325f62ca4e2SLi-hao Kuo 326f62ca4e2SLi-hao Kuo pspim->tx_buf = xfer->tx_buf + i * SP7021_SPI_DATA_SIZE; 327f62ca4e2SLi-hao Kuo pspim->rx_buf = xfer->rx_buf + i * SP7021_SPI_DATA_SIZE; 328f62ca4e2SLi-hao Kuo 329f62ca4e2SLi-hao Kuo if (pspim->tx_cur_len < xfer_len) { 330f62ca4e2SLi-hao Kuo len_temp = min(pspim->data_unit, xfer_len); 331f62ca4e2SLi-hao Kuo sp7021_spi_master_wb(pspim, len_temp); 332f62ca4e2SLi-hao Kuo } 333f62ca4e2SLi-hao Kuo reg_temp = readl(pspim->m_base + SP7021_SPI_CONFIG_REG); 334f62ca4e2SLi-hao Kuo reg_temp &= ~SP7021_CLEAN_RW_BYTE; 335f62ca4e2SLi-hao Kuo reg_temp &= ~SP7021_CLEAN_FLUG_MASK; 336f62ca4e2SLi-hao Kuo reg_temp |= SP7021_FD_SEL | SP7021_FINISH_FLAG_MASK | 337f62ca4e2SLi-hao Kuo SP7021_TX_EMP_FLAG_MASK | SP7021_RX_FULL_FLAG_MASK | 338f62ca4e2SLi-hao Kuo FIELD_PREP(SP7021_TX_UNIT, 0) | FIELD_PREP(SP7021_RX_UNIT, 0); 339f62ca4e2SLi-hao Kuo writel(reg_temp, pspim->m_base + SP7021_SPI_CONFIG_REG); 340f62ca4e2SLi-hao Kuo 341f62ca4e2SLi-hao Kuo reg_temp = FIELD_PREP(SP7021_SET_TX_LEN, xfer_len) | 342f62ca4e2SLi-hao Kuo FIELD_PREP(SP7021_SET_XFER_LEN, xfer_len) | 343f62ca4e2SLi-hao Kuo SP7021_SPI_START_FD; 344f62ca4e2SLi-hao Kuo writel(reg_temp, pspim->m_base + SP7021_SPI_STATUS_REG); 345f62ca4e2SLi-hao Kuo 346f62ca4e2SLi-hao Kuo if (!wait_for_completion_interruptible_timeout(&pspim->isr_done, timeout)) { 347f62ca4e2SLi-hao Kuo dev_err(&spi->dev, "wait_for_completion err\n"); 34820dc69caSYang Yingliang mutex_unlock(&pspim->buf_lock); 349f62ca4e2SLi-hao Kuo return -ETIMEDOUT; 350f62ca4e2SLi-hao Kuo } 351f62ca4e2SLi-hao Kuo 352f62ca4e2SLi-hao Kuo reg_temp = readl(pspim->m_base + SP7021_SPI_STATUS_REG); 353f62ca4e2SLi-hao Kuo if (reg_temp & SP7021_FINISH_FLAG) { 354f62ca4e2SLi-hao Kuo writel(SP7021_FINISH_FLAG, pspim->m_base + SP7021_SPI_STATUS_REG); 355f62ca4e2SLi-hao Kuo writel(readl(pspim->m_base + SP7021_SPI_CONFIG_REG) & 356f62ca4e2SLi-hao Kuo SP7021_CLEAN_FLUG_MASK, pspim->m_base + SP7021_SPI_CONFIG_REG); 357f62ca4e2SLi-hao Kuo } 358f62ca4e2SLi-hao Kuo 359f62ca4e2SLi-hao Kuo if (pspim->xfer_conf & SP7021_CPOL_FD) 360f62ca4e2SLi-hao Kuo writel(pspim->xfer_conf, pspim->m_base + SP7021_SPI_CONFIG_REG); 361f62ca4e2SLi-hao Kuo 362f62ca4e2SLi-hao Kuo mutex_unlock(&pspim->buf_lock); 363f62ca4e2SLi-hao Kuo } 36447e8fe57SLi-hao Kuo return 0; 365f62ca4e2SLi-hao Kuo } 366f62ca4e2SLi-hao Kuo 367f62ca4e2SLi-hao Kuo static int sp7021_spi_slave_transfer_one(struct spi_controller *ctlr, struct spi_device *spi, 368f62ca4e2SLi-hao Kuo struct spi_transfer *xfer) 369f62ca4e2SLi-hao Kuo { 370f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 371f62ca4e2SLi-hao Kuo struct device *dev = pspim->dev; 372*5790597dSLi-hao Kuo int ret; 373f62ca4e2SLi-hao Kuo 374*5790597dSLi-hao Kuo if (xfer->tx_buf && !xfer->rx_buf) { 375f62ca4e2SLi-hao Kuo xfer->tx_dma = dma_map_single(dev, (void *)xfer->tx_buf, 376f62ca4e2SLi-hao Kuo xfer->len, DMA_TO_DEVICE); 377f62ca4e2SLi-hao Kuo if (dma_mapping_error(dev, xfer->tx_dma)) 378f62ca4e2SLi-hao Kuo return -ENOMEM; 379*5790597dSLi-hao Kuo ret = sp7021_spi_slave_tx(spi, xfer); 380*5790597dSLi-hao Kuo dma_unmap_single(dev, xfer->tx_dma, xfer->len, DMA_TO_DEVICE); 381*5790597dSLi-hao Kuo } else if (xfer->rx_buf && !xfer->tx_buf) { 382f62ca4e2SLi-hao Kuo xfer->rx_dma = dma_map_single(dev, xfer->rx_buf, xfer->len, 383f62ca4e2SLi-hao Kuo DMA_FROM_DEVICE); 384f62ca4e2SLi-hao Kuo if (dma_mapping_error(dev, xfer->rx_dma)) 385f62ca4e2SLi-hao Kuo return -ENOMEM; 386f62ca4e2SLi-hao Kuo ret = sp7021_spi_slave_rx(spi, xfer); 387f62ca4e2SLi-hao Kuo dma_unmap_single(dev, xfer->rx_dma, xfer->len, DMA_FROM_DEVICE); 388*5790597dSLi-hao Kuo } else { 389*5790597dSLi-hao Kuo dev_dbg(&ctlr->dev, "%s() wrong command\n", __func__); 390*5790597dSLi-hao Kuo return -EINVAL; 391*5790597dSLi-hao Kuo } 392f62ca4e2SLi-hao Kuo 393f62ca4e2SLi-hao Kuo spi_finalize_current_transfer(ctlr); 394f62ca4e2SLi-hao Kuo return ret; 395f62ca4e2SLi-hao Kuo } 396f62ca4e2SLi-hao Kuo 397f62ca4e2SLi-hao Kuo static void sp7021_spi_disable_unprepare(void *data) 398f62ca4e2SLi-hao Kuo { 399f62ca4e2SLi-hao Kuo clk_disable_unprepare(data); 400f62ca4e2SLi-hao Kuo } 401f62ca4e2SLi-hao Kuo 402f62ca4e2SLi-hao Kuo static void sp7021_spi_reset_control_assert(void *data) 403f62ca4e2SLi-hao Kuo { 404f62ca4e2SLi-hao Kuo reset_control_assert(data); 405f62ca4e2SLi-hao Kuo } 406f62ca4e2SLi-hao Kuo 407f62ca4e2SLi-hao Kuo static int sp7021_spi_controller_probe(struct platform_device *pdev) 408f62ca4e2SLi-hao Kuo { 409f62ca4e2SLi-hao Kuo struct device *dev = &pdev->dev; 410f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim; 411f62ca4e2SLi-hao Kuo struct spi_controller *ctlr; 412f62ca4e2SLi-hao Kuo int mode, ret; 413f62ca4e2SLi-hao Kuo 414f62ca4e2SLi-hao Kuo pdev->id = of_alias_get_id(pdev->dev.of_node, "sp_spi"); 415f62ca4e2SLi-hao Kuo 416f62ca4e2SLi-hao Kuo if (device_property_read_bool(dev, "spi-slave")) 417f62ca4e2SLi-hao Kuo mode = SP7021_SLAVE_MODE; 418f62ca4e2SLi-hao Kuo else 419f62ca4e2SLi-hao Kuo mode = SP7021_MASTER_MODE; 420f62ca4e2SLi-hao Kuo 421f62ca4e2SLi-hao Kuo if (mode == SP7021_SLAVE_MODE) 422f62ca4e2SLi-hao Kuo ctlr = devm_spi_alloc_slave(dev, sizeof(*pspim)); 423f62ca4e2SLi-hao Kuo else 424f62ca4e2SLi-hao Kuo ctlr = devm_spi_alloc_master(dev, sizeof(*pspim)); 425f62ca4e2SLi-hao Kuo if (!ctlr) 426f62ca4e2SLi-hao Kuo return -ENOMEM; 42747e8fe57SLi-hao Kuo device_set_node(&ctlr->dev, dev_fwnode(dev)); 428f62ca4e2SLi-hao Kuo ctlr->bus_num = pdev->id; 429f62ca4e2SLi-hao Kuo ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; 430f62ca4e2SLi-hao Kuo ctlr->auto_runtime_pm = true; 431f62ca4e2SLi-hao Kuo ctlr->prepare_message = sp7021_spi_controller_prepare_message; 432f62ca4e2SLi-hao Kuo if (mode == SP7021_SLAVE_MODE) { 433f62ca4e2SLi-hao Kuo ctlr->transfer_one = sp7021_spi_slave_transfer_one; 434f62ca4e2SLi-hao Kuo ctlr->slave_abort = sp7021_spi_slave_abort; 435f62ca4e2SLi-hao Kuo ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX; 436f62ca4e2SLi-hao Kuo } else { 437f62ca4e2SLi-hao Kuo ctlr->bits_per_word_mask = SPI_BPW_MASK(8); 438f62ca4e2SLi-hao Kuo ctlr->min_speed_hz = 40000; 439f62ca4e2SLi-hao Kuo ctlr->max_speed_hz = 25000000; 440f62ca4e2SLi-hao Kuo ctlr->use_gpio_descriptors = true; 441f62ca4e2SLi-hao Kuo ctlr->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX; 442f62ca4e2SLi-hao Kuo ctlr->transfer_one = sp7021_spi_master_transfer_one; 443f62ca4e2SLi-hao Kuo } 444f62ca4e2SLi-hao Kuo platform_set_drvdata(pdev, ctlr); 445f62ca4e2SLi-hao Kuo pspim = spi_controller_get_devdata(ctlr); 446f62ca4e2SLi-hao Kuo pspim->mode = mode; 447f62ca4e2SLi-hao Kuo pspim->ctlr = ctlr; 448f62ca4e2SLi-hao Kuo pspim->dev = dev; 449f62ca4e2SLi-hao Kuo spin_lock_init(&pspim->lock); 450f62ca4e2SLi-hao Kuo mutex_init(&pspim->buf_lock); 451f62ca4e2SLi-hao Kuo init_completion(&pspim->isr_done); 452f62ca4e2SLi-hao Kuo init_completion(&pspim->slave_isr); 453f62ca4e2SLi-hao Kuo 454f62ca4e2SLi-hao Kuo pspim->m_base = devm_platform_ioremap_resource_byname(pdev, "master"); 455f62ca4e2SLi-hao Kuo if (IS_ERR(pspim->m_base)) 456f62ca4e2SLi-hao Kuo return dev_err_probe(dev, PTR_ERR(pspim->m_base), "m_base get fail\n"); 457f62ca4e2SLi-hao Kuo 458f62ca4e2SLi-hao Kuo pspim->s_base = devm_platform_ioremap_resource_byname(pdev, "slave"); 459f62ca4e2SLi-hao Kuo if (IS_ERR(pspim->s_base)) 460f62ca4e2SLi-hao Kuo return dev_err_probe(dev, PTR_ERR(pspim->s_base), "s_base get fail\n"); 461f62ca4e2SLi-hao Kuo 462f62ca4e2SLi-hao Kuo pspim->m_irq = platform_get_irq_byname(pdev, "master_risc"); 463f62ca4e2SLi-hao Kuo if (pspim->m_irq < 0) 464f62ca4e2SLi-hao Kuo return pspim->m_irq; 465f62ca4e2SLi-hao Kuo 466f62ca4e2SLi-hao Kuo pspim->s_irq = platform_get_irq_byname(pdev, "slave_risc"); 467f62ca4e2SLi-hao Kuo if (pspim->s_irq < 0) 468f62ca4e2SLi-hao Kuo return pspim->s_irq; 469f62ca4e2SLi-hao Kuo 470f62ca4e2SLi-hao Kuo pspim->spi_clk = devm_clk_get(dev, NULL); 471f62ca4e2SLi-hao Kuo if (IS_ERR(pspim->spi_clk)) 472f62ca4e2SLi-hao Kuo return dev_err_probe(dev, PTR_ERR(pspim->spi_clk), "clk get fail\n"); 473f62ca4e2SLi-hao Kuo 474f62ca4e2SLi-hao Kuo pspim->rstc = devm_reset_control_get_exclusive(dev, NULL); 475f62ca4e2SLi-hao Kuo if (IS_ERR(pspim->rstc)) 476f62ca4e2SLi-hao Kuo return dev_err_probe(dev, PTR_ERR(pspim->rstc), "rst get fail\n"); 477f62ca4e2SLi-hao Kuo 478f62ca4e2SLi-hao Kuo ret = clk_prepare_enable(pspim->spi_clk); 479f62ca4e2SLi-hao Kuo if (ret) 480f62ca4e2SLi-hao Kuo return dev_err_probe(dev, ret, "failed to enable clk\n"); 481f62ca4e2SLi-hao Kuo 482f62ca4e2SLi-hao Kuo ret = devm_add_action_or_reset(dev, sp7021_spi_disable_unprepare, pspim->spi_clk); 483f62ca4e2SLi-hao Kuo if (ret) 484f62ca4e2SLi-hao Kuo return ret; 485f62ca4e2SLi-hao Kuo 486f62ca4e2SLi-hao Kuo ret = reset_control_deassert(pspim->rstc); 487f62ca4e2SLi-hao Kuo if (ret) 488f62ca4e2SLi-hao Kuo return dev_err_probe(dev, ret, "failed to deassert reset\n"); 489f62ca4e2SLi-hao Kuo 490f62ca4e2SLi-hao Kuo ret = devm_add_action_or_reset(dev, sp7021_spi_reset_control_assert, pspim->rstc); 491f62ca4e2SLi-hao Kuo if (ret) 492f62ca4e2SLi-hao Kuo return ret; 493f62ca4e2SLi-hao Kuo 49447e8fe57SLi-hao Kuo ret = devm_request_irq(dev, pspim->m_irq, sp7021_spi_master_irq, 49547e8fe57SLi-hao Kuo IRQF_TRIGGER_RISING, pdev->name, pspim); 49647e8fe57SLi-hao Kuo if (ret) 49747e8fe57SLi-hao Kuo return ret; 49847e8fe57SLi-hao Kuo 49947e8fe57SLi-hao Kuo ret = devm_request_irq(dev, pspim->s_irq, sp7021_spi_slave_irq, 50047e8fe57SLi-hao Kuo IRQF_TRIGGER_RISING, pdev->name, pspim); 50147e8fe57SLi-hao Kuo if (ret) 50247e8fe57SLi-hao Kuo return ret; 50347e8fe57SLi-hao Kuo 504f62ca4e2SLi-hao Kuo pm_runtime_enable(dev); 505f62ca4e2SLi-hao Kuo ret = spi_register_controller(ctlr); 506f62ca4e2SLi-hao Kuo if (ret) { 507f62ca4e2SLi-hao Kuo pm_runtime_disable(dev); 508f62ca4e2SLi-hao Kuo return dev_err_probe(dev, ret, "spi_register_master fail\n"); 509f62ca4e2SLi-hao Kuo } 510f62ca4e2SLi-hao Kuo return 0; 511f62ca4e2SLi-hao Kuo } 512f62ca4e2SLi-hao Kuo 513f62ca4e2SLi-hao Kuo static int sp7021_spi_controller_remove(struct platform_device *pdev) 514f62ca4e2SLi-hao Kuo { 515f62ca4e2SLi-hao Kuo struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev); 516f62ca4e2SLi-hao Kuo 517f62ca4e2SLi-hao Kuo spi_unregister_controller(ctlr); 518f62ca4e2SLi-hao Kuo pm_runtime_disable(&pdev->dev); 519f62ca4e2SLi-hao Kuo pm_runtime_set_suspended(&pdev->dev); 520f62ca4e2SLi-hao Kuo return 0; 521f62ca4e2SLi-hao Kuo } 522f62ca4e2SLi-hao Kuo 523f62ca4e2SLi-hao Kuo static int __maybe_unused sp7021_spi_controller_suspend(struct device *dev) 524f62ca4e2SLi-hao Kuo { 525f62ca4e2SLi-hao Kuo struct spi_controller *ctlr = dev_get_drvdata(dev); 526f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 527f62ca4e2SLi-hao Kuo 528f62ca4e2SLi-hao Kuo return reset_control_assert(pspim->rstc); 529f62ca4e2SLi-hao Kuo } 530f62ca4e2SLi-hao Kuo 531f62ca4e2SLi-hao Kuo static int __maybe_unused sp7021_spi_controller_resume(struct device *dev) 532f62ca4e2SLi-hao Kuo { 533f62ca4e2SLi-hao Kuo struct spi_controller *ctlr = dev_get_drvdata(dev); 534f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 535f62ca4e2SLi-hao Kuo 536f62ca4e2SLi-hao Kuo reset_control_deassert(pspim->rstc); 537f62ca4e2SLi-hao Kuo return clk_prepare_enable(pspim->spi_clk); 538f62ca4e2SLi-hao Kuo } 539f62ca4e2SLi-hao Kuo 5406938e02fS郭力豪 #ifdef CONFIG_PM 541f62ca4e2SLi-hao Kuo static int sp7021_spi_runtime_suspend(struct device *dev) 542f62ca4e2SLi-hao Kuo { 543f62ca4e2SLi-hao Kuo struct spi_controller *ctlr = dev_get_drvdata(dev); 544f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 545f62ca4e2SLi-hao Kuo 546f62ca4e2SLi-hao Kuo return reset_control_assert(pspim->rstc); 547f62ca4e2SLi-hao Kuo } 548f62ca4e2SLi-hao Kuo 549f62ca4e2SLi-hao Kuo static int sp7021_spi_runtime_resume(struct device *dev) 550f62ca4e2SLi-hao Kuo { 551f62ca4e2SLi-hao Kuo struct spi_controller *ctlr = dev_get_drvdata(dev); 552f62ca4e2SLi-hao Kuo struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); 553f62ca4e2SLi-hao Kuo 554f62ca4e2SLi-hao Kuo return reset_control_deassert(pspim->rstc); 555f62ca4e2SLi-hao Kuo } 5566938e02fS郭力豪 #endif 557f62ca4e2SLi-hao Kuo 558f62ca4e2SLi-hao Kuo static const struct dev_pm_ops sp7021_spi_pm_ops = { 559f62ca4e2SLi-hao Kuo SET_RUNTIME_PM_OPS(sp7021_spi_runtime_suspend, 560f62ca4e2SLi-hao Kuo sp7021_spi_runtime_resume, NULL) 561f62ca4e2SLi-hao Kuo SET_SYSTEM_SLEEP_PM_OPS(sp7021_spi_controller_suspend, 562f62ca4e2SLi-hao Kuo sp7021_spi_controller_resume) 563f62ca4e2SLi-hao Kuo }; 564f62ca4e2SLi-hao Kuo 565f62ca4e2SLi-hao Kuo static const struct of_device_id sp7021_spi_controller_ids[] = { 566f62ca4e2SLi-hao Kuo { .compatible = "sunplus,sp7021-spi" }, 567f62ca4e2SLi-hao Kuo {} 568f62ca4e2SLi-hao Kuo }; 569f62ca4e2SLi-hao Kuo MODULE_DEVICE_TABLE(of, sp7021_spi_controller_ids); 570f62ca4e2SLi-hao Kuo 571f62ca4e2SLi-hao Kuo static struct platform_driver sp7021_spi_controller_driver = { 572f62ca4e2SLi-hao Kuo .probe = sp7021_spi_controller_probe, 573f62ca4e2SLi-hao Kuo .remove = sp7021_spi_controller_remove, 574f62ca4e2SLi-hao Kuo .driver = { 575f62ca4e2SLi-hao Kuo .name = "sunplus,sp7021-spi-controller", 576f62ca4e2SLi-hao Kuo .of_match_table = sp7021_spi_controller_ids, 577f62ca4e2SLi-hao Kuo .pm = &sp7021_spi_pm_ops, 578f62ca4e2SLi-hao Kuo }, 579f62ca4e2SLi-hao Kuo }; 580f62ca4e2SLi-hao Kuo module_platform_driver(sp7021_spi_controller_driver); 581f62ca4e2SLi-hao Kuo 582f62ca4e2SLi-hao Kuo MODULE_AUTHOR("Li-hao Kuo <lhjeff911@gmail.com>"); 583f62ca4e2SLi-hao Kuo MODULE_DESCRIPTION("Sunplus SPI controller driver"); 584f62ca4e2SLi-hao Kuo MODULE_LICENSE("GPL"); 585