audio_notifier.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2017, 2020-2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/init.h>
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/err.h>
  10. #include <linux/string.h>
  11. #include <linux/delay.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/of_device.h>
  14. #include <linux/slab.h>
  15. #include <linux/remoteproc.h>
  16. #include <linux/remoteproc/qcom_rproc.h>
  17. #include <dsp/audio_notifier.h>
  18. #include "audio_ssr.h"
  19. #include "audio_pdr.h"
  20. /* Audio states internal to notifier. Client */
  21. /* used states defined in audio_notifier.h */
  22. /* for AUDIO_NOTIFIER_SERVICE_DOWN & UP */
  23. #define NO_SERVICE -2
  24. #define UNINIT_SERVICE -1
  25. static bool service_early_down;
  26. static struct platform_device *adsp_private;
  27. struct adsp_notify_private {
  28. struct rproc *rproc_h;
  29. bool notifier_probe_complete;
  30. };
  31. /*
  32. * Used for each client registered with audio notifier
  33. */
  34. struct client_data {
  35. struct list_head list;
  36. /* Notifier block given by client */
  37. struct notifier_block *nb;
  38. char client_name[20];
  39. int service;
  40. int domain;
  41. };
  42. /*
  43. * Used for each service and domain combination
  44. * Tracks information specific to the underlying
  45. * service.
  46. */
  47. struct service_info {
  48. const char name[20];
  49. int domain_id;
  50. int state;
  51. void *handle;
  52. /* Hook registered to service */
  53. union {
  54. void (*cb)(int, char *, void *);
  55. struct notifier_block *nb;
  56. } hook;
  57. /* Used to determine when to register and deregister service */
  58. int num_of_clients;
  59. /* List of all clients registered to the service and domain */
  60. struct srcu_notifier_head client_nb_list;
  61. };
  62. static int audio_notifier_ssr_adsp_cb(struct notifier_block *this,
  63. unsigned long opcode, void *data);
  64. static int audio_notifier_ssr_modem_cb(struct notifier_block *this,
  65. unsigned long opcode, void *data);
  66. static void audio_notifier_pdr_adsp_cb(int status, char *service_name, void *priv);
  67. static struct notifier_block notifier_ssr_adsp_nb = {
  68. .notifier_call = audio_notifier_ssr_adsp_cb,
  69. .priority = 0,
  70. };
  71. static struct notifier_block notifier_ssr_modem_nb = {
  72. .notifier_call = audio_notifier_ssr_modem_cb,
  73. .priority = 0,
  74. };
  75. static struct service_info service_data[AUDIO_NOTIFIER_MAX_SERVICES]
  76. [AUDIO_NOTIFIER_MAX_DOMAINS] = {
  77. {{
  78. .name = "SSR_ADSP",
  79. .domain_id = AUDIO_SSR_DOMAIN_ADSP,
  80. .state = AUDIO_NOTIFIER_SERVICE_DOWN,
  81. .hook.nb = &notifier_ssr_adsp_nb
  82. },
  83. {
  84. .name = "SSR_MODEM",
  85. .domain_id = AUDIO_SSR_DOMAIN_MODEM,
  86. .state = AUDIO_NOTIFIER_SERVICE_DOWN,
  87. .hook.nb = &notifier_ssr_modem_nb
  88. } },
  89. {{
  90. .name = "PDR_ADSP",
  91. .domain_id = AUDIO_PDR_DOMAIN_ADSP,
  92. .state = UNINIT_SERVICE,
  93. .hook.cb = &audio_notifier_pdr_adsp_cb
  94. },
  95. { /* PDR MODEM service not enabled */
  96. .name = "INVALID",
  97. .state = NO_SERVICE,
  98. .hook.nb = NULL
  99. } }
  100. };
  101. /* Master list of all audio notifier clients */
  102. LIST_HEAD(client_list);
  103. struct mutex notifier_mutex;
  104. static int audio_notifier_get_default_service(int domain)
  105. {
  106. int service = NO_SERVICE;
  107. /* initial service to connect per domain */
  108. switch (domain) {
  109. case AUDIO_NOTIFIER_ADSP_DOMAIN:
  110. service = AUDIO_NOTIFIER_PDR_SERVICE;
  111. break;
  112. case AUDIO_NOTIFIER_MODEM_DOMAIN:
  113. service = AUDIO_NOTIFIER_SSR_SERVICE;
  114. break;
  115. }
  116. return service;
  117. }
  118. #ifdef CONFIG_MSM_QDSP6_PDR
  119. static void audio_notifier_init_service(int service)
  120. {
  121. int i;
  122. for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++) {
  123. if (service_data[service][i].state == UNINIT_SERVICE)
  124. service_data[service][i].state =
  125. AUDIO_NOTIFIER_SERVICE_DOWN;
  126. }
  127. }
  128. #else
  129. static void audio_notifier_init_service(int service)
  130. {
  131. int i;
  132. for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++)
  133. service_data[service][i].state = NO_SERVICE;
  134. }
  135. #endif
  136. static bool audio_notifier_is_service_enabled(int service)
  137. {
  138. int i;
  139. for (i = 0; i < AUDIO_NOTIFIER_MAX_DOMAINS; i++)
  140. if (service_data[service][i].state != NO_SERVICE)
  141. return true;
  142. return false;
  143. }
  144. static int audio_notifier_reg_service(int service, int domain)
  145. {
  146. void *handle;
  147. int ret = 0;
  148. int curr_state = AUDIO_NOTIFIER_SERVICE_DOWN;
  149. struct platform_device *pdev = adsp_private;
  150. struct adsp_notify_private *priv = NULL;
  151. struct rproc *rproc;
  152. priv = platform_get_drvdata(pdev);
  153. if (!priv) {
  154. dev_err_ratelimited(&pdev->dev, " %s: Private data get failed\n", __func__);
  155. return ret;;
  156. }
  157. rproc = priv->rproc_h;
  158. switch (service) {
  159. case AUDIO_NOTIFIER_SSR_SERVICE:
  160. handle = audio_ssr_register(rproc->name,
  161. service_data[service][domain].hook.nb);
  162. break;
  163. case AUDIO_NOTIFIER_PDR_SERVICE:
  164. handle = audio_pdr_service_register(
  165. service_data[service][domain].domain_id,
  166. service_data[service][domain].hook.cb);
  167. curr_state = AUDIO_NOTIFIER_SERVICE_DOWN;
  168. break;
  169. default:
  170. pr_err_ratelimited("%s: Invalid service %d\n",
  171. __func__, service);
  172. ret = -EINVAL;
  173. goto done;
  174. }
  175. if (IS_ERR_OR_NULL(handle)) {
  176. pr_err_ratelimited("%s: handle is incorrect for service %s\n",
  177. __func__, service_data[service][domain].name);
  178. ret = -EINVAL;
  179. goto done;
  180. }
  181. service_data[service][domain].state = curr_state;
  182. service_data[service][domain].handle = handle;
  183. pr_info("%s: service %s is in use\n",
  184. __func__, service_data[service][domain].name);
  185. pr_debug("%s: service %s has current state %d, handle 0x%pK\n",
  186. __func__, service_data[service][domain].name,
  187. service_data[service][domain].state,
  188. service_data[service][domain].handle);
  189. done:
  190. return ret;
  191. }
  192. static int audio_notifier_dereg_service(int service, int domain)
  193. {
  194. int ret;
  195. switch (service) {
  196. case AUDIO_NOTIFIER_SSR_SERVICE:
  197. ret = audio_ssr_deregister(
  198. service_data[service][domain].handle,
  199. service_data[service][domain].hook.nb);
  200. break;
  201. case AUDIO_NOTIFIER_PDR_SERVICE:
  202. ret = audio_pdr_service_deregister(
  203. service_data[service][domain].domain_id);
  204. break;
  205. default:
  206. pr_err_ratelimited("%s: Invalid service %d\n",
  207. __func__, service);
  208. ret = -EINVAL;
  209. goto done;
  210. }
  211. if (ret < 0) {
  212. pr_err_ratelimited("%s: deregister failed for service %s, ret %d\n",
  213. __func__, service_data[service][domain].name, ret);
  214. goto done;
  215. }
  216. pr_debug("%s: service %s with handle 0x%pK deregistered\n",
  217. __func__, service_data[service][domain].name,
  218. service_data[service][domain].handle);
  219. mutex_lock(&notifier_mutex);
  220. service_data[service][domain].state = AUDIO_NOTIFIER_SERVICE_DOWN;
  221. service_data[service][domain].handle = NULL;
  222. mutex_unlock(&notifier_mutex);
  223. done:
  224. return ret;
  225. }
  226. static int audio_notifier_reg_client_service(struct client_data *client_data,
  227. int service)
  228. {
  229. int ret = 0;
  230. int domain = client_data->domain;
  231. struct audio_notifier_cb_data data;
  232. switch (service) {
  233. case AUDIO_NOTIFIER_SSR_SERVICE:
  234. case AUDIO_NOTIFIER_PDR_SERVICE:
  235. if (service_data[service][domain].num_of_clients == 0)
  236. ret = audio_notifier_reg_service(service, domain);
  237. break;
  238. default:
  239. pr_err_ratelimited("%s: Invalid service for client %s, service %d, domain %d\n",
  240. __func__, client_data->client_name, service, domain);
  241. ret = -EINVAL;
  242. goto done;
  243. }
  244. if (ret < 0) {
  245. pr_err_ratelimited("%s: service registration failed on service %s for client %s\n",
  246. __func__, service_data[service][domain].name,
  247. client_data->client_name);
  248. goto done;
  249. }
  250. client_data->service = service;
  251. srcu_notifier_chain_register(
  252. &service_data[service][domain].client_nb_list,
  253. client_data->nb);
  254. service_data[service][domain].num_of_clients++;
  255. pr_debug("%s: registered client %s on service %s, current state 0x%x\n",
  256. __func__, client_data->client_name,
  257. service_data[service][domain].name,
  258. service_data[service][domain].state);
  259. /*
  260. * PDR registration returns current state
  261. * Force callback of client with current state for PDR
  262. */
  263. if (client_data->service == AUDIO_NOTIFIER_PDR_SERVICE) {
  264. data.service = service;
  265. data.domain = domain;
  266. (void)client_data->nb->notifier_call(client_data->nb,
  267. service_data[service][domain].state, &data);
  268. }
  269. done:
  270. return ret;
  271. }
  272. static int audio_notifier_reg_client(struct client_data *client_data)
  273. {
  274. int ret = 0;
  275. int service;
  276. int domain = client_data->domain;
  277. service = audio_notifier_get_default_service(domain);
  278. if (service < 0) {
  279. pr_err_ratelimited("%s: service %d is incorrect\n", __func__, service);
  280. ret = -EINVAL;
  281. goto done;
  282. }
  283. /* Search through services to find a valid one to register client on. */
  284. for (; service >= 0; service--) {
  285. /* If a service is not initialized, wait for it to come up. */
  286. if (service_data[service][domain].state == UNINIT_SERVICE) {
  287. pr_err_ratelimited("%s: failed in client registration to PDR\n",
  288. __func__);
  289. ret = -EINVAL;
  290. goto done;
  291. }
  292. /* Skip unsupported service and domain combinations. */
  293. if (service_data[service][domain].state < 0)
  294. continue;
  295. /* Only register clients who have not acquired a service. */
  296. if (client_data->service != NO_SERVICE)
  297. continue;
  298. /*
  299. * Only register clients, who have not acquired a service, on
  300. * the best available service for their domain. Uninitialized
  301. * services will try to register all of their clients after
  302. * they initialize correctly or will disable their service and
  303. * register clients on the next best avaialable service.
  304. */
  305. pr_debug("%s: register client %s on service %s",
  306. __func__, client_data->client_name,
  307. service_data[service][domain].name);
  308. ret = audio_notifier_reg_client_service(client_data, service);
  309. if (ret < 0)
  310. pr_err_ratelimited("%s: client %s failed to register on service %s",
  311. __func__, client_data->client_name,
  312. service_data[service][domain].name);
  313. }
  314. done:
  315. return ret;
  316. }
  317. static int audio_notifier_dereg_client(struct client_data *client_data)
  318. {
  319. int ret = 0;
  320. int service = client_data->service;
  321. int domain = client_data->domain;
  322. switch (client_data->service) {
  323. case AUDIO_NOTIFIER_SSR_SERVICE:
  324. case AUDIO_NOTIFIER_PDR_SERVICE:
  325. if (service_data[service][domain].num_of_clients == 1)
  326. ret = audio_notifier_dereg_service(service, domain);
  327. break;
  328. case NO_SERVICE:
  329. goto done;
  330. default:
  331. pr_err_ratelimited("%s: Invalid service for client %s, service %d\n",
  332. __func__, client_data->client_name,
  333. client_data->service);
  334. ret = -EINVAL;
  335. goto done;
  336. }
  337. if (ret < 0) {
  338. pr_err_ratelimited("%s: deregister failed for client %s on service %s, ret %d\n",
  339. __func__, client_data->client_name,
  340. service_data[service][domain].name, ret);
  341. goto done;
  342. }
  343. ret = srcu_notifier_chain_unregister(&service_data[service][domain].
  344. client_nb_list, client_data->nb);
  345. if (ret < 0) {
  346. pr_err_ratelimited("%s: srcu_notifier_chain_unregister failed, ret %d\n",
  347. __func__, ret);
  348. goto done;
  349. }
  350. pr_debug("%s: deregistered client %s on service %s\n",
  351. __func__, client_data->client_name,
  352. service_data[service][domain].name);
  353. client_data->service = NO_SERVICE;
  354. if (service_data[service][domain].num_of_clients > 0)
  355. service_data[service][domain].num_of_clients--;
  356. done:
  357. return ret;
  358. }
  359. static void audio_notifier_reg_all_clients(void)
  360. {
  361. struct list_head *ptr, *next;
  362. struct client_data *client_data;
  363. int ret;
  364. list_for_each_safe(ptr, next, &client_list) {
  365. client_data = list_entry(ptr, struct client_data, list);
  366. ret = audio_notifier_reg_client(client_data);
  367. if (ret < 0)
  368. pr_err_ratelimited("%s: audio_notifier_reg_client failed for client %s, \
  369. ret %d\n", __func__, client_data->client_name,
  370. ret);
  371. }
  372. }
  373. static int audio_notifier_convert_opcode(unsigned long opcode,
  374. unsigned long *notifier_opcode)
  375. {
  376. int ret = 0;
  377. switch (opcode) {
  378. case QCOM_SSR_BEFORE_SHUTDOWN:
  379. case SERVREG_SERVICE_STATE_EARLY_DOWN:
  380. *notifier_opcode = AUDIO_NOTIFIER_SERVICE_DOWN;
  381. if (opcode == SERVREG_SERVICE_STATE_EARLY_DOWN)
  382. service_early_down = true;
  383. break;
  384. case QCOM_SSR_AFTER_POWERUP:
  385. case SERVREG_SERVICE_STATE_UP:
  386. *notifier_opcode = AUDIO_NOTIFIER_SERVICE_UP;
  387. break;
  388. case SERVREG_SERVICE_STATE_DOWN:
  389. if (!service_early_down)
  390. *notifier_opcode = AUDIO_NOTIFIER_SERVICE_DOWN;
  391. else {
  392. /* Reset service_early_down and nothing to do*/
  393. service_early_down = false;
  394. ret = -EINVAL;
  395. pr_info("%s: Early down aleady handled %d\n", __func__,
  396. service_early_down);
  397. }
  398. break;
  399. default:
  400. pr_debug("%s: Unused opcode 0x%lx\n", __func__, opcode);
  401. ret = -EINVAL;
  402. }
  403. return ret;
  404. }
  405. static int audio_notifier_service_cb(unsigned long opcode,
  406. int service, int domain)
  407. {
  408. int ret = 0;
  409. unsigned long notifier_opcode;
  410. struct audio_notifier_cb_data data;
  411. if (audio_notifier_convert_opcode(opcode, &notifier_opcode) < 0)
  412. return NOTIFY_OK;
  413. data.service = service;
  414. data.domain = domain;
  415. pr_info("%s: service %s, opcode 0x%lx\n",
  416. __func__, service_data[service][domain].name, notifier_opcode);
  417. mutex_lock(&notifier_mutex);
  418. service_data[service][domain].state = notifier_opcode;
  419. ret = srcu_notifier_call_chain(&service_data[service][domain].
  420. client_nb_list, notifier_opcode, &data);
  421. mutex_unlock(&notifier_mutex);
  422. if (ret < 0)
  423. pr_err_ratelimited("%s: srcu_notifier_call_chain returned %d, service %s, \
  424. opcode 0x%lx\n", __func__, ret, service_data[service][domain].name,
  425. notifier_opcode);
  426. return NOTIFY_OK;
  427. }
  428. static void audio_notifier_pdr_adsp_cb(int status, char *service_name, void *priv)
  429. {
  430. audio_notifier_service_cb(status, AUDIO_NOTIFIER_PDR_SERVICE, AUDIO_NOTIFIER_ADSP_DOMAIN);
  431. }
  432. static int audio_notifier_ssr_adsp_cb(struct notifier_block *this,
  433. unsigned long opcode, void *data)
  434. {
  435. return audio_notifier_service_cb(opcode,
  436. AUDIO_NOTIFIER_SSR_SERVICE,
  437. AUDIO_NOTIFIER_ADSP_DOMAIN);
  438. }
  439. static int audio_notifier_ssr_modem_cb(struct notifier_block *this,
  440. unsigned long opcode, void *data)
  441. {
  442. return audio_notifier_service_cb(opcode,
  443. AUDIO_NOTIFIER_SSR_SERVICE,
  444. AUDIO_NOTIFIER_MODEM_DOMAIN);
  445. }
  446. int audio_notifier_deregister(char *client_name)
  447. {
  448. int ret = 0;
  449. int ret2;
  450. struct list_head *ptr, *next;
  451. struct client_data *client_data = NULL;
  452. if (client_name == NULL) {
  453. pr_err_ratelimited("%s: client_name is NULL\n", __func__);
  454. ret = -EINVAL;
  455. goto done;
  456. }
  457. list_for_each_safe(ptr, next, &client_list) {
  458. client_data = list_entry(ptr, struct client_data, list);
  459. if (!strcmp(client_name, client_data->client_name)) {
  460. ret2 = audio_notifier_dereg_client(client_data);
  461. if (ret2 < 0) {
  462. pr_err_ratelimited("%s: audio_notifier_dereg_client failed, \
  463. ret %d\n, service %d, domain %d",
  464. __func__, ret2, client_data->service,
  465. client_data->domain);
  466. ret = ret2;
  467. continue;
  468. }
  469. list_del(&client_data->list);
  470. kfree(client_data);
  471. }
  472. }
  473. done:
  474. return ret;
  475. }
  476. EXPORT_SYMBOL(audio_notifier_deregister);
  477. int audio_notifier_register(char *client_name, int domain,
  478. struct notifier_block *nb)
  479. {
  480. int ret;
  481. struct client_data *client_data;
  482. if (client_name == NULL) {
  483. pr_err_ratelimited("%s: client_name is NULL\n", __func__);
  484. ret = -EINVAL;
  485. goto done;
  486. } else if (nb == NULL) {
  487. pr_err_ratelimited("%s: Notifier block is NULL\n", __func__);
  488. ret = -EINVAL;
  489. goto done;
  490. }
  491. client_data = kmalloc(sizeof(*client_data), GFP_KERNEL);
  492. if (client_data == NULL) {
  493. ret = -ENOMEM;
  494. goto done;
  495. }
  496. INIT_LIST_HEAD(&client_data->list);
  497. client_data->nb = nb;
  498. strlcpy(client_data->client_name, client_name,
  499. sizeof(client_data->client_name));
  500. client_data->service = NO_SERVICE;
  501. client_data->domain = domain;
  502. mutex_lock(&notifier_mutex);
  503. ret = audio_notifier_reg_client(client_data);
  504. if (ret < 0) {
  505. mutex_unlock(&notifier_mutex);
  506. pr_err_ratelimited("%s: audio_notifier_reg_client for client %s failed ret = %d\n",
  507. __func__, client_data->client_name,
  508. ret);
  509. kfree(client_data);
  510. goto done;
  511. }
  512. list_add_tail(&client_data->list, &client_list);
  513. mutex_unlock(&notifier_mutex);
  514. done:
  515. return ret;
  516. }
  517. EXPORT_SYMBOL(audio_notifier_register);
  518. static int audio_notifier_subsys_init(void)
  519. {
  520. int i, j;
  521. mutex_init(&notifier_mutex);
  522. for (i = 0; i < AUDIO_NOTIFIER_MAX_SERVICES; i++) {
  523. for (j = 0; j < AUDIO_NOTIFIER_MAX_DOMAINS; j++) {
  524. if (service_data[i][j].state <= NO_SERVICE)
  525. continue;
  526. srcu_init_notifier_head(
  527. &service_data[i][j].client_nb_list);
  528. }
  529. }
  530. return 0;
  531. }
  532. static int audio_notifier_late_init(void)
  533. {
  534. /*
  535. * If pdr registration failed, register clients on next service
  536. * Do in late init to ensure that SSR subsystem is initialized
  537. */
  538. mutex_lock(&notifier_mutex);
  539. if (!audio_notifier_is_service_enabled(AUDIO_NOTIFIER_PDR_SERVICE))
  540. audio_notifier_reg_all_clients();
  541. mutex_unlock(&notifier_mutex);
  542. return 0;
  543. }
  544. bool audio_notifier_probe_status(void)
  545. {
  546. struct adsp_notify_private *priv = NULL;
  547. struct platform_device *pdev = NULL;
  548. if (!adsp_private)
  549. goto exit;
  550. pdev = adsp_private;
  551. priv = platform_get_drvdata(pdev);
  552. if (!priv) {
  553. dev_err(&pdev->dev," %s: Private data get failed\n", __func__);
  554. goto exit;
  555. }
  556. if (priv->notifier_probe_complete) {
  557. dev_dbg(&pdev->dev, "%s: audio notify probe successfully completed\n",
  558. __func__);
  559. return true;
  560. }
  561. exit:
  562. return false;
  563. }
  564. EXPORT_SYMBOL(audio_notifier_probe_status);
  565. static int audio_notify_probe(struct platform_device *pdev)
  566. {
  567. int ret = -EINVAL;
  568. struct adsp_notify_private *priv = NULL;
  569. struct property *prop;
  570. int size;
  571. phandle rproc_phandle;
  572. adsp_private = NULL;
  573. priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
  574. if (!priv) {
  575. ret = -ENOMEM;
  576. return ret;
  577. }
  578. priv->notifier_probe_complete = false;
  579. platform_set_drvdata(pdev, priv);
  580. prop = of_find_property(pdev->dev.of_node, "qcom,rproc-handle", &size);
  581. if (!prop) {
  582. dev_err(&pdev->dev, "Missing remotproc handle\n");
  583. return ret;
  584. }
  585. rproc_phandle = be32_to_cpup(prop->value);
  586. priv->rproc_h = rproc_get_by_phandle(rproc_phandle);
  587. if (!priv->rproc_h) {
  588. dev_info_ratelimited(&pdev->dev, "remotproc handle NULL\n");
  589. ret = -EPROBE_DEFER;
  590. return ret;
  591. }
  592. adsp_private = pdev;
  593. audio_notifier_subsys_init();
  594. audio_notifier_init_service(AUDIO_NOTIFIER_PDR_SERVICE);
  595. /* Do not return error since PDR enablement is not critical */
  596. audio_notifier_late_init();
  597. priv->notifier_probe_complete = true;
  598. return 0;
  599. }
  600. static int audio_notify_remove(struct platform_device *pdev)
  601. {
  602. return 0;
  603. }
  604. static const struct of_device_id adsp_notify_dt_match[] = {
  605. { .compatible = "qcom,adsp-notify" },
  606. { }
  607. };
  608. MODULE_DEVICE_TABLE(of, adsp_notify_dt_match);
  609. static struct platform_driver adsp_notify_driver = {
  610. .driver = {
  611. .name = "adsp-notify",
  612. .owner = THIS_MODULE,
  613. .of_match_table = adsp_notify_dt_match,
  614. .suppress_bind_attrs = true,
  615. },
  616. .probe = audio_notify_probe,
  617. .remove = audio_notify_remove,
  618. };
  619. static int __init audio_notifier_init(void)
  620. {
  621. return platform_driver_register(&adsp_notify_driver);
  622. }
  623. module_init(audio_notifier_init);
  624. static void __exit audio_notifier_exit(void)
  625. {
  626. platform_driver_unregister(&adsp_notify_driver);
  627. }
  628. module_exit(audio_notifier_exit);
  629. MODULE_SOFTDEP("pre: qcom_q6v5_pas");
  630. MODULE_DESCRIPTION("Audio notifier driver");
  631. MODULE_LICENSE("GPL v2");