xref: /openbmc/u-boot/arch/arm/include/asm/arch-tegra/tegra_mmc.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2150c2493STom Warren /*
3150c2493STom Warren  * (C) Copyright 2009 SAMSUNG Electronics
4150c2493STom Warren  * Minkyu Kang <mk7.kang@samsung.com>
5150c2493STom Warren  * Portions Copyright (C) 2011-2012 NVIDIA Corporation
6150c2493STom Warren  */
7150c2493STom Warren 
8150c2493STom Warren #ifndef __TEGRA_MMC_H_
9150c2493STom Warren #define __TEGRA_MMC_H_
10150c2493STom Warren 
11c0493076SStephen Warren #include <common.h>
12c0493076SStephen Warren #include <clk.h>
13c0493076SStephen Warren #include <reset.h>
1438797bcbSTom Warren #include <fdtdec.h>
150347960bSSimon Glass #include <asm/gpio.h>
16150c2493STom Warren 
1793bfd616SPantelis Antoniou /* for mmc_config definition */
1893bfd616SPantelis Antoniou #include <mmc.h>
1993bfd616SPantelis Antoniou 
20150c2493STom Warren #ifndef __ASSEMBLY__
21150c2493STom Warren struct tegra_mmc {
22150c2493STom Warren 	unsigned int	sysad;		/* _SYSTEM_ADDRESS_0 */
23150c2493STom Warren 	unsigned short	blksize;	/* _BLOCK_SIZE_BLOCK_COUNT_0 15:00 */
24150c2493STom Warren 	unsigned short	blkcnt;		/* _BLOCK_SIZE_BLOCK_COUNT_0 31:16 */
25150c2493STom Warren 	unsigned int	argument;	/* _ARGUMENT_0 */
26150c2493STom Warren 	unsigned short	trnmod;		/* _CMD_XFER_MODE_0 15:00 xfer mode */
27150c2493STom Warren 	unsigned short	cmdreg;		/* _CMD_XFER_MODE_0 31:16 cmd reg */
28150c2493STom Warren 	unsigned int	rspreg0;	/* _RESPONSE_R0_R1_0 CMD RESP 31:00 */
29150c2493STom Warren 	unsigned int	rspreg1;	/* _RESPONSE_R2_R3_0 CMD RESP 63:32 */
30150c2493STom Warren 	unsigned int	rspreg2;	/* _RESPONSE_R4_R5_0 CMD RESP 95:64 */
31150c2493STom Warren 	unsigned int	rspreg3;	/* _RESPONSE_R6_R7_0 CMD RESP 127:96 */
32150c2493STom Warren 	unsigned int	bdata;		/* _BUFFER_DATA_PORT_0 */
33150c2493STom Warren 	unsigned int	prnsts;		/* _PRESENT_STATE_0 */
34150c2493STom Warren 	unsigned char	hostctl;	/* _POWER_CONTROL_HOST_0 7:00 */
35150c2493STom Warren 	unsigned char	pwrcon;		/* _POWER_CONTROL_HOST_0 15:8 */
36150c2493STom Warren 	unsigned char	blkgap;		/* _POWER_CONTROL_HOST_9 23:16 */
37150c2493STom Warren 	unsigned char	wakcon;		/* _POWER_CONTROL_HOST_0 31:24 */
38150c2493STom Warren 	unsigned short	clkcon;		/* _CLOCK_CONTROL_0 15:00 */
39150c2493STom Warren 	unsigned char	timeoutcon;	/* _TIMEOUT_CTRL 23:16 */
40150c2493STom Warren 	unsigned char	swrst;		/* _SW_RESET_ 31:24 */
41150c2493STom Warren 	unsigned int	norintsts;	/* _INTERRUPT_STATUS_0 */
42150c2493STom Warren 	unsigned int	norintstsen;	/* _INTERRUPT_STATUS_ENABLE_0 */
43150c2493STom Warren 	unsigned int	norintsigen;	/* _INTERRUPT_SIGNAL_ENABLE_0 */
44150c2493STom Warren 	unsigned short	acmd12errsts;	/* _AUTO_CMD12_ERR_STATUS_0 15:00 */
45150c2493STom Warren 	unsigned char	res1[2];	/* _RESERVED 31:16 */
46150c2493STom Warren 	unsigned int	capareg;	/* _CAPABILITIES_0 */
47150c2493STom Warren 	unsigned char	res2[4];	/* RESERVED, offset 44h-47h */
48150c2493STom Warren 	unsigned int	maxcurr;	/* _MAXIMUM_CURRENT_0 */
49150c2493STom Warren 	unsigned char	res3[4];	/* RESERVED, offset 4Ch-4Fh */
50150c2493STom Warren 	unsigned short	setacmd12err;	/* offset 50h */
51150c2493STom Warren 	unsigned short	setinterr;	/* offset 52h */
52150c2493STom Warren 	unsigned char	admaerr;	/* offset 54h */
53150c2493STom Warren 	unsigned char	res4[3];	/* RESERVED, offset 55h-57h */
54150c2493STom Warren 	unsigned long	admaaddr;	/* offset 58h-5Fh */
5538797bcbSTom Warren 	unsigned char	res5[0xa0];	/* RESERVED, offset 60h-FBh */
56150c2493STom Warren 	unsigned short	slotintstatus;	/* offset FCh */
57150c2493STom Warren 	unsigned short	hcver;		/* HOST Version */
5838797bcbSTom Warren 	unsigned int	venclkctl;	/* _VENDOR_CLOCK_CNTRL_0,    100h */
5938797bcbSTom Warren 	unsigned int	venspictl;	/* _VENDOR_SPI_CNTRL_0,      104h */
6038797bcbSTom Warren 	unsigned int	venspiintsts;	/* _VENDOR_SPI_INT_STATUS_0, 108h */
6138797bcbSTom Warren 	unsigned int	venceatactl;	/* _VENDOR_CEATA_CNTRL_0,    10Ch */
6238797bcbSTom Warren 	unsigned int	venbootctl;	/* _VENDOR_BOOT_CNTRL_0,     110h */
6338797bcbSTom Warren 	unsigned int	venbootacktout;	/* _VENDOR_BOOT_ACK_TIMEOUT, 114h */
6438797bcbSTom Warren 	unsigned int	venbootdattout;	/* _VENDOR_BOOT_DAT_TIMEOUT, 118h */
6538797bcbSTom Warren 	unsigned int	vendebouncecnt;	/* _VENDOR_DEBOUNCE_COUNT_0, 11Ch */
6638797bcbSTom Warren 	unsigned int	venmiscctl;	/* _VENDOR_MISC_CNTRL_0,     120h */
6738797bcbSTom Warren 	unsigned int	res6[47];	/* 0x124 ~ 0x1DC */
6838797bcbSTom Warren 	unsigned int	sdmemcmppadctl;	/* _SDMEMCOMPPADCTRL_0,      1E0h */
6938797bcbSTom Warren 	unsigned int	autocalcfg;	/* _AUTO_CAL_CONFIG_0,       1E4h */
7038797bcbSTom Warren 	unsigned int	autocalintval;	/* _AUTO_CAL_INTERVAL_0,     1E8h */
7138797bcbSTom Warren 	unsigned int	autocalsts;	/* _AUTO_CAL_STATUS_0,       1ECh */
72150c2493STom Warren };
73150c2493STom Warren 
7438797bcbSTom Warren #define TEGRA_MMC_PWRCTL_SD_BUS_POWER				(1 << 0)
7538797bcbSTom Warren #define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V1_8			(5 << 1)
7638797bcbSTom Warren #define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_0			(6 << 1)
7738797bcbSTom Warren #define TEGRA_MMC_PWRCTL_SD_BUS_VOLTAGE_V3_3			(7 << 1)
7838797bcbSTom Warren 
79150c2493STom Warren #define TEGRA_MMC_HOSTCTL_DMASEL_MASK				(3 << 3)
80150c2493STom Warren #define TEGRA_MMC_HOSTCTL_DMASEL_SDMA				(0 << 3)
81150c2493STom Warren #define TEGRA_MMC_HOSTCTL_DMASEL_ADMA2_32BIT			(2 << 3)
82150c2493STom Warren #define TEGRA_MMC_HOSTCTL_DMASEL_ADMA2_64BIT			(3 << 3)
83150c2493STom Warren 
84150c2493STom Warren #define TEGRA_MMC_TRNMOD_DMA_ENABLE				(1 << 0)
85150c2493STom Warren #define TEGRA_MMC_TRNMOD_BLOCK_COUNT_ENABLE			(1 << 1)
86150c2493STom Warren #define TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_WRITE		(0 << 4)
87150c2493STom Warren #define TEGRA_MMC_TRNMOD_DATA_XFER_DIR_SEL_READ			(1 << 4)
88150c2493STom Warren #define TEGRA_MMC_TRNMOD_MULTI_BLOCK_SELECT			(1 << 5)
89150c2493STom Warren 
90150c2493STom Warren #define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_MASK			(3 << 0)
91150c2493STom Warren #define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_NO_RESPONSE		(0 << 0)
92150c2493STom Warren #define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_136		(1 << 0)
93150c2493STom Warren #define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48		(2 << 0)
94150c2493STom Warren #define TEGRA_MMC_CMDREG_RESP_TYPE_SELECT_LENGTH_48_BUSY	(3 << 0)
95150c2493STom Warren 
96150c2493STom Warren #define TEGRA_MMC_TRNMOD_CMD_CRC_CHECK				(1 << 3)
97150c2493STom Warren #define TEGRA_MMC_TRNMOD_CMD_INDEX_CHECK			(1 << 4)
98150c2493STom Warren #define TEGRA_MMC_TRNMOD_DATA_PRESENT_SELECT_DATA_TRANSFER	(1 << 5)
99150c2493STom Warren 
100150c2493STom Warren #define TEGRA_MMC_PRNSTS_CMD_INHIBIT_CMD			(1 << 0)
101150c2493STom Warren #define TEGRA_MMC_PRNSTS_CMD_INHIBIT_DAT			(1 << 1)
102150c2493STom Warren 
103150c2493STom Warren #define TEGRA_MMC_CLKCON_INTERNAL_CLOCK_ENABLE			(1 << 0)
104150c2493STom Warren #define TEGRA_MMC_CLKCON_INTERNAL_CLOCK_STABLE			(1 << 1)
105150c2493STom Warren #define TEGRA_MMC_CLKCON_SD_CLOCK_ENABLE			(1 << 2)
106150c2493STom Warren 
107150c2493STom Warren #define TEGRA_MMC_CLKCON_SDCLK_FREQ_SEL_SHIFT			8
108150c2493STom Warren #define TEGRA_MMC_CLKCON_SDCLK_FREQ_SEL_MASK			(0xff << 8)
109150c2493STom Warren 
1104119b709SMarcel Ziswiler #define TEGRA_MMC_MISCON_ENABLE_EXT_LOOPBACK			(1 << 17)
1114119b709SMarcel Ziswiler 
112150c2493STom Warren #define TEGRA_MMC_SWRST_SW_RESET_FOR_ALL			(1 << 0)
113150c2493STom Warren #define TEGRA_MMC_SWRST_SW_RESET_FOR_CMD_LINE			(1 << 1)
114150c2493STom Warren #define TEGRA_MMC_SWRST_SW_RESET_FOR_DAT_LINE			(1 << 2)
115150c2493STom Warren 
116150c2493STom Warren #define TEGRA_MMC_NORINTSTS_CMD_COMPLETE			(1 << 0)
117150c2493STom Warren #define TEGRA_MMC_NORINTSTS_XFER_COMPLETE			(1 << 1)
118150c2493STom Warren #define TEGRA_MMC_NORINTSTS_DMA_INTERRUPT			(1 << 3)
119150c2493STom Warren #define TEGRA_MMC_NORINTSTS_ERR_INTERRUPT			(1 << 15)
120150c2493STom Warren #define TEGRA_MMC_NORINTSTS_CMD_TIMEOUT				(1 << 16)
121150c2493STom Warren 
122150c2493STom Warren #define TEGRA_MMC_NORINTSTSEN_CMD_COMPLETE			(1 << 0)
123150c2493STom Warren #define TEGRA_MMC_NORINTSTSEN_XFER_COMPLETE			(1 << 1)
124150c2493STom Warren #define TEGRA_MMC_NORINTSTSEN_DMA_INTERRUPT			(1 << 3)
125150c2493STom Warren #define TEGRA_MMC_NORINTSTSEN_BUFFER_WRITE_READY		(1 << 4)
126150c2493STom Warren #define TEGRA_MMC_NORINTSTSEN_BUFFER_READ_READY			(1 << 5)
127150c2493STom Warren 
128150c2493STom Warren #define TEGRA_MMC_NORINTSIGEN_XFER_COMPLETE			(1 << 1)
129150c2493STom Warren 
13038797bcbSTom Warren /* SDMMC1/3 settings from section 24.6 of T30 TRM */
13138797bcbSTom Warren #define MEMCOMP_PADCTRL_VREF	7
13238797bcbSTom Warren #define AUTO_CAL_ENABLED	(1 << 29)
13338797bcbSTom Warren #define AUTO_CAL_PD_OFFSET	(0x70 << 8)
13438797bcbSTom Warren #define AUTO_CAL_PU_OFFSET	(0x62 << 0)
13538797bcbSTom Warren 
136150c2493STom Warren #endif	/* __ASSEMBLY__ */
137150c2493STom Warren #endif	/* __TEGRA_MMC_H_ */
138