xref: /linux/drivers/misc/cardreader/rts5228.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1*849a9366SRicky Wu /* SPDX-License-Identifier: GPL-2.0-only */
2*849a9366SRicky Wu /* Driver for Realtek PCI-Express card reader
3*849a9366SRicky Wu  *
4*849a9366SRicky Wu  * Copyright(c) 2018-2019 Realtek Semiconductor Corp. All rights reserved.
5*849a9366SRicky Wu  *
6*849a9366SRicky Wu  * Author:
7*849a9366SRicky Wu  *   Ricky WU <ricky_wu@realtek.com>
8*849a9366SRicky Wu  *   Rui FENG <rui_feng@realsil.com.cn>
9*849a9366SRicky Wu  *   Wei WANG <wei_wang@realsil.com.cn>
10*849a9366SRicky Wu  */
11*849a9366SRicky Wu #ifndef RTS5228_H
12*849a9366SRicky Wu #define RTS5228_H
13*849a9366SRicky Wu 
14*849a9366SRicky Wu 
15*849a9366SRicky Wu #define RTS5228_AUTOLOAD_CFG0			0xFF7B
16*849a9366SRicky Wu #define RTS5228_AUTOLOAD_CFG1			0xFF7C
17*849a9366SRicky Wu #define RTS5228_AUTOLOAD_CFG2			0xFF7D
18*849a9366SRicky Wu #define RTS5228_AUTOLOAD_CFG3			0xFF7E
19*849a9366SRicky Wu #define RTS5228_AUTOLOAD_CFG4			0xFF7F
20*849a9366SRicky Wu 
21*849a9366SRicky Wu #define RTS5228_REG_VREF			0xFE97
22*849a9366SRicky Wu #define RTS5228_PWD_SUSPND_EN			(1 << 4)
23*849a9366SRicky Wu 
24*849a9366SRicky Wu #define RTS5228_PAD_H3L1			0xFF79
25*849a9366SRicky Wu #define PAD_GPIO_H3L1			(1 << 3)
26*849a9366SRicky Wu 
27*849a9366SRicky Wu /* SSC_CTL2 0xFC12 */
28*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_MASK		0x07
29*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_DISALBE	0x00
30*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_8M		0x01
31*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_4M		0x02
32*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_2M		0x03
33*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_1M		0x04
34*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_512K		0x05
35*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_256K		0x06
36*849a9366SRicky Wu #define RTS5228_SSC_DEPTH_128K		0x07
37*849a9366SRicky Wu 
38*849a9366SRicky Wu /* DMACTL 0xFE2C */
39*849a9366SRicky Wu #define RTS5228_DMA_PACK_SIZE_MASK		0xF0
40*849a9366SRicky Wu 
41*849a9366SRicky Wu #define RTS5228_REG_LDO12_CFG			0xFF6E
42*849a9366SRicky Wu #define RTS5228_LDO12_VO_TUNE_MASK		(0x07<<1)
43*849a9366SRicky Wu #define RTS5228_LDO12_100				(0x00<<1)
44*849a9366SRicky Wu #define RTS5228_LDO12_105				(0x01<<1)
45*849a9366SRicky Wu #define RTS5228_LDO12_110				(0x02<<1)
46*849a9366SRicky Wu #define RTS5228_LDO12_115				(0x03<<1)
47*849a9366SRicky Wu #define RTS5228_LDO12_120				(0x04<<1)
48*849a9366SRicky Wu #define RTS5228_LDO12_125				(0x05<<1)
49*849a9366SRicky Wu #define RTS5228_LDO12_130				(0x06<<1)
50*849a9366SRicky Wu #define RTS5228_LDO12_135				(0x07<<1)
51*849a9366SRicky Wu #define RTS5228_REG_PWD_LDO12			(0x01<<0)
52*849a9366SRicky Wu 
53*849a9366SRicky Wu #define RTS5228_REG_LDO12_L12	0xFF6F
54*849a9366SRicky Wu #define RTS5228_LDO12_L12_MASK			(0x07<<4)
55*849a9366SRicky Wu #define RTS5228_LDO12_L12_120			(0x04<<4)
56*849a9366SRicky Wu 
57*849a9366SRicky Wu /* LDO control register */
58*849a9366SRicky Wu #define RTS5228_CARD_PWR_CTL			0xFD50
59*849a9366SRicky Wu #define RTS5228_PUPDC					(0x01<<5)
60*849a9366SRicky Wu 
61*849a9366SRicky Wu #define RTS5228_LDO1233318_POW_CTL		0xFF70
62*849a9366SRicky Wu #define RTS5228_LDO3318_POWERON			(0x01<<3)
63*849a9366SRicky Wu #define RTS5228_LDO1_POWEROFF			(0x00<<0)
64*849a9366SRicky Wu #define RTS5228_LDO1_SOFTSTART			(0x01<<0)
65*849a9366SRicky Wu #define RTS5228_LDO1_FULLON				(0x03<<0)
66*849a9366SRicky Wu #define RTS5228_LDO1_POWERON_MASK		(0x03<<0)
67*849a9366SRicky Wu #define RTS5228_LDO_POWERON_MASK		(0x0F<<0)
68*849a9366SRicky Wu 
69*849a9366SRicky Wu #define RTS5228_DV3318_CFG				0xFF71
70*849a9366SRicky Wu #define RTS5228_DV3318_TUNE_MASK		(0x07<<4)
71*849a9366SRicky Wu #define RTS5228_DV3318_17				(0x00<<4)
72*849a9366SRicky Wu #define RTS5228_DV3318_1V75				(0x01<<4)
73*849a9366SRicky Wu #define RTS5228_DV3318_18				(0x02<<4)
74*849a9366SRicky Wu #define RTS5228_DV3318_1V85				(0x03<<4)
75*849a9366SRicky Wu #define RTS5228_DV3318_19				(0x04<<4)
76*849a9366SRicky Wu #define RTS5228_DV3318_33				(0x07<<4)
77*849a9366SRicky Wu #define RTS5228_DV3318_SR_MASK			(0x03<<2)
78*849a9366SRicky Wu #define RTS5228_DV3318_SR_0				(0x00<<2)
79*849a9366SRicky Wu #define RTS5228_DV3318_SR_250			(0x01<<2)
80*849a9366SRicky Wu #define RTS5228_DV3318_SR_500			(0x02<<2)
81*849a9366SRicky Wu #define RTS5228_DV3318_SR_1000			(0x03<<2)
82*849a9366SRicky Wu 
83*849a9366SRicky Wu #define RTS5228_LDO1_CFG0				0xFF72
84*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_MASK		(0x07<<5)
85*849a9366SRicky Wu #define RTS5228_LDO1_OCP_EN				(0x01<<4)
86*849a9366SRicky Wu #define RTS5228_LDO1_OCP_LMT_THD_MASK	(0x03<<2)
87*849a9366SRicky Wu #define RTS5228_LDO1_OCP_LMT_EN			(0x01<<1)
88*849a9366SRicky Wu 
89*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_730		(0x00<<5)
90*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_780		(0x01<<5)
91*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_860		(0x02<<5)
92*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_930		(0x03<<5)
93*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_1000		(0x04<<5)
94*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_1070		(0x05<<5)
95*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_1140		(0x06<<5)
96*849a9366SRicky Wu #define RTS5228_LDO1_OCP_THD_1220		(0x07<<5)
97*849a9366SRicky Wu 
98*849a9366SRicky Wu #define RTS5228_LDO1_LMT_THD_450		(0x00<<2)
99*849a9366SRicky Wu #define RTS5228_LDO1_LMT_THD_1000		(0x01<<2)
100*849a9366SRicky Wu #define RTS5228_LDO1_LMT_THD_1500		(0x02<<2)
101*849a9366SRicky Wu #define RTS5228_LDO1_LMT_THD_2000		(0x03<<2)
102*849a9366SRicky Wu 
103*849a9366SRicky Wu #define RTS5228_LDO1_CFG1				0xFF73
104*849a9366SRicky Wu #define RTS5228_LDO1_SR_TIME_MASK		(0x03<<6)
105*849a9366SRicky Wu #define RTS5228_LDO1_SR_0_0				(0x00<<6)
106*849a9366SRicky Wu #define RTS5228_LDO1_SR_0_25			(0x01<<6)
107*849a9366SRicky Wu #define RTS5228_LDO1_SR_0_5				(0x02<<6)
108*849a9366SRicky Wu #define RTS5228_LDO1_SR_1_0				(0x03<<6)
109*849a9366SRicky Wu #define RTS5228_LDO1_TUNE_MASK			(0x07<<1)
110*849a9366SRicky Wu #define RTS5228_LDO1_18					(0x05<<1)
111*849a9366SRicky Wu #define RTS5228_LDO1_33					(0x07<<1)
112*849a9366SRicky Wu #define RTS5228_LDO1_PWD_MASK			(0x01<<0)
113*849a9366SRicky Wu 
114*849a9366SRicky Wu #define RTS5228_AUXCLK_GAT_CTL			0xFF74
115*849a9366SRicky Wu 
116*849a9366SRicky Wu #define RTS5228_REG_RREF_CTL_0			0xFF75
117*849a9366SRicky Wu #define RTS5228_FORCE_RREF_EXTL			(0x01<<7)
118*849a9366SRicky Wu #define RTS5228_REG_BG33_MASK			(0x07<<0)
119*849a9366SRicky Wu #define RTS5228_RREF_12_1V				(0x04<<0)
120*849a9366SRicky Wu #define RTS5228_RREF_12_3V				(0x05<<0)
121*849a9366SRicky Wu 
122*849a9366SRicky Wu #define RTS5228_REG_RREF_CTL_1			0xFF76
123*849a9366SRicky Wu 
124*849a9366SRicky Wu #define RTS5228_REG_RREF_CTL_2			0xFF77
125*849a9366SRicky Wu #define RTS5228_TEST_INTL_RREF			(0x01<<7)
126*849a9366SRicky Wu #define RTS5228_DGLCH_TIME_MASK			(0x03<<5)
127*849a9366SRicky Wu #define RTS5228_DGLCH_TIME_50			(0x00<<5)
128*849a9366SRicky Wu #define RTS5228_DGLCH_TIME_75			(0x01<<5)
129*849a9366SRicky Wu #define RTS5228_DGLCH_TIME_100			(0x02<<5)
130*849a9366SRicky Wu #define RTS5228_DGLCH_TIME_125			(0x03<<5)
131*849a9366SRicky Wu #define RTS5228_REG_REXT_TUNE_MASK		(0x1F<<0)
132*849a9366SRicky Wu 
133*849a9366SRicky Wu #define RTS5228_REG_PME_FORCE_CTL		0xFF78
134*849a9366SRicky Wu #define FORCE_PM_CONTROL		0x20
135*849a9366SRicky Wu #define FORCE_PM_VALUE			0x10
136*849a9366SRicky Wu 
137*849a9366SRicky Wu 
138*849a9366SRicky Wu /* Single LUN, support SD */
139*849a9366SRicky Wu #define DEFAULT_SINGLE		0
140*849a9366SRicky Wu #define SD_LUN				1
141*849a9366SRicky Wu 
142*849a9366SRicky Wu 
143*849a9366SRicky Wu /* For Change_FPGA_SSCClock Function */
144*849a9366SRicky Wu #define MULTIPLY_BY_1    0x00
145*849a9366SRicky Wu #define MULTIPLY_BY_2    0x01
146*849a9366SRicky Wu #define MULTIPLY_BY_3    0x02
147*849a9366SRicky Wu #define MULTIPLY_BY_4    0x03
148*849a9366SRicky Wu #define MULTIPLY_BY_5    0x04
149*849a9366SRicky Wu #define MULTIPLY_BY_6    0x05
150*849a9366SRicky Wu #define MULTIPLY_BY_7    0x06
151*849a9366SRicky Wu #define MULTIPLY_BY_8    0x07
152*849a9366SRicky Wu #define MULTIPLY_BY_9    0x08
153*849a9366SRicky Wu #define MULTIPLY_BY_10   0x09
154*849a9366SRicky Wu 
155*849a9366SRicky Wu #define DIVIDE_BY_2      0x01
156*849a9366SRicky Wu #define DIVIDE_BY_3      0x02
157*849a9366SRicky Wu #define DIVIDE_BY_4      0x03
158*849a9366SRicky Wu #define DIVIDE_BY_5      0x04
159*849a9366SRicky Wu #define DIVIDE_BY_6      0x05
160*849a9366SRicky Wu #define DIVIDE_BY_7      0x06
161*849a9366SRicky Wu #define DIVIDE_BY_8      0x07
162*849a9366SRicky Wu #define DIVIDE_BY_9      0x08
163*849a9366SRicky Wu #define DIVIDE_BY_10     0x09
164*849a9366SRicky Wu 
165*849a9366SRicky Wu int rts5228_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
166*849a9366SRicky Wu 		u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk);
167*849a9366SRicky Wu 
168*849a9366SRicky Wu #endif /* RTS5228_H */
169