wcd-dsp-glink.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/mutex.h>
  16. #include <linux/errno.h>
  17. #include <linux/fs.h>
  18. #include <linux/uaccess.h>
  19. #include <linux/slab.h>
  20. #include <linux/list.h>
  21. #include <linux/cdev.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/vmalloc.h>
  24. #include <soc/qcom/glink.h>
  25. #include "sound/wcd-dsp-glink.h"
  26. #define WDSP_GLINK_DRIVER_NAME "wcd-dsp-glink"
  27. #define WDSP_MAX_WRITE_SIZE (256 * 1024)
  28. #define WDSP_MAX_READ_SIZE (4 * 1024)
  29. #define WDSP_MAX_NO_OF_INTENTS (20)
  30. #define WDSP_MAX_NO_OF_CHANNELS (10)
  31. #define WDSP_WRITE_PKT_SIZE (sizeof(struct wdsp_write_pkt))
  32. #define WDSP_REG_PKT_SIZE (sizeof(struct wdsp_reg_pkt))
  33. #define WDSP_CMD_PKT_SIZE (sizeof(struct wdsp_cmd_pkt))
  34. #define WDSP_CH_CFG_SIZE (sizeof(struct wdsp_glink_ch_cfg))
  35. #define MINOR_NUMBER_COUNT 1
  36. #define WDSP_EDGE "wdsp"
  37. #define RESP_QUEUE_SIZE 3
  38. #define QOS_PKT_SIZE 1024
  39. #define TIMEOUT_MS 1000
  40. struct wdsp_glink_dev {
  41. struct class *cls;
  42. struct device *dev;
  43. struct cdev cdev;
  44. dev_t dev_num;
  45. };
  46. struct wdsp_glink_rsp_que {
  47. /* Size of valid data in buffer */
  48. u32 buf_size;
  49. /* Response buffer */
  50. u8 buf[WDSP_MAX_READ_SIZE];
  51. };
  52. struct wdsp_glink_tx_buf {
  53. struct work_struct tx_work;
  54. struct work_struct free_tx_work;
  55. /* Glink channel information */
  56. struct wdsp_glink_ch *ch;
  57. /* Tx buffer to send to glink */
  58. u8 buf[0];
  59. };
  60. struct wdsp_glink_ch {
  61. struct wdsp_glink_priv *wpriv;
  62. /* Glink channel handle */
  63. void *handle;
  64. /* Channel states like connect, disconnect */
  65. int channel_state;
  66. struct mutex mutex;
  67. /* To free up the channel memory */
  68. bool free_mem;
  69. /* Glink local channel open work */
  70. struct work_struct lcl_ch_open_wrk;
  71. /* Glink local channel close work */
  72. struct work_struct lcl_ch_cls_wrk;
  73. /* Wait for ch connect state before sending any command */
  74. wait_queue_head_t ch_connect_wait;
  75. /*
  76. * Glink channel configuration. This has to be the last
  77. * member of the strucuture as it has variable size
  78. */
  79. struct wdsp_glink_ch_cfg ch_cfg;
  80. };
  81. struct wdsp_glink_state {
  82. /* Glink link state information */
  83. enum glink_link_state link_state;
  84. void *handle;
  85. };
  86. struct wdsp_glink_priv {
  87. /* Respone buffer related */
  88. u8 rsp_cnt;
  89. struct wdsp_glink_rsp_que rsp[RESP_QUEUE_SIZE];
  90. struct completion rsp_complete;
  91. struct mutex rsp_mutex;
  92. /* Glink channel related */
  93. struct mutex glink_mutex;
  94. struct wdsp_glink_state glink_state;
  95. struct wdsp_glink_ch **ch;
  96. u8 no_of_channels;
  97. struct work_struct ch_open_cls_wrk;
  98. struct workqueue_struct *work_queue;
  99. wait_queue_head_t link_state_wait;
  100. struct device *dev;
  101. };
  102. static int wdsp_glink_close_ch(struct wdsp_glink_ch *ch);
  103. static int wdsp_glink_open_ch(struct wdsp_glink_ch *ch);
  104. /*
  105. * wdsp_glink_free_tx_buf_work - Work function to free tx pkt
  106. * work: Work structure
  107. */
  108. static void wdsp_glink_free_tx_buf_work(struct work_struct *work)
  109. {
  110. struct wdsp_glink_tx_buf *tx_buf;
  111. tx_buf = container_of(work, struct wdsp_glink_tx_buf,
  112. free_tx_work);
  113. vfree(tx_buf);
  114. }
  115. /*
  116. * wdsp_glink_free_tx_buf - Function to free tx buffer
  117. * priv: Pointer to the channel
  118. * pkt_priv: Pointer to the tx buffer
  119. */
  120. static void wdsp_glink_free_tx_buf(const void *priv, const void *pkt_priv)
  121. {
  122. struct wdsp_glink_tx_buf *tx_buf = (struct wdsp_glink_tx_buf *)pkt_priv;
  123. struct wdsp_glink_priv *wpriv;
  124. struct wdsp_glink_ch *ch;
  125. if (!priv) {
  126. pr_err("%s: Invalid priv\n", __func__);
  127. return;
  128. }
  129. if (!tx_buf) {
  130. pr_err("%s: Invalid tx_buf\n", __func__);
  131. return;
  132. }
  133. ch = (struct wdsp_glink_ch *)priv;
  134. wpriv = ch->wpriv;
  135. /* Work queue to free tx pkt */
  136. INIT_WORK(&tx_buf->free_tx_work, wdsp_glink_free_tx_buf_work);
  137. queue_work(wpriv->work_queue, &tx_buf->free_tx_work);
  138. }
  139. /*
  140. * wdsp_glink_notify_rx - Glink notify rx callback for responses
  141. * handle: Opaque Channel handle returned by GLink
  142. * priv: Private pointer to the channel
  143. * pkt_priv: Private pointer to the packet
  144. * ptr: Pointer to the Rx data
  145. * size: Size of the Rx data
  146. */
  147. static void wdsp_glink_notify_rx(void *handle, const void *priv,
  148. const void *pkt_priv, const void *ptr,
  149. size_t size)
  150. {
  151. u8 *rx_buf;
  152. u8 rsp_cnt;
  153. struct wdsp_glink_ch *ch;
  154. struct wdsp_glink_priv *wpriv;
  155. if (!ptr || !priv) {
  156. pr_err("%s: Invalid parameters\n", __func__);
  157. return;
  158. }
  159. ch = (struct wdsp_glink_ch *)priv;
  160. wpriv = ch->wpriv;
  161. rx_buf = (u8 *)ptr;
  162. if (size > WDSP_MAX_READ_SIZE) {
  163. dev_err(wpriv->dev, "%s: Size %zd is greater than allowed %d\n",
  164. __func__, size, WDSP_MAX_READ_SIZE);
  165. size = WDSP_MAX_READ_SIZE;
  166. }
  167. mutex_lock(&wpriv->rsp_mutex);
  168. rsp_cnt = wpriv->rsp_cnt;
  169. if (rsp_cnt >= RESP_QUEUE_SIZE) {
  170. dev_err(wpriv->dev, "%s: Resp Queue is Full\n", __func__);
  171. rsp_cnt = 0;
  172. }
  173. dev_dbg(wpriv->dev, "%s: copy into buffer %d\n", __func__, rsp_cnt);
  174. memcpy(wpriv->rsp[rsp_cnt].buf, rx_buf, size);
  175. wpriv->rsp[rsp_cnt].buf_size = size;
  176. wpriv->rsp_cnt = ++rsp_cnt;
  177. mutex_unlock(&wpriv->rsp_mutex);
  178. glink_rx_done(handle, ptr, true);
  179. complete(&wpriv->rsp_complete);
  180. }
  181. /*
  182. * wdsp_glink_notify_tx_done - Glink notify tx done callback to
  183. * free tx buffer
  184. * handle: Opaque Channel handle returned by GLink
  185. * priv: Private pointer to the channel
  186. * pkt_priv: Private pointer to the packet
  187. * ptr: Pointer to the Tx data
  188. */
  189. static void wdsp_glink_notify_tx_done(void *handle, const void *priv,
  190. const void *pkt_priv, const void *ptr)
  191. {
  192. wdsp_glink_free_tx_buf(priv, pkt_priv);
  193. }
  194. /*
  195. * wdsp_glink_notify_tx_abort - Glink notify tx abort callback to
  196. * free tx buffer
  197. * handle: Opaque Channel handle returned by GLink
  198. * priv: Private pointer to the channel
  199. * pkt_priv: Private pointer to the packet
  200. */
  201. static void wdsp_glink_notify_tx_abort(void *handle, const void *priv,
  202. const void *pkt_priv)
  203. {
  204. wdsp_glink_free_tx_buf(priv, pkt_priv);
  205. }
  206. /*
  207. * wdsp_glink_notify_rx_intent_req - Glink notify rx intent request callback
  208. * to queue buffer to receive from remote client
  209. * handle: Opaque channel handle returned by GLink
  210. * priv: Private pointer to the channel
  211. * req_size: Size of intent to be queued
  212. */
  213. static bool wdsp_glink_notify_rx_intent_req(void *handle, const void *priv,
  214. size_t req_size)
  215. {
  216. struct wdsp_glink_priv *wpriv;
  217. struct wdsp_glink_ch *ch;
  218. int rc = 0;
  219. bool ret = false;
  220. if (!priv) {
  221. pr_err("%s: Invalid priv\n", __func__);
  222. goto done;
  223. }
  224. if (req_size > WDSP_MAX_READ_SIZE) {
  225. pr_err("%s: Invalid req_size %zd\n", __func__, req_size);
  226. goto done;
  227. }
  228. ch = (struct wdsp_glink_ch *)priv;
  229. wpriv = ch->wpriv;
  230. dev_dbg(wpriv->dev, "%s: intent size %zd requested for ch name %s",
  231. __func__, req_size, ch->ch_cfg.name);
  232. mutex_lock(&ch->mutex);
  233. rc = glink_queue_rx_intent(ch->handle, ch, req_size);
  234. if (rc < 0) {
  235. dev_err(wpriv->dev, "%s: Failed to queue rx intent, rc = %d\n",
  236. __func__, rc);
  237. mutex_unlock(&ch->mutex);
  238. goto done;
  239. }
  240. mutex_unlock(&ch->mutex);
  241. ret = true;
  242. done:
  243. return ret;
  244. }
  245. /*
  246. * wdsp_glink_lcl_ch_open_wrk - Work function to open channel again
  247. * when local disconnect event happens
  248. * work: Work structure
  249. */
  250. static void wdsp_glink_lcl_ch_open_wrk(struct work_struct *work)
  251. {
  252. struct wdsp_glink_ch *ch;
  253. ch = container_of(work, struct wdsp_glink_ch,
  254. lcl_ch_open_wrk);
  255. wdsp_glink_open_ch(ch);
  256. }
  257. /*
  258. * wdsp_glink_lcl_ch_cls_wrk - Work function to close channel locally
  259. * when remote disconnect event happens
  260. * work: Work structure
  261. */
  262. static void wdsp_glink_lcl_ch_cls_wrk(struct work_struct *work)
  263. {
  264. struct wdsp_glink_ch *ch;
  265. ch = container_of(work, struct wdsp_glink_ch,
  266. lcl_ch_cls_wrk);
  267. wdsp_glink_close_ch(ch);
  268. }
  269. /*
  270. * wdsp_glink_notify_state - Glink channel state information event callback
  271. * handle: Opaque Channel handle returned by GLink
  272. * priv: Private pointer to the channel
  273. * event: channel state event
  274. */
  275. static void wdsp_glink_notify_state(void *handle, const void *priv,
  276. unsigned int event)
  277. {
  278. struct wdsp_glink_priv *wpriv;
  279. struct wdsp_glink_ch *ch;
  280. int i, ret = 0;
  281. if (!priv) {
  282. pr_err("%s: Invalid priv\n", __func__);
  283. return;
  284. }
  285. ch = (struct wdsp_glink_ch *)priv;
  286. wpriv = ch->wpriv;
  287. mutex_lock(&ch->mutex);
  288. ch->channel_state = event;
  289. if (event == GLINK_CONNECTED) {
  290. dev_dbg(wpriv->dev, "%s: glink channel: %s connected\n",
  291. __func__, ch->ch_cfg.name);
  292. for (i = 0; i < ch->ch_cfg.no_of_intents; i++) {
  293. dev_dbg(wpriv->dev, "%s: intent_size = %d\n", __func__,
  294. ch->ch_cfg.intents_size[i]);
  295. ret = glink_queue_rx_intent(ch->handle, ch,
  296. ch->ch_cfg.intents_size[i]);
  297. if (ret < 0)
  298. dev_warn(wpriv->dev, "%s: Failed to queue intent %d of size %d\n",
  299. __func__, i,
  300. ch->ch_cfg.intents_size[i]);
  301. }
  302. ret = glink_qos_latency(ch->handle, ch->ch_cfg.latency_in_us,
  303. QOS_PKT_SIZE);
  304. if (ret < 0)
  305. dev_warn(wpriv->dev, "%s: Failed to request qos %d for ch %s\n",
  306. __func__, ch->ch_cfg.latency_in_us,
  307. ch->ch_cfg.name);
  308. wake_up(&ch->ch_connect_wait);
  309. mutex_unlock(&ch->mutex);
  310. } else if (event == GLINK_LOCAL_DISCONNECTED) {
  311. /*
  312. * Don't use dev_dbg here as dev may not be valid if channel
  313. * closed from driver close.
  314. */
  315. pr_debug("%s: channel: %s disconnected locally\n",
  316. __func__, ch->ch_cfg.name);
  317. mutex_unlock(&ch->mutex);
  318. if (ch->free_mem) {
  319. kfree(ch);
  320. ch = NULL;
  321. }
  322. } else if (event == GLINK_REMOTE_DISCONNECTED) {
  323. dev_dbg(wpriv->dev, "%s: remote channel: %s disconnected remotely\n",
  324. __func__, ch->ch_cfg.name);
  325. mutex_unlock(&ch->mutex);
  326. /*
  327. * If remote disconnect happens, local side also has
  328. * to close the channel as per glink design in a
  329. * separate work_queue.
  330. */
  331. queue_work(wpriv->work_queue, &ch->lcl_ch_cls_wrk);
  332. }
  333. }
  334. /*
  335. * wdsp_glink_close_ch - Internal function to close glink channel
  336. * ch: Glink Channel structure.
  337. */
  338. static int wdsp_glink_close_ch(struct wdsp_glink_ch *ch)
  339. {
  340. struct wdsp_glink_priv *wpriv = ch->wpriv;
  341. int ret = 0;
  342. mutex_lock(&wpriv->glink_mutex);
  343. if (ch->handle) {
  344. ret = glink_close(ch->handle);
  345. if (ret < 0) {
  346. dev_err(wpriv->dev, "%s: glink_close is failed, ret = %d\n",
  347. __func__, ret);
  348. } else {
  349. ch->handle = NULL;
  350. dev_dbg(wpriv->dev, "%s: ch %s is closed\n", __func__,
  351. ch->ch_cfg.name);
  352. }
  353. } else {
  354. dev_dbg(wpriv->dev, "%s: ch %s is already closed\n", __func__,
  355. ch->ch_cfg.name);
  356. }
  357. mutex_unlock(&wpriv->glink_mutex);
  358. return ret;
  359. }
  360. /*
  361. * wdsp_glink_open_ch - Internal function to open glink channel
  362. * ch: Glink Channel structure.
  363. */
  364. static int wdsp_glink_open_ch(struct wdsp_glink_ch *ch)
  365. {
  366. struct wdsp_glink_priv *wpriv = ch->wpriv;
  367. struct glink_open_config open_cfg;
  368. int ret = 0;
  369. mutex_lock(&wpriv->glink_mutex);
  370. if (!ch->handle) {
  371. memset(&open_cfg, 0, sizeof(open_cfg));
  372. open_cfg.options = GLINK_OPT_INITIAL_XPORT;
  373. open_cfg.edge = WDSP_EDGE;
  374. open_cfg.notify_rx = wdsp_glink_notify_rx;
  375. open_cfg.notify_tx_done = wdsp_glink_notify_tx_done;
  376. open_cfg.notify_tx_abort = wdsp_glink_notify_tx_abort;
  377. open_cfg.notify_state = wdsp_glink_notify_state;
  378. open_cfg.notify_rx_intent_req = wdsp_glink_notify_rx_intent_req;
  379. open_cfg.priv = ch;
  380. open_cfg.name = ch->ch_cfg.name;
  381. dev_dbg(wpriv->dev, "%s: ch->ch_cfg.name = %s, latency_in_us = %d, intents = %d\n",
  382. __func__, ch->ch_cfg.name, ch->ch_cfg.latency_in_us,
  383. ch->ch_cfg.no_of_intents);
  384. ch->handle = glink_open(&open_cfg);
  385. if (IS_ERR_OR_NULL(ch->handle)) {
  386. dev_err(wpriv->dev, "%s: glink_open failed for ch %s\n",
  387. __func__, ch->ch_cfg.name);
  388. ch->handle = NULL;
  389. ret = -EINVAL;
  390. }
  391. } else {
  392. dev_err(wpriv->dev, "%s: ch %s is already opened\n", __func__,
  393. ch->ch_cfg.name);
  394. }
  395. mutex_unlock(&wpriv->glink_mutex);
  396. return ret;
  397. }
  398. /*
  399. * wdsp_glink_close_all_ch - Internal function to close all glink channels
  400. * wpriv: Wdsp_glink private structure
  401. */
  402. static void wdsp_glink_close_all_ch(struct wdsp_glink_priv *wpriv)
  403. {
  404. int i;
  405. for (i = 0; i < wpriv->no_of_channels; i++)
  406. if (wpriv->ch && wpriv->ch[i])
  407. wdsp_glink_close_ch(wpriv->ch[i]);
  408. }
  409. /*
  410. * wdsp_glink_open_all_ch - Internal function to open all glink channels
  411. * wpriv: Wdsp_glink private structure
  412. */
  413. static int wdsp_glink_open_all_ch(struct wdsp_glink_priv *wpriv)
  414. {
  415. int ret = 0, i, j;
  416. for (i = 0; i < wpriv->no_of_channels; i++) {
  417. if (wpriv->ch && wpriv->ch[i]) {
  418. ret = wdsp_glink_open_ch(wpriv->ch[i]);
  419. if (ret < 0)
  420. goto err_open;
  421. }
  422. }
  423. goto done;
  424. err_open:
  425. for (j = 0; j < i; j++)
  426. if (wpriv->ch[i])
  427. wdsp_glink_close_ch(wpriv->ch[j]);
  428. done:
  429. return ret;
  430. }
  431. /*
  432. * wdsp_glink_ch_open_wq - Work function to open glink channels
  433. * work: Work structure
  434. */
  435. static void wdsp_glink_ch_open_cls_wrk(struct work_struct *work)
  436. {
  437. struct wdsp_glink_priv *wpriv;
  438. wpriv = container_of(work, struct wdsp_glink_priv,
  439. ch_open_cls_wrk);
  440. if (wpriv->glink_state.link_state == GLINK_LINK_STATE_DOWN) {
  441. dev_info(wpriv->dev, "%s: GLINK_LINK_STATE_DOWN\n",
  442. __func__);
  443. wdsp_glink_close_all_ch(wpriv);
  444. } else if (wpriv->glink_state.link_state == GLINK_LINK_STATE_UP) {
  445. dev_info(wpriv->dev, "%s: GLINK_LINK_STATE_UP\n",
  446. __func__);
  447. wdsp_glink_open_all_ch(wpriv);
  448. }
  449. }
  450. /*
  451. * wdsp_glink_link_state_cb - Glink link state callback to inform
  452. * about link states
  453. * cb_info: Glink link state callback information structure
  454. * priv: Private structure of link state passed while register
  455. */
  456. static void wdsp_glink_link_state_cb(struct glink_link_state_cb_info *cb_info,
  457. void *priv)
  458. {
  459. struct wdsp_glink_priv *wpriv;
  460. if (!cb_info || !priv) {
  461. pr_err("%s: Invalid parameters\n", __func__);
  462. return;
  463. }
  464. wpriv = (struct wdsp_glink_priv *)priv;
  465. mutex_lock(&wpriv->glink_mutex);
  466. wpriv->glink_state.link_state = cb_info->link_state;
  467. wake_up(&wpriv->link_state_wait);
  468. mutex_unlock(&wpriv->glink_mutex);
  469. queue_work(wpriv->work_queue, &wpriv->ch_open_cls_wrk);
  470. }
  471. /*
  472. * wdsp_glink_ch_info_init- Internal function to allocate channel memory
  473. * and register with glink
  474. * wpriv: Wdsp_glink private structure.
  475. * pkt: Glink registration packet contains glink channel information.
  476. * pkt_size: Size of the pkt.
  477. */
  478. static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
  479. struct wdsp_reg_pkt *pkt, size_t pkt_size)
  480. {
  481. int ret = 0, i, j;
  482. struct glink_link_info link_info;
  483. struct wdsp_glink_ch_cfg *ch_cfg;
  484. struct wdsp_glink_ch **ch;
  485. u8 no_of_channels;
  486. u8 *payload;
  487. u32 ch_size, ch_cfg_size;
  488. size_t size = WDSP_WRITE_PKT_SIZE + WDSP_REG_PKT_SIZE;
  489. mutex_lock(&wpriv->glink_mutex);
  490. if (wpriv->ch) {
  491. dev_err_ratelimited(wpriv->dev, "%s: glink ch memory is already allocated\n",
  492. __func__);
  493. ret = -EINVAL;
  494. goto done;
  495. }
  496. payload = (u8 *)pkt->payload;
  497. no_of_channels = pkt->no_of_channels;
  498. if (no_of_channels > WDSP_MAX_NO_OF_CHANNELS) {
  499. dev_err_ratelimited(wpriv->dev, "%s: no_of_channels: %d but max allowed are %d\n",
  500. __func__, no_of_channels, WDSP_MAX_NO_OF_CHANNELS);
  501. ret = -EINVAL;
  502. goto done;
  503. }
  504. ch = kcalloc(no_of_channels, sizeof(struct wdsp_glink_ch *),
  505. GFP_ATOMIC);
  506. if (!ch) {
  507. ret = -ENOMEM;
  508. goto done;
  509. }
  510. wpriv->ch = ch;
  511. wpriv->no_of_channels = no_of_channels;
  512. for (i = 0; i < no_of_channels; i++) {
  513. ch_cfg = (struct wdsp_glink_ch_cfg *)payload;
  514. size += WDSP_CH_CFG_SIZE;
  515. if (size > pkt_size) {
  516. dev_err_ratelimited(wpriv->dev, "%s: Invalid size = %zd, pkt_size = %zd\n",
  517. __func__, size, pkt_size);
  518. ret = -EINVAL;
  519. goto err_ch_mem;
  520. }
  521. if (ch_cfg->no_of_intents > WDSP_MAX_NO_OF_INTENTS) {
  522. dev_err_ratelimited(wpriv->dev, "%s: Invalid no_of_intents = %d\n",
  523. __func__, ch_cfg->no_of_intents);
  524. ret = -EINVAL;
  525. goto err_ch_mem;
  526. }
  527. size += (sizeof(u32) * ch_cfg->no_of_intents);
  528. if (size > pkt_size) {
  529. dev_err_ratelimited(wpriv->dev, "%s: Invalid size = %zd, pkt_size = %zd\n",
  530. __func__, size, pkt_size);
  531. ret = -EINVAL;
  532. goto err_ch_mem;
  533. }
  534. ch_cfg_size = sizeof(struct wdsp_glink_ch_cfg) +
  535. (sizeof(u32) * ch_cfg->no_of_intents);
  536. ch_size = sizeof(struct wdsp_glink_ch) +
  537. (sizeof(u32) * ch_cfg->no_of_intents);
  538. dev_dbg(wpriv->dev, "%s: channels: %d ch_cfg_size: %d, size: %zd, pkt_size: %zd",
  539. __func__, no_of_channels, ch_cfg_size, size, pkt_size);
  540. ch[i] = kzalloc(ch_size, GFP_KERNEL);
  541. if (!ch[i]) {
  542. ret = -ENOMEM;
  543. goto err_ch_mem;
  544. }
  545. ch[i]->channel_state = GLINK_LOCAL_DISCONNECTED;
  546. memcpy(&ch[i]->ch_cfg, payload, ch_cfg_size);
  547. payload += ch_cfg_size;
  548. mutex_init(&ch[i]->mutex);
  549. ch[i]->wpriv = wpriv;
  550. INIT_WORK(&ch[i]->lcl_ch_open_wrk, wdsp_glink_lcl_ch_open_wrk);
  551. INIT_WORK(&ch[i]->lcl_ch_cls_wrk, wdsp_glink_lcl_ch_cls_wrk);
  552. init_waitqueue_head(&ch[i]->ch_connect_wait);
  553. }
  554. INIT_WORK(&wpriv->ch_open_cls_wrk, wdsp_glink_ch_open_cls_wrk);
  555. /* Register glink link_state notification */
  556. link_info.glink_link_state_notif_cb = wdsp_glink_link_state_cb;
  557. link_info.transport = NULL;
  558. link_info.edge = WDSP_EDGE;
  559. wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
  560. wpriv->glink_state.handle = glink_register_link_state_cb(&link_info,
  561. wpriv);
  562. if (!wpriv->glink_state.handle) {
  563. dev_err(wpriv->dev, "%s: Unable to register wdsp link state\n",
  564. __func__);
  565. ret = -EINVAL;
  566. goto err_ch_mem;
  567. }
  568. goto done;
  569. err_ch_mem:
  570. for (j = 0; j < i; j++) {
  571. mutex_destroy(&ch[j]->mutex);
  572. kfree(wpriv->ch[j]);
  573. wpriv->ch[j] = NULL;
  574. }
  575. kfree(wpriv->ch);
  576. wpriv->ch = NULL;
  577. wpriv->no_of_channels = 0;
  578. done:
  579. mutex_unlock(&wpriv->glink_mutex);
  580. return ret;
  581. }
  582. /*
  583. * wdsp_glink_tx_buf_work - Work queue function to send tx buffer to glink
  584. * work: Work structure
  585. */
  586. static void wdsp_glink_tx_buf_work(struct work_struct *work)
  587. {
  588. struct wdsp_glink_priv *wpriv;
  589. struct wdsp_glink_ch *ch;
  590. struct wdsp_glink_tx_buf *tx_buf;
  591. struct wdsp_write_pkt *wpkt;
  592. struct wdsp_cmd_pkt *cpkt;
  593. int ret = 0;
  594. tx_buf = container_of(work, struct wdsp_glink_tx_buf,
  595. tx_work);
  596. ch = tx_buf->ch;
  597. wpriv = ch->wpriv;
  598. wpkt = (struct wdsp_write_pkt *)tx_buf->buf;
  599. cpkt = (struct wdsp_cmd_pkt *)wpkt->payload;
  600. dev_dbg(wpriv->dev, "%s: ch name = %s, payload size = %d\n",
  601. __func__, cpkt->ch_name, cpkt->payload_size);
  602. mutex_lock(&tx_buf->ch->mutex);
  603. if (ch->channel_state == GLINK_CONNECTED) {
  604. mutex_unlock(&tx_buf->ch->mutex);
  605. ret = glink_tx(ch->handle, tx_buf,
  606. cpkt->payload, cpkt->payload_size,
  607. GLINK_TX_REQ_INTENT);
  608. if (ret < 0) {
  609. dev_err(wpriv->dev, "%s: glink tx failed, ret = %d\n",
  610. __func__, ret);
  611. /*
  612. * If glink_tx() is failed then free tx_buf here as
  613. * there won't be any tx_done notification to
  614. * free the buffer.
  615. */
  616. vfree(tx_buf);
  617. }
  618. } else {
  619. mutex_unlock(&tx_buf->ch->mutex);
  620. dev_err(wpriv->dev, "%s: channel %s is not in connected state\n",
  621. __func__, ch->ch_cfg.name);
  622. /*
  623. * Free tx_buf here as there won't be any tx_done
  624. * notification in this case also.
  625. */
  626. vfree(tx_buf);
  627. }
  628. }
  629. /*
  630. * wdsp_glink_read - Read API to send the data to userspace
  631. * file: Pointer to the file structure
  632. * buf: Pointer to the userspace buffer
  633. * count: Number bytes to read from the file
  634. * ppos: Pointer to the position into the file
  635. */
  636. static ssize_t wdsp_glink_read(struct file *file, char __user *buf,
  637. size_t count, loff_t *ppos)
  638. {
  639. int ret = 0, ret1 = 0;
  640. struct wdsp_glink_rsp_que *rsp;
  641. struct wdsp_glink_priv *wpriv;
  642. wpriv = (struct wdsp_glink_priv *)file->private_data;
  643. if (!wpriv) {
  644. pr_err("%s: Invalid private data\n", __func__);
  645. ret = -EINVAL;
  646. goto done;
  647. }
  648. if (count > WDSP_MAX_READ_SIZE) {
  649. dev_info_ratelimited(wpriv->dev, "%s: count = %zd is more than WDSP_MAX_READ_SIZE\n",
  650. __func__, count);
  651. count = WDSP_MAX_READ_SIZE;
  652. }
  653. /*
  654. * Complete signal has given from glink rx notification callback
  655. * or from flush API. Also use interruptible wait_for_completion API
  656. * to allow the system to go in suspend.
  657. */
  658. ret = wait_for_completion_interruptible(&wpriv->rsp_complete);
  659. if (ret)
  660. goto done;
  661. mutex_lock(&wpriv->rsp_mutex);
  662. if (wpriv->rsp_cnt) {
  663. wpriv->rsp_cnt--;
  664. dev_dbg(wpriv->dev, "%s: read from buffer %d\n",
  665. __func__, wpriv->rsp_cnt);
  666. rsp = &wpriv->rsp[wpriv->rsp_cnt];
  667. if (count < rsp->buf_size) {
  668. ret1 = copy_to_user(buf, &rsp->buf, count);
  669. /* Return the number of bytes copied */
  670. ret = count;
  671. } else {
  672. ret1 = copy_to_user(buf, &rsp->buf, rsp->buf_size);
  673. /* Return the number of bytes copied */
  674. ret = rsp->buf_size;
  675. }
  676. if (ret1) {
  677. mutex_unlock(&wpriv->rsp_mutex);
  678. dev_err_ratelimited(wpriv->dev, "%s: copy_to_user failed %d\n",
  679. __func__, ret);
  680. ret = -EFAULT;
  681. goto done;
  682. }
  683. } else {
  684. /*
  685. * This will execute only if flush API is called or
  686. * something wrong with ref_cnt
  687. */
  688. dev_dbg(wpriv->dev, "%s: resp count = %d\n", __func__,
  689. wpriv->rsp_cnt);
  690. ret = -EINVAL;
  691. }
  692. mutex_unlock(&wpriv->rsp_mutex);
  693. done:
  694. return ret;
  695. }
  696. /*
  697. * wdsp_glink_write - Write API to receive the data from userspace
  698. * file: Pointer to the file structure
  699. * buf: Pointer to the userspace buffer
  700. * count: Number bytes to read from the file
  701. * ppos: Pointer to the position into the file
  702. */
  703. static ssize_t wdsp_glink_write(struct file *file, const char __user *buf,
  704. size_t count, loff_t *ppos)
  705. {
  706. int ret = 0, i, tx_buf_size;
  707. struct wdsp_write_pkt *wpkt;
  708. struct wdsp_cmd_pkt *cpkt;
  709. struct wdsp_glink_tx_buf *tx_buf;
  710. struct wdsp_glink_priv *wpriv;
  711. size_t pkt_max_size;
  712. wpriv = (struct wdsp_glink_priv *)file->private_data;
  713. if (!wpriv) {
  714. pr_err("%s: Invalid private data\n", __func__);
  715. ret = -EINVAL;
  716. goto done;
  717. }
  718. if ((count < WDSP_WRITE_PKT_SIZE) ||
  719. (count > WDSP_MAX_WRITE_SIZE)) {
  720. dev_err_ratelimited(wpriv->dev, "%s: Invalid count = %zd\n",
  721. __func__, count);
  722. ret = -EINVAL;
  723. goto done;
  724. }
  725. dev_dbg(wpriv->dev, "%s: count = %zd\n", __func__, count);
  726. tx_buf_size = count + sizeof(struct wdsp_glink_tx_buf);
  727. tx_buf = vzalloc(tx_buf_size);
  728. if (!tx_buf) {
  729. ret = -ENOMEM;
  730. goto done;
  731. }
  732. ret = copy_from_user(tx_buf->buf, buf, count);
  733. if (ret) {
  734. dev_err_ratelimited(wpriv->dev, "%s: copy_from_user failed %d\n",
  735. __func__, ret);
  736. ret = -EFAULT;
  737. goto free_buf;
  738. }
  739. wpkt = (struct wdsp_write_pkt *)tx_buf->buf;
  740. switch (wpkt->pkt_type) {
  741. case WDSP_REG_PKT:
  742. if (count < (WDSP_WRITE_PKT_SIZE + WDSP_REG_PKT_SIZE +
  743. WDSP_CH_CFG_SIZE)) {
  744. dev_err_ratelimited(wpriv->dev, "%s: Invalid reg pkt size = %zd\n",
  745. __func__, count);
  746. ret = -EINVAL;
  747. goto free_buf;
  748. }
  749. ret = wdsp_glink_ch_info_init(wpriv,
  750. (struct wdsp_reg_pkt *)wpkt->payload,
  751. count);
  752. if (ret < 0)
  753. dev_err_ratelimited(wpriv->dev, "%s: glink register failed, ret = %d\n",
  754. __func__, ret);
  755. vfree(tx_buf);
  756. break;
  757. case WDSP_READY_PKT:
  758. ret = wait_event_timeout(wpriv->link_state_wait,
  759. (wpriv->glink_state.link_state ==
  760. GLINK_LINK_STATE_UP),
  761. msecs_to_jiffies(TIMEOUT_MS));
  762. if (!ret) {
  763. dev_err_ratelimited(wpriv->dev, "%s: Link state wait timeout\n",
  764. __func__);
  765. ret = -ETIMEDOUT;
  766. goto free_buf;
  767. }
  768. ret = 0;
  769. vfree(tx_buf);
  770. break;
  771. case WDSP_CMD_PKT:
  772. if (count <= (WDSP_WRITE_PKT_SIZE + WDSP_CMD_PKT_SIZE)) {
  773. dev_err_ratelimited(wpriv->dev, "%s: Invalid cmd pkt size = %zd\n",
  774. __func__, count);
  775. ret = -EINVAL;
  776. goto free_buf;
  777. }
  778. mutex_lock(&wpriv->glink_mutex);
  779. if (wpriv->glink_state.link_state == GLINK_LINK_STATE_DOWN) {
  780. mutex_unlock(&wpriv->glink_mutex);
  781. dev_err_ratelimited(wpriv->dev, "%s: Link state is Down\n",
  782. __func__);
  783. ret = -ENETRESET;
  784. goto free_buf;
  785. }
  786. mutex_unlock(&wpriv->glink_mutex);
  787. cpkt = (struct wdsp_cmd_pkt *)wpkt->payload;
  788. pkt_max_size = sizeof(struct wdsp_write_pkt) +
  789. sizeof(struct wdsp_cmd_pkt) +
  790. cpkt->payload_size;
  791. if (count < pkt_max_size) {
  792. dev_err_ratelimited(wpriv->dev, "%s: Invalid cmd pkt count = %zd, pkt_size = %zd\n",
  793. __func__, count, pkt_max_size);
  794. ret = -EINVAL;
  795. goto free_buf;
  796. }
  797. dev_dbg(wpriv->dev, "%s: requested ch_name: %s, pkt_size: %zd\n",
  798. __func__, cpkt->ch_name, pkt_max_size);
  799. for (i = 0; i < wpriv->no_of_channels; i++) {
  800. if (wpriv->ch && wpriv->ch[i] &&
  801. (!strcmp(cpkt->ch_name,
  802. wpriv->ch[i]->ch_cfg.name))) {
  803. tx_buf->ch = wpriv->ch[i];
  804. break;
  805. }
  806. }
  807. if (!tx_buf->ch) {
  808. dev_err_ratelimited(wpriv->dev, "%s: Failed to get glink channel\n",
  809. __func__);
  810. ret = -EINVAL;
  811. goto free_buf;
  812. }
  813. ret = wait_event_timeout(tx_buf->ch->ch_connect_wait,
  814. (tx_buf->ch->channel_state ==
  815. GLINK_CONNECTED),
  816. msecs_to_jiffies(TIMEOUT_MS));
  817. if (!ret) {
  818. dev_err_ratelimited(wpriv->dev, "%s: glink channel %s is not in connected state %d\n",
  819. __func__, tx_buf->ch->ch_cfg.name,
  820. tx_buf->ch->channel_state);
  821. ret = -ETIMEDOUT;
  822. goto free_buf;
  823. }
  824. ret = 0;
  825. INIT_WORK(&tx_buf->tx_work, wdsp_glink_tx_buf_work);
  826. queue_work(wpriv->work_queue, &tx_buf->tx_work);
  827. break;
  828. default:
  829. dev_err_ratelimited(wpriv->dev, "%s: Invalid packet type\n",
  830. __func__);
  831. ret = -EINVAL;
  832. vfree(tx_buf);
  833. break;
  834. }
  835. goto done;
  836. free_buf:
  837. vfree(tx_buf);
  838. done:
  839. return ret;
  840. }
  841. /*
  842. * wdsp_glink_open - Open API to initialize private data
  843. * inode: Pointer to the inode structure
  844. * file: Pointer to the file structure
  845. */
  846. static int wdsp_glink_open(struct inode *inode, struct file *file)
  847. {
  848. int ret = 0;
  849. struct wdsp_glink_priv *wpriv;
  850. struct wdsp_glink_dev *wdev;
  851. if (!inode->i_cdev) {
  852. pr_err("%s: cdev is NULL\n", __func__);
  853. ret = -EINVAL;
  854. goto done;
  855. }
  856. wdev = container_of(inode->i_cdev, struct wdsp_glink_dev, cdev);
  857. wpriv = kzalloc(sizeof(struct wdsp_glink_priv), GFP_KERNEL);
  858. if (!wpriv) {
  859. ret = -ENOMEM;
  860. goto done;
  861. }
  862. wpriv->dev = wdev->dev;
  863. wpriv->work_queue = create_singlethread_workqueue("wdsp_glink_wq");
  864. if (!wpriv->work_queue) {
  865. dev_err(wpriv->dev, "%s: Error creating wdsp_glink_wq\n",
  866. __func__);
  867. ret = -EINVAL;
  868. goto err_wq;
  869. }
  870. wpriv->glink_state.link_state = GLINK_LINK_STATE_DOWN;
  871. init_completion(&wpriv->rsp_complete);
  872. init_waitqueue_head(&wpriv->link_state_wait);
  873. mutex_init(&wpriv->rsp_mutex);
  874. mutex_init(&wpriv->glink_mutex);
  875. file->private_data = wpriv;
  876. goto done;
  877. err_wq:
  878. kfree(wpriv);
  879. done:
  880. return ret;
  881. }
  882. /*
  883. * wdsp_glink_flush - Flush API to unblock read.
  884. * file: Pointer to the file structure
  885. * id: Lock owner ID
  886. */
  887. static int wdsp_glink_flush(struct file *file, fl_owner_t id)
  888. {
  889. struct wdsp_glink_priv *wpriv;
  890. wpriv = (struct wdsp_glink_priv *)file->private_data;
  891. if (!wpriv) {
  892. pr_err("%s: Invalid private data\n", __func__);
  893. return -EINVAL;
  894. }
  895. complete(&wpriv->rsp_complete);
  896. return 0;
  897. }
  898. /*
  899. * wdsp_glink_release - Release API to clean up resources.
  900. * Whenever a file structure is shared across multiple threads,
  901. * release won't be invoked until all copies are closed
  902. * (file->f_count.counter should be 0). If we need to flush pending
  903. * data when any copy is closed, you should implement the flush method.
  904. *
  905. * inode: Pointer to the inode structure
  906. * file: Pointer to the file structure
  907. */
  908. static int wdsp_glink_release(struct inode *inode, struct file *file)
  909. {
  910. int i, ret = 0;
  911. struct wdsp_glink_priv *wpriv;
  912. wpriv = (struct wdsp_glink_priv *)file->private_data;
  913. if (!wpriv) {
  914. pr_err("%s: Invalid private data\n", __func__);
  915. ret = -EINVAL;
  916. goto done;
  917. }
  918. if (wpriv->glink_state.handle)
  919. glink_unregister_link_state_cb(wpriv->glink_state.handle);
  920. flush_workqueue(wpriv->work_queue);
  921. destroy_workqueue(wpriv->work_queue);
  922. /*
  923. * Clean up glink channel memory in channel state
  924. * callback only if close channels are called from here.
  925. */
  926. if (wpriv->ch) {
  927. for (i = 0; i < wpriv->no_of_channels; i++) {
  928. if (wpriv->ch[i]) {
  929. wpriv->ch[i]->free_mem = true;
  930. /*
  931. * Channel handle NULL means channel is already
  932. * closed. Free the channel memory here itself.
  933. */
  934. if (!wpriv->ch[i]->handle) {
  935. kfree(wpriv->ch[i]);
  936. wpriv->ch[i] = NULL;
  937. } else {
  938. wdsp_glink_close_ch(wpriv->ch[i]);
  939. }
  940. }
  941. }
  942. kfree(wpriv->ch);
  943. wpriv->ch = NULL;
  944. }
  945. mutex_destroy(&wpriv->glink_mutex);
  946. mutex_destroy(&wpriv->rsp_mutex);
  947. kfree(wpriv);
  948. file->private_data = NULL;
  949. done:
  950. return ret;
  951. }
  952. static const struct file_operations wdsp_glink_fops = {
  953. .owner = THIS_MODULE,
  954. .open = wdsp_glink_open,
  955. .read = wdsp_glink_read,
  956. .write = wdsp_glink_write,
  957. .flush = wdsp_glink_flush,
  958. .release = wdsp_glink_release,
  959. };
  960. /*
  961. * wdsp_glink_probe - Driver probe to expose char device
  962. * pdev: Pointer to device tree data.
  963. */
  964. static int wdsp_glink_probe(struct platform_device *pdev)
  965. {
  966. int ret;
  967. struct wdsp_glink_dev *wdev;
  968. wdev = devm_kzalloc(&pdev->dev, sizeof(*wdev), GFP_KERNEL);
  969. if (!wdev) {
  970. ret = -ENOMEM;
  971. goto done;
  972. }
  973. ret = alloc_chrdev_region(&wdev->dev_num, 0, MINOR_NUMBER_COUNT,
  974. WDSP_GLINK_DRIVER_NAME);
  975. if (ret < 0) {
  976. dev_err(&pdev->dev, "%s: Failed to alloc char dev, err = %d\n",
  977. __func__, ret);
  978. goto err_chrdev;
  979. }
  980. wdev->cls = class_create(THIS_MODULE, WDSP_GLINK_DRIVER_NAME);
  981. if (IS_ERR(wdev->cls)) {
  982. ret = PTR_ERR(wdev->cls);
  983. dev_err(&pdev->dev, "%s: Failed to create class, err = %d\n",
  984. __func__, ret);
  985. goto err_class;
  986. }
  987. wdev->dev = device_create(wdev->cls, NULL, wdev->dev_num,
  988. NULL, WDSP_GLINK_DRIVER_NAME);
  989. if (IS_ERR(wdev->dev)) {
  990. ret = PTR_ERR(wdev->dev);
  991. dev_err(&pdev->dev, "%s: Failed to create device, err = %d\n",
  992. __func__, ret);
  993. goto err_dev_create;
  994. }
  995. cdev_init(&wdev->cdev, &wdsp_glink_fops);
  996. ret = cdev_add(&wdev->cdev, wdev->dev_num, MINOR_NUMBER_COUNT);
  997. if (ret < 0) {
  998. dev_err(&pdev->dev, "%s: Failed to register char dev, err = %d\n",
  999. __func__, ret);
  1000. goto err_cdev_add;
  1001. }
  1002. platform_set_drvdata(pdev, wdev);
  1003. goto done;
  1004. err_cdev_add:
  1005. device_destroy(wdev->cls, wdev->dev_num);
  1006. err_dev_create:
  1007. class_destroy(wdev->cls);
  1008. err_class:
  1009. unregister_chrdev_region(0, MINOR_NUMBER_COUNT);
  1010. err_chrdev:
  1011. devm_kfree(&pdev->dev, wdev);
  1012. done:
  1013. return ret;
  1014. }
  1015. /*
  1016. * wdsp_glink_remove - Driver remove to handle cleanup
  1017. * pdev: Pointer to device tree data.
  1018. */
  1019. static int wdsp_glink_remove(struct platform_device *pdev)
  1020. {
  1021. struct wdsp_glink_dev *wdev = platform_get_drvdata(pdev);
  1022. if (wdev) {
  1023. cdev_del(&wdev->cdev);
  1024. device_destroy(wdev->cls, wdev->dev_num);
  1025. class_destroy(wdev->cls);
  1026. unregister_chrdev_region(0, MINOR_NUMBER_COUNT);
  1027. devm_kfree(&pdev->dev, wdev);
  1028. } else {
  1029. dev_err(&pdev->dev, "%s: Invalid device data\n", __func__);
  1030. }
  1031. return 0;
  1032. }
  1033. static const struct of_device_id wdsp_glink_of_match[] = {
  1034. {.compatible = "qcom,wcd-dsp-glink"},
  1035. { }
  1036. };
  1037. MODULE_DEVICE_TABLE(of, wdsp_glink_of_match);
  1038. static struct platform_driver wdsp_glink_driver = {
  1039. .probe = wdsp_glink_probe,
  1040. .remove = wdsp_glink_remove,
  1041. .driver = {
  1042. .name = WDSP_GLINK_DRIVER_NAME,
  1043. .owner = THIS_MODULE,
  1044. .of_match_table = wdsp_glink_of_match,
  1045. },
  1046. };
  1047. module_platform_driver(wdsp_glink_driver);
  1048. MODULE_DESCRIPTION("SoC WCD_DSP GLINK Driver");
  1049. MODULE_LICENSE("GPL v2");