latch.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. LASTPC_V3,
  47. };
  48. /* platform-dependent configs for lastpc */
  49. struct plt_cfg_pc_latch {
  50. unsigned int nr_max_core;
  51. unsigned int nr_max_big_core;
  52. unsigned int mp0_dbg_ctrl;
  53. unsigned int mp0_dbg_flag;
  54. unsigned int mp1_dbg_ctrl;
  55. unsigned int mp1_dbg_flag;
  56. unsigned int anake_core_dbg_sel;
  57. unsigned int anake_core_dbg_mon;
  58. unsigned int spm_pwr_sts;
  59. int (*dump)(const struct plt_cfg_pc_latch *self, char *buf, int *wp);
  60. unsigned int bypass_sram_flag0;
  61. unsigned long plat_sram_flag0;
  62. unsigned int version;
  63. };
  64. /* platform-dependent configs for lastbus */
  65. struct lastbus_mcusys_offsets {
  66. unsigned int bus_mcu_m0;
  67. unsigned int bus_mcu_s1;
  68. unsigned int bus_mcu_m0_m;
  69. unsigned int bus_mcu_s1_m;
  70. };
  71. struct lastbus_perisys_offsets {
  72. unsigned int bus_peri_r0;
  73. unsigned int bus_peri_r1;
  74. unsigned int bus_peri_mon;
  75. };
  76. struct lastbus_infrasys_offsets {
  77. unsigned int bus_infra_ctrl;
  78. unsigned int bus_infra_mask_l;
  79. unsigned int bus_infra_mask_h;
  80. unsigned int bus_infra_snapshot;
  81. };
  82. struct plt_cfg_bus_latch;
  83. struct lastbus_ops {
  84. int (*init)(const struct plt_cfg_bus_latch *self);
  85. int (*is_timeout)(const struct plt_cfg_bus_latch *self);
  86. int (*dump)(const struct plt_cfg_bus_latch *self, char *buf, int *wp);
  87. };
  88. struct lastbus_monitor;
  89. struct lastbus_ops_v2 {
  90. int (*init)(const struct lastbus_monitor *m);
  91. bool (*is_timeout)(const struct lastbus_monitor *m);
  92. int (*dump)(const struct lastbus_monitor *m, char *buf, int *wp);
  93. };
  94. struct lastbus_monitor {
  95. const char *name;
  96. void *base;
  97. unsigned int num_ports;
  98. struct lastbus_ops_v2 ops;
  99. };
  100. enum LASTBUS_SW_VERSION {
  101. LASTBUS_SW_V1 = 0,
  102. LASTBUS_SW_V2 = 1,
  103. };
  104. #define NR_MAX_LASTBUS_MONITOR 16
  105. struct plt_cfg_bus_latch_v2 {
  106. unsigned int used_num;
  107. struct lastbus_monitor monitors[NR_MAX_LASTBUS_MONITOR];
  108. };
  109. struct plt_cfg_bus_latch {
  110. unsigned int sw_version;
  111. unsigned int supported;
  112. struct plt_cfg_bus_latch_v2 v2;
  113. unsigned int num_master_port;
  114. unsigned int num_slave_port;
  115. unsigned int num_perisys_mon;
  116. unsigned int num_infrasys_mon;
  117. unsigned int secure_perisys;
  118. unsigned int perisys_enable;
  119. unsigned int perisys_timeout;
  120. unsigned int perisys_eventmask;
  121. unsigned int infrasys_enable;
  122. unsigned int infrasys_config;
  123. struct lastbus_ops mcusys_ops;
  124. struct lastbus_ops perisys_ops;
  125. struct lastbus_ops infrasys_ops;
  126. struct lastbus_mcusys_offsets mcusys_offsets;
  127. struct lastbus_perisys_offsets perisys_offsets;
  128. struct lastbus_infrasys_offsets infrasys_offsets;
  129. unsigned int infra_timeout_26m;
  130. unsigned int peri_timeout_26m;
  131. };
  132. struct plt_cfg_cache_latch;
  133. struct cache_ops {
  134. int (*init)(struct plt_cfg_cache_latch *self);
  135. int (*has_error)(struct plt_cfg_cache_latch *self);
  136. int (*dump)(struct plt_cfg_cache_latch *self, char *buf, int *wp);
  137. int (*reset)(struct plt_cfg_cache_latch *self);
  138. };
  139. struct cache_reg_info {
  140. unsigned int ctrl_offset;
  141. unsigned int ctrl_mask;
  142. unsigned int dump_offset;
  143. unsigned int dump_length;
  144. };
  145. struct plt_cfg_cache_latch {
  146. unsigned int support_level;
  147. struct cache_ops ops;
  148. struct cache_reg_info reg_info;
  149. };
  150. struct plt_cfg_l2_parity_latch {
  151. unsigned int supported;
  152. unsigned int mp0_l2_cache_parity1_rdata;
  153. unsigned int mp0_l2_cache_parity2_rdata;
  154. unsigned int mp1_l2_cache_parity1_rdata;
  155. unsigned int mp1_l2_cache_parity2_rdata;
  156. };
  157. struct plt_cfg_big_core {
  158. unsigned int cpuid;
  159. unsigned int nr_circular_buffer_entry;
  160. unsigned long circular_buffer_addr;
  161. };
  162. struct plt_circular_buffer_op {
  163. void (*unlock)(void);
  164. void (*lock)(void);
  165. };
  166. extern int plt_get_cluster_id(unsigned int cpu_id, unsigned int *core_id_in_cluster);
  167. extern unsigned long plt_get_cpu_power_status_at_wdt(void);
  168. extern const struct plt_cfg_pc_latch cfg_pc_latch;
  169. extern const struct plt_cfg_bus_latch cfg_bus_latch;
  170. extern const struct plt_cfg_l2_parity_latch cfg_l2_parity_latch;
  171. extern const struct plt_cfg_big_core cfg_big_core[];
  172. extern struct plt_circular_buffer_op circular_buffer_op;
  173. extern int g_is_64bit_kernel;
  174. void latch_lastbus_init(void);
  175. #endif