18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2010 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Authors: Alex Deucher
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#ifndef _BTCD_H_
258c2ecf20Sopenharmony_ci#define _BTCD_H_
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* pm registers */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define GENERAL_PWRMGT                                  0x63c
308c2ecf20Sopenharmony_ci#       define GLOBAL_PWRMGT_EN                         (1 << 0)
318c2ecf20Sopenharmony_ci#       define STATIC_PM_EN                             (1 << 1)
328c2ecf20Sopenharmony_ci#       define THERMAL_PROTECTION_DIS                   (1 << 2)
338c2ecf20Sopenharmony_ci#       define THERMAL_PROTECTION_TYPE                  (1 << 3)
348c2ecf20Sopenharmony_ci#       define ENABLE_GEN2PCIE                          (1 << 4)
358c2ecf20Sopenharmony_ci#       define ENABLE_GEN2XSP                           (1 << 5)
368c2ecf20Sopenharmony_ci#       define SW_SMIO_INDEX(x)                         ((x) << 6)
378c2ecf20Sopenharmony_ci#       define SW_SMIO_INDEX_MASK                       (3 << 6)
388c2ecf20Sopenharmony_ci#       define SW_SMIO_INDEX_SHIFT                      6
398c2ecf20Sopenharmony_ci#       define LOW_VOLT_D2_ACPI                         (1 << 8)
408c2ecf20Sopenharmony_ci#       define LOW_VOLT_D3_ACPI                         (1 << 9)
418c2ecf20Sopenharmony_ci#       define VOLT_PWRMGT_EN                           (1 << 10)
428c2ecf20Sopenharmony_ci#       define BACKBIAS_PAD_EN                          (1 << 18)
438c2ecf20Sopenharmony_ci#       define BACKBIAS_VALUE                           (1 << 19)
448c2ecf20Sopenharmony_ci#       define DYN_SPREAD_SPECTRUM_EN                   (1 << 23)
458c2ecf20Sopenharmony_ci#       define AC_DC_SW                                 (1 << 24)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define TARGET_AND_CURRENT_PROFILE_INDEX                  0x66c
488c2ecf20Sopenharmony_ci#       define CURRENT_PROFILE_INDEX_MASK                 (0xf << 4)
498c2ecf20Sopenharmony_ci#       define CURRENT_PROFILE_INDEX_SHIFT                4
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define	CG_BIF_REQ_AND_RSP				0x7f4
528c2ecf20Sopenharmony_ci#define		CG_CLIENT_REQ(x)			((x) << 0)
538c2ecf20Sopenharmony_ci#define		CG_CLIENT_REQ_MASK			(0xff << 0)
548c2ecf20Sopenharmony_ci#define		CG_CLIENT_REQ_SHIFT			0
558c2ecf20Sopenharmony_ci#define		CG_CLIENT_RESP(x)			((x) << 8)
568c2ecf20Sopenharmony_ci#define		CG_CLIENT_RESP_MASK			(0xff << 8)
578c2ecf20Sopenharmony_ci#define		CG_CLIENT_RESP_SHIFT			8
588c2ecf20Sopenharmony_ci#define		CLIENT_CG_REQ(x)			((x) << 16)
598c2ecf20Sopenharmony_ci#define		CLIENT_CG_REQ_MASK			(0xff << 16)
608c2ecf20Sopenharmony_ci#define		CLIENT_CG_REQ_SHIFT			16
618c2ecf20Sopenharmony_ci#define		CLIENT_CG_RESP(x)			((x) << 24)
628c2ecf20Sopenharmony_ci#define		CLIENT_CG_RESP_MASK			(0xff << 24)
638c2ecf20Sopenharmony_ci#define		CLIENT_CG_RESP_SHIFT			24
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define	SCLK_PSKIP_CNTL					0x8c0
668c2ecf20Sopenharmony_ci#define		PSKIP_ON_ALLOW_STOP_HI(x)		((x) << 16)
678c2ecf20Sopenharmony_ci#define		PSKIP_ON_ALLOW_STOP_HI_MASK		(0xff << 16)
688c2ecf20Sopenharmony_ci#define		PSKIP_ON_ALLOW_STOP_HI_SHIFT		16
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define	CG_ULV_CONTROL					0x8c8
718c2ecf20Sopenharmony_ci#define	CG_ULV_PARAMETER				0x8cc
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define	MC_ARB_DRAM_TIMING				0x2774
748c2ecf20Sopenharmony_ci#define	MC_ARB_DRAM_TIMING2				0x2778
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define	MC_ARB_RFSH_RATE				0x27b0
778c2ecf20Sopenharmony_ci#define		POWERMODE0(x)				((x) << 0)
788c2ecf20Sopenharmony_ci#define		POWERMODE0_MASK				(0xff << 0)
798c2ecf20Sopenharmony_ci#define		POWERMODE0_SHIFT			0
808c2ecf20Sopenharmony_ci#define		POWERMODE1(x)				((x) << 8)
818c2ecf20Sopenharmony_ci#define		POWERMODE1_MASK				(0xff << 8)
828c2ecf20Sopenharmony_ci#define		POWERMODE1_SHIFT			8
838c2ecf20Sopenharmony_ci#define		POWERMODE2(x)				((x) << 16)
848c2ecf20Sopenharmony_ci#define		POWERMODE2_MASK				(0xff << 16)
858c2ecf20Sopenharmony_ci#define		POWERMODE2_SHIFT			16
868c2ecf20Sopenharmony_ci#define		POWERMODE3(x)				((x) << 24)
878c2ecf20Sopenharmony_ci#define		POWERMODE3_MASK				(0xff << 24)
888c2ecf20Sopenharmony_ci#define		POWERMODE3_SHIFT			24
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define MC_ARB_BURST_TIME                               0x2808
918c2ecf20Sopenharmony_ci#define		STATE0(x)				((x) << 0)
928c2ecf20Sopenharmony_ci#define		STATE0_MASK				(0x1f << 0)
938c2ecf20Sopenharmony_ci#define		STATE0_SHIFT				0
948c2ecf20Sopenharmony_ci#define		STATE1(x)				((x) << 5)
958c2ecf20Sopenharmony_ci#define		STATE1_MASK				(0x1f << 5)
968c2ecf20Sopenharmony_ci#define		STATE1_SHIFT				5
978c2ecf20Sopenharmony_ci#define		STATE2(x)				((x) << 10)
988c2ecf20Sopenharmony_ci#define		STATE2_MASK				(0x1f << 10)
998c2ecf20Sopenharmony_ci#define		STATE2_SHIFT				10
1008c2ecf20Sopenharmony_ci#define		STATE3(x)				((x) << 15)
1018c2ecf20Sopenharmony_ci#define		STATE3_MASK				(0x1f << 15)
1028c2ecf20Sopenharmony_ci#define		STATE3_SHIFT				15
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define MC_SEQ_RAS_TIMING                               0x28a0
1058c2ecf20Sopenharmony_ci#define MC_SEQ_CAS_TIMING                               0x28a4
1068c2ecf20Sopenharmony_ci#define MC_SEQ_MISC_TIMING                              0x28a8
1078c2ecf20Sopenharmony_ci#define MC_SEQ_MISC_TIMING2                             0x28ac
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define MC_SEQ_RD_CTL_D0                                0x28b4
1108c2ecf20Sopenharmony_ci#define MC_SEQ_RD_CTL_D1                                0x28b8
1118c2ecf20Sopenharmony_ci#define MC_SEQ_WR_CTL_D0                                0x28bc
1128c2ecf20Sopenharmony_ci#define MC_SEQ_WR_CTL_D1                                0x28c0
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define MC_PMG_AUTO_CFG                                 0x28d4
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define MC_SEQ_STATUS_M                                 0x29f4
1178c2ecf20Sopenharmony_ci#       define PMG_PWRSTATE                             (1 << 16)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0                                    0x2a00
1208c2ecf20Sopenharmony_ci#define         MC_SEQ_MISC0_GDDR5_SHIFT                28
1218c2ecf20Sopenharmony_ci#define         MC_SEQ_MISC0_GDDR5_MASK                 0xf0000000
1228c2ecf20Sopenharmony_ci#define         MC_SEQ_MISC0_GDDR5_VALUE                5
1238c2ecf20Sopenharmony_ci#define MC_SEQ_MISC1                                    0x2a04
1248c2ecf20Sopenharmony_ci#define MC_SEQ_RESERVE_M                                0x2a08
1258c2ecf20Sopenharmony_ci#define MC_PMG_CMD_EMRS                                 0x2a0c
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define MC_SEQ_MISC3                                    0x2a2c
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define MC_SEQ_MISC5                                    0x2a54
1308c2ecf20Sopenharmony_ci#define MC_SEQ_MISC6                                    0x2a58
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define MC_SEQ_MISC7                                    0x2a64
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define MC_SEQ_CG                                       0x2a68
1358c2ecf20Sopenharmony_ci#define		CG_SEQ_REQ(x)				((x) << 0)
1368c2ecf20Sopenharmony_ci#define		CG_SEQ_REQ_MASK				(0xff << 0)
1378c2ecf20Sopenharmony_ci#define		CG_SEQ_REQ_SHIFT			0
1388c2ecf20Sopenharmony_ci#define		CG_SEQ_RESP(x)				((x) << 8)
1398c2ecf20Sopenharmony_ci#define		CG_SEQ_RESP_MASK			(0xff << 8)
1408c2ecf20Sopenharmony_ci#define		CG_SEQ_RESP_SHIFT			8
1418c2ecf20Sopenharmony_ci#define		SEQ_CG_REQ(x)				((x) << 16)
1428c2ecf20Sopenharmony_ci#define		SEQ_CG_REQ_MASK				(0xff << 16)
1438c2ecf20Sopenharmony_ci#define		SEQ_CG_REQ_SHIFT			16
1448c2ecf20Sopenharmony_ci#define		SEQ_CG_RESP(x)				((x) << 24)
1458c2ecf20Sopenharmony_ci#define		SEQ_CG_RESP_MASK			(0xff << 24)
1468c2ecf20Sopenharmony_ci#define		SEQ_CG_RESP_SHIFT			24
1478c2ecf20Sopenharmony_ci#define MC_SEQ_RAS_TIMING_LP                            0x2a6c
1488c2ecf20Sopenharmony_ci#define MC_SEQ_CAS_TIMING_LP                            0x2a70
1498c2ecf20Sopenharmony_ci#define MC_SEQ_MISC_TIMING_LP                           0x2a74
1508c2ecf20Sopenharmony_ci#define MC_SEQ_MISC_TIMING2_LP                          0x2a78
1518c2ecf20Sopenharmony_ci#define MC_SEQ_WR_CTL_D0_LP                             0x2a7c
1528c2ecf20Sopenharmony_ci#define MC_SEQ_WR_CTL_D1_LP                             0x2a80
1538c2ecf20Sopenharmony_ci#define MC_SEQ_PMG_CMD_EMRS_LP                          0x2a84
1548c2ecf20Sopenharmony_ci#define MC_SEQ_PMG_CMD_MRS_LP                           0x2a88
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define MC_PMG_CMD_MRS                                  0x2aac
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define MC_SEQ_RD_CTL_D0_LP                             0x2b1c
1598c2ecf20Sopenharmony_ci#define MC_SEQ_RD_CTL_D1_LP                             0x2b20
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci#define MC_PMG_CMD_MRS1                                 0x2b44
1628c2ecf20Sopenharmony_ci#define MC_SEQ_PMG_CMD_MRS1_LP                          0x2b48
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define	LB_SYNC_RESET_SEL				0x6b28
1658c2ecf20Sopenharmony_ci#define		LB_SYNC_RESET_SEL_MASK			(3 << 0)
1668c2ecf20Sopenharmony_ci#define		LB_SYNC_RESET_SEL_SHIFT			0
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci/* PCIE link stuff */
1698c2ecf20Sopenharmony_ci#define PCIE_LC_SPEED_CNTL                                0xa4 /* PCIE_P */
1708c2ecf20Sopenharmony_ci#       define LC_GEN2_EN_STRAP                           (1 << 0)
1718c2ecf20Sopenharmony_ci#       define LC_TARGET_LINK_SPEED_OVERRIDE_EN           (1 << 1)
1728c2ecf20Sopenharmony_ci#       define LC_FORCE_EN_HW_SPEED_CHANGE                (1 << 5)
1738c2ecf20Sopenharmony_ci#       define LC_FORCE_DIS_HW_SPEED_CHANGE               (1 << 6)
1748c2ecf20Sopenharmony_ci#       define LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_MASK      (0x3 << 8)
1758c2ecf20Sopenharmony_ci#       define LC_SPEED_CHANGE_ATTEMPTS_ALLOWED_SHIFT     3
1768c2ecf20Sopenharmony_ci#       define LC_CURRENT_DATA_RATE                       (1 << 11)
1778c2ecf20Sopenharmony_ci#       define LC_HW_VOLTAGE_IF_CONTROL(x)                ((x) << 12)
1788c2ecf20Sopenharmony_ci#       define LC_HW_VOLTAGE_IF_CONTROL_MASK              (3 << 12)
1798c2ecf20Sopenharmony_ci#       define LC_HW_VOLTAGE_IF_CONTROL_SHIFT             12
1808c2ecf20Sopenharmony_ci#       define LC_VOLTAGE_TIMER_SEL_MASK                  (0xf << 14)
1818c2ecf20Sopenharmony_ci#       define LC_CLR_FAILED_SPD_CHANGE_CNT               (1 << 21)
1828c2ecf20Sopenharmony_ci#       define LC_OTHER_SIDE_EVER_SENT_GEN2               (1 << 23)
1838c2ecf20Sopenharmony_ci#       define LC_OTHER_SIDE_SUPPORTS_GEN2                (1 << 24)
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#endif
186