| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
enum { |
| 5 |
UP_TAG_BASE = 0x60000000, |
| 6 |
TIMER_BASE = 0x60005000, |
| 7 |
CLK_RST_BASE = 0x60006000, |
| 8 |
FLOW_CTLR_BASE = 0x60007000, |
| 9 |
SECURE_BOOT_BASE = 0x6000C200, |
| 10 |
TEGRA_EVP_BASE = 0x6000f000, |
| 11 |
APB_MISC_BASE = 0x70000000, |
| 12 |
PINMUX_BASE = 0x70003000, |
| 13 |
PMC_CTLR_BASE = 0x7000e400, |
| 14 |
MC_CTLR_BASE = 0x70019000, |
| 15 |
FUSE_BASE = 0x7000F800, |
| 16 |
TEGRA_SDMMC1_BASE = 0x700b0000, |
| 17 |
TEGRA_SDMMC3_BASE = 0x700b0400, |
| 18 |
EMC_BASE = 0x7001B000, |
| 19 |
I2C5_BASE = 0x7000D000, |
| 20 |
I2S_BASE = 0x702d1000 |
| 21 |
}; |
| 22 |
|
| 23 |
|
| 24 |
static uint32_t *up_tag_ptr = (void *)(UP_TAG_BASE + 0x0); |
| 25 |
enum { |
| 26 |
UP_TAG_AVP = 0xaaaaaaaa |
| 27 |
}; |
| 28 |
|
| 29 |
|
| 30 |
static uint32_t *misc_pp_config_ctl_ptr = (void *)(APB_MISC_BASE + 0x24); |
| 31 |
enum { |
| 32 |
PP_CONFIG_CTL_TBE = 0x1 << 7, |
| 33 |
PP_CONFIG_CTL_JTAG = 0x1 << 6 |
| 34 |
}; |
| 35 |
|
| 36 |
static uint32_t *misc_gp_asdbgreg_ptr = (void *)(APB_MISC_BASE + 0x810); |
| 37 |
enum { |
| 38 |
CFG2TMC_RAM_SVOP_PDP_MASK = 0x3 << 24, |
| 39 |
CFG2TMC_RAM_SVOP_PDP_VAL_2 = 0x2 << 24, |
| 40 |
}; |
| 41 |
|
| 42 |
|
| 43 |
static uint32_t *pinmux_pwr_i2c_scl_ptr = (void *)(PINMUX_BASE + 0xdc); |
| 44 |
static uint32_t *pinmux_pwr_i2c_sda_ptr = (void *)(PINMUX_BASE + 0xe0); |
| 45 |
static uint32_t *pinmux_dvfs_pwm_ptr = (void *)(PINMUX_BASE + 0x184); |
| 46 |
static uint32_t *pinmux_gpio_pa6_ptr = (void *)(PINMUX_BASE + 0x244); |
| 47 |
enum { |
| 48 |
E_INPUT = 1 << 6, |
| 49 |
TRISTATE = 1 << 4, |
| 50 |
PM_CLDVFS = 1, |
| 51 |
PM_I2CPMU = 0 |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
static uint32_t *timer_us_ptr = (void *)(TIMER_BASE + 0x10); |
| 56 |
static uint32_t *timer_us_cfg_ptr = (void *)(TIMER_BASE + 0x14); |
| 57 |
|
| 58 |
|
| 59 |
static uint32_t *clk_rst_rst_devices_l_ptr = (void *)(CLK_RST_BASE + 0x4); |
| 60 |
enum { |
| 61 |
SWR_TRIG_SYS_RST = 0x1 << 2 |
| 62 |
}; |
| 63 |
|
| 64 |
static uint32_t *clk_rst_rst_devices_u_ptr = (void *)(CLK_RST_BASE + 0xc); |
| 65 |
|
| 66 |
static uint32_t *clk_rst_cclkg_burst_policy_ptr = (void *)(CLK_RST_BASE + 0x368); |
| 67 |
enum { |
| 68 |
CCLKG_PLLP_BURST_POLICY = 0x20004444 |
| 69 |
}; |
| 70 |
|
| 71 |
static uint32_t *clk_rst_cclklp_burst_policy_ptr = (void *)(CLK_RST_BASE + 0x370); |
| 72 |
enum { |
| 73 |
CCLKLP_PLLP_BURST_POLICY = 0x20004444 |
| 74 |
}; |
| 75 |
|
| 76 |
static uint32_t *clk_rst_super_cclkg_div_ptr = (void *)(CLK_RST_BASE + 0x36c); |
| 77 |
static uint32_t *clk_rst_super_cclklp_div_ptr = (void *)(CLK_RST_BASE + 0x374); |
| 78 |
enum { |
| 79 |
SUPER_CDIV_ENB = 0x1 << 31 |
| 80 |
}; |
| 81 |
|
| 82 |
static uint32_t *clk_rst_osc_ctrl_ptr = (void *)(CLK_RST_BASE + 0x50); |
| 83 |
enum { |
| 84 |
OSC_XOE = 0x1 << 0, |
| 85 |
OSC_XOFS_SHIFT = 4, |
| 86 |
OSC_XOFS_MASK = 0x3f << OSC_XOFS_SHIFT, |
| 87 |
OSC_FREQ_SHIFT = 28, |
| 88 |
OSC_FREQ_MASK = 0xf << OSC_FREQ_SHIFT |
| 89 |
}; |
| 90 |
|
| 91 |
static uint32_t *clk_rst_pllx_base_ptr = (void *)(CLK_RST_BASE + 0xe0); |
| 92 |
enum { |
| 93 |
PLLX_ENABLE = 0x1 << 30 |
| 94 |
}; |
| 95 |
|
| 96 |
static uint32_t *clk_rst_clk_source_i2c5_ptr = (void *)(CLK_RST_BASE + 0x128); |
| 97 |
enum { |
| 98 |
I2C5_CLK_DIVISOR = 4 |
| 99 |
}; |
| 100 |
|
| 101 |
static uint32_t *clk_rst_rst_dev_h_set_ptr = (void *)(CLK_RST_BASE + 0x308); |
| 102 |
enum { |
| 103 |
I2C5_RST = 0x1 << 15 |
| 104 |
}; |
| 105 |
|
| 106 |
static uint32_t *clk_rst_rst_dev_h_clr_ptr = (void *)(CLK_RST_BASE + 0x30c); |
| 107 |
|
| 108 |
static uint32_t *clk_rst_rst_dev_u_clr_ptr = (void *)(CLK_RST_BASE + 0x314); |
| 109 |
enum { |
| 110 |
SWR_CSITE_RST = 0x1 << 9 |
| 111 |
}; |
| 112 |
|
| 113 |
static uint32_t *clk_rst_rst_dev_v_clr_ptr = (void *)(CLK_RST_BASE + 0x434); |
| 114 |
enum { |
| 115 |
MSELECT_RST = 0x1 << 3 |
| 116 |
}; |
| 117 |
|
| 118 |
static uint32_t *clk_rst_clk_enb_l_set_ptr = (void *)(CLK_RST_BASE + 0x320); |
| 119 |
enum { |
| 120 |
CLK_ENB_CPU = 0x1 << 0 |
| 121 |
}; |
| 122 |
|
| 123 |
static uint32_t *clk_rst_clk_enb_h_set_ptr = (void *)(CLK_RST_BASE + 0x328); |
| 124 |
enum { |
| 125 |
CLK_ENB_I2C5 = 0x1 << 15 |
| 126 |
}; |
| 127 |
|
| 128 |
static uint32_t *clk_rst_clk_out_enb_u_set_ptr = |
| 129 |
(void *)(CLK_RST_BASE + 0x330); |
| 130 |
enum { |
| 131 |
CLK_ENB_CSITE = 0x1 << 9 |
| 132 |
}; |
| 133 |
|
| 134 |
static uint32_t *clk_rst_cpu_softrst_ctrl2_ptr = |
| 135 |
(void *)(CLK_RST_BASE + 0x388); |
| 136 |
enum { |
| 137 |
CAR2PMC_CPU_ACK_WIDTH_SHIFT = 0, |
| 138 |
CAR2PMC_CPU_ACK_WIDTH_MASK = 0xfff << CAR2PMC_CPU_ACK_WIDTH_SHIFT |
| 139 |
}; |
| 140 |
|
| 141 |
static uint32_t *clk_rst_clk_enb_v_set_ptr = (void *)(CLK_RST_BASE + 0x440); |
| 142 |
enum { |
| 143 |
CLK_ENB_CPUG = 0x1 << 0, |
| 144 |
}; |
| 145 |
|
| 146 |
static uint32_t *clk_rst_clk_enb_y_set_ptr = (void *)(CLK_RST_BASE + 0x29c); |
| 147 |
enum { |
| 148 |
CLK_ENB_PLLP_OUT_CPU = 0x1 << 31 |
| 149 |
}; |
| 150 |
|
| 151 |
static uint32_t *clk_rst_cpug_cmplx_clr_ptr = |
| 152 |
(void *)(CLK_RST_BASE + 0x454); |
| 153 |
enum { |
| 154 |
CLR_CPURESET0 = 0x1 << 0, |
| 155 |
CLR_CPURESET1 = 0x1 << 1, |
| 156 |
CLR_CPURESET2 = 0x1 << 2, |
| 157 |
CLR_CPURESET3 = 0x1 << 3, |
| 158 |
CLR_DBGRESET0 = 0x1 << 12, |
| 159 |
CLR_DBGRESET1 = 0x1 << 13, |
| 160 |
CLR_DBGRESET2 = 0x1 << 14, |
| 161 |
CLR_DBGRESET3 = 0x1 << 15, |
| 162 |
CLR_CORERESET0 = 0x1 << 16, |
| 163 |
CLR_CORERESET1 = 0x1 << 17, |
| 164 |
CLR_CORERESET2 = 0x1 << 18, |
| 165 |
CLR_CORERESET3 = 0x1 << 19, |
| 166 |
CLR_CXRESET0 = 0x1 << 20, |
| 167 |
CLR_CXRESET1 = 0x1 << 21, |
| 168 |
CLR_CXRESET2 = 0x1 << 22, |
| 169 |
CLR_CXRESET3 = 0x1 << 23, |
| 170 |
CLR_L2RESET = 0x1 << 24, |
| 171 |
CLR_NONCPURESET = 0x1 << 29, |
| 172 |
CLR_PRESETDBG = 0x1 << 30 |
| 173 |
}; |
| 174 |
|
| 175 |
static uint32_t *clk_rst_spare_reg0_ptr = |
| 176 |
(void *)(CLK_RST_BASE + 0x55c); |
| 177 |
enum { |
| 178 |
CLK_M_DIVISOR_MASK = 0x3 << 2, |
| 179 |
CLK_M_DIVISOR_BY_2 = 0x1 << 2 |
| 180 |
}; |
| 181 |
|
| 182 |
static uint32_t *clk_rst_lvl2_clk_gate_ovra_ptr = (void *)(CLK_RST_BASE + 0xf8); |
| 183 |
static uint32_t *clk_rst_lvl2_clk_gate_ovrb_ptr = (void *)(CLK_RST_BASE + 0xfc); |
| 184 |
static uint32_t *clk_rst_lvl2_clk_gate_ovrc_ptr = (void *)(CLK_RST_BASE + 0x3a0); |
| 185 |
static uint32_t *clk_rst_lvl2_clk_gate_ovrd_ptr = (void *)(CLK_RST_BASE + 0x3a4); |
| 186 |
static uint32_t *clk_rst_lvl2_clk_gate_ovre_ptr = (void *)(CLK_RST_BASE + 0x554); |
| 187 |
|
| 188 |
static uint32_t *clk_rst_clk_out_enb_l_ptr = (void *)(CLK_RST_BASE + 0x10); |
| 189 |
static uint32_t *clk_rst_clk_out_enb_h_ptr = (void *)(CLK_RST_BASE + 0x14); |
| 190 |
static uint32_t *clk_rst_clk_out_enb_u_ptr = (void *)(CLK_RST_BASE + 0x18); |
| 191 |
static uint32_t *clk_rst_clk_out_enb_v_ptr = (void *)(CLK_RST_BASE + 0x360); |
| 192 |
static uint32_t *clk_rst_clk_out_enb_w_ptr = (void *)(CLK_RST_BASE + 0x364); |
| 193 |
static uint32_t *clk_rst_clk_out_enb_x_ptr = (void *)(CLK_RST_BASE + 0x280); |
| 194 |
static uint32_t *clk_rst_clk_out_enb_y_ptr = (void *)(CLK_RST_BASE + 0x298); |
| 195 |
|
| 196 |
static uint32_t *clk_rst_clk_enb_l_clr_ptr = (void *)(CLK_RST_BASE + 0x324); |
| 197 |
static uint32_t *clk_rst_clk_enb_h_clr_ptr = (void *)(CLK_RST_BASE + 0x32c); |
| 198 |
static uint32_t *clk_rst_clk_enb_u_clr_ptr = (void *)(CLK_RST_BASE + 0x334); |
| 199 |
static uint32_t *clk_rst_clk_enb_v_clr_ptr = (void *)(CLK_RST_BASE + 0x444); |
| 200 |
static uint32_t *clk_rst_clk_enb_w_clr_ptr = (void *)(CLK_RST_BASE + 0x44c); |
| 201 |
static uint32_t *clk_rst_clk_enb_x_clr_ptr = (void *)(CLK_RST_BASE + 0x288); |
| 202 |
static uint32_t *clk_rst_clk_enb_y_clr_ptr = (void *)(CLK_RST_BASE + 0x2a0); |
| 203 |
|
| 204 |
#define MBIST_CLK_ENB_L_0 0x80000130 |
| 205 |
#define MBIST_CLK_ENB_H_0 0x020000C1 |
| 206 |
#define MBIST_CLK_ENB_U_0 0x01F00200 |
| 207 |
#define MBIST_CLK_ENB_V_0 0x80400008 |
| 208 |
#define MBIST_CLK_ENB_W_0 0x002000FC |
| 209 |
#define MBIST_CLK_ENB_X_0 0x23004780 |
| 210 |
#define MBIST_CLK_ENB_Y_0 0x00000300 |
| 211 |
|
| 212 |
static uint32_t *clk_rst_clk_enb_v_ptr = (void *)(CLK_RST_BASE + 0x440); |
| 213 |
enum { |
| 214 |
CLK_ENB_MSELECT = 0x1 << 3 |
| 215 |
}; |
| 216 |
|
| 217 |
static uint32_t *clk_rst_clk_enb_w_set_ptr = (void *)(CLK_RST_BASE + 0x448); |
| 218 |
enum { |
| 219 |
CLK_ENB_MC1 = 0x1 << 30, |
| 220 |
CLK_ENB_DVFS = 0x1 << 27 |
| 221 |
}; |
| 222 |
|
| 223 |
static uint32_t *clk_rst_clk_source_mselect_ptr = (void *)(CLK_RST_BASE + 0x3b4); |
| 224 |
enum { |
| 225 |
CLK_SRC_PLLP_OUT0 = (0x0 << 29), |
| 226 |
MSELECT_CLK_DIVISOR_4 = 6 |
| 227 |
}; |
| 228 |
|
| 229 |
static uint32_t *clk_rst_clk_dvfs_ref_ptr = (void *)(CLK_RST_BASE + 0x62c); |
| 230 |
enum { |
| 231 |
DVFS_REF_CLK_DIVISOR = 0xe |
| 232 |
}; |
| 233 |
|
| 234 |
static uint32_t *clk_rst_clk_dvfs_soc_ptr = (void *)(CLK_RST_BASE + 0x630); |
| 235 |
enum { |
| 236 |
DVFS_SOC_CLK_DIVISOR = 0xe |
| 237 |
}; |
| 238 |
|
| 239 |
|
| 240 |
static uint32_t *flow_ctlr_halt_cop_events_ptr = |
| 241 |
(void *)(FLOW_CTLR_BASE + 0x4); |
| 242 |
enum { |
| 243 |
EVENT_MSEC = 0x1 << 24, |
| 244 |
EVENT_JTAG = 0x1 << 28, |
| 245 |
FLOW_MODE_SHIFT = 29, |
| 246 |
FLOW_MODE_STOP = 2 << FLOW_MODE_SHIFT, |
| 247 |
}; |
| 248 |
|
| 249 |
static uint32_t *flow_ctlr_ram_repair_ptr = |
| 250 |
(void *)(FLOW_CTLR_BASE + 0x40); |
| 251 |
static uint32_t *flow_ctlr_ram_repair_cluster1_ptr = |
| 252 |
(void *)(FLOW_CTLR_BASE + 0x58); |
| 253 |
enum { |
| 254 |
RAM_REPAIR_REQ = 0x1 << 0, |
| 255 |
RAM_REPAIR_STS = 0x1 << 1, |
| 256 |
}; |
| 257 |
|
| 258 |
static uint32_t *flow_ctlr_bpmp_cluster_control_ptr = |
| 259 |
(void *)(FLOW_CTLR_BASE + 0x98); |
| 260 |
enum { |
| 261 |
ACTIVE_SLOW = 0x1 << 0 |
| 262 |
}; |
| 263 |
|
| 264 |
|
| 265 |
enum { |
| 266 |
PARTID_CRAIL = 0, |
| 267 |
PARTID_CE1 = 9, |
| 268 |
PARTID_CE2 = 10, |
| 269 |
PARTID_CE3 = 11, |
| 270 |
PARTID_CE0 = 14, |
| 271 |
PARTID_C0NC = 15, |
| 272 |
}; |
| 273 |
|
| 274 |
static uint32_t *pmc_dpd_sample_ptr = (void *)(PMC_CTLR_BASE + 0x20); |
| 275 |
static uint32_t *pmc_clamp_status_ptr = (void *)(PMC_CTLR_BASE + 0x2c); |
| 276 |
|
| 277 |
static uint32_t *pmc_pwrgate_toggle_ptr = (void *)(PMC_CTLR_BASE + 0x30); |
| 278 |
enum { |
| 279 |
PWRGATE_TOGGLE_START = 0x1 << 8 |
| 280 |
}; |
| 281 |
|
| 282 |
static uint32_t *pmc_remove_clamping_cmd_ptr = (void *)(PMC_CTLR_BASE + 0x34); |
| 283 |
|
| 284 |
static uint32_t *pmc_pwrgate_status_ptr = (void *)(PMC_CTLR_BASE + 0x38); |
| 285 |
|
| 286 |
static uint32_t *pmc_cpupwrgood_timer_ptr = (void *)(PMC_CTLR_BASE + 0xc8); |
| 287 |
|
| 288 |
static uint32_t *pmc_odmdata_ptr = (void *)(PMC_CTLR_BASE + 0xa0); |
| 289 |
|
| 290 |
static uint32_t *pmc_scratch4_ptr = (void *)(PMC_CTLR_BASE + 0x60); |
| 291 |
enum { |
| 292 |
PMC_WAKEUP_CLUSTER_LPCPU = 1 << 31 |
| 293 |
}; |
| 294 |
|
| 295 |
static uint32_t *pmc_scratch190_ptr = (void *)(PMC_CTLR_BASE + 0x818); |
| 296 |
|
| 297 |
|
| 298 |
static uint32_t *pmc_scratch201_ptr = (void *)(PMC_CTLR_BASE + 0x844); |
| 299 |
enum { |
| 300 |
PMIC_77621 = 0x1 << 1 |
| 301 |
}; |
| 302 |
|
| 303 |
static uint32_t *pmc_secure_scratch34_ptr = (void *)(PMC_CTLR_BASE + 0x368); |
| 304 |
static uint32_t *pmc_secure_scratch35_ptr = (void *)(PMC_CTLR_BASE + 0x36c); |
| 305 |
|
| 306 |
static uint32_t *pmc_osc_edpd_over_ptr = (void *)(PMC_CTLR_BASE + 0x1a4); |
| 307 |
enum { |
| 308 |
PMC_XOFS_SHIFT = 1, |
| 309 |
PMC_XOFS_MASK = 0x3f << PMC_XOFS_SHIFT |
| 310 |
}; |
| 311 |
|
| 312 |
static uint32_t *pmc_sticky_bits_ptr = (void *)(PMC_CTLR_BASE + 0x2c0); |
| 313 |
enum { |
| 314 |
HDA_LPBK_DIS = 1 << 0, |
| 315 |
}; |
| 316 |
|
| 317 |
static uint32_t *pmc_set_sw_clamp_ptr = (void *)(PMC_CTLR_BASE + 0x47c); |
| 318 |
|
| 319 |
|
| 320 |
static uint32_t *mc_intstatus_ptr = (void *)(MC_CTLR_BASE); |
| 321 |
static uint32_t *mc_intmask_ptr = (void *)(MC_CTLR_BASE + 0x4); |
| 322 |
static uint32_t *mc_video_protect_size_mb_ptr = (void *)(MC_CTLR_BASE + 0x64c); |
| 323 |
|
| 324 |
static uint32_t *mc_video_protect_reg_ctrl_ptr = |
| 325 |
(void *)(MC_CTLR_BASE + 0x650); |
| 326 |
enum { |
| 327 |
VPR_WR_ACCESS_DISABLE = 0x1 << 0, |
| 328 |
VPR_ALLOW_TZ_WR_ACCESS = 0x1 << 1 |
| 329 |
}; |
| 330 |
|
| 331 |
static uint32_t *fuse_security_mode_ptr = (void *)(FUSE_BASE + 0x1a0); |
| 332 |
enum { |
| 333 |
SECURITY_MODE = 0x1 << 0 |
| 334 |
}; |
| 335 |
|
| 336 |
|
| 337 |
static uint32_t *sb_pfcfg_ptr = (void *)(SECURE_BOOT_BASE + 0x8); |
| 338 |
enum { |
| 339 |
SECURE_BOOT_DEBUG_CONFIG = 0x1 << 3 |
| 340 |
}; |
| 341 |
|
| 342 |
static uint32_t *sb_aa64_reset_low = (void *)(SECURE_BOOT_BASE + 0x30); |
| 343 |
static uint32_t *sb_aa64_reset_high = (void *)(SECURE_BOOT_BASE + 0x34); |
| 344 |
|
| 345 |
|
| 346 |
static uint32_t *pmacro_cfg_pm_global = (void *)(EMC_BASE + 0xc30); |
| 347 |
enum { |
| 348 |
DISABLE_CFG_BYTE0 = 0x1 << 16, |
| 349 |
DISABLE_CFG_BYTE1 = 0x1 << 17, |
| 350 |
DISABLE_CFG_BYTE2 = 0x1 << 18, |
| 351 |
DISABLE_CFG_BYTE3 = 0x1 << 19, |
| 352 |
DISABLE_CFG_BYTE4 = 0x1 << 20, |
| 353 |
DISABLE_CFG_BYTE5 = 0x1 << 21, |
| 354 |
DISABLE_CFG_BYTE6 = 0x1 << 22, |
| 355 |
DISABLE_CFG_BYTE7 = 0x1 << 23, |
| 356 |
DISABLE_CFG_BYTES = 0xff << 16, |
| 357 |
ENABLE_CFG_BYTES = 0 << 16, |
| 358 |
DISABLE_CFG_CMD0 = 0x1 << 24, |
| 359 |
DISABLE_CFG_CMD1 = 0x1 << 25, |
| 360 |
DISABLE_CFG_CMD2 = 0x1 << 26, |
| 361 |
DISABLE_CFG_CMD3 = 0x1 << 27, |
| 362 |
}; |
| 363 |
|
| 364 |
static uint32_t *pmacro_training_ctrl_0_ptr = (void *)(EMC_BASE + 0xcf8); |
| 365 |
static uint32_t *pmacro_training_ctrl_1_ptr = (void *)(EMC_BASE + 0xcfc); |
| 366 |
enum { |
| 367 |
TRAINING_E_WRPTR = 0x1 << 3 |
| 368 |
}; |
| 369 |
|
| 370 |
static uint32_t *fbio_cfg7_ptr = (void *)(EMC_BASE + 0x584); |
| 371 |
enum { |
| 372 |
CH1_ENABLE = 0x1 << 2 |
| 373 |
}; |
| 374 |
|
| 375 |
|
| 376 |
static uint32_t *i2c5_cnfg_ptr = (void *)(I2C5_BASE + 0x0); |
| 377 |
enum { |
| 378 |
I2C_DEBOUNCE_CNT_4 = 2 << 12, |
| 379 |
I2C_NEW_MASTER_FSM = 1 << 11, |
| 380 |
I2C_SEND = 1 << 9, |
| 381 |
I2C_LENGTH_2_BYTES = 1 << 1 |
| 382 |
}; |
| 383 |
|
| 384 |
static uint32_t *i2c5_cmd_addr0_ptr = (void *)(I2C5_BASE + 0x4); |
| 385 |
static uint32_t *i2c5_cmd_data1_ptr = (void *)(I2C5_BASE + 0xc); |
| 386 |
static uint32_t *i2c5_status_ptr = (void *)(I2C5_BASE + 0x1c); |
| 387 |
enum { |
| 388 |
I2C_STATUS_BUSY = 1 << 8, |
| 389 |
I2C_STATUS_CMD1_STAT_MASK = 0xf << 0, |
| 390 |
I2C_STATUS_CMD1_XFER_SUCCESS = 0 << 0 |
| 391 |
}; |
| 392 |
|
| 393 |
static uint32_t *i2c5_config_load_ptr = (void *)(I2C5_BASE + 0x8c); |
| 394 |
enum { |
| 395 |
MSTR_CONFIG_LOAD = 1 << 0 |
| 396 |
}; |
| 397 |
|
| 398 |
#define MAX77620_I2C_ADDR (0x3c << 1) |
| 399 |
#define MAX77620_GPIO5_DATA (0x3b | (0x9 << 8)) |
| 400 |
|
| 401 |
#define MAX77621_I2C_ADDR (0x1b << 1) |
| 402 |
#define MAX77621_VOUT_REG 0x0 |
| 403 |
#define MAX77621_VOUT_VAL (0x80 | 0x27) |
| 404 |
#define MAX77621_VOUT_DATA (MAX77621_VOUT_REG | (MAX77621_VOUT_VAL << 8)) |
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
static __always_inline void __noreturn halt(void) |
| 409 |
{ |
| 410 |
for (;;); |
| 411 |
} |
| 412 |
|
| 413 |
static inline uint32_t read32(const void *addr) |
| 414 |
{ |
| 415 |
return *(volatile uint32_t *)addr; |
| 416 |
} |
| 417 |
|
| 418 |
static inline void write32(void *addr, uint32_t val) |
| 419 |
{ |
| 420 |
*(volatile uint32_t *)addr = val; |
| 421 |
} |
| 422 |
|
| 423 |
static inline void setbits32(uint32_t bits, void *addr) |
| 424 |
{ |
| 425 |
write32(addr, read32(addr) | bits); |
| 426 |
} |
| 427 |
|
| 428 |
static inline void clrbits32(uint32_t bits, void *addr) |
| 429 |
{ |
| 430 |
write32(addr, read32(addr) & ~bits); |
| 431 |
} |
| 432 |
|
| 433 |
static void __noreturn reset(void) |
| 434 |
{ |
| 435 |
write32(clk_rst_rst_devices_l_ptr, SWR_TRIG_SYS_RST); |
| 436 |
halt(); |
| 437 |
} |
| 438 |
|
| 439 |
static void udelay(unsigned int usecs) |
| 440 |
{ |
| 441 |
uint32_t start = read32(timer_us_ptr); |
| 442 |
while (read32(timer_us_ptr) - start < usecs) |
| 443 |
; |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
static uint32_t *uart_clk_out_enb_regs[4] = { |
| 448 |
(uint32_t *)0x60006010, |
| 449 |
(uint32_t *)0x60006010, |
| 450 |
(uint32_t *)0x60006014, |
| 451 |
(uint32_t *)0x60006018 |
| 452 |
}; |
| 453 |
|
| 454 |
static uint32_t *uart_rst_devices_regs[4] = { |
| 455 |
(uint32_t *)0x60006004, |
| 456 |
(uint32_t *)0x60006004, |
| 457 |
(uint32_t *)0x60006008, |
| 458 |
(uint32_t *)0x6000600c |
| 459 |
}; |
| 460 |
|
| 461 |
static uint32_t uart_enable_mask[4] = { |
| 462 |
1 << 6, |
| 463 |
1 << 7, |
| 464 |
1 << 23, |
| 465 |
1 << 1 |
| 466 |
}; |
| 467 |
|
| 468 |
static uint32_t *uart_clk_source_regs[4] = { |
| 469 |
(uint32_t *)0x60006178, |
| 470 |
(uint32_t *)0x6000617c, |
| 471 |
(uint32_t *)0x600061a0, |
| 472 |
(uint32_t *)0x600061c0 |
| 473 |
}; |
| 474 |
|
| 475 |
static uint32_t *uart_base_regs[4] = { |
| 476 |
(uint32_t *)0x70006000, |
| 477 |
(uint32_t *)0x70006040, |
| 478 |
(uint32_t *)0x70006200, |
| 479 |
(uint32_t *)0x70006300 |
| 480 |
}; |
| 481 |
|
| 482 |
enum { |
| 483 |
UART_THR_DLAB = 0x0, |
| 484 |
UART_IER_DLAB = 0x1, |
| 485 |
UART_IIR_FCR = 0x2, |
| 486 |
UART_LCR = 0x3 |
| 487 |
}; |
| 488 |
enum { |
| 489 |
UART_RATE_115200 = (408000000/115200/16), |
| 490 |
FCR_TX_CLR = 0x4, |
| 491 |
FCR_RX_CLR = 0x2, |
| 492 |
FCR_EN_FIFO = 0x1, |
| 493 |
LCR_DLAB = 0x80, |
| 494 |
LCR_WD_SIZE_8 = 0x3 |
| 495 |
}; |
| 496 |
|
| 497 |
static void enable_uart(void) |
| 498 |
{ |
| 499 |
uint32_t *uart_clk_enb_reg; |
| 500 |
uint32_t *uart_rst_reg; |
| 501 |
uint32_t *uart_clk_source; |
| 502 |
uint32_t uart_port; |
| 503 |
uint32_t uart_mask; |
| 504 |
uint32_t *uart_base; |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
uart_port = (read32(pmc_odmdata_ptr) >> 15) & 0x7; |
| 516 |
|
| 517 |
|
| 518 |
if (uart_port >= 4) |
| 519 |
uart_port = 0; |
| 520 |
|
| 521 |
uart_clk_enb_reg = uart_clk_out_enb_regs[uart_port]; |
| 522 |
uart_rst_reg = uart_rst_devices_regs[uart_port]; |
| 523 |
uart_mask = uart_enable_mask[uart_port]; |
| 524 |
uart_clk_source = uart_clk_source_regs[uart_port]; |
| 525 |
uart_base = uart_base_regs[uart_port]; |
| 526 |
|
| 527 |
|
| 528 |
setbits32(uart_mask, uart_clk_enb_reg); |
| 529 |
|
| 530 |
|
| 531 |
setbits32(uart_mask, uart_rst_reg); |
| 532 |
clrbits32(uart_mask, uart_rst_reg); |
| 533 |
|
| 534 |
|
| 535 |
write32(uart_clk_source, 0); |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
write32((uart_base + UART_LCR), LCR_DLAB); |
| 540 |
write32((uart_base + UART_THR_DLAB), (UART_RATE_115200 & 0xff)); |
| 541 |
write32((uart_base + UART_IER_DLAB), (UART_RATE_115200 >> 8)); |
| 542 |
|
| 543 |
write32((uart_base + UART_LCR), LCR_WD_SIZE_8); |
| 544 |
|
| 545 |
write32((uart_base + UART_IIR_FCR), |
| 546 |
(FCR_TX_CLR + FCR_RX_CLR + FCR_EN_FIFO)); |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
static void enable_jtag(void) |
| 554 |
{ |
| 555 |
write32(misc_pp_config_ctl_ptr, PP_CONFIG_CTL_JTAG); |
| 556 |
} |
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
static void config_oscillator(void) |
| 561 |
{ |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
uint32_t xofs = (read32(pmc_osc_edpd_over_ptr) & |
| 567 |
PMC_XOFS_MASK) >> PMC_XOFS_SHIFT; |
| 568 |
|
| 569 |
uint32_t osc_ctrl = read32(clk_rst_osc_ctrl_ptr); |
| 570 |
osc_ctrl &= ~OSC_XOFS_MASK; |
| 571 |
osc_ctrl |= (xofs << OSC_XOFS_SHIFT); |
| 572 |
osc_ctrl |= OSC_XOE; |
| 573 |
write32(clk_rst_osc_ctrl_ptr, osc_ctrl); |
| 574 |
} |
| 575 |
|
| 576 |
static void enable_select_cpu_clocks(void) |
| 577 |
{ |
| 578 |
|
| 579 |
write32(clk_rst_clk_enb_l_set_ptr, CLK_ENB_CPU); |
| 580 |
write32(clk_rst_clk_enb_v_set_ptr, CLK_ENB_CPUG); |
| 581 |
udelay(10); |
| 582 |
|
| 583 |
|
| 584 |
write32(clk_rst_cclkg_burst_policy_ptr, CCLKG_PLLP_BURST_POLICY); |
| 585 |
write32(clk_rst_cclklp_burst_policy_ptr, CCLKLP_PLLP_BURST_POLICY); |
| 586 |
udelay(10); |
| 587 |
} |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
static void config_core_sight(void) |
| 592 |
{ |
| 593 |
|
| 594 |
write32(clk_rst_clk_out_enb_u_set_ptr, CLK_ENB_CSITE); |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
write32(clk_rst_rst_dev_u_clr_ptr, SWR_CSITE_RST); |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
void ram_repair(void) |
| 608 |
{ |
| 609 |
|
| 610 |
setbits32(RAM_REPAIR_REQ, flow_ctlr_ram_repair_ptr); |
| 611 |
|
| 612 |
while (!(read32(flow_ctlr_ram_repair_ptr) & RAM_REPAIR_STS)) |
| 613 |
; |
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
static void power_on_partition(unsigned int id) |
| 619 |
{ |
| 620 |
uint32_t bit = 0x1 << id; |
| 621 |
if (!(read32(pmc_pwrgate_status_ptr) & bit)) { |
| 622 |
|
| 623 |
write32(pmc_pwrgate_toggle_ptr, id | PWRGATE_TOGGLE_START); |
| 624 |
|
| 625 |
|
| 626 |
while (!(read32(pmc_pwrgate_status_ptr) & bit)) |
| 627 |
; |
| 628 |
|
| 629 |
|
| 630 |
while (read32(pmc_clamp_status_ptr) & bit) |
| 631 |
; |
| 632 |
} |
| 633 |
} |
| 634 |
|
| 635 |
static void config_hda_lpbk_dis(void) |
| 636 |
{ |
| 637 |
|
| 638 |
if (read32(fuse_security_mode_ptr) & SECURITY_MODE) |
| 639 |
setbits32(HDA_LPBK_DIS, pmc_sticky_bits_ptr); |
| 640 |
} |
| 641 |
|
| 642 |
static void set_gpio_pa6_input_mode(void) |
| 643 |
{ |
| 644 |
setbits32(E_INPUT, pinmux_gpio_pa6_ptr); |
| 645 |
} |
| 646 |
|
| 647 |
static void set_clk_m(void) |
| 648 |
{ |
| 649 |
uint32_t spare; |
| 650 |
|
| 651 |
|
| 652 |
spare = read32(clk_rst_spare_reg0_ptr); |
| 653 |
spare &= ~CLK_M_DIVISOR_MASK; |
| 654 |
spare |= CLK_M_DIVISOR_BY_2; |
| 655 |
write32(clk_rst_spare_reg0_ptr, spare); |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
write32(timer_us_cfg_ptr, 0x045f); |
| 662 |
} |
| 663 |
|
| 664 |
static void restore_ram_svop(void) |
| 665 |
{ |
| 666 |
uint32_t asdbgreg; |
| 667 |
|
| 668 |
asdbgreg = read32(misc_gp_asdbgreg_ptr); |
| 669 |
asdbgreg &= ~CFG2TMC_RAM_SVOP_PDP_MASK; |
| 670 |
asdbgreg |= CFG2TMC_RAM_SVOP_PDP_VAL_2; |
| 671 |
write32(misc_gp_asdbgreg_ptr, asdbgreg); |
| 672 |
} |
| 673 |
|
| 674 |
static void set_pmacro_training_wrptr(void) |
| 675 |
{ |
| 676 |
|
| 677 |
write32(pmacro_cfg_pm_global, DISABLE_CFG_BYTES); |
| 678 |
|
| 679 |
|
| 680 |
write32(pmacro_training_ctrl_0_ptr, TRAINING_E_WRPTR); |
| 681 |
write32(pmacro_training_ctrl_1_ptr, TRAINING_E_WRPTR); |
| 682 |
|
| 683 |
|
| 684 |
write32(pmacro_cfg_pm_global, ENABLE_CFG_BYTES); |
| 685 |
} |
| 686 |
|
| 687 |
static uint32_t *i2s_0_master = (void *)(I2S_BASE + 0x0a0); |
| 688 |
static uint32_t *i2s_1_master = (void *)(I2S_BASE + 0x1a0); |
| 689 |
static uint32_t *i2s_2_master = (void *)(I2S_BASE + 0x2a0); |
| 690 |
static uint32_t *i2s_3_master = (void *)(I2S_BASE + 0x3a0); |
| 691 |
static uint32_t *i2s_4_master = (void *)(I2S_BASE + 0x4a0); |
| 692 |
|
| 693 |
static uint32_t *i2s_0_slcg = (void *)(I2S_BASE + 0x088); |
| 694 |
static uint32_t *i2s_1_slcg = (void *)(I2S_BASE + 0x188); |
| 695 |
static uint32_t *i2s_2_slcg = (void *)(I2S_BASE + 0x288); |
| 696 |
static uint32_t *i2s_3_slcg = (void *)(I2S_BASE + 0x388); |
| 697 |
static uint32_t *i2s_4_slcg = (void *)(I2S_BASE + 0x488); |
| 698 |
|
| 699 |
static uint32_t *clk_rst_ape_clear = (void *)(CLK_RST_BASE + 0x2ac); |
| 700 |
static uint32_t *clk_rst_ape_set = (void *)(CLK_RST_BASE + 0x2a8); |
| 701 |
|
| 702 |
static void mbist_workaround(void) |
| 703 |
{ |
| 704 |
uint32_t clks_to_be_cleared; |
| 705 |
uint32_t i2s_read; |
| 706 |
|
| 707 |
write32(clk_rst_ape_clear, 0x40); |
| 708 |
udelay(2); |
| 709 |
|
| 710 |
i2s_read = read32(i2s_0_master); |
| 711 |
i2s_read |= 0x400; |
| 712 |
write32(i2s_0_master, i2s_read); |
| 713 |
|
| 714 |
i2s_read = read32(i2s_0_slcg); |
| 715 |
i2s_read &= ~1; |
| 716 |
write32(i2s_0_slcg, i2s_read); |
| 717 |
|
| 718 |
i2s_read = read32(i2s_1_master); |
| 719 |
i2s_read |= 0x400; |
| 720 |
write32(i2s_1_master, i2s_read); |
| 721 |
|
| 722 |
i2s_read = read32(i2s_1_slcg); |
| 723 |
i2s_read &= ~1; |
| 724 |
write32(i2s_1_slcg, i2s_read); |
| 725 |
|
| 726 |
i2s_read = read32(i2s_2_master); |
| 727 |
i2s_read |= 0x400; |
| 728 |
write32(i2s_2_master, i2s_read); |
| 729 |
|
| 730 |
i2s_read = read32(i2s_2_slcg); |
| 731 |
i2s_read &= ~1; |
| 732 |
write32(i2s_2_slcg, i2s_read); |
| 733 |
|
| 734 |
i2s_read = read32(i2s_3_master); |
| 735 |
i2s_read |= 0x400; |
| 736 |
write32(i2s_3_master, i2s_read); |
| 737 |
|
| 738 |
i2s_read = read32(i2s_3_slcg); |
| 739 |
i2s_read &= ~1; |
| 740 |
write32(i2s_3_slcg, i2s_read); |
| 741 |
|
| 742 |
i2s_read = read32(i2s_4_master); |
| 743 |
i2s_read |= 0x400; |
| 744 |
write32(i2s_4_master, i2s_read); |
| 745 |
|
| 746 |
i2s_read = read32(i2s_4_slcg); |
| 747 |
i2s_read &= ~1; |
| 748 |
write32(i2s_4_slcg, i2s_read); |
| 749 |
|
| 750 |
udelay(2); |
| 751 |
|
| 752 |
write32(clk_rst_lvl2_clk_gate_ovra_ptr, 0); |
| 753 |
write32(clk_rst_lvl2_clk_gate_ovrb_ptr, 0); |
| 754 |
write32(clk_rst_lvl2_clk_gate_ovrc_ptr, 0x00000002); |
| 755 |
write32(clk_rst_lvl2_clk_gate_ovrd_ptr, 0x01000000); |
| 756 |
write32(clk_rst_lvl2_clk_gate_ovre_ptr, 0x00000c00); |
| 757 |
|
| 758 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_l_ptr); |
| 759 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_L_0; |
| 760 |
write32(clk_rst_clk_enb_l_clr_ptr, clks_to_be_cleared); |
| 761 |
|
| 762 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_h_ptr); |
| 763 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_H_0; |
| 764 |
write32(clk_rst_clk_enb_h_clr_ptr, clks_to_be_cleared); |
| 765 |
|
| 766 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_u_ptr); |
| 767 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_U_0; |
| 768 |
write32(clk_rst_clk_enb_u_clr_ptr, clks_to_be_cleared); |
| 769 |
|
| 770 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_v_ptr); |
| 771 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_V_0; |
| 772 |
write32(clk_rst_clk_enb_v_clr_ptr, clks_to_be_cleared); |
| 773 |
|
| 774 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_w_ptr); |
| 775 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_W_0; |
| 776 |
write32(clk_rst_clk_enb_w_clr_ptr, clks_to_be_cleared); |
| 777 |
|
| 778 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_x_ptr); |
| 779 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_X_0; |
| 780 |
write32(clk_rst_clk_enb_x_clr_ptr, clks_to_be_cleared); |
| 781 |
|
| 782 |
clks_to_be_cleared = read32(clk_rst_clk_out_enb_y_ptr); |
| 783 |
clks_to_be_cleared &= ~MBIST_CLK_ENB_Y_0; |
| 784 |
write32(clk_rst_clk_enb_y_clr_ptr, clks_to_be_cleared); |
| 785 |
|
| 786 |
if (read32(fbio_cfg7_ptr) & CH1_ENABLE) |
| 787 |
|
| 788 |
write32(clk_rst_clk_enb_w_set_ptr, CLK_ENB_MC1); |
| 789 |
} |
| 790 |
|
| 791 |
static uint32_t *sdmmc1_vendor_io_trim = (void *)(TEGRA_SDMMC1_BASE + 0x1ac); |
| 792 |
static uint32_t *sdmmc3_vendor_io_trim = (void *)(TEGRA_SDMMC3_BASE + 0x1ac); |
| 793 |
static uint32_t *sdmmc1_comppadctrl = (void *)(TEGRA_SDMMC1_BASE + 0x1e0); |
| 794 |
static uint32_t *sdmmc3_comppadctrl = (void *)(TEGRA_SDMMC3_BASE + 0x1e0); |
| 795 |
|
| 796 |
enum { |
| 797 |
SDMMC1_DEV_L = 0x1 << 14, |
| 798 |
SDMMC3_DEV_U = 0x1 << 5, |
| 799 |
PAD_E_INPUT_COMPPADCTRL = 0x1 << 31, |
| 800 |
SEL_VREG_VENDOR_IO_TRIM = 0x1 << 2 |
| 801 |
}; |
| 802 |
|
| 803 |
static void low_power_sdmmc_pads(void) |
| 804 |
{ |
| 805 |
|
| 806 |
setbits32(SDMMC1_DEV_L, clk_rst_clk_out_enb_l_ptr); |
| 807 |
udelay(2); |
| 808 |
|
| 809 |
clrbits32(SDMMC1_DEV_L, clk_rst_rst_devices_l_ptr); |
| 810 |
|
| 811 |
|
| 812 |
clrbits32(SEL_VREG_VENDOR_IO_TRIM, sdmmc1_vendor_io_trim); |
| 813 |
clrbits32(PAD_E_INPUT_COMPPADCTRL, sdmmc1_comppadctrl); |
| 814 |
|
| 815 |
read32(sdmmc1_comppadctrl); |
| 816 |
|
| 817 |
clrbits32(SDMMC1_DEV_L, clk_rst_clk_out_enb_l_ptr); |
| 818 |
|
| 819 |
|
| 820 |
setbits32(SDMMC3_DEV_U, clk_rst_clk_out_enb_u_ptr); |
| 821 |
udelay(2); |
| 822 |
|
| 823 |
clrbits32(SDMMC3_DEV_U, clk_rst_rst_devices_u_ptr); |
| 824 |
|
| 825 |
|
| 826 |
clrbits32(SEL_VREG_VENDOR_IO_TRIM, sdmmc3_vendor_io_trim); |
| 827 |
clrbits32(PAD_E_INPUT_COMPPADCTRL, sdmmc3_comppadctrl); |
| 828 |
|
| 829 |
read32(sdmmc3_comppadctrl); |
| 830 |
|
| 831 |
clrbits32(SDMMC3_DEV_U, clk_rst_clk_out_enb_u_ptr); |
| 832 |
} |
| 833 |
|
| 834 |
static void config_mselect(void) |
| 835 |
{ |
| 836 |
|
| 837 |
write32(clk_rst_clk_source_mselect_ptr, |
| 838 |
(CLK_SRC_PLLP_OUT0 | MSELECT_CLK_DIVISOR_4)); |
| 839 |
|
| 840 |
write32(clk_rst_clk_enb_v_ptr, CLK_ENB_MSELECT); |
| 841 |
|
| 842 |
udelay(2); |
| 843 |
write32(clk_rst_rst_dev_v_clr_ptr, MSELECT_RST); |
| 844 |
} |
| 845 |
|
| 846 |
|
| 847 |
static void i2c_send(uint32_t addr, uint32_t data) |
| 848 |
{ |
| 849 |
uint32_t delay; |
| 850 |
|
| 851 |
write32(i2c5_cmd_addr0_ptr, addr); |
| 852 |
write32(i2c5_cmd_data1_ptr, data); |
| 853 |
|
| 854 |
write32(i2c5_cnfg_ptr, (I2C_DEBOUNCE_CNT_4 | I2C_NEW_MASTER_FSM | |
| 855 |
I2C_LENGTH_2_BYTES)); |
| 856 |
|
| 857 |
write32(i2c5_config_load_ptr, MSTR_CONFIG_LOAD); |
| 858 |
delay = 0; |
| 859 |
while (read32(i2c5_config_load_ptr) & MSTR_CONFIG_LOAD) { |
| 860 |
udelay(1); |
| 861 |
if (++delay > 100) |
| 862 |
reset(); |
| 863 |
} |
| 864 |
|
| 865 |
write32(i2c5_cnfg_ptr, (I2C_DEBOUNCE_CNT_4 | I2C_NEW_MASTER_FSM | |
| 866 |
I2C_SEND | I2C_LENGTH_2_BYTES)); |
| 867 |
|
| 868 |
|
| 869 |
delay = 0; |
| 870 |
while (read32(i2c5_status_ptr) & I2C_STATUS_BUSY) { |
| 871 |
udelay(1); |
| 872 |
if (++delay > 1000) |
| 873 |
reset(); |
| 874 |
} |
| 875 |
|
| 876 |
|
| 877 |
if (read32(i2c5_status_ptr) & I2C_STATUS_CMD1_STAT_MASK) |
| 878 |
reset(); |
| 879 |
} |
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
void lp0_resume(void) |
| 884 |
{ |
| 885 |
uint32_t orig_timer; |
| 886 |
|
| 887 |
|
| 888 |
if (read32(up_tag_ptr) != UP_TAG_AVP) |
| 889 |
reset(); |
| 890 |
|
| 891 |
|
| 892 |
enable_jtag(); |
| 893 |
|
| 894 |
|
| 895 |
config_hda_lpbk_dis(); |
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
set_gpio_pa6_input_mode(); |
| 904 |
|
| 905 |
config_oscillator(); |
| 906 |
|
| 907 |
|
| 908 |
set_clk_m(); |
| 909 |
|
| 910 |
|
| 911 |
restore_ram_svop(); |
| 912 |
|
| 913 |
|
| 914 |
set_pmacro_training_wrptr(); |
| 915 |
|
| 916 |
|
| 917 |
mbist_workaround(); |
| 918 |
|
| 919 |
|
| 920 |
low_power_sdmmc_pads(); |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
if (read32(pmc_scratch4_ptr) & PMC_WAKEUP_CLUSTER_LPCPU) { |
| 927 |
setbits32(ACTIVE_SLOW, flow_ctlr_bpmp_cluster_control_ptr); |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
write32(sb_aa64_reset_low, (read32(pmc_secure_scratch34_ptr) | 1)); |
| 932 |
write32(sb_aa64_reset_high, read32(pmc_secure_scratch35_ptr)); |
| 933 |
|
| 934 |
|
| 935 |
write32(clk_rst_super_cclkg_div_ptr, SUPER_CDIV_ENB); |
| 936 |
write32(clk_rst_super_cclklp_div_ptr, SUPER_CDIV_ENB); |
| 937 |
|
| 938 |
config_core_sight(); |
| 939 |
|
| 940 |
|
| 941 |
config_mselect(); |
| 942 |
|
| 943 |
|
| 944 |
enable_uart(); |
| 945 |
|
| 946 |
|
| 947 |
clrbits32(PLLX_ENABLE, clk_rst_pllx_base_ptr); |
| 948 |
|
| 949 |
|
| 950 |
clrbits32(CAR2PMC_CPU_ACK_WIDTH_MASK, clk_rst_cpu_softrst_ctrl2_ptr); |
| 951 |
|
| 952 |
|
| 953 |
clrbits32(1, pmc_scratch190_ptr); |
| 954 |
|
| 955 |
|
| 956 |
write32(pmc_dpd_sample_ptr, 0); |
| 957 |
udelay(10); |
| 958 |
|
| 959 |
|
| 960 |
if (!read32(mc_intmask_ptr)) { |
| 961 |
uint32_t mc_intst_val = read32(mc_intstatus_ptr); |
| 962 |
if (mc_intst_val) |
| 963 |
write32(mc_intstatus_ptr, mc_intst_val); |
| 964 |
} |
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
write32(mc_video_protect_size_mb_ptr, 0); |
| 971 |
write32(mc_video_protect_reg_ctrl_ptr, |
| 972 |
VPR_WR_ACCESS_DISABLE | VPR_ALLOW_TZ_WR_ACCESS); |
| 973 |
|
| 974 |
|
| 975 |
write32(pinmux_dvfs_pwm_ptr, (TRISTATE | PM_CLDVFS)); |
| 976 |
|
| 977 |
|
| 978 |
write32(pinmux_pwr_i2c_scl_ptr, (E_INPUT | PM_I2CPMU)); |
| 979 |
write32(pinmux_pwr_i2c_sda_ptr, (E_INPUT | PM_I2CPMU)); |
| 980 |
|
| 981 |
|
| 982 |
write32(clk_rst_clk_enb_w_set_ptr, CLK_ENB_DVFS); |
| 983 |
|
| 984 |
|
| 985 |
write32(clk_rst_clk_dvfs_ref_ptr, DVFS_REF_CLK_DIVISOR); |
| 986 |
write32(clk_rst_clk_dvfs_soc_ptr, DVFS_SOC_CLK_DIVISOR); |
| 987 |
|
| 988 |
|
| 989 |
write32(clk_rst_clk_enb_h_set_ptr, CLK_ENB_I2C5); |
| 990 |
write32(clk_rst_rst_dev_h_set_ptr, I2C5_RST); |
| 991 |
udelay(5); |
| 992 |
write32(clk_rst_clk_source_i2c5_ptr, CLK_SRC_PLLP_OUT0 | I2C5_CLK_DIVISOR); |
| 993 |
write32(clk_rst_rst_dev_h_clr_ptr, I2C5_RST); |
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
if (read32(pmc_scratch201_ptr) & PMIC_77621) |
| 1002 |
|
| 1003 |
i2c_send(MAX77621_I2C_ADDR, MAX77621_VOUT_DATA); |
| 1004 |
else |
| 1005 |
|
| 1006 |
i2c_send(MAX77620_I2C_ADDR, MAX77620_GPIO5_DATA); |
| 1007 |
|
| 1008 |
|
| 1009 |
write32(clk_rst_rst_dev_h_set_ptr, I2C5_RST); |
| 1010 |
write32(clk_rst_clk_enb_h_clr_ptr, CLK_ENB_I2C5); |
| 1011 |
|
| 1012 |
|
| 1013 |
udelay(2000); |
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
orig_timer = read32(pmc_cpupwrgood_timer_ptr); |
| 1030 |
write32(pmc_cpupwrgood_timer_ptr, orig_timer * (204000000 / 32768)); |
| 1031 |
|
| 1032 |
|
| 1033 |
power_on_partition(PARTID_CRAIL); |
| 1034 |
|
| 1035 |
|
| 1036 |
write32(pmc_set_sw_clamp_ptr, 0); |
| 1037 |
write32(pmc_remove_clamping_cmd_ptr, (1 << PARTID_CRAIL)); |
| 1038 |
|
| 1039 |
while (read32(pmc_clamp_status_ptr) & (1 << PARTID_CRAIL)) |
| 1040 |
; |
| 1041 |
|
| 1042 |
|
| 1043 |
write32(clk_rst_clk_enb_w_clr_ptr, CLK_ENB_DVFS); |
| 1044 |
|
| 1045 |
|
| 1046 |
if (!(read32(flow_ctlr_bpmp_cluster_control_ptr) & ACTIVE_SLOW)) |
| 1047 |
ram_repair(); |
| 1048 |
|
| 1049 |
|
| 1050 |
power_on_partition(PARTID_C0NC); |
| 1051 |
|
| 1052 |
|
| 1053 |
write32(clk_rst_clk_enb_y_set_ptr, CLK_ENB_PLLP_OUT_CPU); |
| 1054 |
udelay(2); |
| 1055 |
|
| 1056 |
|
| 1057 |
enable_select_cpu_clocks(); |
| 1058 |
udelay(10); |
| 1059 |
|
| 1060 |
|
| 1061 |
write32(clk_rst_cpug_cmplx_clr_ptr, CLR_NONCPURESET); |
| 1062 |
|
| 1063 |
|
| 1064 |
power_on_partition(PARTID_CE0); |
| 1065 |
|
| 1066 |
|
| 1067 |
write32(pmc_cpupwrgood_timer_ptr, orig_timer); |
| 1068 |
|
| 1069 |
|
| 1070 |
write32(clk_rst_cpug_cmplx_clr_ptr, (CLR_CPURESET0 | CLR_CORERESET0)); |
| 1071 |
|
| 1072 |
|
| 1073 |
while (1) |
| 1074 |
write32(flow_ctlr_halt_cop_events_ptr, |
| 1075 |
FLOW_MODE_STOP | EVENT_JTAG); |
| 1076 |
} |
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
extern uint8_t blob_data; |
| 1081 |
extern uint8_t blob_data_size; |
| 1082 |
extern uint8_t blob_total_size; |
| 1083 |
|
| 1084 |
struct lp0_header { |
| 1085 |
uint32_t length_insecure; |
| 1086 |
uint32_t reserved[3]; |
| 1087 |
uint8_t rsa_modulus[256]; |
| 1088 |
uint8_t aes_signature[16]; |
| 1089 |
uint8_t rsa_signature[256]; |
| 1090 |
uint8_t random_aes_block[16]; |
| 1091 |
uint32_t length_secure; |
| 1092 |
uint32_t destination; |
| 1093 |
uint32_t entry_point; |
| 1094 |
uint32_t code_length; |
| 1095 |
} __packed; |
| 1096 |
|
| 1097 |
struct lp0_header header __attribute__((section(".header"))) = |
| 1098 |
{ |
| 1099 |
.length_insecure = (uintptr_t)&blob_total_size, |
| 1100 |
.length_secure = (uintptr_t)&blob_total_size, |
| 1101 |
.destination = (uintptr_t)&blob_data, |
| 1102 |
.entry_point = (uintptr_t)&lp0_resume, |
| 1103 |
.code_length = (uintptr_t)&blob_data_size |
| 1104 |
}; |