qcom_pd_mapper.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Qualcomm Protection Domain mapper
  4. *
  5. * Copyright (c) 2023 Linaro Ltd.
  6. */
  7. #include <linux/auxiliary_bus.h>
  8. #include <linux/kernel.h>
  9. #include <linux/mod_devicetable.h>
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/refcount.h>
  13. #include <linux/slab.h>
  14. #include <linux/soc/qcom/qmi.h>
  15. #include "pdr_internal.h"
  16. #define SERVREG_QMI_VERSION 0x101
  17. #define SERVREG_QMI_INSTANCE 0
  18. #define TMS_SERVREG_SERVICE "tms/servreg"
  19. struct qcom_pdm_domain_data {
  20. const char *domain;
  21. u32 instance_id;
  22. /* NULL-terminated array */
  23. const char * services[];
  24. };
  25. struct qcom_pdm_domain {
  26. struct list_head list;
  27. const char *name;
  28. u32 instance_id;
  29. };
  30. struct qcom_pdm_service {
  31. struct list_head list;
  32. struct list_head domains;
  33. const char *name;
  34. };
  35. struct qcom_pdm_data {
  36. refcount_t refcnt;
  37. struct qmi_handle handle;
  38. struct list_head services;
  39. };
  40. static DEFINE_MUTEX(qcom_pdm_mutex); /* protects __qcom_pdm_data */
  41. static struct qcom_pdm_data *__qcom_pdm_data;
  42. static struct qcom_pdm_service *qcom_pdm_find(struct qcom_pdm_data *data,
  43. const char *name)
  44. {
  45. struct qcom_pdm_service *service;
  46. list_for_each_entry(service, &data->services, list) {
  47. if (!strcmp(service->name, name))
  48. return service;
  49. }
  50. return NULL;
  51. }
  52. static int qcom_pdm_add_service_domain(struct qcom_pdm_data *data,
  53. const char *service_name,
  54. const char *domain_name,
  55. u32 instance_id)
  56. {
  57. struct qcom_pdm_service *service;
  58. struct qcom_pdm_domain *domain;
  59. service = qcom_pdm_find(data, service_name);
  60. if (service) {
  61. list_for_each_entry(domain, &service->domains, list) {
  62. if (!strcmp(domain->name, domain_name))
  63. return -EBUSY;
  64. }
  65. } else {
  66. service = kzalloc(sizeof(*service), GFP_KERNEL);
  67. if (!service)
  68. return -ENOMEM;
  69. INIT_LIST_HEAD(&service->domains);
  70. service->name = service_name;
  71. list_add_tail(&service->list, &data->services);
  72. }
  73. domain = kzalloc(sizeof(*domain), GFP_KERNEL);
  74. if (!domain) {
  75. if (list_empty(&service->domains)) {
  76. list_del(&service->list);
  77. kfree(service);
  78. }
  79. return -ENOMEM;
  80. }
  81. domain->name = domain_name;
  82. domain->instance_id = instance_id;
  83. list_add_tail(&domain->list, &service->domains);
  84. return 0;
  85. }
  86. static int qcom_pdm_add_domain(struct qcom_pdm_data *data,
  87. const struct qcom_pdm_domain_data *domain)
  88. {
  89. int ret;
  90. int i;
  91. ret = qcom_pdm_add_service_domain(data,
  92. TMS_SERVREG_SERVICE,
  93. domain->domain,
  94. domain->instance_id);
  95. if (ret)
  96. return ret;
  97. for (i = 0; domain->services[i]; i++) {
  98. ret = qcom_pdm_add_service_domain(data,
  99. domain->services[i],
  100. domain->domain,
  101. domain->instance_id);
  102. if (ret)
  103. return ret;
  104. }
  105. return 0;
  106. }
  107. static void qcom_pdm_free_domains(struct qcom_pdm_data *data)
  108. {
  109. struct qcom_pdm_service *service, *tservice;
  110. struct qcom_pdm_domain *domain, *tdomain;
  111. list_for_each_entry_safe(service, tservice, &data->services, list) {
  112. list_for_each_entry_safe(domain, tdomain, &service->domains, list) {
  113. list_del(&domain->list);
  114. kfree(domain);
  115. }
  116. list_del(&service->list);
  117. kfree(service);
  118. }
  119. }
  120. static void qcom_pdm_get_domain_list(struct qmi_handle *qmi,
  121. struct sockaddr_qrtr *sq,
  122. struct qmi_txn *txn,
  123. const void *decoded)
  124. {
  125. struct qcom_pdm_data *data = container_of(qmi, struct qcom_pdm_data, handle);
  126. const struct servreg_get_domain_list_req *req = decoded;
  127. struct servreg_get_domain_list_resp *rsp;
  128. struct qcom_pdm_service *service;
  129. u32 offset;
  130. int ret;
  131. rsp = kzalloc(sizeof(*rsp), GFP_KERNEL);
  132. if (!rsp)
  133. return;
  134. offset = req->domain_offset_valid ? req->domain_offset : 0;
  135. rsp->resp.result = QMI_RESULT_SUCCESS_V01;
  136. rsp->resp.error = QMI_ERR_NONE_V01;
  137. rsp->db_rev_count_valid = true;
  138. rsp->db_rev_count = 1;
  139. rsp->total_domains_valid = true;
  140. rsp->total_domains = 0;
  141. mutex_lock(&qcom_pdm_mutex);
  142. service = qcom_pdm_find(data, req->service_name);
  143. if (service) {
  144. struct qcom_pdm_domain *domain;
  145. rsp->domain_list_valid = true;
  146. rsp->domain_list_len = 0;
  147. list_for_each_entry(domain, &service->domains, list) {
  148. u32 i = rsp->total_domains++;
  149. if (i >= offset && i < SERVREG_DOMAIN_LIST_LENGTH) {
  150. u32 j = rsp->domain_list_len++;
  151. strscpy(rsp->domain_list[j].name, domain->name,
  152. sizeof(rsp->domain_list[i].name));
  153. rsp->domain_list[j].instance = domain->instance_id;
  154. pr_debug("PDM: found %s / %d\n", domain->name,
  155. domain->instance_id);
  156. }
  157. }
  158. }
  159. pr_debug("PDM: service '%s' offset %d returning %d domains (of %d)\n", req->service_name,
  160. req->domain_offset_valid ? req->domain_offset : -1, rsp->domain_list_len, rsp->total_domains);
  161. ret = qmi_send_response(qmi, sq, txn, SERVREG_GET_DOMAIN_LIST_REQ,
  162. SERVREG_GET_DOMAIN_LIST_RESP_MAX_LEN,
  163. servreg_get_domain_list_resp_ei, rsp);
  164. if (ret)
  165. pr_err("Error sending servreg response: %d\n", ret);
  166. mutex_unlock(&qcom_pdm_mutex);
  167. kfree(rsp);
  168. }
  169. static void qcom_pdm_pfr(struct qmi_handle *qmi,
  170. struct sockaddr_qrtr *sq,
  171. struct qmi_txn *txn,
  172. const void *decoded)
  173. {
  174. const struct servreg_loc_pfr_req *req = decoded;
  175. struct servreg_loc_pfr_resp rsp = {};
  176. int ret;
  177. pr_warn_ratelimited("PDM: service '%s' crash: '%s'\n", req->service, req->reason);
  178. rsp.rsp.result = QMI_RESULT_SUCCESS_V01;
  179. rsp.rsp.error = QMI_ERR_NONE_V01;
  180. ret = qmi_send_response(qmi, sq, txn, SERVREG_LOC_PFR_REQ,
  181. SERVREG_LOC_PFR_RESP_MAX_LEN,
  182. servreg_loc_pfr_resp_ei, &rsp);
  183. if (ret)
  184. pr_err("Error sending servreg response: %d\n", ret);
  185. }
  186. static const struct qmi_msg_handler qcom_pdm_msg_handlers[] = {
  187. {
  188. .type = QMI_REQUEST,
  189. .msg_id = SERVREG_GET_DOMAIN_LIST_REQ,
  190. .ei = servreg_get_domain_list_req_ei,
  191. .decoded_size = sizeof(struct servreg_get_domain_list_req),
  192. .fn = qcom_pdm_get_domain_list,
  193. },
  194. {
  195. .type = QMI_REQUEST,
  196. .msg_id = SERVREG_LOC_PFR_REQ,
  197. .ei = servreg_loc_pfr_req_ei,
  198. .decoded_size = sizeof(struct servreg_loc_pfr_req),
  199. .fn = qcom_pdm_pfr,
  200. },
  201. { },
  202. };
  203. static const struct qcom_pdm_domain_data adsp_audio_pd = {
  204. .domain = "msm/adsp/audio_pd",
  205. .instance_id = 74,
  206. .services = {
  207. "avs/audio",
  208. NULL,
  209. },
  210. };
  211. static const struct qcom_pdm_domain_data adsp_charger_pd = {
  212. .domain = "msm/adsp/charger_pd",
  213. .instance_id = 74,
  214. .services = { NULL },
  215. };
  216. static const struct qcom_pdm_domain_data adsp_root_pd = {
  217. .domain = "msm/adsp/root_pd",
  218. .instance_id = 74,
  219. .services = { NULL },
  220. };
  221. static const struct qcom_pdm_domain_data adsp_root_pd_pdr = {
  222. .domain = "msm/adsp/root_pd",
  223. .instance_id = 74,
  224. .services = {
  225. "tms/pdr_enabled",
  226. NULL,
  227. },
  228. };
  229. static const struct qcom_pdm_domain_data adsp_sensor_pd = {
  230. .domain = "msm/adsp/sensor_pd",
  231. .instance_id = 74,
  232. .services = { NULL },
  233. };
  234. static const struct qcom_pdm_domain_data msm8996_adsp_audio_pd = {
  235. .domain = "msm/adsp/audio_pd",
  236. .instance_id = 4,
  237. .services = { NULL },
  238. };
  239. static const struct qcom_pdm_domain_data msm8996_adsp_root_pd = {
  240. .domain = "msm/adsp/root_pd",
  241. .instance_id = 4,
  242. .services = { NULL },
  243. };
  244. static const struct qcom_pdm_domain_data cdsp_root_pd = {
  245. .domain = "msm/cdsp/root_pd",
  246. .instance_id = 76,
  247. .services = { NULL },
  248. };
  249. static const struct qcom_pdm_domain_data slpi_root_pd = {
  250. .domain = "msm/slpi/root_pd",
  251. .instance_id = 90,
  252. .services = { NULL },
  253. };
  254. static const struct qcom_pdm_domain_data slpi_sensor_pd = {
  255. .domain = "msm/slpi/sensor_pd",
  256. .instance_id = 90,
  257. .services = { NULL },
  258. };
  259. static const struct qcom_pdm_domain_data mpss_root_pd = {
  260. .domain = "msm/modem/root_pd",
  261. .instance_id = 180,
  262. .services = {
  263. NULL,
  264. },
  265. };
  266. static const struct qcom_pdm_domain_data mpss_root_pd_gps = {
  267. .domain = "msm/modem/root_pd",
  268. .instance_id = 180,
  269. .services = {
  270. "gps/gps_service",
  271. NULL,
  272. },
  273. };
  274. static const struct qcom_pdm_domain_data mpss_root_pd_gps_pdr = {
  275. .domain = "msm/modem/root_pd",
  276. .instance_id = 180,
  277. .services = {
  278. "gps/gps_service",
  279. "tms/pdr_enabled",
  280. NULL,
  281. },
  282. };
  283. static const struct qcom_pdm_domain_data msm8996_mpss_root_pd = {
  284. .domain = "msm/modem/root_pd",
  285. .instance_id = 100,
  286. .services = { NULL },
  287. };
  288. static const struct qcom_pdm_domain_data mpss_wlan_pd = {
  289. .domain = "msm/modem/wlan_pd",
  290. .instance_id = 180,
  291. .services = {
  292. "kernel/elf_loader",
  293. "wlan/fw",
  294. NULL,
  295. },
  296. };
  297. static const struct qcom_pdm_domain_data *msm8996_domains[] = {
  298. &msm8996_adsp_audio_pd,
  299. &msm8996_adsp_root_pd,
  300. &msm8996_mpss_root_pd,
  301. NULL,
  302. };
  303. static const struct qcom_pdm_domain_data *msm8998_domains[] = {
  304. &mpss_root_pd,
  305. &mpss_wlan_pd,
  306. NULL,
  307. };
  308. static const struct qcom_pdm_domain_data *qcm2290_domains[] = {
  309. &adsp_audio_pd,
  310. &adsp_root_pd,
  311. &adsp_sensor_pd,
  312. &mpss_root_pd_gps,
  313. &mpss_wlan_pd,
  314. NULL,
  315. };
  316. static const struct qcom_pdm_domain_data *qcs404_domains[] = {
  317. &adsp_audio_pd,
  318. &adsp_root_pd,
  319. &adsp_sensor_pd,
  320. &cdsp_root_pd,
  321. &mpss_root_pd,
  322. &mpss_wlan_pd,
  323. NULL,
  324. };
  325. static const struct qcom_pdm_domain_data *sc7180_domains[] = {
  326. &adsp_audio_pd,
  327. &adsp_root_pd_pdr,
  328. &adsp_sensor_pd,
  329. &mpss_root_pd_gps_pdr,
  330. &mpss_wlan_pd,
  331. NULL,
  332. };
  333. static const struct qcom_pdm_domain_data *sc7280_domains[] = {
  334. &adsp_audio_pd,
  335. &adsp_root_pd_pdr,
  336. &adsp_charger_pd,
  337. &adsp_sensor_pd,
  338. &cdsp_root_pd,
  339. &mpss_root_pd_gps_pdr,
  340. NULL,
  341. };
  342. static const struct qcom_pdm_domain_data *sc8180x_domains[] = {
  343. &adsp_audio_pd,
  344. &adsp_root_pd,
  345. &adsp_charger_pd,
  346. &cdsp_root_pd,
  347. &mpss_root_pd_gps,
  348. &mpss_wlan_pd,
  349. NULL,
  350. };
  351. static const struct qcom_pdm_domain_data *sc8280xp_domains[] = {
  352. &adsp_audio_pd,
  353. &adsp_root_pd_pdr,
  354. &adsp_charger_pd,
  355. &cdsp_root_pd,
  356. NULL,
  357. };
  358. static const struct qcom_pdm_domain_data *sdm660_domains[] = {
  359. &adsp_audio_pd,
  360. &adsp_root_pd,
  361. &adsp_sensor_pd,
  362. &cdsp_root_pd,
  363. &mpss_root_pd,
  364. &mpss_wlan_pd,
  365. NULL,
  366. };
  367. static const struct qcom_pdm_domain_data *sdm670_domains[] = {
  368. &adsp_audio_pd,
  369. &adsp_root_pd,
  370. &cdsp_root_pd,
  371. &mpss_root_pd,
  372. &mpss_wlan_pd,
  373. NULL,
  374. };
  375. static const struct qcom_pdm_domain_data *sdm845_domains[] = {
  376. &adsp_audio_pd,
  377. &adsp_root_pd,
  378. &cdsp_root_pd,
  379. &mpss_root_pd,
  380. &mpss_wlan_pd,
  381. &slpi_root_pd,
  382. &slpi_sensor_pd,
  383. NULL,
  384. };
  385. static const struct qcom_pdm_domain_data *sm6115_domains[] = {
  386. &adsp_audio_pd,
  387. &adsp_root_pd,
  388. &adsp_sensor_pd,
  389. &cdsp_root_pd,
  390. &mpss_root_pd_gps,
  391. &mpss_wlan_pd,
  392. NULL,
  393. };
  394. static const struct qcom_pdm_domain_data *sm6350_domains[] = {
  395. &adsp_audio_pd,
  396. &adsp_root_pd,
  397. &adsp_sensor_pd,
  398. &cdsp_root_pd,
  399. &mpss_wlan_pd,
  400. NULL,
  401. };
  402. static const struct qcom_pdm_domain_data *sm8150_domains[] = {
  403. &adsp_audio_pd,
  404. &adsp_root_pd,
  405. &cdsp_root_pd,
  406. &mpss_root_pd_gps,
  407. &mpss_wlan_pd,
  408. NULL,
  409. };
  410. static const struct qcom_pdm_domain_data *sm8250_domains[] = {
  411. &adsp_audio_pd,
  412. &adsp_root_pd,
  413. &cdsp_root_pd,
  414. &slpi_root_pd,
  415. &slpi_sensor_pd,
  416. NULL,
  417. };
  418. static const struct qcom_pdm_domain_data *sm8350_domains[] = {
  419. &adsp_audio_pd,
  420. &adsp_root_pd_pdr,
  421. &adsp_charger_pd,
  422. &cdsp_root_pd,
  423. &mpss_root_pd_gps,
  424. &slpi_root_pd,
  425. &slpi_sensor_pd,
  426. NULL,
  427. };
  428. static const struct qcom_pdm_domain_data *sm8550_domains[] = {
  429. &adsp_audio_pd,
  430. &adsp_root_pd,
  431. &adsp_charger_pd,
  432. &adsp_sensor_pd,
  433. &cdsp_root_pd,
  434. &mpss_root_pd_gps,
  435. NULL,
  436. };
  437. static const struct qcom_pdm_domain_data *x1e80100_domains[] = {
  438. &adsp_audio_pd,
  439. &adsp_root_pd,
  440. &adsp_charger_pd,
  441. &adsp_sensor_pd,
  442. &cdsp_root_pd,
  443. NULL,
  444. };
  445. static const struct of_device_id qcom_pdm_domains[] __maybe_unused = {
  446. { .compatible = "qcom,apq8016", .data = NULL, },
  447. { .compatible = "qcom,apq8064", .data = NULL, },
  448. { .compatible = "qcom,apq8074", .data = NULL, },
  449. { .compatible = "qcom,apq8084", .data = NULL, },
  450. { .compatible = "qcom,apq8096", .data = msm8996_domains, },
  451. { .compatible = "qcom,msm8226", .data = NULL, },
  452. { .compatible = "qcom,msm8909", .data = NULL, },
  453. { .compatible = "qcom,msm8916", .data = NULL, },
  454. { .compatible = "qcom,msm8939", .data = NULL, },
  455. { .compatible = "qcom,msm8974", .data = NULL, },
  456. { .compatible = "qcom,msm8996", .data = msm8996_domains, },
  457. { .compatible = "qcom,msm8998", .data = msm8998_domains, },
  458. { .compatible = "qcom,qcm2290", .data = qcm2290_domains, },
  459. { .compatible = "qcom,qcm6490", .data = sc7280_domains, },
  460. { .compatible = "qcom,qcs404", .data = qcs404_domains, },
  461. { .compatible = "qcom,sc7180", .data = sc7180_domains, },
  462. { .compatible = "qcom,sc7280", .data = sc7280_domains, },
  463. { .compatible = "qcom,sc8180x", .data = sc8180x_domains, },
  464. { .compatible = "qcom,sc8280xp", .data = sc8280xp_domains, },
  465. { .compatible = "qcom,sda660", .data = sdm660_domains, },
  466. { .compatible = "qcom,sdm660", .data = sdm660_domains, },
  467. { .compatible = "qcom,sdm670", .data = sdm670_domains, },
  468. { .compatible = "qcom,sdm845", .data = sdm845_domains, },
  469. { .compatible = "qcom,sm4250", .data = sm6115_domains, },
  470. { .compatible = "qcom,sm6115", .data = sm6115_domains, },
  471. { .compatible = "qcom,sm6350", .data = sm6350_domains, },
  472. { .compatible = "qcom,sm7325", .data = sc7280_domains, },
  473. { .compatible = "qcom,sm8150", .data = sm8150_domains, },
  474. { .compatible = "qcom,sm8250", .data = sm8250_domains, },
  475. { .compatible = "qcom,sm8350", .data = sm8350_domains, },
  476. { .compatible = "qcom,sm8450", .data = sm8350_domains, },
  477. { .compatible = "qcom,sm8550", .data = sm8550_domains, },
  478. { .compatible = "qcom,sm8650", .data = sm8550_domains, },
  479. { .compatible = "qcom,x1e80100", .data = x1e80100_domains, },
  480. {},
  481. };
  482. static void qcom_pdm_stop(struct qcom_pdm_data *data)
  483. {
  484. qcom_pdm_free_domains(data);
  485. /* The server is removed automatically */
  486. qmi_handle_release(&data->handle);
  487. kfree(data);
  488. }
  489. static struct qcom_pdm_data *qcom_pdm_start(void)
  490. {
  491. const struct qcom_pdm_domain_data * const *domains;
  492. const struct of_device_id *match;
  493. struct qcom_pdm_data *data;
  494. struct device_node *root;
  495. int ret, i;
  496. root = of_find_node_by_path("/");
  497. if (!root)
  498. return ERR_PTR(-ENODEV);
  499. match = of_match_node(qcom_pdm_domains, root);
  500. of_node_put(root);
  501. if (!match) {
  502. pr_notice("PDM: no support for the platform, userspace daemon might be required.\n");
  503. return ERR_PTR(-ENODEV);
  504. }
  505. domains = match->data;
  506. if (!domains) {
  507. pr_debug("PDM: no domains\n");
  508. return ERR_PTR(-ENODEV);
  509. }
  510. data = kzalloc(sizeof(*data), GFP_KERNEL);
  511. if (!data)
  512. return ERR_PTR(-ENOMEM);
  513. INIT_LIST_HEAD(&data->services);
  514. ret = qmi_handle_init(&data->handle, SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN,
  515. NULL, qcom_pdm_msg_handlers);
  516. if (ret) {
  517. kfree(data);
  518. return ERR_PTR(ret);
  519. }
  520. refcount_set(&data->refcnt, 1);
  521. for (i = 0; domains[i]; i++) {
  522. ret = qcom_pdm_add_domain(data, domains[i]);
  523. if (ret)
  524. goto err_stop;
  525. }
  526. ret = qmi_add_server(&data->handle, SERVREG_LOCATOR_SERVICE,
  527. SERVREG_QMI_VERSION, SERVREG_QMI_INSTANCE);
  528. if (ret) {
  529. pr_err("PDM: error adding server %d\n", ret);
  530. goto err_stop;
  531. }
  532. return data;
  533. err_stop:
  534. qcom_pdm_stop(data);
  535. return ERR_PTR(ret);
  536. }
  537. static int qcom_pdm_probe(struct auxiliary_device *auxdev,
  538. const struct auxiliary_device_id *id)
  539. {
  540. struct qcom_pdm_data *data;
  541. int ret = 0;
  542. mutex_lock(&qcom_pdm_mutex);
  543. if (!__qcom_pdm_data) {
  544. data = qcom_pdm_start();
  545. if (IS_ERR(data))
  546. ret = PTR_ERR(data);
  547. else
  548. __qcom_pdm_data = data;
  549. } else {
  550. refcount_inc(&__qcom_pdm_data->refcnt);
  551. }
  552. auxiliary_set_drvdata(auxdev, __qcom_pdm_data);
  553. mutex_unlock(&qcom_pdm_mutex);
  554. return ret;
  555. }
  556. static void qcom_pdm_remove(struct auxiliary_device *auxdev)
  557. {
  558. struct qcom_pdm_data *data;
  559. data = auxiliary_get_drvdata(auxdev);
  560. if (!data)
  561. return;
  562. if (refcount_dec_and_mutex_lock(&data->refcnt, &qcom_pdm_mutex)) {
  563. __qcom_pdm_data = NULL;
  564. qcom_pdm_stop(data);
  565. mutex_unlock(&qcom_pdm_mutex);
  566. }
  567. }
  568. static const struct auxiliary_device_id qcom_pdm_table[] = {
  569. { .name = "qcom_common.pd-mapper" },
  570. {},
  571. };
  572. MODULE_DEVICE_TABLE(auxiliary, qcom_pdm_table);
  573. static struct auxiliary_driver qcom_pdm_drv = {
  574. .name = "qcom-pdm-mapper",
  575. .id_table = qcom_pdm_table,
  576. .probe = qcom_pdm_probe,
  577. .remove = qcom_pdm_remove,
  578. };
  579. module_auxiliary_driver(qcom_pdm_drv);
  580. MODULE_DESCRIPTION("Qualcomm Protection Domain Mapper");
  581. MODULE_LICENSE("GPL");