Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * include/linux/spi/mxs-spi.h
0004  *
0005  * Freescale i.MX233/i.MX28 SPI controller register definition
0006  *
0007  * Copyright 2008 Embedded Alley Solutions, Inc.
0008  * Copyright 2009-2011 Freescale Semiconductor, Inc.
0009  */
0010 
0011 #ifndef __LINUX_SPI_MXS_SPI_H__
0012 #define __LINUX_SPI_MXS_SPI_H__
0013 
0014 #include <linux/dmaengine.h>
0015 
0016 #define ssp_is_old(host)    ((host)->devid == IMX23_SSP)
0017 
0018 /* SSP registers */
0019 #define HW_SSP_CTRL0                0x000
0020 #define  BM_SSP_CTRL0_RUN           (1 << 29)
0021 #define  BM_SSP_CTRL0_SDIO_IRQ_CHECK        (1 << 28)
0022 #define  BM_SSP_CTRL0_LOCK_CS           (1 << 27)
0023 #define  BM_SSP_CTRL0_IGNORE_CRC        (1 << 26)
0024 #define  BM_SSP_CTRL0_READ          (1 << 25)
0025 #define  BM_SSP_CTRL0_DATA_XFER         (1 << 24)
0026 #define  BP_SSP_CTRL0_BUS_WIDTH         22
0027 #define  BM_SSP_CTRL0_BUS_WIDTH         (0x3 << 22)
0028 #define  BM_SSP_CTRL0_WAIT_FOR_IRQ      (1 << 21)
0029 #define  BM_SSP_CTRL0_WAIT_FOR_CMD      (1 << 20)
0030 #define  BM_SSP_CTRL0_LONG_RESP         (1 << 19)
0031 #define  BM_SSP_CTRL0_GET_RESP          (1 << 17)
0032 #define  BM_SSP_CTRL0_ENABLE            (1 << 16)
0033 #define  BP_SSP_CTRL0_XFER_COUNT        0
0034 #define  BM_SSP_CTRL0_XFER_COUNT        0xffff
0035 #define HW_SSP_CMD0             0x010
0036 #define  BM_SSP_CMD0_DBL_DATA_RATE_EN       (1 << 25)
0037 #define  BM_SSP_CMD0_SLOW_CLKING_EN     (1 << 22)
0038 #define  BM_SSP_CMD0_CONT_CLKING_EN     (1 << 21)
0039 #define  BM_SSP_CMD0_APPEND_8CYC        (1 << 20)
0040 #define  BP_SSP_CMD0_BLOCK_SIZE         16
0041 #define  BM_SSP_CMD0_BLOCK_SIZE         (0xf << 16)
0042 #define  BP_SSP_CMD0_BLOCK_COUNT        8
0043 #define  BM_SSP_CMD0_BLOCK_COUNT        (0xff << 8)
0044 #define  BP_SSP_CMD0_CMD            0
0045 #define  BM_SSP_CMD0_CMD            0xff
0046 #define HW_SSP_CMD1             0x020
0047 #define HW_SSP_XFER_SIZE            0x030
0048 #define HW_SSP_BLOCK_SIZE           0x040
0049 #define  BP_SSP_BLOCK_SIZE_BLOCK_COUNT      4
0050 #define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT      (0xffffff << 4)
0051 #define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE       0
0052 #define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE       0xf
0053 #define HW_SSP_TIMING(h)            (ssp_is_old(h) ? 0x050 : 0x070)
0054 #define  BP_SSP_TIMING_TIMEOUT          16
0055 #define  BM_SSP_TIMING_TIMEOUT          (0xffff << 16)
0056 #define  BP_SSP_TIMING_CLOCK_DIVIDE     8
0057 #define  BM_SSP_TIMING_CLOCK_DIVIDE     (0xff << 8)
0058 #define  BF_SSP_TIMING_CLOCK_DIVIDE(v)      \
0059             (((v) << 8) & BM_SSP_TIMING_CLOCK_DIVIDE)
0060 #define  BP_SSP_TIMING_CLOCK_RATE       0
0061 #define  BM_SSP_TIMING_CLOCK_RATE       0xff
0062 #define BF_SSP_TIMING_CLOCK_RATE(v)     \
0063             (((v) << 0) & BM_SSP_TIMING_CLOCK_RATE)
0064 #define HW_SSP_CTRL1(h)             (ssp_is_old(h) ? 0x060 : 0x080)
0065 #define  BM_SSP_CTRL1_SDIO_IRQ          (1 << 31)
0066 #define  BM_SSP_CTRL1_SDIO_IRQ_EN       (1 << 30)
0067 #define  BM_SSP_CTRL1_RESP_ERR_IRQ      (1 << 29)
0068 #define  BM_SSP_CTRL1_RESP_ERR_IRQ_EN       (1 << 28)
0069 #define  BM_SSP_CTRL1_RESP_TIMEOUT_IRQ      (1 << 27)
0070 #define  BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN   (1 << 26)
0071 #define  BM_SSP_CTRL1_DATA_TIMEOUT_IRQ      (1 << 25)
0072 #define  BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN   (1 << 24)
0073 #define  BM_SSP_CTRL1_DATA_CRC_IRQ      (1 << 23)
0074 #define  BM_SSP_CTRL1_DATA_CRC_IRQ_EN       (1 << 22)
0075 #define  BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ     (1 << 21)
0076 #define  BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN  (1 << 20)
0077 #define  BM_SSP_CTRL1_RECV_TIMEOUT_IRQ      (1 << 17)
0078 #define  BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN   (1 << 16)
0079 #define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ      (1 << 15)
0080 #define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN   (1 << 14)
0081 #define  BM_SSP_CTRL1_DMA_ENABLE        (1 << 13)
0082 #define  BM_SSP_CTRL1_PHASE         (1 << 10)
0083 #define  BM_SSP_CTRL1_POLARITY          (1 << 9)
0084 #define  BP_SSP_CTRL1_WORD_LENGTH       4
0085 #define  BM_SSP_CTRL1_WORD_LENGTH       (0xf << 4)
0086 #define  BF_SSP_CTRL1_WORD_LENGTH(v)        \
0087             (((v) << 4) & BM_SSP_CTRL1_WORD_LENGTH)
0088 #define  BV_SSP_CTRL1_WORD_LENGTH__FOUR_BITS    0x3
0089 #define  BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS   0x7
0090 #define  BV_SSP_CTRL1_WORD_LENGTH__SIXTEEN_BITS 0xF
0091 #define  BP_SSP_CTRL1_SSP_MODE          0
0092 #define  BM_SSP_CTRL1_SSP_MODE          0xf
0093 #define  BF_SSP_CTRL1_SSP_MODE(v)       \
0094             (((v) << 0) & BM_SSP_CTRL1_SSP_MODE)
0095 #define  BV_SSP_CTRL1_SSP_MODE__SPI     0x0
0096 #define  BV_SSP_CTRL1_SSP_MODE__SSI     0x1
0097 #define  BV_SSP_CTRL1_SSP_MODE__SD_MMC      0x3
0098 #define  BV_SSP_CTRL1_SSP_MODE__MS      0x4
0099 
0100 #define HW_SSP_DATA(h)              (ssp_is_old(h) ? 0x070 : 0x090)
0101 
0102 #define HW_SSP_SDRESP0(h)           (ssp_is_old(h) ? 0x080 : 0x0a0)
0103 #define HW_SSP_SDRESP1(h)           (ssp_is_old(h) ? 0x090 : 0x0b0)
0104 #define HW_SSP_SDRESP2(h)           (ssp_is_old(h) ? 0x0a0 : 0x0c0)
0105 #define HW_SSP_SDRESP3(h)           (ssp_is_old(h) ? 0x0b0 : 0x0d0)
0106 #define HW_SSP_STATUS(h)            (ssp_is_old(h) ? 0x0c0 : 0x100)
0107 #define  BM_SSP_STATUS_CARD_DETECT      (1 << 28)
0108 #define  BM_SSP_STATUS_SDIO_IRQ         (1 << 17)
0109 #define  BM_SSP_STATUS_FIFO_EMPTY       (1 << 5)
0110 
0111 #define BF_SSP(value, field)    (((value) << BP_SSP_##field) & BM_SSP_##field)
0112 
0113 #define SSP_PIO_NUM 3
0114 
0115 enum mxs_ssp_id {
0116     IMX23_SSP,
0117     IMX28_SSP,
0118 };
0119 
0120 struct mxs_ssp {
0121     struct device           *dev;
0122     void __iomem            *base;
0123     struct clk          *clk;
0124     unsigned int            clk_rate;
0125     enum mxs_ssp_id         devid;
0126 
0127     struct dma_chan         *dmach;
0128     unsigned int            dma_dir;
0129     enum dma_transfer_direction slave_dirn;
0130     u32             ssp_pio_words[SSP_PIO_NUM];
0131 };
0132 
0133 void mxs_ssp_set_clk_rate(struct mxs_ssp *ssp, unsigned int rate);
0134 
0135 #endif  /* __LINUX_SPI_MXS_SPI_H__ */