bolero-cdc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /* Copyright (c) 2018, 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/of_platform.h>
  13. #include <linux/module.h>
  14. #include <linux/io.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/printk.h>
  18. #include <linux/delay.h>
  19. #include <linux/kernel.h>
  20. #include "bolero-cdc.h"
  21. #include "internal.h"
  22. #define BOLERO_VERSION_1_0 0x0001
  23. #define BOLERO_VERSION_ENTRY_SIZE 32
  24. static struct snd_soc_codec_driver bolero;
  25. /* MCLK_MUX table for all macros */
  26. static u16 bolero_mclk_mux_tbl[MAX_MACRO][MCLK_MUX_MAX] = {
  27. {TX_MACRO, VA_MACRO},
  28. {TX_MACRO, RX_MACRO},
  29. {TX_MACRO, WSA_MACRO},
  30. {TX_MACRO, VA_MACRO},
  31. };
  32. static void bolero_ahb_write_device(char __iomem *io_base,
  33. u16 reg, u8 value)
  34. {
  35. u32 temp = (u32)(value) & 0x000000FF;
  36. iowrite32(temp, io_base + reg);
  37. }
  38. static void bolero_ahb_read_device(char __iomem *io_base,
  39. u16 reg, u8 *value)
  40. {
  41. u32 temp;
  42. temp = ioread32(io_base + reg);
  43. *value = (u8)temp;
  44. }
  45. static int __bolero_reg_read(struct bolero_priv *priv,
  46. u16 macro_id, u16 reg, u8 *val)
  47. {
  48. int ret = -EINVAL;
  49. u16 current_mclk_mux_macro;
  50. mutex_lock(&priv->clk_lock);
  51. current_mclk_mux_macro =
  52. priv->current_mclk_mux_macro[macro_id];
  53. if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) {
  54. dev_dbg_ratelimited(priv->dev,
  55. "%s: mclk_fn not init for macro-id:%d, current_mclk_mux_macro:%d\n",
  56. __func__, macro_id, current_mclk_mux_macro);
  57. goto err;
  58. }
  59. ret = priv->macro_params[current_mclk_mux_macro].mclk_fn(
  60. priv->macro_params[current_mclk_mux_macro].dev, true);
  61. if (ret) {
  62. dev_dbg_ratelimited(priv->dev,
  63. "%s: clock enable failed for macro-id:%d, current_mclk_mux_macro:%d\n",
  64. __func__, macro_id, current_mclk_mux_macro);
  65. goto err;
  66. }
  67. bolero_ahb_read_device(
  68. priv->macro_params[macro_id].io_base, reg, val);
  69. priv->macro_params[current_mclk_mux_macro].mclk_fn(
  70. priv->macro_params[current_mclk_mux_macro].dev, false);
  71. err:
  72. mutex_unlock(&priv->clk_lock);
  73. return ret;
  74. }
  75. static int __bolero_reg_write(struct bolero_priv *priv,
  76. u16 macro_id, u16 reg, u8 val)
  77. {
  78. int ret = -EINVAL;
  79. u16 current_mclk_mux_macro;
  80. mutex_lock(&priv->clk_lock);
  81. current_mclk_mux_macro =
  82. priv->current_mclk_mux_macro[macro_id];
  83. if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) {
  84. dev_dbg_ratelimited(priv->dev,
  85. "%s: mclk_fn not init for macro-id:%d, current_mclk_mux_macro:%d\n",
  86. __func__, macro_id, current_mclk_mux_macro);
  87. goto err;
  88. }
  89. ret = priv->macro_params[current_mclk_mux_macro].mclk_fn(
  90. priv->macro_params[current_mclk_mux_macro].dev, true);
  91. if (ret) {
  92. dev_dbg_ratelimited(priv->dev,
  93. "%s: clock enable failed for macro-id:%d, current_mclk_mux_macro:%d\n",
  94. __func__, macro_id, current_mclk_mux_macro);
  95. goto err;
  96. }
  97. bolero_ahb_write_device(
  98. priv->macro_params[macro_id].io_base, reg, val);
  99. priv->macro_params[current_mclk_mux_macro].mclk_fn(
  100. priv->macro_params[current_mclk_mux_macro].dev, false);
  101. err:
  102. mutex_unlock(&priv->clk_lock);
  103. return ret;
  104. }
  105. static bool bolero_is_valid_macro_dev(struct device *dev)
  106. {
  107. if (of_device_is_compatible(dev->parent->of_node, "qcom,bolero-codec"))
  108. return true;
  109. return false;
  110. }
  111. static bool bolero_is_valid_codec_dev(struct device *dev)
  112. {
  113. if (of_device_is_compatible(dev->of_node, "qcom,bolero-codec"))
  114. return true;
  115. return false;
  116. }
  117. /**
  118. * bolero_get_device_ptr - Get child or macro device ptr
  119. *
  120. * @dev: bolero device ptr.
  121. * @macro_id: ID of macro calling this API.
  122. *
  123. * Returns dev ptr on success or NULL on error.
  124. */
  125. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id)
  126. {
  127. struct bolero_priv *priv;
  128. if (!dev) {
  129. pr_err("%s: dev is null\n", __func__);
  130. return NULL;
  131. }
  132. if (!bolero_is_valid_codec_dev(dev)) {
  133. pr_err("%s: invalid codec\n", __func__);
  134. return NULL;
  135. }
  136. priv = dev_get_drvdata(dev);
  137. if (!priv || (macro_id >= MAX_MACRO)) {
  138. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  139. return NULL;
  140. }
  141. return priv->macro_params[macro_id].dev;
  142. }
  143. EXPORT_SYMBOL(bolero_get_device_ptr);
  144. static int bolero_copy_dais_from_macro(struct bolero_priv *priv)
  145. {
  146. struct snd_soc_dai_driver *dai_ptr;
  147. u16 macro_idx;
  148. /* memcpy into bolero_dais all macro dais */
  149. if (!priv->bolero_dais)
  150. priv->bolero_dais = devm_kzalloc(priv->dev,
  151. priv->num_dais *
  152. sizeof(
  153. struct snd_soc_dai_driver),
  154. GFP_KERNEL);
  155. if (!priv->bolero_dais)
  156. return -ENOMEM;
  157. dai_ptr = priv->bolero_dais;
  158. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  159. if (priv->macro_params[macro_idx].dai_ptr) {
  160. memcpy(dai_ptr,
  161. priv->macro_params[macro_idx].dai_ptr,
  162. priv->macro_params[macro_idx].num_dais *
  163. sizeof(struct snd_soc_dai_driver));
  164. dai_ptr += priv->macro_params[macro_idx].num_dais;
  165. }
  166. }
  167. return 0;
  168. }
  169. /**
  170. * bolero_register_macro - Registers macro to bolero
  171. *
  172. * @dev: macro device ptr.
  173. * @macro_id: ID of macro calling this API.
  174. * @ops: macro params to register.
  175. *
  176. * Returns 0 on success or -EINVAL on error.
  177. */
  178. int bolero_register_macro(struct device *dev, u16 macro_id,
  179. struct macro_ops *ops)
  180. {
  181. struct bolero_priv *priv;
  182. int ret = -EINVAL;
  183. if (!dev || !ops) {
  184. pr_err("%s: dev or ops is null\n", __func__);
  185. return -EINVAL;
  186. }
  187. if (!bolero_is_valid_macro_dev(dev)) {
  188. dev_err(dev, "%s: child device for macro:%d not added yet\n",
  189. __func__, macro_id);
  190. return -EINVAL;
  191. }
  192. priv = dev_get_drvdata(dev->parent);
  193. if (!priv || (macro_id >= MAX_MACRO)) {
  194. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  195. return -EINVAL;
  196. }
  197. priv->macro_params[macro_id].init = ops->init;
  198. priv->macro_params[macro_id].exit = ops->exit;
  199. priv->macro_params[macro_id].io_base = ops->io_base;
  200. priv->macro_params[macro_id].num_dais = ops->num_dais;
  201. priv->macro_params[macro_id].dai_ptr = ops->dai_ptr;
  202. priv->macro_params[macro_id].mclk_fn = ops->mclk_fn;
  203. priv->macro_params[macro_id].dev = dev;
  204. priv->current_mclk_mux_macro[macro_id] =
  205. bolero_mclk_mux_tbl[macro_id][MCLK_MUX0];
  206. priv->num_dais += ops->num_dais;
  207. priv->num_macros_registered++;
  208. priv->macros_supported[macro_id] = true;
  209. if (priv->num_macros_registered == priv->child_num) {
  210. ret = bolero_copy_dais_from_macro(priv);
  211. if (ret < 0) {
  212. dev_err(dev, "%s: copy_dais failed\n", __func__);
  213. return ret;
  214. }
  215. if (priv->macros_supported[TX_MACRO] == false) {
  216. bolero_mclk_mux_tbl[WSA_MACRO][MCLK_MUX0] = WSA_MACRO;
  217. priv->current_mclk_mux_macro[WSA_MACRO] = WSA_MACRO;
  218. bolero_mclk_mux_tbl[VA_MACRO][MCLK_MUX0] = VA_MACRO;
  219. priv->current_mclk_mux_macro[VA_MACRO] = VA_MACRO;
  220. }
  221. ret = snd_soc_register_codec(dev->parent, &bolero,
  222. priv->bolero_dais, priv->num_dais);
  223. if (ret < 0) {
  224. dev_err(dev, "%s: register codec failed\n", __func__);
  225. return ret;
  226. }
  227. }
  228. return 0;
  229. }
  230. EXPORT_SYMBOL(bolero_register_macro);
  231. /**
  232. * bolero_unregister_macro - De-Register macro from bolero
  233. *
  234. * @dev: macro device ptr.
  235. * @macro_id: ID of macro calling this API.
  236. *
  237. */
  238. void bolero_unregister_macro(struct device *dev, u16 macro_id)
  239. {
  240. struct bolero_priv *priv;
  241. if (!dev) {
  242. pr_err("%s: dev is null\n", __func__);
  243. return;
  244. }
  245. if (!bolero_is_valid_macro_dev(dev)) {
  246. dev_err(dev, "%s: macro:%d not in valid registered macro-list\n",
  247. __func__, macro_id);
  248. return;
  249. }
  250. priv = dev_get_drvdata(dev->parent);
  251. if (!priv || (macro_id >= MAX_MACRO)) {
  252. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  253. return;
  254. }
  255. priv->macro_params[macro_id].init = NULL;
  256. priv->macro_params[macro_id].num_dais = 0;
  257. priv->macro_params[macro_id].dai_ptr = NULL;
  258. priv->macro_params[macro_id].mclk_fn = NULL;
  259. priv->macro_params[macro_id].dev = NULL;
  260. priv->num_dais -= priv->macro_params[macro_id].num_dais;
  261. priv->num_macros_registered--;
  262. /* UNREGISTER CODEC HERE */
  263. if (priv->child_num - 1 == priv->num_macros_registered)
  264. snd_soc_unregister_codec(dev->parent);
  265. }
  266. EXPORT_SYMBOL(bolero_unregister_macro);
  267. /**
  268. * bolero_request_clock - request for clock enable/disable
  269. *
  270. * @dev: macro device ptr.
  271. * @macro_id: ID of macro calling this API.
  272. * @mclk_mux_id: MCLK_MUX ID.
  273. * @enable: enable or disable clock flag
  274. *
  275. * Returns 0 on success or -EINVAL on error.
  276. */
  277. int bolero_request_clock(struct device *dev, u16 macro_id,
  278. enum mclk_mux mclk_mux_id,
  279. bool enable)
  280. {
  281. struct bolero_priv *priv;
  282. u16 mclk_mux0_macro, mclk_mux1_macro;
  283. int ret = 0;
  284. if (!dev) {
  285. pr_err("%s: dev is null\n", __func__);
  286. return -EINVAL;
  287. }
  288. if (!bolero_is_valid_macro_dev(dev)) {
  289. dev_err(dev, "%s: macro:%d not in valid registered macro-list\n",
  290. __func__, macro_id);
  291. return -EINVAL;
  292. }
  293. priv = dev_get_drvdata(dev->parent);
  294. if (!priv || (macro_id >= MAX_MACRO)) {
  295. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  296. return -EINVAL;
  297. }
  298. mclk_mux0_macro = bolero_mclk_mux_tbl[macro_id][MCLK_MUX0];
  299. mutex_lock(&priv->clk_lock);
  300. switch (mclk_mux_id) {
  301. case MCLK_MUX0:
  302. ret = priv->macro_params[mclk_mux0_macro].mclk_fn(
  303. priv->macro_params[mclk_mux0_macro].dev, enable);
  304. if (ret < 0) {
  305. dev_err(dev,
  306. "%s: MCLK_MUX0 %s failed for macro:%d, mclk_mux0_macro:%d\n",
  307. __func__,
  308. enable ? "enable" : "disable",
  309. macro_id, mclk_mux0_macro);
  310. goto err;
  311. }
  312. break;
  313. case MCLK_MUX1:
  314. mclk_mux1_macro = bolero_mclk_mux_tbl[macro_id][MCLK_MUX1];
  315. ret = priv->macro_params[mclk_mux0_macro].mclk_fn(
  316. priv->macro_params[mclk_mux0_macro].dev,
  317. true);
  318. if (ret < 0) {
  319. dev_err(dev,
  320. "%s: MCLK_MUX0 en failed for macro:%d mclk_mux0_macro:%d\n",
  321. __func__, macro_id, mclk_mux0_macro);
  322. goto err;
  323. }
  324. ret = priv->macro_params[mclk_mux1_macro].mclk_fn(
  325. priv->macro_params[mclk_mux1_macro].dev, enable);
  326. if (ret < 0) {
  327. dev_err(dev,
  328. "%s: MCLK_MUX1 %s failed for macro:%d, mclk_mux1_macro:%d\n",
  329. __func__,
  330. enable ? "enable" : "disable",
  331. macro_id, mclk_mux1_macro);
  332. priv->macro_params[mclk_mux0_macro].mclk_fn(
  333. priv->macro_params[mclk_mux0_macro].dev,
  334. false);
  335. goto err;
  336. }
  337. priv->macro_params[mclk_mux0_macro].mclk_fn(
  338. priv->macro_params[mclk_mux0_macro].dev,
  339. false);
  340. break;
  341. case MCLK_MUX_MAX:
  342. default:
  343. dev_err(dev, "%s: invalid mclk_mux_id: %d\n",
  344. __func__, mclk_mux_id);
  345. ret = -EINVAL;
  346. goto err;
  347. }
  348. if (enable)
  349. priv->current_mclk_mux_macro[macro_id] =
  350. bolero_mclk_mux_tbl[macro_id][mclk_mux_id];
  351. else
  352. priv->current_mclk_mux_macro[macro_id] =
  353. bolero_mclk_mux_tbl[macro_id][MCLK_MUX0];
  354. err:
  355. mutex_unlock(&priv->clk_lock);
  356. return ret;
  357. }
  358. EXPORT_SYMBOL(bolero_request_clock);
  359. static ssize_t bolero_version_read(struct snd_info_entry *entry,
  360. void *file_private_data,
  361. struct file *file,
  362. char __user *buf, size_t count,
  363. loff_t pos)
  364. {
  365. struct bolero_priv *priv;
  366. char buffer[BOLERO_VERSION_ENTRY_SIZE];
  367. int len = 0;
  368. priv = (struct bolero_priv *) entry->private_data;
  369. if (!priv) {
  370. pr_err("%s: bolero priv is null\n", __func__);
  371. return -EINVAL;
  372. }
  373. switch (priv->version) {
  374. case BOLERO_VERSION_1_0:
  375. len = snprintf(buffer, sizeof(buffer), "BOLERO_1_0\n");
  376. break;
  377. default:
  378. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  379. }
  380. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  381. }
  382. static struct snd_info_entry_ops bolero_info_ops = {
  383. .read = bolero_version_read,
  384. };
  385. /*
  386. * bolero_info_create_codec_entry - creates bolero module
  387. * @codec_root: The parent directory
  388. * @codec: Codec instance
  389. *
  390. * Creates bolero module and version entry under the given
  391. * parent directory.
  392. *
  393. * Return: 0 on success or negative error code on failure.
  394. */
  395. int bolero_info_create_codec_entry(struct snd_info_entry *codec_root,
  396. struct snd_soc_codec *codec)
  397. {
  398. struct snd_info_entry *version_entry;
  399. struct bolero_priv *priv;
  400. struct snd_soc_card *card;
  401. if (!codec_root || !codec)
  402. return -EINVAL;
  403. priv = snd_soc_codec_get_drvdata(codec);
  404. if (priv->entry) {
  405. dev_dbg(priv->dev,
  406. "%s:bolero module already created\n", __func__);
  407. return 0;
  408. }
  409. card = codec->component.card;
  410. priv->entry = snd_info_create_subdir(codec_root->module,
  411. "bolero", codec_root);
  412. if (!priv->entry) {
  413. dev_dbg(codec->dev, "%s: failed to create bolero entry\n",
  414. __func__);
  415. return -ENOMEM;
  416. }
  417. version_entry = snd_info_create_card_entry(card->snd_card,
  418. "version",
  419. priv->entry);
  420. if (!version_entry) {
  421. dev_err(codec->dev, "%s: failed to create bolero version entry\n",
  422. __func__);
  423. return -ENOMEM;
  424. }
  425. version_entry->private_data = priv;
  426. version_entry->size = BOLERO_VERSION_ENTRY_SIZE;
  427. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  428. version_entry->c.ops = &bolero_info_ops;
  429. if (snd_info_register(version_entry) < 0) {
  430. snd_info_free_entry(version_entry);
  431. return -ENOMEM;
  432. }
  433. priv->version_entry = version_entry;
  434. return 0;
  435. }
  436. EXPORT_SYMBOL(bolero_info_create_codec_entry);
  437. static int bolero_soc_codec_probe(struct snd_soc_codec *codec)
  438. {
  439. struct bolero_priv *priv = dev_get_drvdata(codec->dev);
  440. int macro_idx, ret = 0;
  441. /* call init for supported macros */
  442. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  443. if (priv->macro_params[macro_idx].init) {
  444. ret = priv->macro_params[macro_idx].init(codec);
  445. if (ret < 0) {
  446. dev_err(codec->dev,
  447. "%s: init for macro %d failed\n",
  448. __func__, macro_idx);
  449. goto err;
  450. }
  451. }
  452. }
  453. priv->codec = codec;
  454. priv->version = BOLERO_VERSION_1_0;
  455. dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__);
  456. err:
  457. return ret;
  458. }
  459. static int bolero_soc_codec_remove(struct snd_soc_codec *codec)
  460. {
  461. struct bolero_priv *priv = dev_get_drvdata(codec->dev);
  462. int macro_idx;
  463. /* call exit for supported macros */
  464. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++)
  465. if (priv->macro_params[macro_idx].exit)
  466. priv->macro_params[macro_idx].exit(codec);
  467. return 0;
  468. }
  469. static struct regmap *bolero_get_regmap(struct device *dev)
  470. {
  471. struct bolero_priv *priv = dev_get_drvdata(dev);
  472. return priv->regmap;
  473. }
  474. static struct snd_soc_codec_driver bolero = {
  475. .probe = bolero_soc_codec_probe,
  476. .remove = bolero_soc_codec_remove,
  477. .get_regmap = bolero_get_regmap,
  478. };
  479. static void bolero_add_child_devices(struct work_struct *work)
  480. {
  481. struct bolero_priv *priv;
  482. int rc;
  483. priv = container_of(work, struct bolero_priv,
  484. bolero_add_child_devices_work);
  485. if (!priv) {
  486. pr_err("%s: Memory for bolero priv does not exist\n",
  487. __func__);
  488. return;
  489. }
  490. if (!priv->dev || !priv->dev->of_node) {
  491. dev_err(priv->dev, "%s: DT node for bolero does not exist\n",
  492. __func__);
  493. return;
  494. }
  495. rc = of_platform_populate(priv->dev->of_node, NULL, NULL, priv->dev);
  496. if (rc)
  497. dev_err(priv->dev, "%s: failed to add child nodes, rc=%d\n",
  498. __func__, rc);
  499. else
  500. dev_dbg(priv->dev, "%s: added child node\n", __func__);
  501. }
  502. static int bolero_probe(struct platform_device *pdev)
  503. {
  504. struct bolero_priv *priv;
  505. u32 num_macros = 0;
  506. int ret;
  507. priv = devm_kzalloc(&pdev->dev, sizeof(struct bolero_priv),
  508. GFP_KERNEL);
  509. if (!priv)
  510. return -ENOMEM;
  511. ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-macros",
  512. &num_macros);
  513. if (ret) {
  514. dev_err(&pdev->dev,
  515. "%s:num-macros property not found\n",
  516. __func__);
  517. return ret;
  518. }
  519. priv->child_num = num_macros;
  520. if (priv->child_num > MAX_MACRO) {
  521. dev_err(&pdev->dev,
  522. "%s:child_num(%d) > MAX_MACRO(%d) than supported\n",
  523. __func__, priv->child_num, MAX_MACRO);
  524. return -EINVAL;
  525. }
  526. priv->va_without_decimation = of_property_read_bool(pdev->dev.of_node,
  527. "qcom,va-without-decimation");
  528. if (priv->va_without_decimation)
  529. bolero_reg_access[VA_MACRO] = bolero_va_top_reg_access;
  530. priv->dev = &pdev->dev;
  531. priv->regmap = bolero_regmap_init(priv->dev,
  532. &bolero_regmap_config);
  533. if (IS_ERR_OR_NULL((void *)(priv->regmap))) {
  534. dev_err(&pdev->dev, "%s:regmap init failed\n", __func__);
  535. return -EINVAL;
  536. }
  537. priv->read_dev = __bolero_reg_read;
  538. priv->write_dev = __bolero_reg_write;
  539. dev_set_drvdata(&pdev->dev, priv);
  540. mutex_init(&priv->io_lock);
  541. mutex_init(&priv->clk_lock);
  542. INIT_WORK(&priv->bolero_add_child_devices_work,
  543. bolero_add_child_devices);
  544. schedule_work(&priv->bolero_add_child_devices_work);
  545. return 0;
  546. }
  547. static int bolero_remove(struct platform_device *pdev)
  548. {
  549. struct bolero_priv *priv = dev_get_drvdata(&pdev->dev);
  550. if (!priv)
  551. return -EINVAL;
  552. of_platform_depopulate(&pdev->dev);
  553. mutex_destroy(&priv->io_lock);
  554. mutex_destroy(&priv->clk_lock);
  555. return 0;
  556. }
  557. static const struct of_device_id bolero_dt_match[] = {
  558. {.compatible = "qcom,bolero-codec"},
  559. {}
  560. };
  561. MODULE_DEVICE_TABLE(of, bolero_dt_match);
  562. static struct platform_driver bolero_drv = {
  563. .driver = {
  564. .name = "bolero-codec",
  565. .owner = THIS_MODULE,
  566. .of_match_table = bolero_dt_match,
  567. },
  568. .probe = bolero_probe,
  569. .remove = bolero_remove,
  570. };
  571. module_platform_driver(bolero_drv);
  572. MODULE_DESCRIPTION("Bolero driver");
  573. MODULE_LICENSE("GPL v2");