]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmc.h
EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Drivers / DwEmmcDxe / DwEmmc.h
1 /** @file
2 *
3 * Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 *
7 **/
8
9
10 #ifndef __DWEMMC_H__
11 #define __DWEMMC_H__
12
13 #include <Protocol/EmbeddedGpio.h>
14
15 // DW MMC Registers
16 #define DWEMMC_CTRL ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x000)
17 #define DWEMMC_PWREN ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x004)
18 #define DWEMMC_CLKDIV ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x008)
19 #define DWEMMC_CLKSRC ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x00c)
20 #define DWEMMC_CLKENA ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x010)
21 #define DWEMMC_TMOUT ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x014)
22 #define DWEMMC_CTYPE ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x018)
23 #define DWEMMC_BLKSIZ ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x01c)
24 #define DWEMMC_BYTCNT ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x020)
25 #define DWEMMC_INTMASK ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x024)
26 #define DWEMMC_CMDARG ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x028)
27 #define DWEMMC_CMD ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x02c)
28 #define DWEMMC_RESP0 ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x030)
29 #define DWEMMC_RESP1 ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x034)
30 #define DWEMMC_RESP2 ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x038)
31 #define DWEMMC_RESP3 ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x03c)
32 #define DWEMMC_RINTSTS ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x044)
33 #define DWEMMC_STATUS ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x048)
34 #define DWEMMC_FIFOTH ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x04c)
35 #define DWEMMC_TCBCNT ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x05c)
36 #define DWEMMC_TBBCNT ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x060)
37 #define DWEMMC_DEBNCE ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x064)
38 #define DWEMMC_HCON ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x070)
39 #define DWEMMC_UHSREG ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x074)
40 #define DWEMMC_BMOD ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x080)
41 #define DWEMMC_DBADDR ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x088)
42 #define DWEMMC_IDSTS ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x08c)
43 #define DWEMMC_IDINTEN ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x090)
44 #define DWEMMC_DSCADDR ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x094)
45 #define DWEMMC_BUFADDR ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0x098)
46 #define DWEMMC_CARDTHRCTL ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0X100)
47 #define DWEMMC_DATA ((UINT32)PcdGet32 (PcdDwEmmcDxeBaseAddress) + 0X200)
48
49 #define CMD_UPDATE_CLK 0x80202000
50 #define CMD_START_BIT (1 << 31)
51
52 #define MMC_8BIT_MODE (1 << 16)
53
54 #define BIT_CMD_RESPONSE_EXPECT (1 << 6)
55 #define BIT_CMD_LONG_RESPONSE (1 << 7)
56 #define BIT_CMD_CHECK_RESPONSE_CRC (1 << 8)
57 #define BIT_CMD_DATA_EXPECTED (1 << 9)
58 #define BIT_CMD_READ (0 << 10)
59 #define BIT_CMD_WRITE (1 << 10)
60 #define BIT_CMD_BLOCK_TRANSFER (0 << 11)
61 #define BIT_CMD_STREAM_TRANSFER (1 << 11)
62 #define BIT_CMD_SEND_AUTO_STOP (1 << 12)
63 #define BIT_CMD_WAIT_PRVDATA_COMPLETE (1 << 13)
64 #define BIT_CMD_STOP_ABORT_CMD (1 << 14)
65 #define BIT_CMD_SEND_INIT (1 << 15)
66 #define BIT_CMD_UPDATE_CLOCK_ONLY (1 << 21)
67 #define BIT_CMD_READ_CEATA_DEVICE (1 << 22)
68 #define BIT_CMD_CCS_EXPECTED (1 << 23)
69 #define BIT_CMD_ENABLE_BOOT (1 << 24)
70 #define BIT_CMD_EXPECT_BOOT_ACK (1 << 25)
71 #define BIT_CMD_DISABLE_BOOT (1 << 26)
72 #define BIT_CMD_MANDATORY_BOOT (0 << 27)
73 #define BIT_CMD_ALTERNATE_BOOT (1 << 27)
74 #define BIT_CMD_VOLT_SWITCH (1 << 28)
75 #define BIT_CMD_USE_HOLD_REG (1 << 29)
76 #define BIT_CMD_START (1 << 31)
77
78 #define DWEMMC_INT_EBE (1 << 15) /* End-bit Err */
79 #define DWEMMC_INT_SBE (1 << 13) /* Start-bit Err */
80 #define DWEMMC_INT_HLE (1 << 12) /* Hardware-lock Err */
81 #define DWEMMC_INT_FRUN (1 << 11) /* FIFO UN/OV RUN */
82 #define DWEMMC_INT_DRT (1 << 9) /* Data timeout */
83 #define DWEMMC_INT_RTO (1 << 8) /* Response timeout */
84 #define DWEMMC_INT_DCRC (1 << 7) /* Data CRC err */
85 #define DWEMMC_INT_RCRC (1 << 6) /* Response CRC err */
86 #define DWEMMC_INT_RXDR (1 << 5)
87 #define DWEMMC_INT_TXDR (1 << 4)
88 #define DWEMMC_INT_DTO (1 << 3) /* Data trans over */
89 #define DWEMMC_INT_CMD_DONE (1 << 2)
90 #define DWEMMC_INT_RE (1 << 1)
91
92 #define DWEMMC_IDMAC_DES0_DIC (1 << 1)
93 #define DWEMMC_IDMAC_DES0_LD (1 << 2)
94 #define DWEMMC_IDMAC_DES0_FS (1 << 3)
95 #define DWEMMC_IDMAC_DES0_CH (1 << 4)
96 #define DWEMMC_IDMAC_DES0_ER (1 << 5)
97 #define DWEMMC_IDMAC_DES0_CES (1 << 30)
98 #define DWEMMC_IDMAC_DES0_OWN (1 << 31)
99 #define DWEMMC_IDMAC_DES1_BS1(x) ((x) & 0x1fff)
100 #define DWEMMC_IDMAC_DES2_BS2(x) (((x) & 0x1fff) << 13)
101 #define DWEMMC_IDMAC_SWRESET (1 << 0)
102 #define DWEMMC_IDMAC_FB (1 << 1)
103 #define DWEMMC_IDMAC_ENABLE (1 << 7)
104
105 #define EMMC_FIX_RCA 6
106
107 /* bits in MMC0_CTRL */
108 #define DWEMMC_CTRL_RESET (1 << 0)
109 #define DWEMMC_CTRL_FIFO_RESET (1 << 1)
110 #define DWEMMC_CTRL_DMA_RESET (1 << 2)
111 #define DWEMMC_CTRL_INT_EN (1 << 4)
112 #define DWEMMC_CTRL_DMA_EN (1 << 5)
113 #define DWEMMC_CTRL_IDMAC_EN (1 << 25)
114 #define DWEMMC_CTRL_RESET_ALL (DWEMMC_CTRL_RESET | DWEMMC_CTRL_FIFO_RESET | DWEMMC_CTRL_DMA_RESET)
115
116 #define DWEMMC_STS_DATA_BUSY (1 << 9)
117
118 #define DWEMMC_FIFO_TWMARK(x) (x & 0xfff)
119 #define DWEMMC_FIFO_RWMARK(x) ((x & 0x1ff) << 16)
120 #define DWEMMC_DMA_BURST_SIZE(x) ((x & 0x7) << 28)
121
122 #define DWEMMC_CARD_RD_THR(x) ((x & 0xfff) << 16)
123 #define DWEMMC_CARD_RD_THR_EN (1 << 0)
124
125 #define DWEMMC_GET_HDATA_WIDTH(x) (((x) >> 7) & 0x7)
126
127 #endif // __DWEMMC_H__