19069a0a3c560f74dd1fe650cafebab5e2dd32a9
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / host / rk2818-sdmmc.h
1 /* drivers/mmc/host/rk2818-sdmmc.h
2  *
3  * Copyright (C) 2010 ROCKCHIP, Inc.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #ifndef __RK2818_SDMMC_H
17 #define __RK2818_SDMMC_H
18
19 #define MAX_SG_CHN      2
20
21
22 #define SDMMC_CTRL            (0x000)
23 #define SDMMC_PWREN           (0x004)
24 #define SDMMC_CLKDIV          (0x008)
25 #define SDMMC_CLKSRC          (0x00c)
26 #define SDMMC_CLKENA          (0x010)
27 #define SDMMC_TMOUT           (0x014)
28 #define SDMMC_CTYPE           (0x018)
29 #define SDMMC_BLKSIZ          (0x01c)
30 #define SDMMC_BYTCNT          (0x020)
31 #define SDMMC_INTMASK         (0x024)
32 #define SDMMC_CMDARG          (0x028)
33 #define SDMMC_CMD             (0x02c)
34 #define SDMMC_RESP0           (0x030)
35 #define SDMMC_RESP1           (0x034)
36 #define SDMMC_RESP2           (0x038)
37 #define SDMMC_RESP3           (0x03c)
38 #define SDMMC_MINTSTS         (0x040)
39 #define SDMMC_RINTSTS         (0x044)
40 #define SDMMC_STATUS          (0x048)
41 #define SDMMC_FIFOTH          (0x04c)
42 #define SDMMC_CDETECT         (0x050)
43 #define SDMMC_WRTPRT          (0x054)
44 #define SDMMC_TCBCNT          (0x05c)
45 #define SDMMC_TBBCNT          (0x060)
46 #define SDMMC_DEBNCE          (0x064)
47
48 #define SDMMC_DATA            (0x100)
49
50 #define RK2818_BIT(n)                           (1<<(n))
51
52 /* Control register defines */
53 #define SDMMC_CTRL_OD_PULLUP      RK2818_BIT(24)
54 #define SDMMC_CTRL_ABRT_READ_DATA RK2818_BIT(8)
55 #define SDMMC_CTRL_SEND_IRQ_RESP  RK2818_BIT(7)
56 #define SDMMC_CTRL_READ_WAIT      RK2818_BIT(6)
57 #define SDMMC_CTRL_DMA_ENABLE     RK2818_BIT(5)
58 #define SDMMC_CTRL_INT_ENABLE     RK2818_BIT(4)
59 #define SDMMC_CTRL_DMA_RESET      RK2818_BIT(2)
60 #define SDMMC_CTRL_FIFO_RESET     RK2818_BIT(1)
61 #define SDMMC_CTRL_RESET          RK2818_BIT(0)
62 /* Clock Enable register defines */
63 #define SDMMC_CLKEN_LOW_PWR      RK2818_BIT(16)
64 #define SDMMC_CLKEN_ENABLE       RK2818_BIT(0)
65 /* time-out register defines */
66 #define SDMMC_TMOUT_DATA(n)      _SBF(8, (n))
67 #define SDMMC_TMOUT_DATA_MSK     0xFFFFFF00
68 #define SDMMC_TMOUT_RESP(n)      ((n) & 0xFF)
69 #define SDMMC_TMOUT_RESP_MSK     0xFF
70 /* card-type register defines */
71 #define SDMMC_CTYPE_8BIT         RK2818_BIT(16)
72 #define SDMMC_CTYPE_4BIT         RK2818_BIT(0)
73 /* Interrupt status & mask register defines */
74 #define SDMMC_INT_SDIO          RK2818_BIT(16)
75 #define SDMMC_INT_EBE           RK2818_BIT(15)
76 #define SDMMC_INT_ACD           RK2818_BIT(14)
77 #define SDMMC_INT_SBE           RK2818_BIT(13)
78 #define SDMMC_INT_HLE           RK2818_BIT(12)
79 #define SDMMC_INT_FRUN          RK2818_BIT(11)
80 #define SDMMC_INT_HTO           RK2818_BIT(10)
81 #define SDMMC_INT_DRTO          RK2818_BIT(9)
82 #define SDMMC_INT_RTO           RK2818_BIT(8)
83 #define SDMMC_INT_DCRC          RK2818_BIT(7)
84 #define SDMMC_INT_RCRC          RK2818_BIT(6)
85 #define SDMMC_INT_RXDR          RK2818_BIT(5)
86 #define SDMMC_INT_TXDR          RK2818_BIT(4)
87 #define SDMMC_INT_DTO                   RK2818_BIT(3)
88 #define SDMMC_INT_CMD_DONE              RK2818_BIT(2)
89 #define SDMMC_INT_RE            RK2818_BIT(1)
90 #define SDMMC_INT_CD            RK2818_BIT(0)
91
92 /* Command register defines */
93 #define SDMMC_CMD_START         RK2818_BIT(31)
94 #define SDMMC_CMD_CCS_EXP       RK2818_BIT(23)
95 #define SDMMC_CMD_CEATA_RD      RK2818_BIT(22)
96 #define SDMMC_CMD_UPD_CLK       RK2818_BIT(21)
97 #define SDMMC_CMD_INIT          RK2818_BIT(15)
98 #define SDMMC_CMD_STOP          RK2818_BIT(14)
99 #define SDMMC_CMD_PRV_DAT_WAIT  RK2818_BIT(13)
100 #define SDMMC_CMD_SEND_STOP     RK2818_BIT(12)
101 #define SDMMC_CMD_STRM_MODE     RK2818_BIT(11)
102 #define SDMMC_CMD_DAT_WR        RK2818_BIT(10)
103 #define SDMMC_CMD_DAT_EXP       RK2818_BIT(9)
104 #define SDMMC_CMD_RESP_CRC      RK2818_BIT(8)
105 #define SDMMC_CMD_RESP_LONG     RK2818_BIT(7)
106 #define SDMMC_CMD_RESP_EXP      RK2818_BIT(6)
107 #define SDMMC_CMD_INDX(n)       ((n) & 0x1F)
108 /* Status register defines */
109 #define SDMMC_STAUTS_RESP_INDEX RK2818_BIT(11)
110 #define SDMMC_STAUTS_MC_BUSY    RK2818_BIT(10)
111 #define SDMMC_STAUTS_DATA_BUSY  RK2818_BIT(9)
112 #define SDMMC_STAUTS_CARD_PRESENT       RK2818_BIT(8)
113 #define SDMMC_STAUTS_FIFO_FULL  RK2818_BIT(3)
114 #define SDMMC_STAUTS_FIFO_EMPTY RK2818_BIT(2)
115 #define SDMMC_STAUTS_FIFO_TX_WATERMARK  RK2818_BIT(1)
116 #define SDMMC_STAUTS_FIFO_RX_WATERMARK  RK2818_BIT(0)
117
118
119
120
121 #define SDMMC_GET_FCNT(x)       (((x)>>17) & 0x1FF)
122 #define SDMMC_FIFO_SZ           32
123
124 #define SDMMC_WRITE_PROTECT             RK2818_BIT(0)
125 #define SDMMC_CARD_DETECT_N             RK2818_BIT(0)
126
127 /* Specifies how often in millisecs to poll for card removal-insertion changes
128  * when the timer switch is open */
129 #define RK_SDMMC0_SWITCH_POLL_DELAY 35
130
131
132 #endif