wcd_cpe_services.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef __CPE_SERVICES__
  13. #define __CPE_SERVICES__
  14. #define CPE_IRQ_OUTBOX_IRQ 0x01
  15. #define CPE_IRQ_MEM_ACCESS_ERROR 0x02
  16. #define CPE_IRQ_WDOG_BITE 0x04
  17. #define CPE_IRQ_BUFFER_OVERFLOW 0x08
  18. #define CPE_IRQ_LAB_OVFUNF 0x10
  19. #define CPE_IRQ_FLL_LOCK_LOST 0x20
  20. #define CPE_IRQ_RCO_WDOG_INT 0x40
  21. #define EFAILED (MAX_ERRNO - 1)
  22. #define ENOTREADY (MAX_ERRNO - 2)
  23. #define MAX_SUPPORTED_CLKFREQ 8
  24. #define CPE_SVC_INIT_PARAM_V1 1
  25. enum cpe_svc_result {
  26. CPE_SVC_SUCCESS = 0,
  27. CPE_SVC_FAILED = -EFAILED,
  28. CPE_SVC_NO_MEMORY = -ENOMEM,
  29. CPE_SVC_INVALID_HANDLE = -EINVAL,
  30. CPE_SVC_NOT_READY = -ENOTREADY,
  31. CPE_SVC_SHUTTING_DOWN = -ESHUTDOWN,
  32. CPE_SVC_BUSY = -EBUSY,
  33. };
  34. enum cpe_svc_event {
  35. CPE_SVC_CMI_MSG = 0x01,
  36. CPE_SVC_OFFLINE = 0x02,
  37. CPE_SVC_ONLINE = 0x04,
  38. CPE_SVC_BOOT_FAILED = 0x08,
  39. CPE_SVC_READ_COMPLETE = 0x10,
  40. CPE_SVC_READ_ERROR = 0x20,
  41. CPE_SVC_BOOT = 0x40,
  42. CPE_SVC_CMI_CLIENTS_DEREG = 0x100,
  43. CPE_SVC_EVENT_ANCHOR = 0x7FFF
  44. };
  45. enum cpe_svc_module {
  46. CPE_SVC_LISTEN_PROC = 1,
  47. CPE_SVC_MODULE_ANCHOR = 0x7F
  48. };
  49. enum cpe_svc_route_dest {
  50. CPE_SVC_EXTERNAL = 1,
  51. CPE_SVC_INTERNAL = 2,
  52. CPE_SVC_ROUTE_ANCHOR = 0x7F
  53. };
  54. enum cpe_svc_mem_type {
  55. CPE_SVC_DATA_MEM = 1,
  56. CPE_SVC_INSTRUCTION_MEM = 2,
  57. CPE_SVC_IPC_MEM = 3,
  58. CPE_SVC_MEM_TYPE_ANCHOR = 0x7F
  59. };
  60. enum cpe_svc_codec_id {
  61. CPE_SVC_CODEC_TOMTOM = 5,
  62. CPE_SVC_CODEC_WCD9335 = 7,
  63. CPE_SVC_CODEC_WCD9326 = 8,
  64. CPE_SVC_CODEC_ID_ANCHOR = 0x7ffffff
  65. };
  66. enum cpe_svc_codec_version {
  67. CPE_SVC_CODEC_V1P0 = 1,
  68. CPE_SVC_CODEC_VERSION_ANCHOR = 0x7fffffff
  69. };
  70. struct cpe_svc_codec_info_v1 {
  71. u16 major_version;/*must be 1*/
  72. u16 minor_version;/*must be 0*/
  73. u32 id;
  74. u32 version;
  75. /*Add 1.1 version fields after this line*/
  76. };
  77. struct cpe_svc_notification {
  78. enum cpe_svc_event event;
  79. enum cpe_svc_result result;
  80. void *payload;
  81. void *private_data;
  82. };
  83. struct cpe_svc_msg_payload {
  84. u8 *cmi_msg;
  85. };
  86. struct cpe_svc_read_complete {
  87. u8 *buffer;
  88. size_t size;
  89. };
  90. struct cpe_svc_boot_event {
  91. u32 debug_address;
  92. size_t debug_buffer_size;
  93. u32 status;
  94. };
  95. struct cpe_svc_mem_segment {
  96. enum cpe_svc_mem_type type;
  97. u32 cpe_addr;
  98. size_t size;
  99. u8 *data;
  100. };
  101. struct cpe_svc_hw_cfg {
  102. size_t DRAM_size;
  103. u32 DRAM_offset;
  104. size_t IRAM_size;
  105. u32 IRAM_offset;
  106. u8 inbox_size;
  107. u8 outbox_size;
  108. };
  109. struct cpe_svc_cfg_clk_plan {
  110. u32 current_clk_feq;
  111. u32 num_clk_freqs;
  112. u32 clk_freqs[MAX_SUPPORTED_CLKFREQ];
  113. };
  114. struct cpe_svc_init_param {
  115. void *context;
  116. u32 version;
  117. void (*query_freq_plans_cb)(void *cdc_priv,
  118. struct cpe_svc_cfg_clk_plan *clk_freq);
  119. void (*change_freq_plan_cb)(void *cdc_priv,
  120. u32 clk_freq);
  121. };
  122. void *cpe_svc_initialize(
  123. void irq_control_callback(u32 enable),
  124. const void *codec_info, void *context);
  125. enum cpe_svc_result cpe_svc_deinitialize(void *cpe_handle);
  126. void *cpe_svc_register(void *cpe_handle,
  127. void (*notification_callback)(
  128. const struct cpe_svc_notification *parameter),
  129. u32 mask, const char *name);
  130. enum cpe_svc_result cpe_svc_deregister(void *cpe_handle, void *reg_handle);
  131. enum cpe_svc_result cpe_svc_download_segment(void *cpe_handle,
  132. const struct cpe_svc_mem_segment *segment);
  133. enum cpe_svc_result cpe_svc_boot(void *cpe_handle, int debug_mode);
  134. enum cpe_svc_result cpe_svc_shutdown(void *cpe_handle);
  135. enum cpe_svc_result cpe_svc_reset(void *cpe_handle);
  136. enum cpe_svc_result cpe_svc_process_irq(void *cpe_handle, u32 cpe_irq);
  137. enum cpe_svc_result
  138. cpe_svc_route_notification(void *cpe_handle, enum cpe_svc_module module,
  139. enum cpe_svc_route_dest dest);
  140. enum cpe_svc_result cpe_svc_ramdump(void *cpe_handle,
  141. struct cpe_svc_mem_segment *buffer);
  142. enum cpe_svc_result cpe_svc_set_debug_mode(void *cpe_handle, u32 mode);
  143. const struct cpe_svc_hw_cfg *cpe_svc_get_hw_cfg(void *cpe_handle);
  144. enum cpe_svc_result cpe_svc_toggle_lab(void *cpe_handle, bool enable);
  145. enum cpe_svc_result cpe_svc_ftm_test(void *cpe_handle, u32 *status);
  146. #endif /*__CPE_SERVICES__*/