audio_prm.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/slab.h>
  6. #include <linux/wait.h>
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/sched.h>
  10. #include <linux/delay.h>
  11. #include <linux/jiffies.h>
  12. #include <linux/of.h>
  13. #include <linux/of_platform.h>
  14. #include <ipc/gpr-lite.h>
  15. #include <soc/snd_event.h>
  16. #include <dsp/audio_prm.h>
  17. #include <dsp/spf-core.h>
  18. #include <dsp/audio_notifier.h>
  19. #define TIMEOUT_MS 500
  20. #define MAX_RETRY_COUNT 3
  21. #define APM_READY_WAIT_DURATION 2
  22. struct audio_prm {
  23. struct gpr_device *adev;
  24. wait_queue_head_t wait;
  25. struct mutex lock;
  26. bool resp_received;
  27. atomic_t state;
  28. atomic_t status;
  29. bool is_adsp_up;
  30. };
  31. static struct audio_prm g_prm;
  32. static bool is_apm_ready_check_done = false;
  33. static int audio_prm_callback(struct gpr_device *adev, void *data)
  34. {
  35. struct gpr_hdr *hdr = (struct gpr_hdr *)data;
  36. uint32_t *payload = GPR_PKT_GET_PAYLOAD(uint32_t, data);
  37. //dev_err(&adev->dev, "%s: Payload %x", __func__, hdr->opcode);
  38. switch (hdr->opcode) {
  39. case GPR_IBASIC_RSP_RESULT:
  40. pr_err("%s: Failed response received",__func__);
  41. atomic_set(&g_prm.status, payload[1]);
  42. g_prm.resp_received = true;
  43. break;
  44. case PRM_CMD_RSP_REQUEST_HW_RSC:
  45. case PRM_CMD_RSP_RELEASE_HW_RSC:
  46. /* payload[1] contains the error status for response */
  47. if (payload[1] != 0) {
  48. atomic_set(&g_prm.status, payload[1]);
  49. pr_err("%s: cmd = 0x%x returned error = 0x%x\n",
  50. __func__, payload[0], payload[1]);
  51. }
  52. g_prm.resp_received = true;
  53. /* payload[0] contains the param_ID for response */
  54. switch (payload[0]) {
  55. case PARAM_ID_RSC_AUDIO_HW_CLK:
  56. case PARAM_ID_RSC_LPASS_CORE:
  57. case PARAM_ID_RSC_HW_CORE:
  58. if (payload[1] != 0)
  59. pr_err("%s: PRM command failed with error %d\n",
  60. __func__, payload[1]);
  61. atomic_set(&g_prm.state, payload[1]);
  62. break;
  63. default:
  64. pr_err("%s: hit default case",__func__);
  65. break;
  66. };
  67. default:
  68. break;
  69. };
  70. if (g_prm.resp_received)
  71. wake_up(&g_prm.wait);
  72. return 0;
  73. }
  74. static int prm_gpr_send_pkt(struct gpr_pkt *pkt, wait_queue_head_t *wait)
  75. {
  76. int ret = 0;
  77. int retry;
  78. if (wait)
  79. atomic_set(&g_prm.state, 1);
  80. atomic_set(&g_prm.status, 0);
  81. mutex_lock(&g_prm.lock);
  82. pr_debug("%s: enter",__func__);
  83. if (g_prm.adev == NULL) {
  84. pr_err("%s: apr is unregistered\n", __func__);
  85. mutex_unlock(&g_prm.lock);
  86. return -ENODEV;
  87. }
  88. if (!is_apm_ready_check_done && g_prm.is_adsp_up &&
  89. (gpr_get_q6_state() == GPR_SUBSYS_LOADED)) {
  90. pr_info("%s: apm ready check not done\n", __func__);
  91. retry = 0;
  92. while (!spf_core_is_apm_ready() || retry < MAX_RETRY_COUNT) {
  93. msleep(APM_READY_WAIT_DURATION);
  94. retry++;
  95. }
  96. is_apm_ready_check_done = true;
  97. pr_info("%s: apm ready check done\n", __func__);
  98. }
  99. g_prm.resp_received = false;
  100. ret = gpr_send_pkt(g_prm.adev, pkt);
  101. if (ret < 0) {
  102. pr_err("%s: packet not transmitted %d\n", __func__, ret);
  103. mutex_unlock(&g_prm.lock);
  104. return ret;
  105. }
  106. if (wait) {
  107. ret = wait_event_timeout(g_prm.wait,
  108. (g_prm.resp_received),
  109. msecs_to_jiffies(2 * TIMEOUT_MS));
  110. if (!ret) {
  111. pr_err("%s: pkt send timeout\n", __func__);
  112. ret = -ETIMEDOUT;
  113. } else if (atomic_read(&g_prm.status) > 0) {
  114. pr_err("%s: DSP returned error %d\n", __func__,
  115. atomic_read(&g_prm.status));
  116. ret = -EINVAL;
  117. } else {
  118. ret = 0;
  119. }
  120. }
  121. pr_debug("%s: exit",__func__);
  122. mutex_unlock(&g_prm.lock);
  123. return ret;
  124. }
  125. /**
  126. */
  127. int audio_prm_set_lpass_hw_core_req(struct clk_cfg *cfg, uint32_t hw_core_id, uint8_t enable)
  128. {
  129. struct gpr_pkt *pkt;
  130. prm_cmd_request_hw_core_t prm_rsc_request;
  131. int ret = 0;
  132. uint32_t size;
  133. size = GPR_HDR_SIZE + sizeof(prm_cmd_request_hw_core_t);
  134. pkt = kzalloc(size, GFP_KERNEL);
  135. if (!pkt)
  136. return -ENOMEM;
  137. pkt->hdr.header = GPR_SET_FIELD(GPR_PKT_VERSION, GPR_PKT_VER) |
  138. GPR_SET_FIELD(GPR_PKT_HEADER_SIZE, GPR_PKT_HEADER_WORD_SIZE_V) |
  139. GPR_SET_FIELD(GPR_PKT_PACKET_SIZE, size);
  140. pkt->hdr.src_port = GPR_SVC_ASM;
  141. pkt->hdr.dst_port = PRM_MODULE_INSTANCE_ID;
  142. pkt->hdr.dst_domain_id = GPR_IDS_DOMAIN_ID_ADSP_V;
  143. pkt->hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
  144. pkt->hdr.token = 0; /* TBD */
  145. if (enable)
  146. pkt->hdr.opcode = PRM_CMD_REQUEST_HW_RSC;
  147. else
  148. pkt->hdr.opcode = PRM_CMD_RELEASE_HW_RSC;
  149. //pr_err("%s: clk_id %d size of cmd_req %ld \n",__func__, cfg->clk_id, sizeof(prm_cmd_request_hw_core_t));
  150. prm_rsc_request.payload_header.payload_address_lsw = 0;
  151. prm_rsc_request.payload_header.payload_address_msw = 0;
  152. prm_rsc_request.payload_header.mem_map_handle = 0;
  153. prm_rsc_request.payload_header.payload_size = sizeof(prm_cmd_request_hw_core_t) - sizeof(apm_cmd_header_t);
  154. /** Populate the param payload */
  155. prm_rsc_request.module_payload_0.module_instance_id = PRM_MODULE_INSTANCE_ID;
  156. prm_rsc_request.module_payload_0.error_code = 0;
  157. prm_rsc_request.module_payload_0.param_id = PARAM_ID_RSC_HW_CORE;
  158. prm_rsc_request.module_payload_0.param_size =
  159. sizeof(prm_cmd_request_hw_core_t) - sizeof(apm_cmd_header_t) - sizeof(apm_module_param_data_t);
  160. prm_rsc_request.hw_core_id = hw_core_id; // HW_CORE_ID_LPASS;
  161. memcpy(&pkt->payload, &prm_rsc_request, sizeof(prm_cmd_request_hw_core_t));
  162. ret = prm_gpr_send_pkt(pkt, &g_prm.wait);
  163. kfree(pkt);
  164. return ret;
  165. }
  166. EXPORT_SYMBOL(audio_prm_set_lpass_hw_core_req);
  167. /**
  168. * prm_set_lpass_clk_cfg() - Set PRM clock
  169. *
  170. * Return: 0 if clock set is success
  171. */
  172. static int audio_prm_set_lpass_clk_cfg_req(struct clk_cfg *cfg)
  173. {
  174. struct gpr_pkt *pkt;
  175. prm_cmd_request_rsc_t prm_rsc_request;
  176. int ret = 0;
  177. uint32_t size;
  178. size = GPR_HDR_SIZE + sizeof(prm_cmd_request_rsc_t);
  179. pkt = kzalloc(size, GFP_KERNEL);
  180. if (!pkt)
  181. return -ENOMEM;
  182. pkt->hdr.header = GPR_SET_FIELD(GPR_PKT_VERSION, GPR_PKT_VER) |
  183. GPR_SET_FIELD(GPR_PKT_HEADER_SIZE, GPR_PKT_HEADER_WORD_SIZE_V) |
  184. GPR_SET_FIELD(GPR_PKT_PACKET_SIZE, size);
  185. pkt->hdr.src_port = GPR_SVC_ASM;
  186. pkt->hdr.dst_port = PRM_MODULE_INSTANCE_ID;
  187. pkt->hdr.dst_domain_id = GPR_IDS_DOMAIN_ID_ADSP_V;
  188. pkt->hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
  189. pkt->hdr.token = 0; /* TBD */
  190. pkt->hdr.opcode = PRM_CMD_REQUEST_HW_RSC;
  191. //pr_err("%s: clk_id %d size of cmd_req %ld \n",__func__, cfg->clk_id, sizeof(prm_cmd_request_rsc_t));
  192. prm_rsc_request.payload_header.payload_address_lsw = 0;
  193. prm_rsc_request.payload_header.payload_address_msw = 0;
  194. prm_rsc_request.payload_header.mem_map_handle = 0;
  195. prm_rsc_request.payload_header.payload_size = sizeof(prm_cmd_request_rsc_t) - sizeof(apm_cmd_header_t);
  196. /** Populate the param payload */
  197. prm_rsc_request.module_payload_0.module_instance_id = PRM_MODULE_INSTANCE_ID;
  198. prm_rsc_request.module_payload_0.error_code = 0;
  199. prm_rsc_request.module_payload_0.param_id = PARAM_ID_RSC_AUDIO_HW_CLK;
  200. prm_rsc_request.module_payload_0.param_size =
  201. sizeof(prm_cmd_request_rsc_t) - sizeof(apm_cmd_header_t) - sizeof(apm_module_param_data_t);
  202. prm_rsc_request.num_clk_id_t.num_clock_id = MAX_AUD_HW_CLK_NUM_REQ;
  203. prm_rsc_request.clock_ids_t[0].clock_id = cfg->clk_id;
  204. prm_rsc_request.clock_ids_t[0].clock_freq = cfg->clk_freq_in_hz;
  205. prm_rsc_request.clock_ids_t[0].clock_attri = cfg->clk_attri;
  206. prm_rsc_request.clock_ids_t[0].clock_root = cfg->clk_root;
  207. memcpy(&pkt->payload, &prm_rsc_request, sizeof(prm_cmd_request_rsc_t));
  208. ret = prm_gpr_send_pkt(pkt, &g_prm.wait);
  209. kfree(pkt);
  210. return ret;
  211. }
  212. static int audio_prm_set_lpass_clk_cfg_rel(struct clk_cfg *cfg)
  213. {
  214. struct gpr_pkt *pkt;
  215. prm_cmd_release_rsc_t prm_rsc_release;
  216. int ret = 0;
  217. uint32_t size;
  218. size = GPR_HDR_SIZE + sizeof(prm_cmd_release_rsc_t);
  219. pkt = kzalloc(size, GFP_KERNEL);
  220. if (!pkt)
  221. return -ENOMEM;
  222. pkt->hdr.header = GPR_SET_FIELD(GPR_PKT_VERSION, GPR_PKT_VER) |
  223. GPR_SET_FIELD(GPR_PKT_HEADER_SIZE, GPR_PKT_HEADER_WORD_SIZE_V) |
  224. GPR_SET_FIELD(GPR_PKT_PACKET_SIZE, size);
  225. pkt->hdr.src_port = GPR_SVC_ASM;
  226. pkt->hdr.dst_port = PRM_MODULE_INSTANCE_ID;
  227. pkt->hdr.dst_domain_id = GPR_IDS_DOMAIN_ID_ADSP_V;
  228. pkt->hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
  229. pkt->hdr.token = 0; /* TBD */
  230. pkt->hdr.opcode = PRM_CMD_RELEASE_HW_RSC;
  231. //pr_err("%s: clk_id %d size of cmd_req %ld \n",__func__, cfg->clk_id, sizeof(prm_cmd_release_rsc_t));
  232. prm_rsc_release.payload_header.payload_address_lsw = 0;
  233. prm_rsc_release.payload_header.payload_address_msw = 0;
  234. prm_rsc_release.payload_header.mem_map_handle = 0;
  235. prm_rsc_release.payload_header.payload_size = sizeof(prm_cmd_release_rsc_t) - sizeof(apm_cmd_header_t);
  236. /** Populate the param payload */
  237. prm_rsc_release.module_payload_0.module_instance_id = PRM_MODULE_INSTANCE_ID;
  238. prm_rsc_release.module_payload_0.error_code = 0;
  239. prm_rsc_release.module_payload_0.param_id = PARAM_ID_RSC_AUDIO_HW_CLK;
  240. prm_rsc_release.module_payload_0.param_size =
  241. sizeof(prm_cmd_release_rsc_t) - sizeof(apm_cmd_header_t) - sizeof(apm_module_param_data_t);
  242. prm_rsc_release.num_clk_id_t.num_clock_id = MAX_AUD_HW_CLK_NUM_REQ;
  243. prm_rsc_release.clock_ids_t[0].clock_id = cfg->clk_id;
  244. memcpy(&pkt->payload, &prm_rsc_release, sizeof(prm_cmd_release_rsc_t));
  245. ret = prm_gpr_send_pkt(pkt, &g_prm.wait);
  246. kfree(pkt);
  247. return ret;
  248. }
  249. /**
  250. * audio_prm_set_cdc_earpa_duty_cycling_req() - send codec reg values
  251. * for codec duty cycling.
  252. *
  253. * Return: 0 if reg passing is success.
  254. */
  255. int audio_prm_set_cdc_earpa_duty_cycling_req(struct prm_earpa_hw_intf_config *earpa_config,
  256. uint32_t enable)
  257. {
  258. struct gpr_pkt *pkt;
  259. prm_cmd_request_cdc_duty_cycling_t prm_rsc_request_reg_info;
  260. int ret = 0;
  261. uint32_t size;
  262. size = GPR_HDR_SIZE + sizeof(prm_cmd_request_cdc_duty_cycling_t);
  263. pkt = kzalloc(size, GFP_KERNEL);
  264. if (!pkt)
  265. return -ENOMEM;
  266. pkt->hdr.header = GPR_SET_FIELD(GPR_PKT_VERSION, GPR_PKT_VER) |
  267. GPR_SET_FIELD(GPR_PKT_HEADER_SIZE, GPR_PKT_HEADER_WORD_SIZE_V) |
  268. GPR_SET_FIELD(GPR_PKT_PACKET_SIZE, size);
  269. pkt->hdr.src_port = GPR_SVC_ASM;
  270. pkt->hdr.dst_port = PRM_MODULE_INSTANCE_ID;
  271. pkt->hdr.dst_domain_id = GPR_IDS_DOMAIN_ID_ADSP_V;
  272. pkt->hdr.src_domain_id = GPR_IDS_DOMAIN_ID_APPS_V;
  273. pkt->hdr.token = 0;
  274. if (enable)
  275. pkt->hdr.opcode = PRM_CMD_REQUEST_HW_RSC;
  276. else
  277. pkt->hdr.opcode = PRM_CMD_RELEASE_HW_RSC;
  278. memset(&prm_rsc_request_reg_info, 0, sizeof(prm_cmd_request_cdc_duty_cycling_t));
  279. prm_rsc_request_reg_info.payload_header.payload_address_lsw = 0;
  280. prm_rsc_request_reg_info.payload_header.payload_address_msw = 0;
  281. prm_rsc_request_reg_info.payload_header.mem_map_handle = 0;
  282. prm_rsc_request_reg_info.payload_header.payload_size =
  283. sizeof(prm_cmd_request_cdc_duty_cycling_t) - sizeof(apm_cmd_header_t);
  284. /* Populate the param payload */
  285. prm_rsc_request_reg_info.module_payload_0.module_instance_id =
  286. PRM_MODULE_INSTANCE_ID;
  287. prm_rsc_request_reg_info.module_payload_0.error_code = 0;
  288. prm_rsc_request_reg_info.module_payload_0.param_id =
  289. PARAM_ID_RSC_HW_CODEC_REG_INFO;
  290. prm_rsc_request_reg_info.module_payload_0.param_size =
  291. sizeof(prm_cmd_request_cdc_duty_cycling_t) -
  292. sizeof(apm_cmd_header_t) - sizeof(apm_module_param_data_t);
  293. prm_rsc_request_reg_info.hw_codec_reg_info_t.num_reg_info_t = MAX_EARPA_REG;
  294. /* Setting up DIGITAL Mute register value */
  295. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_reg_id =
  296. HW_CODEC_DIG_REG_ID_MUTE_CTRL;
  297. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_reg_addr_msw = 0;
  298. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_reg_addr_lsw =
  299. earpa_config->ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr;
  300. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].num_ops =
  301. MAX_EARPA_CDC_DUTY_CYC_OPERATION;
  302. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_op[0].hw_codec_op_id =
  303. HW_CODEC_OP_DIG_MUTE_ENABLE;
  304. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_op[0].hw_codec_op_value =
  305. DIG_MUTE_ENABLE;
  306. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_op[1].hw_codec_op_id =
  307. HW_CODEC_OP_DIG_MUTE_DISABLE;
  308. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[0].hw_codec_op[1].hw_codec_op_value =
  309. DIG_MUTE_DISABLE;
  310. /* Setting up LPASS_PA_REG Values */
  311. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_reg_id =
  312. HW_CODEC_ANALOG_REG_ID_CMD_FIFO_WRITE;
  313. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_reg_addr_msw = 0;
  314. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_reg_addr_lsw =
  315. earpa_config->ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr;
  316. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].num_ops =
  317. MAX_EARPA_CDC_DUTY_CYC_OPERATION;
  318. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_op[0].hw_codec_op_id =
  319. HW_CODEC_OP_ANA_PGA_ENABLE;
  320. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_op[0].hw_codec_op_value =
  321. earpa_config->ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr;
  322. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_op[1].hw_codec_op_id =
  323. HW_CODEC_OP_ANA_PGA_DISABLE;
  324. prm_rsc_request_reg_info.hw_codec_reg_info_t.hw_codec_reg[1].hw_codec_op[1].hw_codec_op_value =
  325. earpa_config->ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr;
  326. memcpy(&pkt->payload, &prm_rsc_request_reg_info, sizeof(prm_cmd_request_cdc_duty_cycling_t));
  327. ret = prm_gpr_send_pkt(pkt, &g_prm.wait);
  328. kfree(pkt);
  329. return ret;
  330. }
  331. EXPORT_SYMBOL(audio_prm_set_cdc_earpa_duty_cycling_req);
  332. int audio_prm_set_lpass_clk_cfg (struct clk_cfg *clk, uint8_t enable)
  333. {
  334. int ret = 0;
  335. if (enable)
  336. ret = audio_prm_set_lpass_clk_cfg_req (clk);
  337. else
  338. ret = audio_prm_set_lpass_clk_cfg_rel (clk);
  339. return ret;
  340. }
  341. EXPORT_SYMBOL(audio_prm_set_lpass_clk_cfg);
  342. static int audio_prm_service_cb(struct notifier_block *this,
  343. unsigned long opcode, void *data)
  344. {
  345. pr_info("%s: Service opcode 0x%lx\n", __func__, opcode);
  346. switch (opcode) {
  347. case AUDIO_NOTIFIER_SERVICE_DOWN:
  348. mutex_lock(&g_prm.lock);
  349. pr_debug("%s: making apm_ready check false\n", __func__);
  350. is_apm_ready_check_done = false;
  351. g_prm.is_adsp_up = false;
  352. mutex_unlock(&g_prm.lock);
  353. break;
  354. case AUDIO_NOTIFIER_SERVICE_UP:
  355. mutex_lock(&g_prm.lock);
  356. g_prm.is_adsp_up = true;
  357. mutex_unlock(&g_prm.lock);
  358. break;
  359. default:
  360. break;
  361. }
  362. return NOTIFY_OK;
  363. }
  364. static struct notifier_block service_nb = {
  365. .notifier_call = audio_prm_service_cb,
  366. .priority = -INT_MAX,
  367. };
  368. static int audio_prm_probe(struct gpr_device *adev)
  369. {
  370. int ret = 0;
  371. ret = audio_notifier_register("audio_prm", AUDIO_NOTIFIER_ADSP_DOMAIN,
  372. &service_nb);
  373. if (ret < 0) {
  374. if (ret != -EPROBE_DEFER)
  375. pr_err("%s: Audio notifier register failed ret = %d\n",
  376. __func__, ret);
  377. return ret;
  378. }
  379. dev_set_drvdata(&adev->dev, &g_prm);
  380. g_prm.adev = adev;
  381. init_waitqueue_head(&g_prm.wait);
  382. g_prm.is_adsp_up = true;
  383. pr_err("%s: prm probe success\n", __func__);
  384. return ret;
  385. }
  386. static int audio_prm_remove(struct gpr_device *adev)
  387. {
  388. int ret = 0;
  389. audio_notifier_deregister("audio_prm");
  390. mutex_lock(&g_prm.lock);
  391. g_prm.is_adsp_up = false;
  392. g_prm.adev = NULL;
  393. mutex_unlock(&g_prm.lock);
  394. return ret;
  395. }
  396. static const struct of_device_id audio_prm_device_id[] = {
  397. { .compatible = "qcom,audio_prm" },
  398. {},
  399. };
  400. MODULE_DEVICE_TABLE(of, audio_prm_device_id);
  401. static struct gpr_driver qcom_audio_prm_driver = {
  402. .probe = audio_prm_probe,
  403. .remove = audio_prm_remove,
  404. .callback = audio_prm_callback,
  405. .driver = {
  406. .name = "qcom-audio_prm",
  407. .of_match_table = of_match_ptr(audio_prm_device_id),
  408. },
  409. };
  410. static int __init audio_prm_module_init(void)
  411. {
  412. int ret;
  413. ret = gpr_driver_register(&qcom_audio_prm_driver);
  414. if (ret)
  415. pr_err("%s: gpr driver register failed = %d\n", __func__, ret);
  416. mutex_init(&g_prm.lock);
  417. return ret;
  418. }
  419. static void __exit audio_prm_module_exit(void)
  420. {
  421. mutex_destroy(&g_prm.lock);
  422. gpr_driver_unregister(&qcom_audio_prm_driver);
  423. }
  424. module_init(audio_prm_module_init);
  425. module_exit(audio_prm_module_exit);
  426. MODULE_DESCRIPTION("audio prm");
  427. MODULE_LICENSE("GPL v2");