1*5fdac65bSjmcneill /* $NetBSD: sunxi_mmc.h,v 1.3 2017/09/11 22:00:05 jmcneill Exp $ */ 211d415cdSjmcneill 311d415cdSjmcneill /*- 411d415cdSjmcneill * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> 511d415cdSjmcneill * All rights reserved. 611d415cdSjmcneill * 711d415cdSjmcneill * Redistribution and use in source and binary forms, with or without 811d415cdSjmcneill * modification, are permitted provided that the following conditions 911d415cdSjmcneill * are met: 1011d415cdSjmcneill * 1. Redistributions of source code must retain the above copyright 1111d415cdSjmcneill * notice, this list of conditions and the following disclaimer. 1211d415cdSjmcneill * 2. Redistributions in binary form must reproduce the above copyright 1311d415cdSjmcneill * notice, this list of conditions and the following disclaimer in the 1411d415cdSjmcneill * documentation and/or other materials provided with the distribution. 1511d415cdSjmcneill * 1611d415cdSjmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1711d415cdSjmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1811d415cdSjmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1911d415cdSjmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2011d415cdSjmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2111d415cdSjmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 2211d415cdSjmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2311d415cdSjmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2411d415cdSjmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2511d415cdSjmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2611d415cdSjmcneill * SUCH DAMAGE. 2711d415cdSjmcneill */ 2811d415cdSjmcneill 2911d415cdSjmcneill #ifndef _ARM_SUNXI_MMC_H 3011d415cdSjmcneill #define _ARM_SUNXI_MMC_H 3111d415cdSjmcneill 3211d415cdSjmcneill #define SUNXI_MMC_GCTRL 0x0000 3311d415cdSjmcneill #define SUNXI_MMC_CLKCR 0x0004 3411d415cdSjmcneill #define SUNXI_MMC_TIMEOUT 0x0008 3511d415cdSjmcneill #define SUNXI_MMC_WIDTH 0x000C 3611d415cdSjmcneill #define SUNXI_MMC_BLKSZ 0x0010 3711d415cdSjmcneill #define SUNXI_MMC_BYTECNT 0x0014 3811d415cdSjmcneill #define SUNXI_MMC_CMD 0x0018 3911d415cdSjmcneill #define SUNXI_MMC_ARG 0x001C 4011d415cdSjmcneill #define SUNXI_MMC_RESP0 0x0020 4111d415cdSjmcneill #define SUNXI_MMC_RESP1 0x0024 4211d415cdSjmcneill #define SUNXI_MMC_RESP2 0x0028 4311d415cdSjmcneill #define SUNXI_MMC_RESP3 0x002C 4411d415cdSjmcneill #define SUNXI_MMC_IMASK 0x0030 4511d415cdSjmcneill #define SUNXI_MMC_MINT 0x0034 4611d415cdSjmcneill #define SUNXI_MMC_RINT 0x0038 4711d415cdSjmcneill #define SUNXI_MMC_STATUS 0x003C 4811d415cdSjmcneill #define SUNXI_MMC_FTRGLEVEL 0x0040 4911d415cdSjmcneill #define SUNXI_MMC_FUNCSEL 0x0044 5011d415cdSjmcneill #define SUNXI_MMC_CBCR 0x0048 5111d415cdSjmcneill #define SUNXI_MMC_BBCR 0x004C 5211d415cdSjmcneill #define SUNXI_MMC_DBGC 0x0050 5311d415cdSjmcneill #define SUNXI_MMC_A12A 0x0058 /* A80 */ 547bc60651Sjmcneill #define SUNXI_MMC_NTSR 0x005C 5511d415cdSjmcneill #define SUNXI_MMC_HWRST 0x0078 /* A80 */ 5611d415cdSjmcneill #define SUNXI_MMC_DMAC 0x0080 5711d415cdSjmcneill #define SUNXI_MMC_DLBA 0x0084 5811d415cdSjmcneill #define SUNXI_MMC_IDST 0x0088 5911d415cdSjmcneill #define SUNXI_MMC_IDIE 0x008C 6011d415cdSjmcneill #define SUNXI_MMC_CHDA 0x0090 6111d415cdSjmcneill #define SUNXI_MMC_CBDA 0x0094 62*5fdac65bSjmcneill #define SUNXI_MMC_SAMP_DL 0x0144 637bc60651Sjmcneill 6411d415cdSjmcneill #define SUNXI_MMC_GCTRL_ACCESS_BY_AHB __BIT(31) 6511d415cdSjmcneill #define SUNXI_MMC_GCTRL_WAIT_MEM_ACCESS_DONE __BIT(30) 6611d415cdSjmcneill #define SUNXI_MMC_GCTRL_DDR_MODE __BIT(10) 6711d415cdSjmcneill #define SUNXI_MMC_GCTRL_DEBOUNCEEN __BIT(8) 6811d415cdSjmcneill #define SUNXI_MMC_GCTRL_DMAEN __BIT(5) 6911d415cdSjmcneill #define SUNXI_MMC_GCTRL_INTEN __BIT(4) 7011d415cdSjmcneill #define SUNXI_MMC_GCTRL_DMARESET __BIT(2) 7111d415cdSjmcneill #define SUNXI_MMC_GCTRL_FIFORESET __BIT(1) 7211d415cdSjmcneill #define SUNXI_MMC_GCTRL_SOFTRESET __BIT(0) 7311d415cdSjmcneill #define SUNXI_MMC_GCTRL_RESET \ 7411d415cdSjmcneill (SUNXI_MMC_GCTRL_SOFTRESET | SUNXI_MMC_GCTRL_FIFORESET | \ 7511d415cdSjmcneill SUNXI_MMC_GCTRL_DMARESET) 76*5fdac65bSjmcneill #define SUNXI_MMC_CLKCR_MASK_DATA0 __BIT(31) 7711d415cdSjmcneill #define SUNXI_MMC_CLKCR_LOWPOWERON __BIT(17) 7811d415cdSjmcneill #define SUNXI_MMC_CLKCR_CARDCLKON __BIT(16) 797bc60651Sjmcneill #define SUNXI_MMC_CLKCR_DIV __BITS(7,0) 8011d415cdSjmcneill #define SUNXI_MMC_WIDTH_1 0 8111d415cdSjmcneill #define SUNXI_MMC_WIDTH_4 1 8211d415cdSjmcneill #define SUNXI_MMC_WIDTH_8 2 8311d415cdSjmcneill #define SUNXI_MMC_CMD_START __BIT(31) 8411d415cdSjmcneill #define SUNXI_MMC_CMD_USE_HOLD_REG __BIT(29) 8511d415cdSjmcneill #define SUNXI_MMC_CMD_VOL_SWITCH __BIT(28) 8611d415cdSjmcneill #define SUNXI_MMC_CMD_BOOT_ABORT __BIT(27) 8711d415cdSjmcneill #define SUNXI_MMC_CMD_BOOT_ACK_EXP __BIT(26) 8811d415cdSjmcneill #define SUNXI_MMC_CMD_ALT_BOOT_OPT __BIT(25) 8911d415cdSjmcneill #define SUNXI_MMC_CMD_ENBOOT __BIT(24) 9011d415cdSjmcneill #define SUNXI_MMC_CMD_CCS_EXP __BIT(23) 9111d415cdSjmcneill #define SUNXI_MMC_CMD_RD_CEATA_DEV __BIT(22) 9211d415cdSjmcneill #define SUNXI_MMC_CMD_UPCLK_ONLY __BIT(21) 9311d415cdSjmcneill #define SUNXI_MMC_CMD_SEND_INIT_SEQ __BIT(15) 9411d415cdSjmcneill #define SUNXI_MMC_CMD_STOP_ABORT_CMD __BIT(14) 9511d415cdSjmcneill #define SUNXI_MMC_CMD_WAIT_PRE_OVER __BIT(13) 9611d415cdSjmcneill #define SUNXI_MMC_CMD_SEND_AUTO_STOP __BIT(12) 9711d415cdSjmcneill #define SUNXI_MMC_CMD_SEQMOD __BIT(11) 9811d415cdSjmcneill #define SUNXI_MMC_CMD_WRITE __BIT(10) 9911d415cdSjmcneill #define SUNXI_MMC_CMD_DATA_EXP __BIT(9) 10011d415cdSjmcneill #define SUNXI_MMC_CMD_CHECK_RSP_CRC __BIT(8) 10111d415cdSjmcneill #define SUNXI_MMC_CMD_LONG_RSP __BIT(7) 10211d415cdSjmcneill #define SUNXI_MMC_CMD_RSP_EXP __BIT(6) 10311d415cdSjmcneill #define SUNXI_MMC_INT_CARD_REMOVE __BIT(31) 10411d415cdSjmcneill #define SUNXI_MMC_INT_CARD_INSERT __BIT(30) 10511d415cdSjmcneill #define SUNXI_MMC_INT_SDIO_INT __BIT(16) 10611d415cdSjmcneill #define SUNXI_MMC_INT_END_BIT_ERR __BIT(15) 10711d415cdSjmcneill #define SUNXI_MMC_INT_AUTO_CMD_DONE __BIT(14) 10811d415cdSjmcneill #define SUNXI_MMC_INT_START_BIT_ERR __BIT(13) 10911d415cdSjmcneill #define SUNXI_MMC_INT_HW_LOCKED __BIT(12) 11011d415cdSjmcneill #define SUNXI_MMC_INT_FIFO_RUN_ERR __BIT(11) 11111d415cdSjmcneill #define SUNXI_MMC_INT_VOL_CHG_DONE __BIT(10) 11211d415cdSjmcneill #define SUNXI_MMC_INT_DATA_STARVE __BIT(10) 11311d415cdSjmcneill #define SUNXI_MMC_INT_BOOT_START __BIT(9) 11411d415cdSjmcneill #define SUNXI_MMC_INT_DATA_TIMEOUT __BIT(9) 11511d415cdSjmcneill #define SUNXI_MMC_INT_ACK_RCV __BIT(8) 11611d415cdSjmcneill #define SUNXI_MMC_INT_RESP_TIMEOUT __BIT(8) 11711d415cdSjmcneill #define SUNXI_MMC_INT_DATA_CRC_ERR __BIT(7) 11811d415cdSjmcneill #define SUNXI_MMC_INT_RESP_CRC_ERR __BIT(6) 11911d415cdSjmcneill #define SUNXI_MMC_INT_RX_DATA_REQ __BIT(5) 12011d415cdSjmcneill #define SUNXI_MMC_INT_TX_DATA_REQ __BIT(4) 12111d415cdSjmcneill #define SUNXI_MMC_INT_DATA_OVER __BIT(3) 12211d415cdSjmcneill #define SUNXI_MMC_INT_CMD_DONE __BIT(2) 12311d415cdSjmcneill #define SUNXI_MMC_INT_RESP_ERR __BIT(1) 12411d415cdSjmcneill #define SUNXI_MMC_INT_ERROR \ 12511d415cdSjmcneill (SUNXI_MMC_INT_RESP_ERR | SUNXI_MMC_INT_RESP_CRC_ERR | \ 12611d415cdSjmcneill SUNXI_MMC_INT_DATA_CRC_ERR | SUNXI_MMC_INT_RESP_TIMEOUT | \ 12711d415cdSjmcneill SUNXI_MMC_INT_FIFO_RUN_ERR | SUNXI_MMC_INT_HW_LOCKED | \ 12811d415cdSjmcneill SUNXI_MMC_INT_START_BIT_ERR | SUNXI_MMC_INT_END_BIT_ERR) 12911d415cdSjmcneill #define SUNXI_MMC_STATUS_DMAREQ __BIT(31) 13011d415cdSjmcneill #define SUNXI_MMC_STATUS_DATA_FSM_BUSY __BIT(10) 13111d415cdSjmcneill #define SUNXI_MMC_STATUS_CARD_DATA_BUSY __BIT(9) 13211d415cdSjmcneill #define SUNXI_MMC_STATUS_CARD_PRESENT __BIT(8) 13311d415cdSjmcneill #define SUNXI_MMC_STATUS_FIFO_FULL __BIT(3) 13411d415cdSjmcneill #define SUNXI_MMC_STATUS_FIFO_EMPTY __BIT(2) 13511d415cdSjmcneill #define SUNXI_MMC_STATUS_TXWL_FLAG __BIT(1) 13611d415cdSjmcneill #define SUNXI_MMC_STATUS_RXWL_FLAG __BIT(0) 13711d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_CEATA_DEV_INTEN __BIT(10) 13811d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_SEND_AUTO_STOP_CCSD __BIT(9) 13911d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_SEND_CCSD __BIT(8) 14011d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_ABT_RD_DATA __BIT(2) 14111d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_SDIO_RD_WAIT __BIT(1) 14211d415cdSjmcneill #define SUNXI_MMC_FUNCSEL_SEND_IRQ_RSP __BIT(0) 1437bc60651Sjmcneill #define SUNXI_MMC_NTSR_MODE_SELECT __BIT(31) 1447bc60651Sjmcneill #define SUNXI_MMC_NTSR_SAMPLE_PHASE __BITS(30,6) 1457bc60651Sjmcneill #define SUNXI_MMC_NTSR_OUTPUT_PHASE __BITS(1,0) 14611d415cdSjmcneill #define SUNXI_MMC_DMAC_REFETCH_DES __BIT(31) 14711d415cdSjmcneill #define SUNXI_MMC_DMAC_IDMA_ON __BIT(7) 14811d415cdSjmcneill #define SUNXI_MMC_DMAC_FIX_BURST __BIT(1) 14911d415cdSjmcneill #define SUNXI_MMC_DMAC_SOFTRESET __BIT(0) 15011d415cdSjmcneill #define SUNXI_MMC_IDST_HOST_ABT __BIT(10) 15111d415cdSjmcneill #define SUNXI_MMC_IDST_ABNORMAL_INT_SUM __BIT(9) 15211d415cdSjmcneill #define SUNXI_MMC_IDST_NORMAL_INT_SUM __BIT(8) 15311d415cdSjmcneill #define SUNXI_MMC_IDST_CARD_ERR_SUM __BIT(5) 15411d415cdSjmcneill #define SUNXI_MMC_IDST_DES_INVALID __BIT(4) 15511d415cdSjmcneill #define SUNXI_MMC_IDST_FATAL_BUS_ERR __BIT(2) 15611d415cdSjmcneill #define SUNXI_MMC_IDST_RECEIVE_INT __BIT(1) 15711d415cdSjmcneill #define SUNXI_MMC_IDST_TRANSMIT_INT __BIT(0) 15811d415cdSjmcneill #define SUNXI_MMC_IDST_ERROR \ 15911d415cdSjmcneill (SUNXI_MMC_IDST_ABNORMAL_INT_SUM | SUNXI_MMC_IDST_CARD_ERR_SUM | \ 16011d415cdSjmcneill SUNXI_MMC_IDST_DES_INVALID | SUNXI_MMC_IDST_FATAL_BUS_ERR) 16111d415cdSjmcneill #define SUNXI_MMC_IDST_COMPLETE \ 16211d415cdSjmcneill (SUNXI_MMC_IDST_RECEIVE_INT | SUNXI_MMC_IDST_TRANSMIT_INT) 16311d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_DIC __BIT(1) 16411d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_LD __BIT(2) 16511d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_FD __BIT(3) 16611d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_CH __BIT(4) 16711d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_ER __BIT(5) 16811d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_CES __BIT(30) 16911d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_OWN __BIT(31) 170*5fdac65bSjmcneill #define SUNXI_MMC_SAMP_DL_SW_EN __BIT(7) 17111d415cdSjmcneill 17211d415cdSjmcneill struct sunxi_mmc_idma_descriptor { 17311d415cdSjmcneill uint32_t dma_config; 17411d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_DIC __BIT(1) 17511d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_LD __BIT(2) 17611d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_FD __BIT(3) 17711d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_CH __BIT(4) 17811d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_ER __BIT(5) 17911d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_CES __BIT(30) 18011d415cdSjmcneill #define SUNXI_MMC_IDMA_CONFIG_OWN __BIT(31) 18111d415cdSjmcneill uint32_t dma_buf_size; 18211d415cdSjmcneill uint32_t dma_buf_addr; 18311d415cdSjmcneill uint32_t dma_next; 18411d415cdSjmcneill } __packed; 18511d415cdSjmcneill 18611d415cdSjmcneill #endif /* _ARM_SUNXI_MMC_H */ 187