latch.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2016. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #ifndef __LATCH_H__
  32. #define __LATCH_H__
  33. /* a 32KB buffer is sufficient for lastpc, lastbus, return stack */
  34. #define LATCH_BUF_LENGTH 0x8000
  35. #ifdef MTK_SMC_ID_MGMT
  36. #include "mtk_secure_api.h"
  37. #else
  38. #define MTK_SIP_LK_LASTBUS 0x82000107
  39. #endif
  40. #define LASTBSU_SMC_INIT 0
  41. #define LASTBSU_SMC_CHECK_HANG 1
  42. #define LASTBSU_SMC_MONITOR_GET 2
  43. enum {
  44. LASTPC_V1 = 0,
  45. LASTPC_V2,
  46. };
  47. /* platform-dependent configs for lastpc */
  48. struct plt_cfg_pc_latch {
  49. unsigned int nr_max_core;
  50. unsigned int nr_max_big_core;
  51. unsigned int mp0_dbg_ctrl;
  52. unsigned int mp0_dbg_flag;
  53. unsigned int mp1_dbg_ctrl;
  54. unsigned int mp1_dbg_flag;
  55. unsigned int anake_core_dbg_sel;
  56. unsigned int anake_core_dbg_mon;
  57. unsigned int spm_pwr_sts;
  58. int (*dump)(const struct plt_cfg_pc_latch *self, char *buf, int *wp);
  59. unsigned int bypass_sram_flag0;
  60. unsigned long plat_sram_flag0;
  61. unsigned int version;
  62. };
  63. /* platform-dependent configs for lastbus */
  64. struct lastbus_mcusys_offsets {
  65. unsigned int bus_mcu_m0;
  66. unsigned int bus_mcu_s1;
  67. unsigned int bus_mcu_m0_m;
  68. unsigned int bus_mcu_s1_m;
  69. };
  70. struct lastbus_perisys_offsets {
  71. unsigned int bus_peri_r0;
  72. unsigned int bus_peri_r1;
  73. unsigned int bus_peri_mon;
  74. };
  75. struct lastbus_infrasys_offsets {
  76. unsigned int bus_infra_ctrl;
  77. unsigned int bus_infra_mask_l;
  78. unsigned int bus_infra_mask_h;
  79. unsigned int bus_infra_snapshot;
  80. };
  81. struct plt_cfg_bus_latch;
  82. struct lastbus_ops {
  83. int (*init)(const struct plt_cfg_bus_latch *self);
  84. int (*is_timeout)(const struct plt_cfg_bus_latch *self);
  85. int (*dump)(const struct plt_cfg_bus_latch *self, char *buf, int *wp);
  86. };
  87. struct plt_cfg_bus_latch {
  88. unsigned int supported;
  89. unsigned int num_master_port;
  90. unsigned int num_slave_port;
  91. unsigned int num_perisys_mon;
  92. unsigned int num_infrasys_mon;
  93. unsigned int secure_perisys;
  94. unsigned int perisys_enable;
  95. unsigned int perisys_timeout;
  96. unsigned int perisys_eventmask;
  97. unsigned int infrasys_enable;
  98. unsigned int infrasys_config;
  99. struct lastbus_ops mcusys_ops;
  100. struct lastbus_ops perisys_ops;
  101. struct lastbus_ops infrasys_ops;
  102. struct lastbus_mcusys_offsets mcusys_offsets;
  103. struct lastbus_perisys_offsets perisys_offsets;
  104. struct lastbus_infrasys_offsets infrasys_offsets;
  105. unsigned int infra_timeout_26m;
  106. unsigned int peri_timeout_26m;
  107. };
  108. struct plt_cfg_cache_latch;
  109. struct cache_ops {
  110. int (*init)(struct plt_cfg_cache_latch *self);
  111. int (*has_error)(struct plt_cfg_cache_latch *self);
  112. int (*dump)(struct plt_cfg_cache_latch *self, char *buf, int *wp);
  113. int (*reset)(struct plt_cfg_cache_latch *self);
  114. };
  115. struct cache_reg_info {
  116. unsigned int ctrl_offset;
  117. unsigned int ctrl_mask;
  118. unsigned int dump_offset;
  119. unsigned int dump_length;
  120. };
  121. struct plt_cfg_cache_latch {
  122. unsigned int support_level;
  123. struct cache_ops ops;
  124. struct cache_reg_info reg_info;
  125. };
  126. struct plt_cfg_l2_parity_latch {
  127. unsigned int supported;
  128. unsigned int mp0_l2_cache_parity1_rdata;
  129. unsigned int mp0_l2_cache_parity2_rdata;
  130. unsigned int mp1_l2_cache_parity1_rdata;
  131. unsigned int mp1_l2_cache_parity2_rdata;
  132. };
  133. struct plt_cfg_big_core {
  134. unsigned int cpuid;
  135. unsigned int nr_circular_buffer_entry;
  136. unsigned long circular_buffer_addr;
  137. };
  138. struct plt_circular_buffer_op {
  139. void (*unlock)(void);
  140. void (*lock)(void);
  141. };
  142. extern int plt_get_cluster_id(unsigned int cpu_id, unsigned int *core_id_in_cluster);
  143. extern unsigned long plt_get_cpu_power_status_at_wdt(void);
  144. extern const struct plt_cfg_pc_latch cfg_pc_latch;
  145. extern const struct plt_cfg_bus_latch cfg_bus_latch;
  146. extern const struct plt_cfg_l2_parity_latch cfg_l2_parity_latch;
  147. extern const struct plt_cfg_big_core cfg_big_core[];
  148. extern struct plt_circular_buffer_op circular_buffer_op;
  149. extern int g_is_64bit_kernel;
  150. void latch_lastbus_init(void);
  151. #endif