wcd9xxx-slimslave.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /* Copyright (c) 2012-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/slab.h>
  13. #include <linux/mutex.h>
  14. #include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
  15. #include <linux/mfd/wcd9xxx/wcd9xxx_registers.h>
  16. struct wcd9xxx_slim_sch {
  17. u16 rx_port_ch_reg_base;
  18. u16 port_tx_cfg_reg_base;
  19. u16 port_rx_cfg_reg_base;
  20. };
  21. static struct wcd9xxx_slim_sch sh_ch;
  22. static int wcd9xxx_alloc_slim_sh_ch(struct wcd9xxx *wcd9xxx,
  23. u8 wcd9xxx_pgd_la, u32 cnt,
  24. struct wcd9xxx_ch *channels, u32 path);
  25. static int wcd9xxx_dealloc_slim_sh_ch(struct slim_device *slim,
  26. u32 cnt, struct wcd9xxx_ch *channels);
  27. static int wcd9xxx_configure_ports(struct wcd9xxx *wcd9xxx)
  28. {
  29. if (wcd9xxx->codec_type->slim_slave_type ==
  30. WCD9XXX_SLIM_SLAVE_ADDR_TYPE_TABLA) {
  31. sh_ch.rx_port_ch_reg_base = 0x180;
  32. sh_ch.port_rx_cfg_reg_base = 0x040;
  33. sh_ch.port_tx_cfg_reg_base = 0x040;
  34. } else {
  35. sh_ch.rx_port_ch_reg_base =
  36. 0x180 - (TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS * 4);
  37. sh_ch.port_rx_cfg_reg_base =
  38. 0x040 - TAIKO_SB_PGD_OFFSET_OF_RX_SLAVE_DEV_PORTS;
  39. sh_ch.port_tx_cfg_reg_base = 0x050;
  40. }
  41. return 0;
  42. }
  43. int wcd9xxx_init_slimslave(struct wcd9xxx *wcd9xxx, u8 wcd9xxx_pgd_la,
  44. unsigned int tx_num, unsigned int *tx_slot,
  45. unsigned int rx_num, unsigned int *rx_slot)
  46. {
  47. int ret = 0;
  48. int i;
  49. ret = wcd9xxx_configure_ports(wcd9xxx);
  50. if (ret) {
  51. pr_err("%s: Failed to configure register address offset\n",
  52. __func__);
  53. goto err;
  54. }
  55. if (!rx_num || rx_num > wcd9xxx->num_rx_port) {
  56. pr_err("%s: invalid rx num %d\n", __func__, rx_num);
  57. return -EINVAL;
  58. }
  59. if (wcd9xxx->rx_chs) {
  60. wcd9xxx->num_rx_port = rx_num;
  61. for (i = 0; i < rx_num; i++) {
  62. wcd9xxx->rx_chs[i].ch_num = rx_slot[i];
  63. INIT_LIST_HEAD(&wcd9xxx->rx_chs[i].list);
  64. }
  65. ret = wcd9xxx_alloc_slim_sh_ch(wcd9xxx, wcd9xxx_pgd_la,
  66. wcd9xxx->num_rx_port,
  67. wcd9xxx->rx_chs,
  68. SLIM_SINK);
  69. if (ret) {
  70. pr_err("%s: Failed to alloc %d rx slimbus channels\n",
  71. __func__, wcd9xxx->num_rx_port);
  72. kfree(wcd9xxx->rx_chs);
  73. wcd9xxx->rx_chs = NULL;
  74. wcd9xxx->num_rx_port = 0;
  75. }
  76. } else {
  77. pr_err("Not able to allocate memory for %d slimbus rx ports\n",
  78. wcd9xxx->num_rx_port);
  79. }
  80. if (!tx_num || tx_num > wcd9xxx->num_tx_port) {
  81. pr_err("%s: invalid tx num %d\n", __func__, tx_num);
  82. return -EINVAL;
  83. }
  84. if (wcd9xxx->tx_chs) {
  85. wcd9xxx->num_tx_port = tx_num;
  86. for (i = 0; i < tx_num; i++) {
  87. wcd9xxx->tx_chs[i].ch_num = tx_slot[i];
  88. INIT_LIST_HEAD(&wcd9xxx->tx_chs[i].list);
  89. }
  90. ret = wcd9xxx_alloc_slim_sh_ch(wcd9xxx, wcd9xxx_pgd_la,
  91. wcd9xxx->num_tx_port,
  92. wcd9xxx->tx_chs,
  93. SLIM_SRC);
  94. if (ret) {
  95. pr_err("%s: Failed to alloc %d tx slimbus channels\n",
  96. __func__, wcd9xxx->num_tx_port);
  97. kfree(wcd9xxx->tx_chs);
  98. wcd9xxx->tx_chs = NULL;
  99. wcd9xxx->num_tx_port = 0;
  100. }
  101. } else {
  102. pr_err("Not able to allocate memory for %d slimbus tx ports\n",
  103. wcd9xxx->num_tx_port);
  104. }
  105. return 0;
  106. err:
  107. return ret;
  108. }
  109. int wcd9xxx_deinit_slimslave(struct wcd9xxx *wcd9xxx)
  110. {
  111. if (wcd9xxx->num_rx_port) {
  112. wcd9xxx_dealloc_slim_sh_ch(wcd9xxx->slim,
  113. wcd9xxx->num_rx_port,
  114. wcd9xxx->rx_chs);
  115. wcd9xxx->num_rx_port = 0;
  116. }
  117. if (wcd9xxx->num_tx_port) {
  118. wcd9xxx_dealloc_slim_sh_ch(wcd9xxx->slim,
  119. wcd9xxx->num_tx_port,
  120. wcd9xxx->tx_chs);
  121. wcd9xxx->num_tx_port = 0;
  122. }
  123. return 0;
  124. }
  125. static int wcd9xxx_alloc_slim_sh_ch(struct wcd9xxx *wcd9xxx,
  126. u8 wcd9xxx_pgd_la, u32 cnt,
  127. struct wcd9xxx_ch *channels, u32 path)
  128. {
  129. int ret = 0;
  130. u32 ch_idx ;
  131. /* The slimbus channel allocation seem take longer time
  132. * so do the allocation up front to avoid delay in start of
  133. * playback
  134. */
  135. pr_debug("%s: pgd_la[%d]\n", __func__, wcd9xxx_pgd_la);
  136. for (ch_idx = 0; ch_idx < cnt; ch_idx++) {
  137. ret = slim_get_slaveport(wcd9xxx_pgd_la,
  138. channels[ch_idx].port,
  139. &channels[ch_idx].sph, path);
  140. pr_debug("%s: pgd_la[%d] channels[%d].port[%d]\n"
  141. "channels[%d].sph[%d] path[%d]\n",
  142. __func__, wcd9xxx_pgd_la, ch_idx,
  143. channels[ch_idx].port,
  144. ch_idx, channels[ch_idx].sph, path);
  145. if (ret < 0) {
  146. pr_err("%s: slave port failure id[%d] ret[%d]\n",
  147. __func__, channels[ch_idx].ch_num, ret);
  148. goto err;
  149. }
  150. ret = slim_query_ch(wcd9xxx->slim,
  151. channels[ch_idx].ch_num,
  152. &channels[ch_idx].ch_h);
  153. if (ret < 0) {
  154. pr_err("%s: slim_query_ch failed ch-num[%d] ret[%d]\n",
  155. __func__, channels[ch_idx].ch_num, ret);
  156. goto err;
  157. }
  158. }
  159. err:
  160. return ret;
  161. }
  162. static int wcd9xxx_dealloc_slim_sh_ch(struct slim_device *slim,
  163. u32 cnt, struct wcd9xxx_ch *channels)
  164. {
  165. int idx = 0;
  166. int ret = 0;
  167. /* slim_dealloc_ch */
  168. for (idx = 0; idx < cnt; idx++) {
  169. ret = slim_dealloc_ch(slim, channels[idx].ch_h);
  170. if (ret < 0) {
  171. pr_err("%s: slim_dealloc_ch fail ret[%d] ch_h[%d]\n",
  172. __func__, ret, channels[idx].ch_h);
  173. }
  174. }
  175. return ret;
  176. }
  177. /* Enable slimbus slave device for RX path */
  178. int wcd9xxx_cfg_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  179. struct list_head *wcd9xxx_ch_list,
  180. unsigned int rate, unsigned int bit_width,
  181. u16 *grph)
  182. {
  183. u8 ch_cnt = 0;
  184. u16 ch_h[SLIM_MAX_RX_PORTS] = {0};
  185. u8 payload = 0;
  186. u16 codec_port = 0;
  187. int ret;
  188. struct slim_ch prop;
  189. struct wcd9xxx_ch *rx;
  190. /* Configure slave interface device */
  191. list_for_each_entry(rx, wcd9xxx_ch_list, list) {
  192. payload |= 1 << rx->shift;
  193. ch_h[ch_cnt] = rx->ch_h;
  194. ch_cnt++;
  195. pr_debug("list ch->ch_h %d ch->sph %d\n", rx->ch_h, rx->sph);
  196. }
  197. pr_debug("%s: ch_cnt[%d] rate=%d WATER_MARK_VAL %d\n",
  198. __func__, ch_cnt, rate, WATER_MARK_VAL);
  199. /* slim_define_ch api */
  200. prop.prot = SLIM_AUTO_ISO;
  201. prop.baser = SLIM_RATE_4000HZ;
  202. prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
  203. prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
  204. prop.ratem = (rate/4000);
  205. prop.sampleszbits = bit_width;
  206. pr_info("Before slim_define_ch:\n"
  207. "ch_cnt %d,ch_h[0] %d ch_h[1] %d, grph %d sampleszbits %d \n",
  208. ch_cnt, ch_h[0], ch_h[1], *grph, bit_width);
  209. ret = slim_define_ch(wcd9xxx->slim, &prop, ch_h, ch_cnt,
  210. true, grph);
  211. if (ret < 0) {
  212. pr_err("%s: slim_define_ch failed ret[%d]\n",
  213. __func__, ret);
  214. goto err;
  215. }
  216. list_for_each_entry(rx, wcd9xxx_ch_list, list) {
  217. codec_port = rx->port;
  218. pr_debug("%s: codec_port %d rx 0x%x, payload %d\n"
  219. "sh_ch.rx_port_ch_reg_base0 0x%x\n"
  220. "sh_ch.port_rx_cfg_reg_base 0x%x\n",
  221. __func__, codec_port, (u32)rx, payload,
  222. sh_ch.rx_port_ch_reg_base,
  223. sh_ch.port_rx_cfg_reg_base);
  224. /* look for the valid port range and chose the
  225. * payload accordingly
  226. */
  227. /* write to interface device */
  228. ret = wcd9xxx_interface_reg_write(wcd9xxx,
  229. SB_PGD_RX_PORT_MULTI_CHANNEL_0(
  230. sh_ch.rx_port_ch_reg_base, codec_port),
  231. payload);
  232. if (ret < 0) {
  233. pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
  234. __func__,
  235. SB_PGD_RX_PORT_MULTI_CHANNEL_0(
  236. sh_ch.rx_port_ch_reg_base, codec_port),
  237. payload, ret);
  238. goto err;
  239. }
  240. /* configure the slave port for water mark and enable*/
  241. ret = wcd9xxx_interface_reg_write(wcd9xxx,
  242. SB_PGD_PORT_CFG_BYTE_ADDR(
  243. sh_ch.port_rx_cfg_reg_base, codec_port),
  244. WATER_MARK_VAL);
  245. if (ret < 0) {
  246. pr_err("%s:watermark set failure for port[%d] ret[%d]",
  247. __func__, codec_port, ret);
  248. }
  249. ret = slim_connect_sink(wcd9xxx->slim, &rx->sph, 1, rx->ch_h);
  250. if (ret < 0) {
  251. pr_err("%s: slim_connect_sink failed ret[%d]\n",
  252. __func__, ret);
  253. goto err_close_slim_sch;
  254. }
  255. }
  256. /* slim_control_ch */
  257. ret = slim_control_ch(wcd9xxx->slim, *grph, SLIM_CH_ACTIVATE,
  258. true);
  259. if (ret < 0) {
  260. pr_err("%s: slim_control_ch failed ret[%d]\n",
  261. __func__, ret);
  262. goto err_close_slim_sch;
  263. }
  264. return 0;
  265. err_close_slim_sch:
  266. /* release all acquired handles */
  267. wcd9xxx_close_slim_sch_rx(wcd9xxx, wcd9xxx_ch_list, *grph);
  268. err:
  269. return ret;
  270. }
  271. EXPORT_SYMBOL_GPL(wcd9xxx_cfg_slim_sch_rx);
  272. /* Enable slimbus slave device for RX path */
  273. int wcd9xxx_cfg_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  274. struct list_head *wcd9xxx_ch_list,
  275. unsigned int rate, unsigned int bit_width,
  276. u16 *grph)
  277. {
  278. u16 ch_cnt = 0;
  279. u16 payload = 0;
  280. u16 ch_h[SLIM_MAX_TX_PORTS] = {0};
  281. u16 codec_port;
  282. int ret = 0;
  283. struct wcd9xxx_ch *tx;
  284. struct slim_ch prop;
  285. list_for_each_entry(tx, wcd9xxx_ch_list, list) {
  286. payload |= 1 << tx->shift;
  287. ch_h[ch_cnt] = tx->ch_h;
  288. ch_cnt++;
  289. }
  290. /* slim_define_ch api */
  291. prop.prot = SLIM_AUTO_ISO;
  292. prop.baser = SLIM_RATE_4000HZ;
  293. prop.dataf = SLIM_CH_DATAF_NOT_DEFINED;
  294. prop.auxf = SLIM_CH_AUXF_NOT_APPLICABLE;
  295. prop.ratem = (rate/4000);
  296. prop.sampleszbits = 16;
  297. ret = slim_define_ch(wcd9xxx->slim, &prop, ch_h, ch_cnt,
  298. true, grph);
  299. if (ret < 0) {
  300. pr_err("%s: slim_define_ch failed ret[%d]\n",
  301. __func__, ret);
  302. goto err;
  303. }
  304. pr_debug("%s: ch_cnt[%d] rate[%d]\n", __func__, ch_cnt, rate);
  305. list_for_each_entry(tx, wcd9xxx_ch_list, list) {
  306. codec_port = tx->port;
  307. pr_debug("%s: codec_port %d rx 0x%x, payload 0x%x\n",
  308. __func__, codec_port, (u32)tx, payload);
  309. /* write to interface device */
  310. ret = wcd9xxx_interface_reg_write(wcd9xxx,
  311. SB_PGD_TX_PORT_MULTI_CHANNEL_0(codec_port),
  312. payload & 0x00FF);
  313. if (ret < 0) {
  314. pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
  315. __func__,
  316. SB_PGD_TX_PORT_MULTI_CHANNEL_0(codec_port),
  317. payload, ret);
  318. goto err;
  319. }
  320. /* ports 8,9 */
  321. ret = wcd9xxx_interface_reg_write(wcd9xxx,
  322. SB_PGD_TX_PORT_MULTI_CHANNEL_1(codec_port),
  323. (payload & 0xFF00)>>8);
  324. if (ret < 0) {
  325. pr_err("%s:Intf-dev fail reg[%d] payload[%d] ret[%d]\n",
  326. __func__,
  327. SB_PGD_TX_PORT_MULTI_CHANNEL_1(codec_port),
  328. payload, ret);
  329. goto err;
  330. }
  331. /* configure the slave port for water mark and enable*/
  332. ret = wcd9xxx_interface_reg_write(wcd9xxx,
  333. SB_PGD_PORT_CFG_BYTE_ADDR(
  334. sh_ch.port_tx_cfg_reg_base, codec_port),
  335. WATER_MARK_VAL);
  336. if (ret < 0) {
  337. pr_err("%s:watermark set failure for port[%d] ret[%d]",
  338. __func__, codec_port, ret);
  339. }
  340. ret = slim_connect_src(wcd9xxx->slim, tx->sph, tx->ch_h);
  341. if (ret < 0) {
  342. pr_err("%s: slim_connect_src failed ret[%d]\n",
  343. __func__, ret);
  344. goto err;
  345. }
  346. }
  347. /* slim_control_ch */
  348. ret = slim_control_ch(wcd9xxx->slim, *grph, SLIM_CH_ACTIVATE,
  349. true);
  350. if (ret < 0) {
  351. pr_err("%s: slim_control_ch failed ret[%d]\n",
  352. __func__, ret);
  353. goto err;
  354. }
  355. return 0;
  356. err:
  357. /* release all acquired handles */
  358. wcd9xxx_close_slim_sch_tx(wcd9xxx, wcd9xxx_ch_list, *grph);
  359. return ret;
  360. }
  361. EXPORT_SYMBOL_GPL(wcd9xxx_cfg_slim_sch_tx);
  362. int wcd9xxx_close_slim_sch_rx(struct wcd9xxx *wcd9xxx,
  363. struct list_head *wcd9xxx_ch_list, u16 grph)
  364. {
  365. u32 sph[SLIM_MAX_RX_PORTS] = {0};
  366. int ch_cnt = 0 ;
  367. int ret = 0;
  368. struct wcd9xxx_ch *rx;
  369. list_for_each_entry(rx, wcd9xxx_ch_list, list)
  370. sph[ch_cnt++] = rx->sph;
  371. pr_debug("%s ch_cht %d, sph[0] %d sph[1] %d\n", __func__, ch_cnt,
  372. sph[0], sph[1]);
  373. /* slim_control_ch (REMOVE) */
  374. pr_debug("%s before slim_control_ch grph %d\n", __func__, grph);
  375. ret = slim_control_ch(wcd9xxx->slim, grph, SLIM_CH_REMOVE, true);
  376. if (ret < 0) {
  377. pr_err("%s: slim_control_ch failed ret[%d]\n", __func__, ret);
  378. goto err;
  379. }
  380. err:
  381. return ret;
  382. }
  383. EXPORT_SYMBOL_GPL(wcd9xxx_close_slim_sch_rx);
  384. int wcd9xxx_close_slim_sch_tx(struct wcd9xxx *wcd9xxx,
  385. struct list_head *wcd9xxx_ch_list,
  386. u16 grph)
  387. {
  388. u32 sph[SLIM_MAX_TX_PORTS] = {0};
  389. int ret = 0;
  390. int ch_cnt = 0 ;
  391. struct wcd9xxx_ch *tx;
  392. pr_debug("%s\n", __func__);
  393. list_for_each_entry(tx, wcd9xxx_ch_list, list)
  394. sph[ch_cnt++] = tx->sph;
  395. pr_debug("%s ch_cht %d, sph[0] %d sph[1] %d\n",
  396. __func__, ch_cnt, sph[0], sph[1]);
  397. /* slim_control_ch (REMOVE) */
  398. ret = slim_control_ch(wcd9xxx->slim, grph, SLIM_CH_REMOVE, true);
  399. if (ret < 0) {
  400. pr_err("%s: slim_control_ch failed ret[%d]\n",
  401. __func__, ret);
  402. goto err;
  403. }
  404. err:
  405. return ret;
  406. }
  407. EXPORT_SYMBOL_GPL(wcd9xxx_close_slim_sch_tx);
  408. int wcd9xxx_get_slave_port(unsigned int ch_num)
  409. {
  410. int ret = 0;
  411. ret = (ch_num - BASE_CH_NUM);
  412. pr_debug("%s: ch_num[%d] slave port[%d]\n", __func__, ch_num, ret);
  413. if (ret < 0) {
  414. pr_err("%s: Error:- Invalid slave port found = %d\n",
  415. __func__, ret);
  416. return -EINVAL;
  417. }
  418. return ret;
  419. }
  420. EXPORT_SYMBOL_GPL(wcd9xxx_get_slave_port);
  421. int wcd9xxx_disconnect_port(struct wcd9xxx *wcd9xxx,
  422. struct list_head *wcd9xxx_ch_list, u16 grph)
  423. {
  424. u32 sph[SLIM_MAX_TX_PORTS + SLIM_MAX_RX_PORTS] = {0};
  425. int ch_cnt = 0 ;
  426. int ret = 0;
  427. struct wcd9xxx_ch *slim_ch;
  428. list_for_each_entry(slim_ch, wcd9xxx_ch_list, list)
  429. sph[ch_cnt++] = slim_ch->sph;
  430. /* slim_disconnect_port */
  431. ret = slim_disconnect_ports(wcd9xxx->slim, sph, ch_cnt);
  432. if (ret < 0) {
  433. pr_err("%s: slim_disconnect_ports failed ret[%d]\n",
  434. __func__, ret);
  435. }
  436. return ret;
  437. }
  438. EXPORT_SYMBOL_GPL(wcd9xxx_disconnect_port);
  439. /* This function is called with mutex acquired */
  440. int wcd9xxx_rx_vport_validation(u32 port_id,
  441. struct list_head *codec_dai_list)
  442. {
  443. struct wcd9xxx_ch *ch;
  444. int ret = 0;
  445. pr_debug("%s: port_id %u\n", __func__, port_id);
  446. list_for_each_entry(ch,
  447. codec_dai_list, list) {
  448. pr_debug("%s: ch->port %u\n", __func__, ch->port);
  449. if (ch->port == port_id) {
  450. ret = -EINVAL;
  451. break;
  452. }
  453. }
  454. return ret;
  455. }
  456. EXPORT_SYMBOL_GPL(wcd9xxx_rx_vport_validation);
  457. /* This function is called with mutex acquired */
  458. int wcd9xxx_tx_vport_validation(u32 vtable, u32 port_id,
  459. struct wcd9xxx_codec_dai_data *codec_dai,
  460. u32 num_codec_dais)
  461. {
  462. struct wcd9xxx_ch *ch;
  463. int ret = 0;
  464. u32 index;
  465. u32 size = sizeof(vtable) * 8;
  466. pr_debug("%s: vtable 0x%x port_id %u size %d\n", __func__,
  467. vtable, port_id, size);
  468. for_each_set_bit(index, (unsigned long *)&vtable, size) {
  469. if (index < num_codec_dais) {
  470. list_for_each_entry(ch,
  471. &codec_dai[index].wcd9xxx_ch_list,
  472. list) {
  473. pr_debug("%s: index %u ch->port %u vtable 0x%x\n",
  474. __func__, index, ch->port,
  475. vtable);
  476. if (ch->port == port_id) {
  477. pr_err("%s: TX%u is used by AIF%u_CAP Mixer\n",
  478. __func__, port_id + 1,
  479. (index + 1)/2);
  480. ret = -EINVAL;
  481. break;
  482. }
  483. }
  484. } else {
  485. pr_err("%s: Invalid index %d of codec dai",
  486. __func__, index);
  487. ret = -EINVAL;
  488. }
  489. if (ret)
  490. break;
  491. }
  492. return ret;
  493. }
  494. EXPORT_SYMBOL_GPL(wcd9xxx_tx_vport_validation);