Home | History | Annotate | Line # | Download | only in ic
dwc_mmc_reg.h revision 1.10
      1  1.10     skrll /* $NetBSD: dwc_mmc_reg.h,v 1.10 2020/03/20 17:02:16 skrll Exp $ */
      2   1.1  jmcneill 
      3   1.1  jmcneill /*-
      4   1.6  jmcneill  * Copyright (c) 2014-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 _DWC_MMC_REG_H
     30   1.1  jmcneill #define _DWC_MMC_REG_H
     31   1.1  jmcneill 
     32   1.6  jmcneill #define DWC_MMC_GCTRL			0x0000
     33   1.6  jmcneill #define DWC_MMC_PWREN			0x0004
     34   1.6  jmcneill #define	DWC_MMC_CLKDIV			0x0008
     35   1.6  jmcneill #define	DWC_MMC_CLKSRC			0x000c
     36   1.6  jmcneill #define	DWC_MMC_CLKENA			0x0010
     37   1.6  jmcneill #define DWC_MMC_TIMEOUT			0x0014
     38   1.6  jmcneill #define DWC_MMC_WIDTH			0x0018
     39   1.6  jmcneill #define DWC_MMC_BLKSZ			0x001c
     40   1.6  jmcneill #define DWC_MMC_BYTECNT			0x0020
     41   1.6  jmcneill #define DWC_MMC_IMASK			0x0024
     42   1.6  jmcneill #define DWC_MMC_ARG			0x0028
     43   1.6  jmcneill #define DWC_MMC_CMD			0x002c
     44   1.6  jmcneill #define DWC_MMC_RESP0			0x0030
     45   1.6  jmcneill #define DWC_MMC_RESP1			0x0034
     46   1.6  jmcneill #define DWC_MMC_RESP2			0x0038
     47   1.6  jmcneill #define DWC_MMC_RESP3			0x003c
     48   1.6  jmcneill #define DWC_MMC_MINT			0x0040
     49   1.6  jmcneill #define DWC_MMC_RINT			0x0044
     50   1.6  jmcneill #define DWC_MMC_STATUS			0x0048
     51   1.6  jmcneill #define DWC_MMC_FIFOTH			0x004c
     52   1.6  jmcneill #define	DWC_MMC_CDETECT			0x0050
     53   1.6  jmcneill #define	DWC_MMC_WRITEPROT		0x0054
     54   1.6  jmcneill #define	DWC_MMC_GPIO			0x0058
     55   1.6  jmcneill #define DWC_MMC_CBCR			0x005c
     56   1.6  jmcneill #define DWC_MMC_BBCR			0x0060
     57   1.6  jmcneill #define	DWC_MMC_DEBNCE			0x0064
     58   1.6  jmcneill #define	DWC_MMC_USRID			0x0068
     59   1.6  jmcneill #define	DWC_MMC_VERID			0x006c
     60   1.6  jmcneill #define	DWC_MMC_HCON			0x0070
     61   1.6  jmcneill #define	DWC_MMC_UHS			0x0074
     62   1.6  jmcneill #define	DWC_MMC_RST			0x0078
     63   1.6  jmcneill #define DWC_MMC_DMAC			0x0080
     64   1.6  jmcneill #define	DWC_MMC_PLDMND			0x0084
     65   1.6  jmcneill #define DWC_MMC_DLBA			0x0088
     66   1.6  jmcneill #define DWC_MMC_IDST			0x008c
     67   1.6  jmcneill #define DWC_MMC_IDIE			0x0090
     68   1.6  jmcneill #define DWC_MMC_DSCADDR			0x0094
     69   1.6  jmcneill #define DWC_MMC_BUFADDR			0x0098
     70   1.9  jmcneill #define DWC_MMC_CARDTHRCTL		0x0100
     71   1.6  jmcneill 
     72   1.6  jmcneill #define DWC_MMC_GCTRL_USE_INTERNAL_DMAC	__BIT(25)
     73   1.6  jmcneill #define DWC_MMC_GCTRL_SEND_AUTO_STOP_CCSD __BIT(10)
     74   1.6  jmcneill #define DWC_MMC_GCTRL_DMAEN		__BIT(5)
     75   1.6  jmcneill #define DWC_MMC_GCTRL_INTEN		__BIT(4)
     76   1.6  jmcneill #define DWC_MMC_GCTRL_DMARESET		__BIT(2)
     77   1.6  jmcneill #define DWC_MMC_GCTRL_FIFORESET		__BIT(1)
     78   1.6  jmcneill #define DWC_MMC_GCTRL_SOFTRESET		__BIT(0)
     79   1.6  jmcneill #define DWC_MMC_GCTRL_RESET \
     80   1.6  jmcneill 	(DWC_MMC_GCTRL_SOFTRESET | DWC_MMC_GCTRL_FIFORESET | \
     81   1.6  jmcneill 	 DWC_MMC_GCTRL_DMARESET)
     82   1.6  jmcneill 
     83   1.6  jmcneill #define DWC_MMC_CLKENA_LOWPOWERON	__BIT(16)
     84   1.6  jmcneill #define DWC_MMC_CLKENA_CARDCLKON	__BIT(0)
     85   1.6  jmcneill 
     86   1.6  jmcneill #define DWC_MMC_WIDTH_1		0x00000000
     87   1.6  jmcneill #define DWC_MMC_WIDTH_4		0x00000001
     88   1.6  jmcneill #define DWC_MMC_WIDTH_8		0x00010000
     89   1.6  jmcneill 
     90   1.6  jmcneill #define DWC_MMC_CMD_START		__BIT(31)
     91   1.6  jmcneill #define DWC_MMC_CMD_USE_HOLD_REG	__BIT(29)
     92   1.6  jmcneill #define DWC_MMC_CMD_VOL_SWITCH		__BIT(28)
     93   1.6  jmcneill #define DWC_MMC_CMD_BOOT_MODE		__BIT(27)
     94   1.6  jmcneill #define DWC_MMC_CMD_DISABLE_BOOT	__BIT(26)
     95   1.6  jmcneill #define DWC_MMC_CMD_EXPECT_BOOT_ACT	__BIT(25)
     96   1.6  jmcneill #define DWC_MMC_CMD_ENABLE_BOOT		__BIT(24)
     97   1.6  jmcneill #define DWC_MMC_CMD_UPCLK_ONLY		__BIT(21)
     98   1.6  jmcneill #define DWC_MMC_CMD_SEND_INIT_SEQ	__BIT(15)
     99   1.6  jmcneill #define DWC_MMC_CMD_STOP_ABORT_CMD	__BIT(14)
    100   1.6  jmcneill #define DWC_MMC_CMD_WAIT_PRE_OVER	__BIT(13)
    101   1.6  jmcneill #define DWC_MMC_CMD_SEND_AUTO_STOP	__BIT(12)
    102   1.6  jmcneill #define DWC_MMC_CMD_SEQMOD		__BIT(11)
    103   1.6  jmcneill #define DWC_MMC_CMD_WRITE		__BIT(10)
    104   1.6  jmcneill #define DWC_MMC_CMD_DATA_EXP		__BIT(9)
    105   1.6  jmcneill #define DWC_MMC_CMD_CHECK_RSP_CRC	__BIT(8)
    106   1.6  jmcneill #define DWC_MMC_CMD_LONG_RSP		__BIT(7)
    107   1.6  jmcneill #define DWC_MMC_CMD_RSP_EXP		__BIT(6)
    108   1.6  jmcneill 
    109   1.6  jmcneill #define DWC_MMC_INT_CARD_REMOVE		__BIT(31)
    110   1.6  jmcneill #define DWC_MMC_INT_CARD_INSERT		__BIT(30)
    111   1.9  jmcneill #define DWC_MMC_INT_SDIO_INT(n)		__BIT(16 + (n))
    112   1.6  jmcneill #define DWC_MMC_INT_END_BIT_ERR		__BIT(15)
    113   1.6  jmcneill #define DWC_MMC_INT_AUTO_CMD_DONE	__BIT(14)
    114   1.6  jmcneill #define DWC_MMC_INT_START_BIT_ERR	__BIT(13)
    115   1.6  jmcneill #define DWC_MMC_INT_HW_LOCKED		__BIT(12)
    116   1.6  jmcneill #define DWC_MMC_INT_FIFO_RUN_ERR	__BIT(11)
    117   1.6  jmcneill #define DWC_MMC_INT_VOL_CHG_DONE	__BIT(10)
    118   1.6  jmcneill #define DWC_MMC_INT_DATA_STARVE		__BIT(10)
    119   1.6  jmcneill #define DWC_MMC_INT_BOOT_START		__BIT(9)
    120   1.6  jmcneill #define DWC_MMC_INT_DATA_TIMEOUT	__BIT(9)
    121   1.6  jmcneill #define DWC_MMC_INT_ACK_RCV		__BIT(8)
    122   1.6  jmcneill #define DWC_MMC_INT_RESP_TIMEOUT	__BIT(8)
    123   1.6  jmcneill #define DWC_MMC_INT_DATA_CRC_ERR	__BIT(7)
    124   1.6  jmcneill #define DWC_MMC_INT_RESP_CRC_ERR	__BIT(6)
    125   1.6  jmcneill #define DWC_MMC_INT_RX_DATA_REQ		__BIT(5)
    126   1.6  jmcneill #define DWC_MMC_INT_TX_DATA_REQ		__BIT(4)
    127   1.6  jmcneill #define DWC_MMC_INT_DATA_OVER		__BIT(3)
    128   1.6  jmcneill #define DWC_MMC_INT_CMD_DONE		__BIT(2)
    129   1.6  jmcneill #define DWC_MMC_INT_RESP_ERR		__BIT(1)
    130   1.6  jmcneill #define DWC_MMC_INT_ERROR \
    131   1.6  jmcneill 	(DWC_MMC_INT_RESP_ERR | DWC_MMC_INT_RESP_CRC_ERR | \
    132   1.6  jmcneill 	 DWC_MMC_INT_DATA_CRC_ERR | DWC_MMC_INT_RESP_TIMEOUT | \
    133   1.6  jmcneill 	 DWC_MMC_INT_FIFO_RUN_ERR | DWC_MMC_INT_HW_LOCKED | \
    134   1.6  jmcneill 	 DWC_MMC_INT_START_BIT_ERR  | DWC_MMC_INT_END_BIT_ERR)
    135   1.6  jmcneill 
    136   1.6  jmcneill #define DWC_MMC_STATUS_DMAREQ		__BIT(31)
    137   1.6  jmcneill #define DWC_MMC_STATUS_DATA_FSM_BUSY	__BIT(10)
    138   1.6  jmcneill #define DWC_MMC_STATUS_CARD_DATA_BUSY	__BIT(9)
    139   1.6  jmcneill #define DWC_MMC_STATUS_CARD_PRESENT	__BIT(8)
    140   1.6  jmcneill #define DWC_MMC_STATUS_FIFO_FULL	__BIT(3)
    141   1.6  jmcneill #define DWC_MMC_STATUS_FIFO_EMPTY	__BIT(2)
    142   1.6  jmcneill #define DWC_MMC_STATUS_TXWL_FLAG	__BIT(1)
    143   1.6  jmcneill #define DWC_MMC_STATUS_RXWL_FLAG	__BIT(0)
    144   1.6  jmcneill 
    145   1.6  jmcneill #define	DWC_MMC_FIFOTH_DMA_MULTIPLE_TXN_SIZE __BITS(30,28)
    146   1.6  jmcneill #define	DWC_MMC_FIFOTH_DMA_MULTIPLE_TXN_SIZE_16	3
    147   1.6  jmcneill #define	DWC_MMC_FIFOTH_RX_WMARK		__BITS(27,16)
    148   1.6  jmcneill #define	DWC_MMC_FIFOTH_TX_WMARK		__BITS(11,0)
    149   1.6  jmcneill 
    150   1.6  jmcneill #define DWC_MMC_DMAC_IDMA_ON		__BIT(7)
    151   1.6  jmcneill #define DWC_MMC_DMAC_FIX_BURST		__BIT(1)
    152   1.6  jmcneill #define DWC_MMC_DMAC_SOFTRESET		__BIT(0)
    153   1.6  jmcneill 
    154   1.7  jmcneill #define DWC_MMC_VERID_ID		__BITS(15,0)
    155   1.7  jmcneill #define DWC_MMC_VERID_240A		0x240a
    156  1.10     skrll #define DWC_MMC_VERID_280A		0x280a
    157   1.7  jmcneill 
    158   1.6  jmcneill #define DWC_MMC_IDST_HOST_ABT		__BIT(10)
    159   1.6  jmcneill #define DWC_MMC_IDST_ABNORMAL_INT_SUM	__BIT(9)
    160   1.6  jmcneill #define DWC_MMC_IDST_NORMAL_INT_SUM	__BIT(8)
    161   1.6  jmcneill #define DWC_MMC_IDST_CARD_ERR_SUM	__BIT(5)
    162   1.6  jmcneill #define DWC_MMC_IDST_DES_INVALID	__BIT(4)
    163   1.6  jmcneill #define DWC_MMC_IDST_FATAL_BUS_ERR	__BIT(2)
    164   1.6  jmcneill #define DWC_MMC_IDST_RECEIVE_INT	__BIT(1)
    165   1.6  jmcneill #define DWC_MMC_IDST_TRANSMIT_INT	__BIT(0)
    166   1.6  jmcneill #define DWC_MMC_IDST_ERROR \
    167   1.6  jmcneill 	(DWC_MMC_IDST_ABNORMAL_INT_SUM | DWC_MMC_IDST_CARD_ERR_SUM | \
    168   1.6  jmcneill 	 DWC_MMC_IDST_DES_INVALID | DWC_MMC_IDST_FATAL_BUS_ERR)
    169   1.6  jmcneill #define DWC_MMC_IDST_COMPLETE \
    170   1.6  jmcneill 	(DWC_MMC_IDST_RECEIVE_INT | DWC_MMC_IDST_TRANSMIT_INT)
    171   1.6  jmcneill 
    172   1.9  jmcneill #define DWC_MMC_CARDTHRCTL_RDTHR	__BITS(27,16)
    173   1.9  jmcneill #define DWC_MMC_CARDTHRCTL_RDTHREN	__BIT(0)
    174   1.9  jmcneill 
    175   1.6  jmcneill struct dwc_mmc_idma_desc {
    176   1.6  jmcneill 	uint32_t		dma_config;
    177   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_DIC		__BIT(1)
    178   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_LD		__BIT(2)
    179   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_FD		__BIT(3)
    180   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_CH		__BIT(4)
    181   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_ER		__BIT(5)
    182   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_CES		__BIT(30)
    183   1.6  jmcneill #define DWC_MMC_IDMA_CONFIG_OWN		__BIT(31)
    184   1.6  jmcneill 	uint32_t		dma_buf_size;
    185   1.6  jmcneill 	uint32_t		dma_buf_addr;
    186   1.6  jmcneill 	uint32_t		dma_next;
    187   1.6  jmcneill } __packed;
    188   1.1  jmcneill 
    189   1.1  jmcneill #endif /* !_DWC_MMC_REG_H */
    190