1 /* SPDX-License-Identifier: GPL-2.0-or-later * << 2 /* 1 /* 3 * include/linux/spi/mxs-spi.h 2 * include/linux/spi/mxs-spi.h 4 * 3 * 5 * Freescale i.MX233/i.MX28 SPI controller reg 4 * Freescale i.MX233/i.MX28 SPI controller register definition 6 * 5 * 7 * Copyright 2008 Embedded Alley Solutions, In 6 * Copyright 2008 Embedded Alley Solutions, Inc. 8 * Copyright 2009-2011 Freescale Semiconductor 7 * Copyright 2009-2011 Freescale Semiconductor, Inc. >> 8 * >> 9 * This program is free software; you can redistribute it and/or modify >> 10 * it under the terms of the GNU General Public License as published by >> 11 * the Free Software Foundation; either version 2 of the License, or >> 12 * (at your option) any later version. >> 13 * >> 14 * This program is distributed in the hope that it will be useful, >> 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 17 * GNU General Public License for more details. 9 */ 18 */ 10 19 11 #ifndef __LINUX_SPI_MXS_SPI_H__ 20 #ifndef __LINUX_SPI_MXS_SPI_H__ 12 #define __LINUX_SPI_MXS_SPI_H__ 21 #define __LINUX_SPI_MXS_SPI_H__ 13 22 14 #include <linux/dmaengine.h> 23 #include <linux/dmaengine.h> 15 24 16 #define ssp_is_old(host) ((host)->devid 25 #define ssp_is_old(host) ((host)->devid == IMX23_SSP) 17 26 18 /* SSP registers */ 27 /* SSP registers */ 19 #define HW_SSP_CTRL0 28 #define HW_SSP_CTRL0 0x000 20 #define BM_SSP_CTRL0_RUN 29 #define BM_SSP_CTRL0_RUN (1 << 29) 21 #define BM_SSP_CTRL0_SDIO_IRQ_CHECK 30 #define BM_SSP_CTRL0_SDIO_IRQ_CHECK (1 << 28) 22 #define BM_SSP_CTRL0_LOCK_CS 31 #define BM_SSP_CTRL0_LOCK_CS (1 << 27) 23 #define BM_SSP_CTRL0_IGNORE_CRC 32 #define BM_SSP_CTRL0_IGNORE_CRC (1 << 26) 24 #define BM_SSP_CTRL0_READ 33 #define BM_SSP_CTRL0_READ (1 << 25) 25 #define BM_SSP_CTRL0_DATA_XFER 34 #define BM_SSP_CTRL0_DATA_XFER (1 << 24) 26 #define BP_SSP_CTRL0_BUS_WIDTH 35 #define BP_SSP_CTRL0_BUS_WIDTH 22 27 #define BM_SSP_CTRL0_BUS_WIDTH 36 #define BM_SSP_CTRL0_BUS_WIDTH (0x3 << 22) 28 #define BM_SSP_CTRL0_WAIT_FOR_IRQ 37 #define BM_SSP_CTRL0_WAIT_FOR_IRQ (1 << 21) 29 #define BM_SSP_CTRL0_WAIT_FOR_CMD 38 #define BM_SSP_CTRL0_WAIT_FOR_CMD (1 << 20) 30 #define BM_SSP_CTRL0_LONG_RESP 39 #define BM_SSP_CTRL0_LONG_RESP (1 << 19) 31 #define BM_SSP_CTRL0_GET_RESP 40 #define BM_SSP_CTRL0_GET_RESP (1 << 17) 32 #define BM_SSP_CTRL0_ENABLE 41 #define BM_SSP_CTRL0_ENABLE (1 << 16) 33 #define BP_SSP_CTRL0_XFER_COUNT 42 #define BP_SSP_CTRL0_XFER_COUNT 0 34 #define BM_SSP_CTRL0_XFER_COUNT 43 #define BM_SSP_CTRL0_XFER_COUNT 0xffff 35 #define HW_SSP_CMD0 44 #define HW_SSP_CMD0 0x010 36 #define BM_SSP_CMD0_DBL_DATA_RATE_EN 45 #define BM_SSP_CMD0_DBL_DATA_RATE_EN (1 << 25) 37 #define BM_SSP_CMD0_SLOW_CLKING_EN 46 #define BM_SSP_CMD0_SLOW_CLKING_EN (1 << 22) 38 #define BM_SSP_CMD0_CONT_CLKING_EN 47 #define BM_SSP_CMD0_CONT_CLKING_EN (1 << 21) 39 #define BM_SSP_CMD0_APPEND_8CYC 48 #define BM_SSP_CMD0_APPEND_8CYC (1 << 20) 40 #define BP_SSP_CMD0_BLOCK_SIZE 49 #define BP_SSP_CMD0_BLOCK_SIZE 16 41 #define BM_SSP_CMD0_BLOCK_SIZE 50 #define BM_SSP_CMD0_BLOCK_SIZE (0xf << 16) 42 #define BP_SSP_CMD0_BLOCK_COUNT 51 #define BP_SSP_CMD0_BLOCK_COUNT 8 43 #define BM_SSP_CMD0_BLOCK_COUNT 52 #define BM_SSP_CMD0_BLOCK_COUNT (0xff << 8) 44 #define BP_SSP_CMD0_CMD 53 #define BP_SSP_CMD0_CMD 0 45 #define BM_SSP_CMD0_CMD 54 #define BM_SSP_CMD0_CMD 0xff 46 #define HW_SSP_CMD1 55 #define HW_SSP_CMD1 0x020 47 #define HW_SSP_XFER_SIZE 56 #define HW_SSP_XFER_SIZE 0x030 48 #define HW_SSP_BLOCK_SIZE 57 #define HW_SSP_BLOCK_SIZE 0x040 49 #define BP_SSP_BLOCK_SIZE_BLOCK_COUNT 58 #define BP_SSP_BLOCK_SIZE_BLOCK_COUNT 4 50 #define BM_SSP_BLOCK_SIZE_BLOCK_COUNT 59 #define BM_SSP_BLOCK_SIZE_BLOCK_COUNT (0xffffff << 4) 51 #define BP_SSP_BLOCK_SIZE_BLOCK_SIZE 60 #define BP_SSP_BLOCK_SIZE_BLOCK_SIZE 0 52 #define BM_SSP_BLOCK_SIZE_BLOCK_SIZE 61 #define BM_SSP_BLOCK_SIZE_BLOCK_SIZE 0xf 53 #define HW_SSP_TIMING(h) 62 #define HW_SSP_TIMING(h) (ssp_is_old(h) ? 0x050 : 0x070) 54 #define BP_SSP_TIMING_TIMEOUT 63 #define BP_SSP_TIMING_TIMEOUT 16 55 #define BM_SSP_TIMING_TIMEOUT 64 #define BM_SSP_TIMING_TIMEOUT (0xffff << 16) 56 #define BP_SSP_TIMING_CLOCK_DIVIDE 65 #define BP_SSP_TIMING_CLOCK_DIVIDE 8 57 #define BM_SSP_TIMING_CLOCK_DIVIDE 66 #define BM_SSP_TIMING_CLOCK_DIVIDE (0xff << 8) 58 #define BF_SSP_TIMING_CLOCK_DIVIDE(v) 67 #define BF_SSP_TIMING_CLOCK_DIVIDE(v) \ 59 (((v) << 8) & BM_SSP_T 68 (((v) << 8) & BM_SSP_TIMING_CLOCK_DIVIDE) 60 #define BP_SSP_TIMING_CLOCK_RATE 69 #define BP_SSP_TIMING_CLOCK_RATE 0 61 #define BM_SSP_TIMING_CLOCK_RATE 70 #define BM_SSP_TIMING_CLOCK_RATE 0xff 62 #define BF_SSP_TIMING_CLOCK_RATE(v) 71 #define BF_SSP_TIMING_CLOCK_RATE(v) \ 63 (((v) << 0) & BM_SSP_T 72 (((v) << 0) & BM_SSP_TIMING_CLOCK_RATE) 64 #define HW_SSP_CTRL1(h) 73 #define HW_SSP_CTRL1(h) (ssp_is_old(h) ? 0x060 : 0x080) 65 #define BM_SSP_CTRL1_SDIO_IRQ 74 #define BM_SSP_CTRL1_SDIO_IRQ (1 << 31) 66 #define BM_SSP_CTRL1_SDIO_IRQ_EN 75 #define BM_SSP_CTRL1_SDIO_IRQ_EN (1 << 30) 67 #define BM_SSP_CTRL1_RESP_ERR_IRQ 76 #define BM_SSP_CTRL1_RESP_ERR_IRQ (1 << 29) 68 #define BM_SSP_CTRL1_RESP_ERR_IRQ_EN 77 #define BM_SSP_CTRL1_RESP_ERR_IRQ_EN (1 << 28) 69 #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ 78 #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ (1 << 27) 70 #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN 79 #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN (1 << 26) 71 #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ 80 #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ (1 << 25) 72 #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN 81 #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN (1 << 24) 73 #define BM_SSP_CTRL1_DATA_CRC_IRQ 82 #define BM_SSP_CTRL1_DATA_CRC_IRQ (1 << 23) 74 #define BM_SSP_CTRL1_DATA_CRC_IRQ_EN 83 #define BM_SSP_CTRL1_DATA_CRC_IRQ_EN (1 << 22) 75 #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ 84 #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ (1 << 21) 76 #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN 85 #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN (1 << 20) 77 #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ 86 #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ (1 << 17) 78 #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN 87 #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN (1 << 16) 79 #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ 88 #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ (1 << 15) 80 #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN 89 #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN (1 << 14) 81 #define BM_SSP_CTRL1_DMA_ENABLE 90 #define BM_SSP_CTRL1_DMA_ENABLE (1 << 13) 82 #define BM_SSP_CTRL1_PHASE 91 #define BM_SSP_CTRL1_PHASE (1 << 10) 83 #define BM_SSP_CTRL1_POLARITY 92 #define BM_SSP_CTRL1_POLARITY (1 << 9) 84 #define BP_SSP_CTRL1_WORD_LENGTH 93 #define BP_SSP_CTRL1_WORD_LENGTH 4 85 #define BM_SSP_CTRL1_WORD_LENGTH 94 #define BM_SSP_CTRL1_WORD_LENGTH (0xf << 4) 86 #define BF_SSP_CTRL1_WORD_LENGTH(v) 95 #define BF_SSP_CTRL1_WORD_LENGTH(v) \ 87 (((v) << 4) & BM_SSP_C 96 (((v) << 4) & BM_SSP_CTRL1_WORD_LENGTH) 88 #define BV_SSP_CTRL1_WORD_LENGTH__FOUR_BITS 97 #define BV_SSP_CTRL1_WORD_LENGTH__FOUR_BITS 0x3 89 #define BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS 98 #define BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS 0x7 90 #define BV_SSP_CTRL1_WORD_LENGTH__SIXTEEN_BIT 99 #define BV_SSP_CTRL1_WORD_LENGTH__SIXTEEN_BITS 0xF 91 #define BP_SSP_CTRL1_SSP_MODE 100 #define BP_SSP_CTRL1_SSP_MODE 0 92 #define BM_SSP_CTRL1_SSP_MODE 101 #define BM_SSP_CTRL1_SSP_MODE 0xf 93 #define BF_SSP_CTRL1_SSP_MODE(v) 102 #define BF_SSP_CTRL1_SSP_MODE(v) \ 94 (((v) << 0) & BM_SSP_C 103 (((v) << 0) & BM_SSP_CTRL1_SSP_MODE) 95 #define BV_SSP_CTRL1_SSP_MODE__SPI 104 #define BV_SSP_CTRL1_SSP_MODE__SPI 0x0 96 #define BV_SSP_CTRL1_SSP_MODE__SSI 105 #define BV_SSP_CTRL1_SSP_MODE__SSI 0x1 97 #define BV_SSP_CTRL1_SSP_MODE__SD_MMC 106 #define BV_SSP_CTRL1_SSP_MODE__SD_MMC 0x3 98 #define BV_SSP_CTRL1_SSP_MODE__MS 107 #define BV_SSP_CTRL1_SSP_MODE__MS 0x4 99 108 100 #define HW_SSP_DATA(h) 109 #define HW_SSP_DATA(h) (ssp_is_old(h) ? 0x070 : 0x090) 101 110 102 #define HW_SSP_SDRESP0(h) 111 #define HW_SSP_SDRESP0(h) (ssp_is_old(h) ? 0x080 : 0x0a0) 103 #define HW_SSP_SDRESP1(h) 112 #define HW_SSP_SDRESP1(h) (ssp_is_old(h) ? 0x090 : 0x0b0) 104 #define HW_SSP_SDRESP2(h) 113 #define HW_SSP_SDRESP2(h) (ssp_is_old(h) ? 0x0a0 : 0x0c0) 105 #define HW_SSP_SDRESP3(h) 114 #define HW_SSP_SDRESP3(h) (ssp_is_old(h) ? 0x0b0 : 0x0d0) 106 #define HW_SSP_STATUS(h) 115 #define HW_SSP_STATUS(h) (ssp_is_old(h) ? 0x0c0 : 0x100) 107 #define BM_SSP_STATUS_CARD_DETECT 116 #define BM_SSP_STATUS_CARD_DETECT (1 << 28) 108 #define BM_SSP_STATUS_SDIO_IRQ 117 #define BM_SSP_STATUS_SDIO_IRQ (1 << 17) 109 #define BM_SSP_STATUS_FIFO_EMPTY 118 #define BM_SSP_STATUS_FIFO_EMPTY (1 << 5) 110 119 111 #define BF_SSP(value, field) (((value) << B 120 #define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field) 112 121 113 #define SSP_PIO_NUM 3 122 #define SSP_PIO_NUM 3 114 123 115 enum mxs_ssp_id { 124 enum mxs_ssp_id { 116 IMX23_SSP, 125 IMX23_SSP, 117 IMX28_SSP, 126 IMX28_SSP, 118 }; 127 }; 119 128 120 struct mxs_ssp { 129 struct mxs_ssp { 121 struct device *dev; 130 struct device *dev; 122 void __iomem *base; 131 void __iomem *base; 123 struct clk *clk; 132 struct clk *clk; 124 unsigned int clk_ra 133 unsigned int clk_rate; 125 enum mxs_ssp_id devid; 134 enum mxs_ssp_id devid; 126 135 127 struct dma_chan *dmach 136 struct dma_chan *dmach; 128 unsigned int dma_di 137 unsigned int dma_dir; 129 enum dma_transfer_direction slave_ 138 enum dma_transfer_direction slave_dirn; 130 u32 ssp_pi 139 u32 ssp_pio_words[SSP_PIO_NUM]; 131 }; 140 }; 132 141 133 void mxs_ssp_set_clk_rate(struct mxs_ssp *ssp, 142 void mxs_ssp_set_clk_rate(struct mxs_ssp *ssp, unsigned int rate); 134 143 135 #endif /* __LINUX_SPI_MXS_SPI_H__ */ 144 #endif /* __LINUX_SPI_MXS_SPI_H__ */ 136 145
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.