1 1.3 jmcneill /* $NetBSD: sunxi_mmc.h,v 1.3 2017/09/11 22:00:05 jmcneill Exp $ */ 2 1.1 jmcneill 3 1.1 jmcneill /*- 4 1.1 jmcneill * Copyright (c) 2017 Jared McNeill <jmcneill (at) invisible.ca> 5 1.1 jmcneill * All rights reserved. 6 1.1 jmcneill * 7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without 8 1.1 jmcneill * modification, are permitted provided that the following conditions 9 1.1 jmcneill * are met: 10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright 11 1.1 jmcneill * notice, this list of conditions and the following disclaimer. 12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the 14 1.1 jmcneill * documentation and/or other materials provided with the distribution. 15 1.1 jmcneill * 16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 jmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 jmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 jmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 jmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 1.1 jmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 1.1 jmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 1.1 jmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 1.1 jmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.1 jmcneill * SUCH DAMAGE. 27 1.1 jmcneill */ 28 1.1 jmcneill 29 1.1 jmcneill #ifndef _ARM_SUNXI_MMC_H 30 1.1 jmcneill #define _ARM_SUNXI_MMC_H 31 1.1 jmcneill 32 1.1 jmcneill #define SUNXI_MMC_GCTRL 0x0000 33 1.1 jmcneill #define SUNXI_MMC_CLKCR 0x0004 34 1.1 jmcneill #define SUNXI_MMC_TIMEOUT 0x0008 35 1.1 jmcneill #define SUNXI_MMC_WIDTH 0x000C 36 1.1 jmcneill #define SUNXI_MMC_BLKSZ 0x0010 37 1.1 jmcneill #define SUNXI_MMC_BYTECNT 0x0014 38 1.1 jmcneill #define SUNXI_MMC_CMD 0x0018 39 1.1 jmcneill #define SUNXI_MMC_ARG 0x001C 40 1.1 jmcneill #define SUNXI_MMC_RESP0 0x0020 41 1.1 jmcneill #define SUNXI_MMC_RESP1 0x0024 42 1.1 jmcneill #define SUNXI_MMC_RESP2 0x0028 43 1.1 jmcneill #define SUNXI_MMC_RESP3 0x002C 44 1.1 jmcneill #define SUNXI_MMC_IMASK 0x0030 45 1.1 jmcneill #define SUNXI_MMC_MINT 0x0034 46 1.1 jmcneill #define SUNXI_MMC_RINT 0x0038 47 1.1 jmcneill #define SUNXI_MMC_STATUS 0x003C 48 1.1 jmcneill #define SUNXI_MMC_FTRGLEVEL 0x0040 49 1.1 jmcneill #define SUNXI_MMC_FUNCSEL 0x0044 50 1.1 jmcneill #define SUNXI_MMC_CBCR 0x0048 51 1.1 jmcneill #define SUNXI_MMC_BBCR 0x004C 52 1.1 jmcneill #define SUNXI_MMC_DBGC 0x0050 53 1.1 jmcneill #define SUNXI_MMC_A12A 0x0058 /* A80 */ 54 1.2 jmcneill #define SUNXI_MMC_NTSR 0x005C 55 1.1 jmcneill #define SUNXI_MMC_HWRST 0x0078 /* A80 */ 56 1.1 jmcneill #define SUNXI_MMC_DMAC 0x0080 57 1.1 jmcneill #define SUNXI_MMC_DLBA 0x0084 58 1.1 jmcneill #define SUNXI_MMC_IDST 0x0088 59 1.1 jmcneill #define SUNXI_MMC_IDIE 0x008C 60 1.1 jmcneill #define SUNXI_MMC_CHDA 0x0090 61 1.1 jmcneill #define SUNXI_MMC_CBDA 0x0094 62 1.3 jmcneill #define SUNXI_MMC_SAMP_DL 0x0144 63 1.2 jmcneill 64 1.1 jmcneill #define SUNXI_MMC_GCTRL_ACCESS_BY_AHB __BIT(31) 65 1.1 jmcneill #define SUNXI_MMC_GCTRL_WAIT_MEM_ACCESS_DONE __BIT(30) 66 1.1 jmcneill #define SUNXI_MMC_GCTRL_DDR_MODE __BIT(10) 67 1.1 jmcneill #define SUNXI_MMC_GCTRL_DEBOUNCEEN __BIT(8) 68 1.1 jmcneill #define SUNXI_MMC_GCTRL_DMAEN __BIT(5) 69 1.1 jmcneill #define SUNXI_MMC_GCTRL_INTEN __BIT(4) 70 1.1 jmcneill #define SUNXI_MMC_GCTRL_DMARESET __BIT(2) 71 1.1 jmcneill #define SUNXI_MMC_GCTRL_FIFORESET __BIT(1) 72 1.1 jmcneill #define SUNXI_MMC_GCTRL_SOFTRESET __BIT(0) 73 1.1 jmcneill #define SUNXI_MMC_GCTRL_RESET \ 74 1.1 jmcneill (SUNXI_MMC_GCTRL_SOFTRESET | SUNXI_MMC_GCTRL_FIFORESET | \ 75 1.1 jmcneill SUNXI_MMC_GCTRL_DMARESET) 76 1.3 jmcneill #define SUNXI_MMC_CLKCR_MASK_DATA0 __BIT(31) 77 1.1 jmcneill #define SUNXI_MMC_CLKCR_LOWPOWERON __BIT(17) 78 1.1 jmcneill #define SUNXI_MMC_CLKCR_CARDCLKON __BIT(16) 79 1.2 jmcneill #define SUNXI_MMC_CLKCR_DIV __BITS(7,0) 80 1.1 jmcneill #define SUNXI_MMC_WIDTH_1 0 81 1.1 jmcneill #define SUNXI_MMC_WIDTH_4 1 82 1.1 jmcneill #define SUNXI_MMC_WIDTH_8 2 83 1.1 jmcneill #define SUNXI_MMC_CMD_START __BIT(31) 84 1.1 jmcneill #define SUNXI_MMC_CMD_USE_HOLD_REG __BIT(29) 85 1.1 jmcneill #define SUNXI_MMC_CMD_VOL_SWITCH __BIT(28) 86 1.1 jmcneill #define SUNXI_MMC_CMD_BOOT_ABORT __BIT(27) 87 1.1 jmcneill #define SUNXI_MMC_CMD_BOOT_ACK_EXP __BIT(26) 88 1.1 jmcneill #define SUNXI_MMC_CMD_ALT_BOOT_OPT __BIT(25) 89 1.1 jmcneill #define SUNXI_MMC_CMD_ENBOOT __BIT(24) 90 1.1 jmcneill #define SUNXI_MMC_CMD_CCS_EXP __BIT(23) 91 1.1 jmcneill #define SUNXI_MMC_CMD_RD_CEATA_DEV __BIT(22) 92 1.1 jmcneill #define SUNXI_MMC_CMD_UPCLK_ONLY __BIT(21) 93 1.1 jmcneill #define SUNXI_MMC_CMD_SEND_INIT_SEQ __BIT(15) 94 1.1 jmcneill #define SUNXI_MMC_CMD_STOP_ABORT_CMD __BIT(14) 95 1.1 jmcneill #define SUNXI_MMC_CMD_WAIT_PRE_OVER __BIT(13) 96 1.1 jmcneill #define SUNXI_MMC_CMD_SEND_AUTO_STOP __BIT(12) 97 1.1 jmcneill #define SUNXI_MMC_CMD_SEQMOD __BIT(11) 98 1.1 jmcneill #define SUNXI_MMC_CMD_WRITE __BIT(10) 99 1.1 jmcneill #define SUNXI_MMC_CMD_DATA_EXP __BIT(9) 100 1.1 jmcneill #define SUNXI_MMC_CMD_CHECK_RSP_CRC __BIT(8) 101 1.1 jmcneill #define SUNXI_MMC_CMD_LONG_RSP __BIT(7) 102 1.1 jmcneill #define SUNXI_MMC_CMD_RSP_EXP __BIT(6) 103 1.1 jmcneill #define SUNXI_MMC_INT_CARD_REMOVE __BIT(31) 104 1.1 jmcneill #define SUNXI_MMC_INT_CARD_INSERT __BIT(30) 105 1.1 jmcneill #define SUNXI_MMC_INT_SDIO_INT __BIT(16) 106 1.1 jmcneill #define SUNXI_MMC_INT_END_BIT_ERR __BIT(15) 107 1.1 jmcneill #define SUNXI_MMC_INT_AUTO_CMD_DONE __BIT(14) 108 1.1 jmcneill #define SUNXI_MMC_INT_START_BIT_ERR __BIT(13) 109 1.1 jmcneill #define SUNXI_MMC_INT_HW_LOCKED __BIT(12) 110 1.1 jmcneill #define SUNXI_MMC_INT_FIFO_RUN_ERR __BIT(11) 111 1.1 jmcneill #define SUNXI_MMC_INT_VOL_CHG_DONE __BIT(10) 112 1.1 jmcneill #define SUNXI_MMC_INT_DATA_STARVE __BIT(10) 113 1.1 jmcneill #define SUNXI_MMC_INT_BOOT_START __BIT(9) 114 1.1 jmcneill #define SUNXI_MMC_INT_DATA_TIMEOUT __BIT(9) 115 1.1 jmcneill #define SUNXI_MMC_INT_ACK_RCV __BIT(8) 116 1.1 jmcneill #define SUNXI_MMC_INT_RESP_TIMEOUT __BIT(8) 117 1.1 jmcneill #define SUNXI_MMC_INT_DATA_CRC_ERR __BIT(7) 118 1.1 jmcneill #define SUNXI_MMC_INT_RESP_CRC_ERR __BIT(6) 119 1.1 jmcneill #define SUNXI_MMC_INT_RX_DATA_REQ __BIT(5) 120 1.1 jmcneill #define SUNXI_MMC_INT_TX_DATA_REQ __BIT(4) 121 1.1 jmcneill #define SUNXI_MMC_INT_DATA_OVER __BIT(3) 122 1.1 jmcneill #define SUNXI_MMC_INT_CMD_DONE __BIT(2) 123 1.1 jmcneill #define SUNXI_MMC_INT_RESP_ERR __BIT(1) 124 1.1 jmcneill #define SUNXI_MMC_INT_ERROR \ 125 1.1 jmcneill (SUNXI_MMC_INT_RESP_ERR | SUNXI_MMC_INT_RESP_CRC_ERR | \ 126 1.1 jmcneill SUNXI_MMC_INT_DATA_CRC_ERR | SUNXI_MMC_INT_RESP_TIMEOUT | \ 127 1.1 jmcneill SUNXI_MMC_INT_FIFO_RUN_ERR | SUNXI_MMC_INT_HW_LOCKED | \ 128 1.1 jmcneill SUNXI_MMC_INT_START_BIT_ERR | SUNXI_MMC_INT_END_BIT_ERR) 129 1.1 jmcneill #define SUNXI_MMC_STATUS_DMAREQ __BIT(31) 130 1.1 jmcneill #define SUNXI_MMC_STATUS_DATA_FSM_BUSY __BIT(10) 131 1.1 jmcneill #define SUNXI_MMC_STATUS_CARD_DATA_BUSY __BIT(9) 132 1.1 jmcneill #define SUNXI_MMC_STATUS_CARD_PRESENT __BIT(8) 133 1.1 jmcneill #define SUNXI_MMC_STATUS_FIFO_FULL __BIT(3) 134 1.1 jmcneill #define SUNXI_MMC_STATUS_FIFO_EMPTY __BIT(2) 135 1.1 jmcneill #define SUNXI_MMC_STATUS_TXWL_FLAG __BIT(1) 136 1.1 jmcneill #define SUNXI_MMC_STATUS_RXWL_FLAG __BIT(0) 137 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_CEATA_DEV_INTEN __BIT(10) 138 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_SEND_AUTO_STOP_CCSD __BIT(9) 139 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_SEND_CCSD __BIT(8) 140 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_ABT_RD_DATA __BIT(2) 141 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_SDIO_RD_WAIT __BIT(1) 142 1.1 jmcneill #define SUNXI_MMC_FUNCSEL_SEND_IRQ_RSP __BIT(0) 143 1.2 jmcneill #define SUNXI_MMC_NTSR_MODE_SELECT __BIT(31) 144 1.2 jmcneill #define SUNXI_MMC_NTSR_SAMPLE_PHASE __BITS(30,6) 145 1.2 jmcneill #define SUNXI_MMC_NTSR_OUTPUT_PHASE __BITS(1,0) 146 1.1 jmcneill #define SUNXI_MMC_DMAC_REFETCH_DES __BIT(31) 147 1.1 jmcneill #define SUNXI_MMC_DMAC_IDMA_ON __BIT(7) 148 1.1 jmcneill #define SUNXI_MMC_DMAC_FIX_BURST __BIT(1) 149 1.1 jmcneill #define SUNXI_MMC_DMAC_SOFTRESET __BIT(0) 150 1.1 jmcneill #define SUNXI_MMC_IDST_HOST_ABT __BIT(10) 151 1.1 jmcneill #define SUNXI_MMC_IDST_ABNORMAL_INT_SUM __BIT(9) 152 1.1 jmcneill #define SUNXI_MMC_IDST_NORMAL_INT_SUM __BIT(8) 153 1.1 jmcneill #define SUNXI_MMC_IDST_CARD_ERR_SUM __BIT(5) 154 1.1 jmcneill #define SUNXI_MMC_IDST_DES_INVALID __BIT(4) 155 1.1 jmcneill #define SUNXI_MMC_IDST_FATAL_BUS_ERR __BIT(2) 156 1.1 jmcneill #define SUNXI_MMC_IDST_RECEIVE_INT __BIT(1) 157 1.1 jmcneill #define SUNXI_MMC_IDST_TRANSMIT_INT __BIT(0) 158 1.1 jmcneill #define SUNXI_MMC_IDST_ERROR \ 159 1.1 jmcneill (SUNXI_MMC_IDST_ABNORMAL_INT_SUM | SUNXI_MMC_IDST_CARD_ERR_SUM | \ 160 1.1 jmcneill SUNXI_MMC_IDST_DES_INVALID | SUNXI_MMC_IDST_FATAL_BUS_ERR) 161 1.1 jmcneill #define SUNXI_MMC_IDST_COMPLETE \ 162 1.1 jmcneill (SUNXI_MMC_IDST_RECEIVE_INT | SUNXI_MMC_IDST_TRANSMIT_INT) 163 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_DIC __BIT(1) 164 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_LD __BIT(2) 165 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_FD __BIT(3) 166 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_CH __BIT(4) 167 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_ER __BIT(5) 168 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_CES __BIT(30) 169 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_OWN __BIT(31) 170 1.3 jmcneill #define SUNXI_MMC_SAMP_DL_SW_EN __BIT(7) 171 1.1 jmcneill 172 1.1 jmcneill struct sunxi_mmc_idma_descriptor { 173 1.1 jmcneill uint32_t dma_config; 174 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_DIC __BIT(1) 175 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_LD __BIT(2) 176 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_FD __BIT(3) 177 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_CH __BIT(4) 178 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_ER __BIT(5) 179 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_CES __BIT(30) 180 1.1 jmcneill #define SUNXI_MMC_IDMA_CONFIG_OWN __BIT(31) 181 1.1 jmcneill uint32_t dma_buf_size; 182 1.1 jmcneill uint32_t dma_buf_addr; 183 1.1 jmcneill uint32_t dma_next; 184 1.1 jmcneill } __packed; 185 1.1 jmcneill 186 1.1 jmcneill #endif /* _ARM_SUNXI_MMC_H */ 187