apr.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2010-2014, 2016-2020 The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/module.h>
  7. #include <linux/types.h>
  8. #include <linux/uaccess.h>
  9. #include <linux/spinlock.h>
  10. #include <linux/list.h>
  11. #include <linux/sched.h>
  12. #include <linux/wait.h>
  13. #include <linux/errno.h>
  14. #include <linux/fs.h>
  15. #include <linux/delay.h>
  16. #include <linux/debugfs.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/sysfs.h>
  19. #include <linux/device.h>
  20. #include <linux/of.h>
  21. #include <linux/slab.h>
  22. #include <linux/ipc_logging.h>
  23. #include <linux/of_platform.h>
  24. #include <soc/qcom/subsystem_restart.h>
  25. #include <linux/qcom_scm.h>
  26. #include <soc/snd_event.h>
  27. #include <dsp/apr_audio-v2.h>
  28. #include <dsp/audio_notifier.h>
  29. #include <ipc/apr.h>
  30. #include <ipc/apr_tal.h>
  31. #define APR_PKT_IPC_LOG_PAGE_CNT 2
  32. static int apr_pkt_cnt_adsp_restart = 20;
  33. module_param(apr_pkt_cnt_adsp_restart, int, 0664);
  34. MODULE_PARM_DESC(apr_pkt_cnt_adsp_restart, "set apr pktcount for adsp restart feature");
  35. static struct apr_q6 q6;
  36. static struct apr_client client[APR_DEST_MAX][APR_CLIENT_MAX];
  37. static void *apr_pkt_ctx;
  38. static int apr_send_pkt_count;
  39. static wait_queue_head_t modem_wait;
  40. static bool is_modem_up;
  41. static char *subsys_name = NULL;
  42. /* Subsystem restart: QDSP6 data, functions */
  43. static struct workqueue_struct *apr_reset_workqueue;
  44. static void apr_reset_deregister(struct work_struct *work);
  45. static void dispatch_event(unsigned long code, uint16_t proc);
  46. struct apr_reset_work {
  47. void *handle;
  48. struct work_struct work;
  49. };
  50. struct apr_chld_device {
  51. struct platform_device *pdev;
  52. struct list_head node;
  53. };
  54. struct apr_private {
  55. struct device *dev;
  56. spinlock_t apr_lock;
  57. bool is_initial_boot;
  58. struct work_struct add_chld_dev_work;
  59. };
  60. static struct apr_private *apr_priv;
  61. static bool apr_cf_debug;
  62. static struct work_struct apr_cb_work;
  63. static void state_notify_cb(struct work_struct *work);
  64. #ifdef CONFIG_DEBUG_FS
  65. static struct dentry *debugfs_apr_debug;
  66. static ssize_t apr_debug_write(struct file *filp, const char __user *ubuf,
  67. size_t cnt, loff_t *ppos)
  68. {
  69. char cmd;
  70. if (copy_from_user(&cmd, ubuf, 1))
  71. return -EFAULT;
  72. apr_cf_debug = (cmd == '1') ? true : false;
  73. return cnt;
  74. }
  75. static const struct file_operations apr_debug_ops = {
  76. .write = apr_debug_write,
  77. };
  78. #endif
  79. #define APR_PKT_INFO(x...) \
  80. do { \
  81. if (apr_pkt_ctx) \
  82. ipc_log_string(apr_pkt_ctx, "<APR>: "x); \
  83. } while (0)
  84. struct apr_svc_table {
  85. char name[64];
  86. int idx;
  87. int id;
  88. int client_id;
  89. };
  90. static const struct apr_svc_table svc_tbl_qdsp6[] = {
  91. {
  92. .name = "AFE",
  93. .idx = 0,
  94. .id = APR_SVC_AFE,
  95. .client_id = APR_CLIENT_AUDIO,
  96. },
  97. {
  98. .name = "ASM",
  99. .idx = 1,
  100. .id = APR_SVC_ASM,
  101. .client_id = APR_CLIENT_AUDIO,
  102. },
  103. {
  104. .name = "ADM",
  105. .idx = 2,
  106. .id = APR_SVC_ADM,
  107. .client_id = APR_CLIENT_AUDIO,
  108. },
  109. {
  110. .name = "CORE",
  111. .idx = 3,
  112. .id = APR_SVC_ADSP_CORE,
  113. .client_id = APR_CLIENT_AUDIO,
  114. },
  115. {
  116. .name = "TEST",
  117. .idx = 4,
  118. .id = APR_SVC_TEST_CLIENT,
  119. .client_id = APR_CLIENT_AUDIO,
  120. },
  121. {
  122. .name = "MVM",
  123. .idx = 5,
  124. .id = APR_SVC_ADSP_MVM,
  125. .client_id = APR_CLIENT_AUDIO,
  126. },
  127. {
  128. .name = "CVS",
  129. .idx = 6,
  130. .id = APR_SVC_ADSP_CVS,
  131. .client_id = APR_CLIENT_AUDIO,
  132. },
  133. {
  134. .name = "CVP",
  135. .idx = 7,
  136. .id = APR_SVC_ADSP_CVP,
  137. .client_id = APR_CLIENT_AUDIO,
  138. },
  139. {
  140. .name = "USM",
  141. .idx = 8,
  142. .id = APR_SVC_USM,
  143. .client_id = APR_CLIENT_AUDIO,
  144. },
  145. {
  146. .name = "VIDC",
  147. .idx = 9,
  148. .id = APR_SVC_VIDC,
  149. },
  150. {
  151. .name = "LSM",
  152. .idx = 10,
  153. .id = APR_SVC_LSM,
  154. .client_id = APR_CLIENT_AUDIO,
  155. },
  156. };
  157. static struct apr_svc_table svc_tbl_voice[] = {
  158. {
  159. .name = "VSM",
  160. .idx = 0,
  161. .id = APR_SVC_VSM,
  162. .client_id = APR_CLIENT_VOICE,
  163. },
  164. {
  165. .name = "VPM",
  166. .idx = 1,
  167. .id = APR_SVC_VPM,
  168. .client_id = APR_CLIENT_VOICE,
  169. },
  170. {
  171. .name = "MVS",
  172. .idx = 2,
  173. .id = APR_SVC_MVS,
  174. .client_id = APR_CLIENT_VOICE,
  175. },
  176. {
  177. .name = "MVM",
  178. .idx = 3,
  179. .id = APR_SVC_MVM,
  180. .client_id = APR_CLIENT_VOICE,
  181. },
  182. {
  183. .name = "CVS",
  184. .idx = 4,
  185. .id = APR_SVC_CVS,
  186. .client_id = APR_CLIENT_VOICE,
  187. },
  188. {
  189. .name = "CVP",
  190. .idx = 5,
  191. .id = APR_SVC_CVP,
  192. .client_id = APR_CLIENT_VOICE,
  193. },
  194. {
  195. .name = "SRD",
  196. .idx = 6,
  197. .id = APR_SVC_SRD,
  198. .client_id = APR_CLIENT_VOICE,
  199. },
  200. {
  201. .name = "TEST",
  202. .idx = 7,
  203. .id = APR_SVC_TEST_CLIENT,
  204. .client_id = APR_CLIENT_VOICE,
  205. },
  206. };
  207. /**
  208. * apr_get_modem_state:
  209. *
  210. * Returns current modem load status
  211. *
  212. */
  213. enum apr_subsys_state apr_get_modem_state(void)
  214. {
  215. return atomic_read(&q6.modem_state);
  216. }
  217. EXPORT_SYMBOL(apr_get_modem_state);
  218. /**
  219. * apr_set_modem_state - Update modem load status.
  220. *
  221. * @state: State to update modem load status
  222. *
  223. */
  224. void apr_set_modem_state(enum apr_subsys_state state)
  225. {
  226. atomic_set(&q6.modem_state, state);
  227. }
  228. EXPORT_SYMBOL(apr_set_modem_state);
  229. enum apr_subsys_state apr_cmpxchg_modem_state(enum apr_subsys_state prev,
  230. enum apr_subsys_state new)
  231. {
  232. return atomic_cmpxchg(&q6.modem_state, prev, new);
  233. }
  234. static void apr_modem_down(unsigned long opcode)
  235. {
  236. apr_set_modem_state(APR_SUBSYS_DOWN);
  237. dispatch_event(opcode, APR_DEST_MODEM);
  238. }
  239. static void apr_modem_up(void)
  240. {
  241. if (apr_cmpxchg_modem_state(APR_SUBSYS_DOWN, APR_SUBSYS_UP) ==
  242. APR_SUBSYS_DOWN)
  243. wake_up(&modem_wait);
  244. is_modem_up = 1;
  245. }
  246. enum apr_subsys_state apr_get_q6_state(void)
  247. {
  248. return atomic_read(&q6.q6_state);
  249. }
  250. EXPORT_SYMBOL(apr_get_q6_state);
  251. int apr_set_q6_state(enum apr_subsys_state state)
  252. {
  253. pr_debug("%s: setting adsp state %d\n", __func__, state);
  254. if (state < APR_SUBSYS_DOWN || state > APR_SUBSYS_LOADED)
  255. return -EINVAL;
  256. atomic_set(&q6.q6_state, state);
  257. return 0;
  258. }
  259. EXPORT_SYMBOL(apr_set_q6_state);
  260. static void apr_ssr_disable(struct device *dev, void *data)
  261. {
  262. apr_set_q6_state(APR_SUBSYS_DOWN);
  263. }
  264. static const struct snd_event_ops apr_ssr_ops = {
  265. .disable = apr_ssr_disable,
  266. };
  267. static void apr_adsp_down(unsigned long opcode)
  268. {
  269. pr_info("%s: Q6 is Down\n", __func__);
  270. snd_event_notify(apr_priv->dev, SND_EVENT_DOWN);
  271. apr_set_q6_state(APR_SUBSYS_DOWN);
  272. dispatch_event(opcode, APR_DEST_QDSP6);
  273. }
  274. static void apr_add_child_devices(struct work_struct *work)
  275. {
  276. int ret;
  277. ret = of_platform_populate(apr_priv->dev->of_node,
  278. NULL, NULL, apr_priv->dev);
  279. if (ret)
  280. dev_err(apr_priv->dev, "%s: failed to add child nodes, ret=%d\n",
  281. __func__, ret);
  282. }
  283. static void apr_adsp_up(void)
  284. {
  285. pr_info("%s: Q6 is Up\n", __func__);
  286. apr_set_q6_state(APR_SUBSYS_LOADED);
  287. spin_lock(&apr_priv->apr_lock);
  288. if (apr_priv->is_initial_boot)
  289. schedule_work(&apr_priv->add_chld_dev_work);
  290. spin_unlock(&apr_priv->apr_lock);
  291. snd_event_notify(apr_priv->dev, SND_EVENT_UP);
  292. cancel_work_sync(&apr_cb_work);
  293. }
  294. int apr_load_adsp_image(void)
  295. {
  296. int rc = 0;
  297. mutex_lock(&q6.lock);
  298. if (apr_get_q6_state() == APR_SUBSYS_UP) {
  299. q6.pil = subsystem_get("adsp");
  300. if (IS_ERR(q6.pil)) {
  301. rc = PTR_ERR(q6.pil);
  302. pr_err("APR: Unable to load q6 image, error:%d\n", rc);
  303. } else {
  304. apr_set_q6_state(APR_SUBSYS_LOADED);
  305. pr_debug("APR: Image is loaded, stated\n");
  306. }
  307. } else if (apr_get_q6_state() == APR_SUBSYS_LOADED) {
  308. pr_debug("APR: q6 image already loaded\n");
  309. } else {
  310. pr_debug("APR: cannot load state %d\n", apr_get_q6_state());
  311. }
  312. mutex_unlock(&q6.lock);
  313. return rc;
  314. }
  315. struct apr_client *apr_get_client(int dest_id, int client_id)
  316. {
  317. return &client[dest_id][client_id];
  318. }
  319. /**
  320. * apr_send_pkt - Clients call to send packet
  321. * to destination processor.
  322. *
  323. * @handle: APR service handle
  324. * @buf: payload to send to destination processor.
  325. *
  326. * Returns Bytes(>0)pkt_size on success or error on failure.
  327. */
  328. int apr_send_pkt(void *handle, uint32_t *buf)
  329. {
  330. struct apr_svc *svc = handle;
  331. struct apr_client *clnt;
  332. struct apr_hdr *hdr;
  333. uint16_t dest_id;
  334. uint16_t client_id;
  335. uint16_t w_len;
  336. int rc;
  337. unsigned long flags;
  338. if (!handle || !buf) {
  339. pr_err("APR: Wrong parameters for %s\n",
  340. !handle ? "handle" : "buf");
  341. return -EINVAL;
  342. }
  343. if (svc->need_reset) {
  344. pr_err_ratelimited("apr: send_pkt service need reset\n");
  345. return -ENETRESET;
  346. }
  347. if ((svc->dest_id == APR_DEST_QDSP6) &&
  348. (apr_get_q6_state() != APR_SUBSYS_LOADED)) {
  349. pr_err_ratelimited("%s: Still dsp is not Up\n", __func__);
  350. return -ENETRESET;
  351. } else if ((svc->dest_id == APR_DEST_MODEM) &&
  352. (apr_get_modem_state() == APR_SUBSYS_DOWN)) {
  353. pr_err("apr: Still Modem is not Up\n");
  354. return -ENETRESET;
  355. }
  356. spin_lock_irqsave(&svc->w_lock, flags);
  357. dest_id = svc->dest_id;
  358. client_id = svc->client_id;
  359. clnt = &client[dest_id][client_id];
  360. if (!client[dest_id][client_id].handle) {
  361. pr_err_ratelimited("APR: Still service is not yet opened\n");
  362. spin_unlock_irqrestore(&svc->w_lock, flags);
  363. return -EINVAL;
  364. }
  365. hdr = (struct apr_hdr *)buf;
  366. hdr->src_domain = APR_DOMAIN_APPS;
  367. hdr->src_svc = svc->id;
  368. hdr->dest_domain = svc->dest_domain;
  369. hdr->dest_svc = svc->id;
  370. if (unlikely(apr_cf_debug)) {
  371. APR_PKT_INFO(
  372. "Tx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X]",
  373. (hdr->src_domain << 8) | hdr->src_svc,
  374. (hdr->dest_domain << 8) | hdr->dest_svc, hdr->opcode,
  375. hdr->token);
  376. }
  377. rc = apr_tal_write(clnt->handle, buf,
  378. (struct apr_pkt_priv *)&svc->pkt_owner,
  379. hdr->pkt_size);
  380. if (rc >= 0) {
  381. w_len = rc;
  382. if (w_len != hdr->pkt_size) {
  383. pr_err("%s: Unable to write whole APR pkt successfully: %d\n",
  384. __func__, rc);
  385. rc = -EINVAL;
  386. }
  387. } else {
  388. pr_err_ratelimited("%s: Write APR pkt failed with error %d\n",
  389. __func__, rc);
  390. if (rc == -ECONNRESET) {
  391. pr_err_ratelimited("%s: Received reset error from tal\n",
  392. __func__);
  393. rc = -ENETRESET;
  394. }
  395. if (rc == -EAGAIN || rc == -ETIMEDOUT) {
  396. apr_send_pkt_count++;
  397. pr_err("%s:: send pkt timedout apr_send_pkt_count %d\n",
  398. __func__, apr_send_pkt_count);
  399. }
  400. }
  401. if (apr_send_pkt_count == apr_pkt_cnt_adsp_restart) {
  402. pr_debug("%s:: schedule work for adsp loader restart cb\n",
  403. __func__);
  404. schedule_work(&apr_cb_work);
  405. apr_send_pkt_count = 0;
  406. }
  407. spin_unlock_irqrestore(&svc->w_lock, flags);
  408. return rc;
  409. }
  410. EXPORT_SYMBOL(apr_send_pkt);
  411. int apr_pkt_config(void *handle, struct apr_pkt_cfg *cfg)
  412. {
  413. struct apr_svc *svc = (struct apr_svc *)handle;
  414. uint16_t dest_id;
  415. uint16_t client_id;
  416. struct apr_client *clnt;
  417. if (!handle) {
  418. pr_err("%s: Invalid handle\n", __func__);
  419. return -EINVAL;
  420. }
  421. if (svc->need_reset) {
  422. pr_err("%s: service need reset\n", __func__);
  423. return -ENETRESET;
  424. }
  425. svc->pkt_owner = cfg->pkt_owner;
  426. dest_id = svc->dest_id;
  427. client_id = svc->client_id;
  428. clnt = &client[dest_id][client_id];
  429. return apr_tal_rx_intents_config(clnt->handle,
  430. cfg->intents.num_of_intents, cfg->intents.size);
  431. }
  432. /**
  433. * apr_register - Clients call to register
  434. * to APR.
  435. *
  436. * @dest: destination processor
  437. * @svc_name: name of service to register as
  438. * @svc_fn: callback function to trigger when response
  439. * ack or packets received from destination processor.
  440. * @src_port: Port number within a service
  441. * @priv: private data of client, passed back in cb fn.
  442. *
  443. * Returns apr_svc handle on success or NULL on failure.
  444. */
  445. struct apr_svc *apr_register(char *dest, char *svc_name, apr_fn svc_fn,
  446. uint32_t src_port, void *priv)
  447. {
  448. struct apr_client *clnt;
  449. int client_id = 0;
  450. int svc_idx = 0;
  451. int svc_id = 0;
  452. int dest_id = 0;
  453. int domain_id = 0;
  454. int temp_port = 0;
  455. struct apr_svc *svc = NULL;
  456. int rc = 0;
  457. bool can_open_channel = true;
  458. if (!dest || !svc_name || !svc_fn)
  459. return NULL;
  460. if (!strcmp(dest, "ADSP"))
  461. domain_id = APR_DOMAIN_ADSP;
  462. else if (!strcmp(dest, "MODEM")) {
  463. /* Don't request for SMD channels if destination is MODEM,
  464. * as these channels are no longer used and these clients
  465. * are to listen only for MODEM SSR events
  466. */
  467. can_open_channel = false;
  468. domain_id = APR_DOMAIN_MODEM;
  469. } else {
  470. pr_err("APR: wrong destination\n");
  471. goto done;
  472. }
  473. dest_id = apr_get_dest_id(dest);
  474. if (dest_id == APR_DEST_QDSP6) {
  475. if (apr_get_q6_state() != APR_SUBSYS_LOADED) {
  476. pr_err_ratelimited("%s: adsp not up\n", __func__);
  477. return NULL;
  478. }
  479. pr_debug("%s: adsp Up\n", __func__);
  480. } else if (dest_id == APR_DEST_MODEM) {
  481. if (apr_get_modem_state() == APR_SUBSYS_DOWN) {
  482. if (is_modem_up) {
  483. pr_err("%s: modem shutdown due to SSR, ret",
  484. __func__);
  485. return NULL;
  486. }
  487. pr_debug("%s: Wait for modem to bootup\n", __func__);
  488. rc = wait_event_interruptible_timeout(modem_wait,
  489. (apr_get_modem_state() == APR_SUBSYS_UP),
  490. (1 * HZ));
  491. if (rc == 0) {
  492. pr_err("%s: Modem is not Up\n", __func__);
  493. return NULL;
  494. }
  495. }
  496. pr_debug("%s: modem Up\n", __func__);
  497. }
  498. if (apr_get_svc(svc_name, domain_id, &client_id, &svc_idx, &svc_id)) {
  499. pr_err_ratelimited("%s: apr_get_svc failed\n", __func__);
  500. goto done;
  501. }
  502. clnt = &client[dest_id][client_id];
  503. mutex_lock(&clnt->m_lock);
  504. if (!clnt->handle && can_open_channel) {
  505. clnt->handle = apr_tal_open(client_id, dest_id,
  506. APR_DL_SMD, apr_cb_func, NULL);
  507. if (!clnt->handle) {
  508. svc = NULL;
  509. pr_err_ratelimited("APR: Unable to open handle\n");
  510. mutex_unlock(&clnt->m_lock);
  511. goto done;
  512. }
  513. }
  514. mutex_unlock(&clnt->m_lock);
  515. svc = &clnt->svc[svc_idx];
  516. mutex_lock(&svc->m_lock);
  517. clnt->id = client_id;
  518. if (svc->need_reset) {
  519. mutex_unlock(&svc->m_lock);
  520. pr_err_ratelimited("APR: Service needs reset\n");
  521. svc = NULL;
  522. goto done;
  523. }
  524. svc->id = svc_id;
  525. svc->dest_id = dest_id;
  526. svc->client_id = client_id;
  527. svc->dest_domain = domain_id;
  528. svc->pkt_owner = APR_PKT_OWNER_DRIVER;
  529. if (src_port != 0xFFFFFFFF) {
  530. temp_port = ((src_port >> 8) * 8) + (src_port & 0xFF);
  531. pr_debug("port = %d t_port = %d\n", src_port, temp_port);
  532. if (temp_port >= APR_MAX_PORTS || temp_port < 0) {
  533. pr_err("APR: temp_port out of bounds\n");
  534. mutex_unlock(&svc->m_lock);
  535. return NULL;
  536. }
  537. if (!svc->svc_cnt)
  538. clnt->svc_cnt++;
  539. svc->port_cnt++;
  540. svc->port_fn[temp_port] = svc_fn;
  541. svc->port_priv[temp_port] = priv;
  542. svc->svc_cnt++;
  543. } else {
  544. if (!svc->fn) {
  545. if (!svc->svc_cnt)
  546. clnt->svc_cnt++;
  547. svc->fn = svc_fn;
  548. svc->priv = priv;
  549. svc->svc_cnt++;
  550. }
  551. }
  552. mutex_unlock(&svc->m_lock);
  553. done:
  554. return svc;
  555. }
  556. EXPORT_SYMBOL(apr_register);
  557. void apr_cb_func(void *buf, int len, void *priv)
  558. {
  559. struct apr_client_data data;
  560. struct apr_client *apr_client;
  561. struct apr_svc *c_svc;
  562. struct apr_hdr *hdr;
  563. uint16_t hdr_size;
  564. uint16_t msg_type;
  565. uint16_t ver;
  566. uint16_t src;
  567. uint16_t svc;
  568. uint16_t clnt;
  569. int i;
  570. int temp_port = 0;
  571. uint32_t *ptr;
  572. pr_debug("APR2: len = %d\n", len);
  573. ptr = buf;
  574. pr_debug("\n*****************\n");
  575. for (i = 0; i < len/4; i++)
  576. pr_debug("%x ", ptr[i]);
  577. pr_debug("\n");
  578. pr_debug("\n*****************\n");
  579. if (!buf || len <= APR_HDR_SIZE) {
  580. pr_err("APR: Improper apr pkt received:%pK %d\n", buf, len);
  581. return;
  582. }
  583. hdr = buf;
  584. ver = hdr->hdr_field;
  585. ver = (ver & 0x000F);
  586. if (ver > APR_PKT_VER + 1) {
  587. pr_err("APR: Wrong version: %d\n", ver);
  588. return;
  589. }
  590. hdr_size = hdr->hdr_field;
  591. hdr_size = ((hdr_size & 0x00F0) >> 0x4) * 4;
  592. if (hdr_size < APR_HDR_SIZE) {
  593. pr_err("APR: Wrong hdr size:%d\n", hdr_size);
  594. return;
  595. }
  596. if (hdr->pkt_size < APR_HDR_SIZE) {
  597. pr_err("APR: Wrong paket size\n");
  598. return;
  599. }
  600. if (hdr->pkt_size < hdr_size) {
  601. pr_err("APR: Packet size less than header size\n");
  602. return;
  603. }
  604. msg_type = hdr->hdr_field;
  605. msg_type = (msg_type >> 0x08) & 0x0003;
  606. if (msg_type >= APR_MSG_TYPE_MAX && msg_type != APR_BASIC_RSP_RESULT) {
  607. pr_err("APR: Wrong message type: %d\n", msg_type);
  608. return;
  609. }
  610. if (hdr->src_domain >= APR_DOMAIN_MAX ||
  611. hdr->dest_domain >= APR_DOMAIN_MAX ||
  612. hdr->src_svc >= APR_SVC_MAX ||
  613. hdr->dest_svc >= APR_SVC_MAX) {
  614. pr_err("APR: Wrong APR header\n");
  615. return;
  616. }
  617. svc = hdr->dest_svc;
  618. if (hdr->src_domain == APR_DOMAIN_MODEM) {
  619. if (svc == APR_SVC_MVS || svc == APR_SVC_MVM ||
  620. svc == APR_SVC_CVS || svc == APR_SVC_CVP ||
  621. svc == APR_SVC_TEST_CLIENT)
  622. clnt = APR_CLIENT_VOICE;
  623. else {
  624. pr_err("APR: Wrong svc :%d\n", svc);
  625. return;
  626. }
  627. } else if (hdr->src_domain == APR_DOMAIN_ADSP) {
  628. if (svc == APR_SVC_AFE || svc == APR_SVC_ASM ||
  629. svc == APR_SVC_VSM || svc == APR_SVC_VPM ||
  630. svc == APR_SVC_ADM || svc == APR_SVC_ADSP_CORE ||
  631. svc == APR_SVC_USM ||
  632. svc == APR_SVC_TEST_CLIENT || svc == APR_SVC_ADSP_MVM ||
  633. svc == APR_SVC_ADSP_CVS || svc == APR_SVC_ADSP_CVP ||
  634. svc == APR_SVC_LSM)
  635. clnt = APR_CLIENT_AUDIO;
  636. else if (svc == APR_SVC_VIDC)
  637. clnt = APR_CLIENT_AUDIO;
  638. else {
  639. pr_err("APR: Wrong svc :%d\n", svc);
  640. return;
  641. }
  642. } else {
  643. pr_err("APR: Pkt from wrong source: %d\n", hdr->src_domain);
  644. return;
  645. }
  646. src = apr_get_data_src(hdr);
  647. if (src == APR_DEST_MAX)
  648. return;
  649. pr_debug("src =%d clnt = %d\n", src, clnt);
  650. apr_client = &client[src][clnt];
  651. for (i = 0; i < APR_SVC_MAX; i++)
  652. if (apr_client->svc[i].id == svc) {
  653. pr_debug("%d\n", apr_client->svc[i].id);
  654. c_svc = &apr_client->svc[i];
  655. break;
  656. }
  657. if (i == APR_SVC_MAX) {
  658. pr_err("APR: service is not registered\n");
  659. return;
  660. }
  661. pr_debug("svc_idx = %d\n", i);
  662. pr_debug("%x %x %x %pK %pK\n", c_svc->id, c_svc->dest_id,
  663. c_svc->client_id, c_svc->fn, c_svc->priv);
  664. data.payload_size = hdr->pkt_size - hdr_size;
  665. data.opcode = hdr->opcode;
  666. data.src = src;
  667. data.src_port = hdr->src_port;
  668. data.dest_port = hdr->dest_port;
  669. data.token = hdr->token;
  670. data.msg_type = msg_type;
  671. data.payload = NULL;
  672. if (data.payload_size > 0)
  673. data.payload = (char *)hdr + hdr_size;
  674. if (unlikely(apr_cf_debug)) {
  675. if (hdr->opcode == APR_BASIC_RSP_RESULT && data.payload) {
  676. uint32_t *ptr = data.payload;
  677. APR_PKT_INFO(
  678. "Rx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X] rc[0x%X]",
  679. (hdr->src_domain << 8) | hdr->src_svc,
  680. (hdr->dest_domain << 8) | hdr->dest_svc,
  681. hdr->opcode, hdr->token, ptr[1]);
  682. } else {
  683. APR_PKT_INFO(
  684. "Rx: src_addr[0x%X] dest_addr[0x%X] opcode[0x%X] token[0x%X]",
  685. (hdr->src_domain << 8) | hdr->src_svc,
  686. (hdr->dest_domain << 8) | hdr->dest_svc, hdr->opcode,
  687. hdr->token);
  688. }
  689. }
  690. temp_port = ((data.dest_port >> 8) * 8) + (data.dest_port & 0xFF);
  691. if (((temp_port >= 0) && (temp_port < APR_MAX_PORTS))
  692. && (c_svc->port_cnt && c_svc->port_fn[temp_port]))
  693. c_svc->port_fn[temp_port](&data,
  694. c_svc->port_priv[temp_port]);
  695. else if (c_svc->fn)
  696. c_svc->fn(&data, c_svc->priv);
  697. else
  698. pr_err("APR: Rxed a packet for NULL callback\n");
  699. }
  700. int apr_get_svc(const char *svc_name, int domain_id, int *client_id,
  701. int *svc_idx, int *svc_id)
  702. {
  703. int i;
  704. int size;
  705. struct apr_svc_table *tbl;
  706. int ret = 0;
  707. if (domain_id == APR_DOMAIN_ADSP) {
  708. tbl = (struct apr_svc_table *)&svc_tbl_qdsp6;
  709. size = ARRAY_SIZE(svc_tbl_qdsp6);
  710. } else {
  711. tbl = (struct apr_svc_table *)&svc_tbl_voice;
  712. size = ARRAY_SIZE(svc_tbl_voice);
  713. }
  714. for (i = 0; i < size; i++) {
  715. if (!strcmp(svc_name, tbl[i].name)) {
  716. *client_id = tbl[i].client_id;
  717. *svc_idx = tbl[i].idx;
  718. *svc_id = tbl[i].id;
  719. break;
  720. }
  721. }
  722. pr_debug("%s: svc_name = %s c_id = %d domain_id = %d\n",
  723. __func__, svc_name, *client_id, domain_id);
  724. if (i == size) {
  725. pr_err("%s: APR: Wrong svc name %s\n", __func__, svc_name);
  726. ret = -EINVAL;
  727. }
  728. return ret;
  729. }
  730. static void apr_reset_deregister(struct work_struct *work)
  731. {
  732. struct apr_svc *handle = NULL;
  733. struct apr_reset_work *apr_reset =
  734. container_of(work, struct apr_reset_work, work);
  735. handle = apr_reset->handle;
  736. pr_debug("%s:handle[%pK]\n", __func__, handle);
  737. apr_deregister(handle);
  738. kfree(apr_reset);
  739. }
  740. static void state_notify_cb(struct work_struct *work)
  741. {
  742. if (q6.state_notify_cb)
  743. q6.state_notify_cb(APR_SUBSYS_UNKNOWN, q6.client_handle);
  744. }
  745. void apr_register_adsp_state_cb(void *adsp_cb, void *client_handle)
  746. {
  747. q6.state_notify_cb = adsp_cb;
  748. q6.client_handle = client_handle;
  749. }
  750. EXPORT_SYMBOL(apr_register_adsp_state_cb);
  751. /**
  752. * apr_start_rx_rt - Clients call to vote for thread
  753. * priority upgrade whenever needed.
  754. *
  755. * @handle: APR service handle
  756. *
  757. * Returns 0 on success or error otherwise.
  758. */
  759. int apr_start_rx_rt(void *handle)
  760. {
  761. int rc = 0;
  762. struct apr_svc *svc = handle;
  763. uint16_t dest_id = 0;
  764. uint16_t client_id = 0;
  765. if (!svc) {
  766. pr_err("%s: Invalid APR handle\n", __func__);
  767. return -EINVAL;
  768. }
  769. mutex_lock(&svc->m_lock);
  770. dest_id = svc->dest_id;
  771. client_id = svc->client_id;
  772. if ((client_id >= APR_CLIENT_MAX) || (dest_id >= APR_DEST_MAX)) {
  773. pr_err("%s: %s invalid. client_id = %u, dest_id = %u\n",
  774. __func__,
  775. client_id >= APR_CLIENT_MAX ? "Client ID" : "Dest ID",
  776. client_id, dest_id);
  777. rc = -EINVAL;
  778. goto exit;
  779. }
  780. if (!client[dest_id][client_id].handle) {
  781. pr_err("%s: Client handle is NULL\n", __func__);
  782. rc = -EINVAL;
  783. goto exit;
  784. }
  785. rc = apr_tal_start_rx_rt(client[dest_id][client_id].handle);
  786. if (rc)
  787. pr_err("%s: failed to set RT thread priority for APR RX. rc = %d\n",
  788. __func__, rc);
  789. exit:
  790. mutex_unlock(&svc->m_lock);
  791. return rc;
  792. }
  793. EXPORT_SYMBOL(apr_start_rx_rt);
  794. /**
  795. * apr_end_rx_rt - Clients call to unvote for thread
  796. * priority upgrade (perviously voted with
  797. * apr_start_rx_rt()).
  798. *
  799. * @handle: APR service handle
  800. *
  801. * Returns 0 on success or error otherwise.
  802. */
  803. int apr_end_rx_rt(void *handle)
  804. {
  805. int rc = 0;
  806. struct apr_svc *svc = handle;
  807. uint16_t dest_id = 0;
  808. uint16_t client_id = 0;
  809. if (!svc) {
  810. pr_err("%s: Invalid APR handle\n", __func__);
  811. return -EINVAL;
  812. }
  813. mutex_lock(&svc->m_lock);
  814. dest_id = svc->dest_id;
  815. client_id = svc->client_id;
  816. if ((client_id >= APR_CLIENT_MAX) || (dest_id >= APR_DEST_MAX)) {
  817. pr_err("%s: %s invalid. client_id = %u, dest_id = %u\n",
  818. __func__,
  819. client_id >= APR_CLIENT_MAX ? "Client ID" : "Dest ID",
  820. client_id, dest_id);
  821. rc = -EINVAL;
  822. goto exit;
  823. }
  824. if (!client[dest_id][client_id].handle) {
  825. pr_err("%s: Client handle is NULL\n", __func__);
  826. rc = -EINVAL;
  827. goto exit;
  828. }
  829. rc = apr_tal_end_rx_rt(client[dest_id][client_id].handle);
  830. if (rc)
  831. pr_err("%s: failed to reset RT thread priority for APR RX. rc = %d\n",
  832. __func__, rc);
  833. exit:
  834. mutex_unlock(&svc->m_lock);
  835. return rc;
  836. }
  837. EXPORT_SYMBOL(apr_end_rx_rt);
  838. /**
  839. * apr_deregister - Clients call to de-register
  840. * from APR.
  841. *
  842. * @handle: APR service handle to de-register
  843. *
  844. * Returns 0 on success or -EINVAL on error.
  845. */
  846. int apr_deregister(void *handle)
  847. {
  848. struct apr_svc *svc = handle;
  849. struct apr_client *clnt;
  850. uint16_t dest_id;
  851. uint16_t client_id;
  852. if (!handle)
  853. return -EINVAL;
  854. mutex_lock(&svc->m_lock);
  855. if (!svc->svc_cnt) {
  856. pr_err("%s: svc already deregistered. svc = %pK\n",
  857. __func__, svc);
  858. mutex_unlock(&svc->m_lock);
  859. return -EINVAL;
  860. }
  861. dest_id = svc->dest_id;
  862. client_id = svc->client_id;
  863. clnt = &client[dest_id][client_id];
  864. if (svc->svc_cnt > 0) {
  865. if (svc->port_cnt)
  866. svc->port_cnt--;
  867. svc->svc_cnt--;
  868. if (!svc->svc_cnt) {
  869. client[dest_id][client_id].svc_cnt--;
  870. pr_debug("%s: service is reset %pK\n", __func__, svc);
  871. }
  872. }
  873. if (!svc->svc_cnt) {
  874. svc->priv = NULL;
  875. svc->id = 0;
  876. svc->fn = NULL;
  877. svc->dest_id = 0;
  878. svc->client_id = 0;
  879. svc->need_reset = 0x0;
  880. }
  881. if (client[dest_id][client_id].handle &&
  882. !client[dest_id][client_id].svc_cnt) {
  883. apr_tal_close(client[dest_id][client_id].handle);
  884. client[dest_id][client_id].handle = NULL;
  885. }
  886. mutex_unlock(&svc->m_lock);
  887. return 0;
  888. }
  889. EXPORT_SYMBOL(apr_deregister);
  890. /**
  891. * apr_reset - sets up workqueue to de-register
  892. * the given APR service handle.
  893. *
  894. * @handle: APR service handle
  895. *
  896. */
  897. void apr_reset(void *handle)
  898. {
  899. struct apr_reset_work *apr_reset_worker = NULL;
  900. if (!handle)
  901. return;
  902. pr_debug("%s: handle[%pK]\n", __func__, handle);
  903. if (apr_reset_workqueue == NULL) {
  904. pr_err("%s: apr_reset_workqueue is NULL\n", __func__);
  905. return;
  906. }
  907. apr_reset_worker = kzalloc(sizeof(struct apr_reset_work),
  908. GFP_ATOMIC);
  909. if (apr_reset_worker == NULL) {
  910. pr_err("%s: mem failure\n", __func__);
  911. return;
  912. }
  913. apr_reset_worker->handle = handle;
  914. INIT_WORK(&apr_reset_worker->work, apr_reset_deregister);
  915. queue_work(apr_reset_workqueue, &apr_reset_worker->work);
  916. }
  917. EXPORT_SYMBOL(apr_reset);
  918. /* Dispatch the Reset events to Modem and audio clients */
  919. static void dispatch_event(unsigned long code, uint16_t proc)
  920. {
  921. struct apr_client *apr_client;
  922. struct apr_client_data data;
  923. struct apr_svc *svc;
  924. uint16_t clnt;
  925. int i, j;
  926. memset(&data, 0, sizeof(data));
  927. data.opcode = RESET_EVENTS;
  928. data.reset_event = code;
  929. /* Service domain can be different from the processor */
  930. data.reset_proc = apr_get_reset_domain(proc);
  931. clnt = APR_CLIENT_AUDIO;
  932. apr_client = &client[proc][clnt];
  933. for (i = 0; i < APR_SVC_MAX; i++) {
  934. mutex_lock(&apr_client->svc[i].m_lock);
  935. if (apr_client->svc[i].fn) {
  936. apr_client->svc[i].need_reset = 0x1;
  937. apr_client->svc[i].fn(&data, apr_client->svc[i].priv);
  938. }
  939. if (apr_client->svc[i].port_cnt) {
  940. svc = &(apr_client->svc[i]);
  941. svc->need_reset = 0x1;
  942. for (j = 0; j < APR_MAX_PORTS; j++)
  943. if (svc->port_fn[j])
  944. svc->port_fn[j](&data,
  945. svc->port_priv[j]);
  946. }
  947. mutex_unlock(&apr_client->svc[i].m_lock);
  948. }
  949. clnt = APR_CLIENT_VOICE;
  950. apr_client = &client[proc][clnt];
  951. for (i = 0; i < APR_SVC_MAX; i++) {
  952. mutex_lock(&apr_client->svc[i].m_lock);
  953. if (apr_client->svc[i].fn) {
  954. apr_client->svc[i].need_reset = 0x1;
  955. apr_client->svc[i].fn(&data, apr_client->svc[i].priv);
  956. }
  957. if (apr_client->svc[i].port_cnt) {
  958. svc = &(apr_client->svc[i]);
  959. svc->need_reset = 0x1;
  960. for (j = 0; j < APR_MAX_PORTS; j++)
  961. if (svc->port_fn[j])
  962. svc->port_fn[j](&data,
  963. svc->port_priv[j]);
  964. }
  965. mutex_unlock(&apr_client->svc[i].m_lock);
  966. }
  967. }
  968. static int apr_notifier_service_cb(struct notifier_block *this,
  969. unsigned long opcode, void *data)
  970. {
  971. struct audio_notifier_cb_data *cb_data = data;
  972. if (cb_data == NULL) {
  973. pr_err("%s: Callback data is NULL!\n", __func__);
  974. goto done;
  975. }
  976. pr_debug("%s: Service opcode 0x%lx, domain %d\n",
  977. __func__, opcode, cb_data->domain);
  978. switch (opcode) {
  979. case AUDIO_NOTIFIER_SERVICE_DOWN:
  980. /*
  981. * Use flag to ignore down notifications during
  982. * initial boot. There is no benefit from error
  983. * recovery notifications during initial boot
  984. * up since everything is expected to be down.
  985. */
  986. spin_lock(&apr_priv->apr_lock);
  987. if (apr_priv->is_initial_boot) {
  988. spin_unlock(&apr_priv->apr_lock);
  989. break;
  990. }
  991. spin_unlock(&apr_priv->apr_lock);
  992. if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
  993. apr_modem_down(opcode);
  994. else
  995. apr_adsp_down(opcode);
  996. break;
  997. case AUDIO_NOTIFIER_SERVICE_UP:
  998. if (cb_data->domain == AUDIO_NOTIFIER_MODEM_DOMAIN)
  999. apr_modem_up();
  1000. else
  1001. apr_adsp_up();
  1002. spin_lock(&apr_priv->apr_lock);
  1003. apr_priv->is_initial_boot = false;
  1004. spin_unlock(&apr_priv->apr_lock);
  1005. break;
  1006. default:
  1007. break;
  1008. }
  1009. done:
  1010. return NOTIFY_OK;
  1011. }
  1012. static struct notifier_block adsp_service_nb = {
  1013. .notifier_call = apr_notifier_service_cb,
  1014. .priority = 0,
  1015. };
  1016. static struct notifier_block modem_service_nb = {
  1017. .notifier_call = apr_notifier_service_cb,
  1018. .priority = 0,
  1019. };
  1020. #ifdef CONFIG_DEBUG_FS
  1021. static int __init apr_debug_init(void)
  1022. {
  1023. debugfs_apr_debug = debugfs_create_file("msm_apr_debug",
  1024. S_IFREG | 0444, NULL, NULL,
  1025. &apr_debug_ops);
  1026. return 0;
  1027. }
  1028. #else
  1029. static int __init apr_debug_init(void)
  1030. {
  1031. return 0;
  1032. }
  1033. #endif
  1034. static void apr_cleanup(void)
  1035. {
  1036. int i, j, k;
  1037. of_platform_depopulate(apr_priv->dev);
  1038. subsys_notif_deregister(subsys_name);
  1039. if (apr_reset_workqueue) {
  1040. flush_workqueue(apr_reset_workqueue);
  1041. destroy_workqueue(apr_reset_workqueue);
  1042. }
  1043. mutex_destroy(&q6.lock);
  1044. for (i = 0; i < APR_DEST_MAX; i++) {
  1045. for (j = 0; j < APR_CLIENT_MAX; j++) {
  1046. mutex_destroy(&client[i][j].m_lock);
  1047. for (k = 0; k < APR_SVC_MAX; k++)
  1048. mutex_destroy(&client[i][j].svc[k].m_lock);
  1049. }
  1050. }
  1051. #ifdef CONFIG_DEBUG_FS
  1052. debugfs_remove(debugfs_apr_debug);
  1053. #endif
  1054. }
  1055. static int apr_probe(struct platform_device *pdev)
  1056. {
  1057. int i, j, k, ret = 0;
  1058. init_waitqueue_head(&modem_wait);
  1059. apr_priv = devm_kzalloc(&pdev->dev, sizeof(*apr_priv), GFP_KERNEL);
  1060. if (!apr_priv)
  1061. return -ENOMEM;
  1062. apr_priv->dev = &pdev->dev;
  1063. spin_lock_init(&apr_priv->apr_lock);
  1064. INIT_WORK(&apr_priv->add_chld_dev_work, apr_add_child_devices);
  1065. for (i = 0; i < APR_DEST_MAX; i++)
  1066. for (j = 0; j < APR_CLIENT_MAX; j++) {
  1067. mutex_init(&client[i][j].m_lock);
  1068. for (k = 0; k < APR_SVC_MAX; k++) {
  1069. mutex_init(&client[i][j].svc[k].m_lock);
  1070. spin_lock_init(&client[i][j].svc[k].w_lock);
  1071. }
  1072. }
  1073. apr_set_subsys_state();
  1074. mutex_init(&q6.lock);
  1075. apr_reset_workqueue = create_singlethread_workqueue("apr_driver");
  1076. if (!apr_reset_workqueue) {
  1077. apr_priv = NULL;
  1078. return -ENOMEM;
  1079. }
  1080. apr_pkt_ctx = ipc_log_context_create(APR_PKT_IPC_LOG_PAGE_CNT,
  1081. "apr", 0);
  1082. if (!apr_pkt_ctx)
  1083. pr_err("%s: Unable to create ipc log context\n", __func__);
  1084. spin_lock(&apr_priv->apr_lock);
  1085. apr_priv->is_initial_boot = true;
  1086. spin_unlock(&apr_priv->apr_lock);
  1087. ret = of_property_read_string(pdev->dev.of_node,
  1088. "qcom,subsys-name",
  1089. (const char **)(&subsys_name));
  1090. if (ret) {
  1091. pr_err("%s: missing subsys-name entry in dt node\n", __func__);
  1092. return -EINVAL;
  1093. }
  1094. if (!strcmp(subsys_name, "apr_adsp")) {
  1095. subsys_notif_register("apr_adsp",
  1096. AUDIO_NOTIFIER_ADSP_DOMAIN,
  1097. &adsp_service_nb);
  1098. } else if (!strcmp(subsys_name, "apr_modem")) {
  1099. subsys_notif_register("apr_modem",
  1100. AUDIO_NOTIFIER_MODEM_DOMAIN,
  1101. &modem_service_nb);
  1102. } else {
  1103. pr_err("%s: invalid subsys-name %s\n", __func__, subsys_name);
  1104. return -EINVAL;
  1105. }
  1106. apr_tal_init();
  1107. ret = snd_event_client_register(&pdev->dev, &apr_ssr_ops, NULL);
  1108. if (ret) {
  1109. pr_err("%s: Registration with SND event fwk failed ret = %d\n",
  1110. __func__, ret);
  1111. ret = 0;
  1112. }
  1113. INIT_WORK(&apr_cb_work, state_notify_cb);
  1114. return apr_debug_init();
  1115. }
  1116. static int apr_remove(struct platform_device *pdev)
  1117. {
  1118. snd_event_client_deregister(&pdev->dev);
  1119. apr_cleanup();
  1120. apr_tal_exit();
  1121. apr_priv = NULL;
  1122. return 0;
  1123. }
  1124. static const struct of_device_id apr_machine_of_match[] = {
  1125. { .compatible = "qcom,msm-audio-apr", },
  1126. {},
  1127. };
  1128. static struct platform_driver apr_driver = {
  1129. .probe = apr_probe,
  1130. .remove = apr_remove,
  1131. .driver = {
  1132. .name = "audio_apr",
  1133. .owner = THIS_MODULE,
  1134. .of_match_table = apr_machine_of_match,
  1135. .suppress_bind_attrs = true,
  1136. }
  1137. };
  1138. module_platform_driver(apr_driver);
  1139. MODULE_DESCRIPTION("APR DRIVER");
  1140. MODULE_LICENSE("GPL v2");
  1141. MODULE_DEVICE_TABLE(of, apr_machine_of_match);