18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/* Driver for Realtek PCI-Express card reader
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright(c) 2018-2019 Realtek Semiconductor Corp. All rights reserved.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Author:
78c2ecf20Sopenharmony_ci *   Ricky WU <ricky_wu@realtek.com>
88c2ecf20Sopenharmony_ci *   Rui FENG <rui_feng@realsil.com.cn>
98c2ecf20Sopenharmony_ci *   Wei WANG <wei_wang@realsil.com.cn>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#ifndef RTS5228_H
128c2ecf20Sopenharmony_ci#define RTS5228_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define RTS5228_AUTOLOAD_CFG0			0xFF7B
168c2ecf20Sopenharmony_ci#define RTS5228_AUTOLOAD_CFG1			0xFF7C
178c2ecf20Sopenharmony_ci#define RTS5228_AUTOLOAD_CFG2			0xFF7D
188c2ecf20Sopenharmony_ci#define RTS5228_AUTOLOAD_CFG3			0xFF7E
198c2ecf20Sopenharmony_ci#define RTS5228_AUTOLOAD_CFG4			0xFF7F
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define RTS5228_REG_VREF			0xFE97
228c2ecf20Sopenharmony_ci#define RTS5228_PWD_SUSPND_EN			(1 << 4)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define RTS5228_PAD_H3L1			0xFF79
258c2ecf20Sopenharmony_ci#define PAD_GPIO_H3L1			(1 << 3)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* SSC_CTL2 0xFC12 */
288c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_MASK		0x07
298c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_DISALBE	0x00
308c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_8M		0x01
318c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_4M		0x02
328c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_2M		0x03
338c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_1M		0x04
348c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_512K		0x05
358c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_256K		0x06
368c2ecf20Sopenharmony_ci#define RTS5228_SSC_DEPTH_128K		0x07
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* DMACTL 0xFE2C */
398c2ecf20Sopenharmony_ci#define RTS5228_DMA_PACK_SIZE_MASK		0xF0
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define RTS5228_REG_LDO12_CFG			0xFF6E
428c2ecf20Sopenharmony_ci#define RTS5228_LDO12_VO_TUNE_MASK		(0x07<<1)
438c2ecf20Sopenharmony_ci#define RTS5228_LDO12_100				(0x00<<1)
448c2ecf20Sopenharmony_ci#define RTS5228_LDO12_105				(0x01<<1)
458c2ecf20Sopenharmony_ci#define RTS5228_LDO12_110				(0x02<<1)
468c2ecf20Sopenharmony_ci#define RTS5228_LDO12_115				(0x03<<1)
478c2ecf20Sopenharmony_ci#define RTS5228_LDO12_120				(0x04<<1)
488c2ecf20Sopenharmony_ci#define RTS5228_LDO12_125				(0x05<<1)
498c2ecf20Sopenharmony_ci#define RTS5228_LDO12_130				(0x06<<1)
508c2ecf20Sopenharmony_ci#define RTS5228_LDO12_135				(0x07<<1)
518c2ecf20Sopenharmony_ci#define RTS5228_REG_PWD_LDO12			(0x01<<0)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define RTS5228_REG_LDO12_L12	0xFF6F
548c2ecf20Sopenharmony_ci#define RTS5228_LDO12_L12_MASK			(0x07<<4)
558c2ecf20Sopenharmony_ci#define RTS5228_LDO12_L12_120			(0x04<<4)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* LDO control register */
588c2ecf20Sopenharmony_ci#define RTS5228_CARD_PWR_CTL			0xFD50
598c2ecf20Sopenharmony_ci#define RTS5228_PUPDC					(0x01<<5)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define RTS5228_LDO1233318_POW_CTL		0xFF70
628c2ecf20Sopenharmony_ci#define RTS5228_LDO3318_POWERON			(0x01<<3)
638c2ecf20Sopenharmony_ci#define RTS5228_LDO1_POWEROFF			(0x00<<0)
648c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SOFTSTART			(0x01<<0)
658c2ecf20Sopenharmony_ci#define RTS5228_LDO1_FULLON				(0x03<<0)
668c2ecf20Sopenharmony_ci#define RTS5228_LDO1_POWERON_MASK		(0x03<<0)
678c2ecf20Sopenharmony_ci#define RTS5228_LDO_POWERON_MASK		(0x0F<<0)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define RTS5228_DV3318_CFG				0xFF71
708c2ecf20Sopenharmony_ci#define RTS5228_DV3318_TUNE_MASK		(0x07<<4)
718c2ecf20Sopenharmony_ci#define RTS5228_DV3318_17				(0x00<<4)
728c2ecf20Sopenharmony_ci#define RTS5228_DV3318_1V75				(0x01<<4)
738c2ecf20Sopenharmony_ci#define RTS5228_DV3318_18				(0x02<<4)
748c2ecf20Sopenharmony_ci#define RTS5228_DV3318_1V85				(0x03<<4)
758c2ecf20Sopenharmony_ci#define RTS5228_DV3318_19				(0x04<<4)
768c2ecf20Sopenharmony_ci#define RTS5228_DV3318_33				(0x07<<4)
778c2ecf20Sopenharmony_ci#define RTS5228_DV3318_SR_MASK			(0x03<<2)
788c2ecf20Sopenharmony_ci#define RTS5228_DV3318_SR_0				(0x00<<2)
798c2ecf20Sopenharmony_ci#define RTS5228_DV3318_SR_250			(0x01<<2)
808c2ecf20Sopenharmony_ci#define RTS5228_DV3318_SR_500			(0x02<<2)
818c2ecf20Sopenharmony_ci#define RTS5228_DV3318_SR_1000			(0x03<<2)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#define RTS5228_LDO1_CFG0				0xFF72
848c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_MASK		(0x07<<5)
858c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_EN				(0x01<<4)
868c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_LMT_THD_MASK	(0x03<<2)
878c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_LMT_EN			(0x01<<1)
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_730		(0x00<<5)
908c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_780		(0x01<<5)
918c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_860		(0x02<<5)
928c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_930		(0x03<<5)
938c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_1000		(0x04<<5)
948c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_1070		(0x05<<5)
958c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_1140		(0x06<<5)
968c2ecf20Sopenharmony_ci#define RTS5228_LDO1_OCP_THD_1220		(0x07<<5)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define RTS5228_LDO1_LMT_THD_450		(0x00<<2)
998c2ecf20Sopenharmony_ci#define RTS5228_LDO1_LMT_THD_1000		(0x01<<2)
1008c2ecf20Sopenharmony_ci#define RTS5228_LDO1_LMT_THD_1500		(0x02<<2)
1018c2ecf20Sopenharmony_ci#define RTS5228_LDO1_LMT_THD_2000		(0x03<<2)
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define RTS5228_LDO1_CFG1				0xFF73
1048c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SR_TIME_MASK		(0x03<<6)
1058c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SR_0_0				(0x00<<6)
1068c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SR_0_25			(0x01<<6)
1078c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SR_0_5				(0x02<<6)
1088c2ecf20Sopenharmony_ci#define RTS5228_LDO1_SR_1_0				(0x03<<6)
1098c2ecf20Sopenharmony_ci#define RTS5228_LDO1_TUNE_MASK			(0x07<<1)
1108c2ecf20Sopenharmony_ci#define RTS5228_LDO1_18					(0x05<<1)
1118c2ecf20Sopenharmony_ci#define RTS5228_LDO1_33					(0x07<<1)
1128c2ecf20Sopenharmony_ci#define RTS5228_LDO1_PWD_MASK			(0x01<<0)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define RTS5228_AUXCLK_GAT_CTL			0xFF74
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define RTS5228_REG_RREF_CTL_0			0xFF75
1178c2ecf20Sopenharmony_ci#define RTS5228_FORCE_RREF_EXTL			(0x01<<7)
1188c2ecf20Sopenharmony_ci#define RTS5228_REG_BG33_MASK			(0x07<<0)
1198c2ecf20Sopenharmony_ci#define RTS5228_RREF_12_1V				(0x04<<0)
1208c2ecf20Sopenharmony_ci#define RTS5228_RREF_12_3V				(0x05<<0)
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#define RTS5228_REG_RREF_CTL_1			0xFF76
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define RTS5228_REG_RREF_CTL_2			0xFF77
1258c2ecf20Sopenharmony_ci#define RTS5228_TEST_INTL_RREF			(0x01<<7)
1268c2ecf20Sopenharmony_ci#define RTS5228_DGLCH_TIME_MASK			(0x03<<5)
1278c2ecf20Sopenharmony_ci#define RTS5228_DGLCH_TIME_50			(0x00<<5)
1288c2ecf20Sopenharmony_ci#define RTS5228_DGLCH_TIME_75			(0x01<<5)
1298c2ecf20Sopenharmony_ci#define RTS5228_DGLCH_TIME_100			(0x02<<5)
1308c2ecf20Sopenharmony_ci#define RTS5228_DGLCH_TIME_125			(0x03<<5)
1318c2ecf20Sopenharmony_ci#define RTS5228_REG_REXT_TUNE_MASK		(0x1F<<0)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define RTS5228_REG_PME_FORCE_CTL		0xFF78
1348c2ecf20Sopenharmony_ci#define FORCE_PM_CONTROL		0x20
1358c2ecf20Sopenharmony_ci#define FORCE_PM_VALUE			0x10
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* Single LUN, support SD */
1398c2ecf20Sopenharmony_ci#define DEFAULT_SINGLE		0
1408c2ecf20Sopenharmony_ci#define SD_LUN				1
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/* For Change_FPGA_SSCClock Function */
1448c2ecf20Sopenharmony_ci#define MULTIPLY_BY_1    0x00
1458c2ecf20Sopenharmony_ci#define MULTIPLY_BY_2    0x01
1468c2ecf20Sopenharmony_ci#define MULTIPLY_BY_3    0x02
1478c2ecf20Sopenharmony_ci#define MULTIPLY_BY_4    0x03
1488c2ecf20Sopenharmony_ci#define MULTIPLY_BY_5    0x04
1498c2ecf20Sopenharmony_ci#define MULTIPLY_BY_6    0x05
1508c2ecf20Sopenharmony_ci#define MULTIPLY_BY_7    0x06
1518c2ecf20Sopenharmony_ci#define MULTIPLY_BY_8    0x07
1528c2ecf20Sopenharmony_ci#define MULTIPLY_BY_9    0x08
1538c2ecf20Sopenharmony_ci#define MULTIPLY_BY_10   0x09
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci#define DIVIDE_BY_2      0x01
1568c2ecf20Sopenharmony_ci#define DIVIDE_BY_3      0x02
1578c2ecf20Sopenharmony_ci#define DIVIDE_BY_4      0x03
1588c2ecf20Sopenharmony_ci#define DIVIDE_BY_5      0x04
1598c2ecf20Sopenharmony_ci#define DIVIDE_BY_6      0x05
1608c2ecf20Sopenharmony_ci#define DIVIDE_BY_7      0x06
1618c2ecf20Sopenharmony_ci#define DIVIDE_BY_8      0x07
1628c2ecf20Sopenharmony_ci#define DIVIDE_BY_9      0x08
1638c2ecf20Sopenharmony_ci#define DIVIDE_BY_10     0x09
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ciint rts5228_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,
1668c2ecf20Sopenharmony_ci		u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk);
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#endif /* RTS5228_H */
169