lpass-cpu.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * lpass-cpu.c -- ALSA SoC CPU DAI driver for QTi LPASS
  14. */
  15. #include <linux/clk.h>
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/of.h>
  19. #include <linux/of_device.h>
  20. #include <linux/platform_device.h>
  21. #include <sound/pcm.h>
  22. #include <sound/pcm_params.h>
  23. #include <linux/regmap.h>
  24. #include <sound/soc.h>
  25. #include <sound/soc-dai.h>
  26. #include "lpass-lpaif-reg.h"
  27. #include "lpass.h"
  28. static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  29. unsigned int freq, int dir)
  30. {
  31. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  32. int ret;
  33. if (IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
  34. return 0;
  35. ret = clk_set_rate(drvdata->mi2s_osr_clk[dai->driver->id], freq);
  36. if (ret)
  37. dev_err(dai->dev, "%s() error setting mi2s osrclk to %u: %d\n",
  38. __func__, freq, ret);
  39. return ret;
  40. }
  41. static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream,
  42. struct snd_soc_dai *dai)
  43. {
  44. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  45. int ret;
  46. if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id])) {
  47. ret = clk_prepare_enable(
  48. drvdata->mi2s_osr_clk[dai->driver->id]);
  49. if (ret) {
  50. dev_err(dai->dev, "%s() error in enabling mi2s osr clk: %d\n",
  51. __func__, ret);
  52. return ret;
  53. }
  54. }
  55. ret = clk_prepare_enable(drvdata->mi2s_bit_clk[dai->driver->id]);
  56. if (ret) {
  57. dev_err(dai->dev, "%s() error in enabling mi2s bit clk: %d\n",
  58. __func__, ret);
  59. if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
  60. clk_disable_unprepare(
  61. drvdata->mi2s_osr_clk[dai->driver->id]);
  62. return ret;
  63. }
  64. return 0;
  65. }
  66. static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream,
  67. struct snd_soc_dai *dai)
  68. {
  69. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  70. clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]);
  71. if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
  72. clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
  73. }
  74. static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
  75. struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
  76. {
  77. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  78. snd_pcm_format_t format = params_format(params);
  79. unsigned int channels = params_channels(params);
  80. unsigned int rate = params_rate(params);
  81. unsigned int regval;
  82. int bitwidth, ret;
  83. bitwidth = snd_pcm_format_width(format);
  84. if (bitwidth < 0) {
  85. dev_err(dai->dev, "%s() invalid bit width given: %d\n",
  86. __func__, bitwidth);
  87. return bitwidth;
  88. }
  89. regval = LPAIF_I2SCTL_LOOPBACK_DISABLE |
  90. LPAIF_I2SCTL_WSSRC_INTERNAL;
  91. switch (bitwidth) {
  92. case 16:
  93. regval |= LPAIF_I2SCTL_BITWIDTH_16;
  94. break;
  95. case 24:
  96. regval |= LPAIF_I2SCTL_BITWIDTH_24;
  97. break;
  98. case 32:
  99. regval |= LPAIF_I2SCTL_BITWIDTH_32;
  100. break;
  101. default:
  102. dev_err(dai->dev, "%s() invalid bitwidth given: %d\n",
  103. __func__, bitwidth);
  104. return -EINVAL;
  105. }
  106. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  107. switch (channels) {
  108. case 1:
  109. regval |= LPAIF_I2SCTL_SPKMODE_SD0;
  110. regval |= LPAIF_I2SCTL_SPKMONO_MONO;
  111. break;
  112. case 2:
  113. regval |= LPAIF_I2SCTL_SPKMODE_SD0;
  114. regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
  115. break;
  116. case 4:
  117. regval |= LPAIF_I2SCTL_SPKMODE_QUAD01;
  118. regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
  119. break;
  120. case 6:
  121. regval |= LPAIF_I2SCTL_SPKMODE_6CH;
  122. regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
  123. break;
  124. case 8:
  125. regval |= LPAIF_I2SCTL_SPKMODE_8CH;
  126. regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
  127. break;
  128. default:
  129. dev_err(dai->dev, "%s() invalid channels given: %u\n",
  130. __func__, channels);
  131. return -EINVAL;
  132. }
  133. } else {
  134. switch (channels) {
  135. case 1:
  136. regval |= LPAIF_I2SCTL_MICMODE_SD0;
  137. regval |= LPAIF_I2SCTL_MICMONO_MONO;
  138. break;
  139. case 2:
  140. regval |= LPAIF_I2SCTL_MICMODE_SD0;
  141. regval |= LPAIF_I2SCTL_MICMONO_STEREO;
  142. break;
  143. case 4:
  144. regval |= LPAIF_I2SCTL_MICMODE_QUAD01;
  145. regval |= LPAIF_I2SCTL_MICMONO_STEREO;
  146. break;
  147. case 6:
  148. regval |= LPAIF_I2SCTL_MICMODE_6CH;
  149. regval |= LPAIF_I2SCTL_MICMONO_STEREO;
  150. break;
  151. case 8:
  152. regval |= LPAIF_I2SCTL_MICMODE_8CH;
  153. regval |= LPAIF_I2SCTL_MICMONO_STEREO;
  154. break;
  155. default:
  156. dev_err(dai->dev, "%s() invalid channels given: %u\n",
  157. __func__, channels);
  158. return -EINVAL;
  159. }
  160. }
  161. ret = regmap_write(drvdata->lpaif_map,
  162. LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
  163. regval);
  164. if (ret) {
  165. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  166. __func__, ret);
  167. return ret;
  168. }
  169. ret = clk_set_rate(drvdata->mi2s_bit_clk[dai->driver->id],
  170. rate * bitwidth * 2);
  171. if (ret) {
  172. dev_err(dai->dev, "%s() error setting mi2s bitclk to %u: %d\n",
  173. __func__, rate * bitwidth * 2, ret);
  174. return ret;
  175. }
  176. return 0;
  177. }
  178. static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
  179. struct snd_soc_dai *dai)
  180. {
  181. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  182. int ret;
  183. ret = regmap_write(drvdata->lpaif_map,
  184. LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
  185. 0);
  186. if (ret)
  187. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  188. __func__, ret);
  189. return ret;
  190. }
  191. static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream,
  192. struct snd_soc_dai *dai)
  193. {
  194. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  195. int ret;
  196. unsigned int val, mask;
  197. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  198. val = LPAIF_I2SCTL_SPKEN_ENABLE;
  199. mask = LPAIF_I2SCTL_SPKEN_MASK;
  200. } else {
  201. val = LPAIF_I2SCTL_MICEN_ENABLE;
  202. mask = LPAIF_I2SCTL_MICEN_MASK;
  203. }
  204. ret = regmap_update_bits(drvdata->lpaif_map,
  205. LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
  206. mask, val);
  207. if (ret)
  208. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  209. __func__, ret);
  210. return ret;
  211. }
  212. static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream,
  213. int cmd, struct snd_soc_dai *dai)
  214. {
  215. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  216. int ret = -EINVAL;
  217. unsigned int val, mask;
  218. switch (cmd) {
  219. case SNDRV_PCM_TRIGGER_START:
  220. case SNDRV_PCM_TRIGGER_RESUME:
  221. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  222. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  223. val = LPAIF_I2SCTL_SPKEN_ENABLE;
  224. mask = LPAIF_I2SCTL_SPKEN_MASK;
  225. } else {
  226. val = LPAIF_I2SCTL_MICEN_ENABLE;
  227. mask = LPAIF_I2SCTL_MICEN_MASK;
  228. }
  229. ret = regmap_update_bits(drvdata->lpaif_map,
  230. LPAIF_I2SCTL_REG(drvdata->variant,
  231. dai->driver->id),
  232. mask, val);
  233. if (ret)
  234. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  235. __func__, ret);
  236. break;
  237. case SNDRV_PCM_TRIGGER_STOP:
  238. case SNDRV_PCM_TRIGGER_SUSPEND:
  239. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  240. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  241. val = LPAIF_I2SCTL_SPKEN_DISABLE;
  242. mask = LPAIF_I2SCTL_SPKEN_MASK;
  243. } else {
  244. val = LPAIF_I2SCTL_MICEN_DISABLE;
  245. mask = LPAIF_I2SCTL_MICEN_MASK;
  246. }
  247. ret = regmap_update_bits(drvdata->lpaif_map,
  248. LPAIF_I2SCTL_REG(drvdata->variant,
  249. dai->driver->id),
  250. mask, val);
  251. if (ret)
  252. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  253. __func__, ret);
  254. break;
  255. }
  256. return ret;
  257. }
  258. const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = {
  259. .set_sysclk = lpass_cpu_daiops_set_sysclk,
  260. .startup = lpass_cpu_daiops_startup,
  261. .shutdown = lpass_cpu_daiops_shutdown,
  262. .hw_params = lpass_cpu_daiops_hw_params,
  263. .hw_free = lpass_cpu_daiops_hw_free,
  264. .prepare = lpass_cpu_daiops_prepare,
  265. .trigger = lpass_cpu_daiops_trigger,
  266. };
  267. EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops);
  268. int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai)
  269. {
  270. struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
  271. int ret;
  272. /* ensure audio hardware is disabled */
  273. ret = regmap_write(drvdata->lpaif_map,
  274. LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), 0);
  275. if (ret)
  276. dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n",
  277. __func__, ret);
  278. return ret;
  279. }
  280. EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_probe);
  281. static const struct snd_soc_component_driver lpass_cpu_comp_driver = {
  282. .name = "lpass-cpu",
  283. };
  284. static bool lpass_cpu_regmap_writeable(struct device *dev, unsigned int reg)
  285. {
  286. struct lpass_data *drvdata = dev_get_drvdata(dev);
  287. struct lpass_variant *v = drvdata->variant;
  288. int i;
  289. for (i = 0; i < v->i2s_ports; ++i)
  290. if (reg == LPAIF_I2SCTL_REG(v, i))
  291. return true;
  292. for (i = 0; i < v->irq_ports; ++i) {
  293. if (reg == LPAIF_IRQEN_REG(v, i))
  294. return true;
  295. if (reg == LPAIF_IRQCLEAR_REG(v, i))
  296. return true;
  297. }
  298. for (i = 0; i < v->rdma_channels; ++i) {
  299. if (reg == LPAIF_RDMACTL_REG(v, i))
  300. return true;
  301. if (reg == LPAIF_RDMABASE_REG(v, i))
  302. return true;
  303. if (reg == LPAIF_RDMABUFF_REG(v, i))
  304. return true;
  305. if (reg == LPAIF_RDMAPER_REG(v, i))
  306. return true;
  307. }
  308. for (i = 0; i < v->wrdma_channels; ++i) {
  309. if (reg == LPAIF_WRDMACTL_REG(v, i + v->wrdma_channel_start))
  310. return true;
  311. if (reg == LPAIF_WRDMABASE_REG(v, i + v->wrdma_channel_start))
  312. return true;
  313. if (reg == LPAIF_WRDMABUFF_REG(v, i + v->wrdma_channel_start))
  314. return true;
  315. if (reg == LPAIF_WRDMAPER_REG(v, i + v->wrdma_channel_start))
  316. return true;
  317. }
  318. return false;
  319. }
  320. static bool lpass_cpu_regmap_readable(struct device *dev, unsigned int reg)
  321. {
  322. struct lpass_data *drvdata = dev_get_drvdata(dev);
  323. struct lpass_variant *v = drvdata->variant;
  324. int i;
  325. for (i = 0; i < v->i2s_ports; ++i)
  326. if (reg == LPAIF_I2SCTL_REG(v, i))
  327. return true;
  328. for (i = 0; i < v->irq_ports; ++i) {
  329. if (reg == LPAIF_IRQEN_REG(v, i))
  330. return true;
  331. if (reg == LPAIF_IRQSTAT_REG(v, i))
  332. return true;
  333. }
  334. for (i = 0; i < v->rdma_channels; ++i) {
  335. if (reg == LPAIF_RDMACTL_REG(v, i))
  336. return true;
  337. if (reg == LPAIF_RDMABASE_REG(v, i))
  338. return true;
  339. if (reg == LPAIF_RDMABUFF_REG(v, i))
  340. return true;
  341. if (reg == LPAIF_RDMACURR_REG(v, i))
  342. return true;
  343. if (reg == LPAIF_RDMAPER_REG(v, i))
  344. return true;
  345. }
  346. for (i = 0; i < v->wrdma_channels; ++i) {
  347. if (reg == LPAIF_WRDMACTL_REG(v, i + v->wrdma_channel_start))
  348. return true;
  349. if (reg == LPAIF_WRDMABASE_REG(v, i + v->wrdma_channel_start))
  350. return true;
  351. if (reg == LPAIF_WRDMABUFF_REG(v, i + v->wrdma_channel_start))
  352. return true;
  353. if (reg == LPAIF_WRDMACURR_REG(v, i + v->wrdma_channel_start))
  354. return true;
  355. if (reg == LPAIF_WRDMAPER_REG(v, i + v->wrdma_channel_start))
  356. return true;
  357. }
  358. return false;
  359. }
  360. static bool lpass_cpu_regmap_volatile(struct device *dev, unsigned int reg)
  361. {
  362. struct lpass_data *drvdata = dev_get_drvdata(dev);
  363. struct lpass_variant *v = drvdata->variant;
  364. int i;
  365. for (i = 0; i < v->irq_ports; ++i)
  366. if (reg == LPAIF_IRQSTAT_REG(v, i))
  367. return true;
  368. for (i = 0; i < v->rdma_channels; ++i)
  369. if (reg == LPAIF_RDMACURR_REG(v, i))
  370. return true;
  371. for (i = 0; i < v->wrdma_channels; ++i)
  372. if (reg == LPAIF_WRDMACURR_REG(v, i + v->wrdma_channel_start))
  373. return true;
  374. return false;
  375. }
  376. static struct regmap_config lpass_cpu_regmap_config = {
  377. .reg_bits = 32,
  378. .reg_stride = 4,
  379. .val_bits = 32,
  380. .writeable_reg = lpass_cpu_regmap_writeable,
  381. .readable_reg = lpass_cpu_regmap_readable,
  382. .volatile_reg = lpass_cpu_regmap_volatile,
  383. .cache_type = REGCACHE_FLAT,
  384. };
  385. int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
  386. {
  387. struct lpass_data *drvdata;
  388. struct device_node *dsp_of_node;
  389. struct resource *res;
  390. struct lpass_variant *variant;
  391. struct device *dev = &pdev->dev;
  392. const struct of_device_id *match;
  393. char clk_name[16];
  394. int ret, i, dai_id;
  395. dsp_of_node = of_parse_phandle(pdev->dev.of_node, "qcom,adsp", 0);
  396. if (dsp_of_node) {
  397. dev_err(&pdev->dev, "%s() DSP exists and holds audio resources\n",
  398. __func__);
  399. return -EBUSY;
  400. }
  401. drvdata = devm_kzalloc(&pdev->dev, sizeof(struct lpass_data),
  402. GFP_KERNEL);
  403. if (!drvdata)
  404. return -ENOMEM;
  405. platform_set_drvdata(pdev, drvdata);
  406. match = of_match_device(dev->driver->of_match_table, dev);
  407. if (!match || !match->data)
  408. return -EINVAL;
  409. drvdata->variant = (struct lpass_variant *)match->data;
  410. variant = drvdata->variant;
  411. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpass-lpaif");
  412. drvdata->lpaif = devm_ioremap_resource(&pdev->dev, res);
  413. if (IS_ERR((void const __force *)drvdata->lpaif)) {
  414. dev_err(&pdev->dev, "%s() error mapping reg resource: %ld\n",
  415. __func__,
  416. PTR_ERR((void const __force *)drvdata->lpaif));
  417. return PTR_ERR((void const __force *)drvdata->lpaif);
  418. }
  419. lpass_cpu_regmap_config.max_register = LPAIF_WRDMAPER_REG(variant,
  420. variant->wrdma_channels +
  421. variant->wrdma_channel_start);
  422. drvdata->lpaif_map = devm_regmap_init_mmio(&pdev->dev, drvdata->lpaif,
  423. &lpass_cpu_regmap_config);
  424. if (IS_ERR(drvdata->lpaif_map)) {
  425. dev_err(&pdev->dev, "%s() error initializing regmap: %ld\n",
  426. __func__, PTR_ERR(drvdata->lpaif_map));
  427. return PTR_ERR(drvdata->lpaif_map);
  428. }
  429. if (variant->init)
  430. variant->init(pdev);
  431. for (i = 0; i < variant->num_dai; i++) {
  432. dai_id = variant->dai_driver[i].id;
  433. if (variant->num_dai > 1)
  434. sprintf(clk_name, "mi2s-osr-clk%d", i);
  435. else
  436. sprintf(clk_name, "mi2s-osr-clk");
  437. drvdata->mi2s_osr_clk[dai_id] = devm_clk_get(&pdev->dev,
  438. clk_name);
  439. if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) {
  440. dev_warn(&pdev->dev,
  441. "%s() error getting mi2s-osr-clk: %ld\n",
  442. __func__,
  443. PTR_ERR(drvdata->mi2s_osr_clk[dai_id]));
  444. }
  445. if (variant->num_dai > 1)
  446. sprintf(clk_name, "mi2s-bit-clk%d", i);
  447. else
  448. sprintf(clk_name, "mi2s-bit-clk");
  449. drvdata->mi2s_bit_clk[dai_id] = devm_clk_get(&pdev->dev,
  450. clk_name);
  451. if (IS_ERR(drvdata->mi2s_bit_clk[dai_id])) {
  452. dev_err(&pdev->dev,
  453. "%s() error getting mi2s-bit-clk: %ld\n",
  454. __func__,
  455. PTR_ERR(drvdata->mi2s_bit_clk[dai_id]));
  456. return PTR_ERR(drvdata->mi2s_bit_clk[dai_id]);
  457. }
  458. }
  459. drvdata->ahbix_clk = devm_clk_get(&pdev->dev, "ahbix-clk");
  460. if (IS_ERR(drvdata->ahbix_clk)) {
  461. dev_err(&pdev->dev, "%s() error getting ahbix-clk: %ld\n",
  462. __func__, PTR_ERR(drvdata->ahbix_clk));
  463. return PTR_ERR(drvdata->ahbix_clk);
  464. }
  465. ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY);
  466. if (ret) {
  467. dev_err(&pdev->dev, "%s() error setting rate on ahbix_clk: %d\n",
  468. __func__, ret);
  469. return ret;
  470. }
  471. dev_dbg(&pdev->dev, "%s() set ahbix_clk rate to %lu\n", __func__,
  472. clk_get_rate(drvdata->ahbix_clk));
  473. ret = clk_prepare_enable(drvdata->ahbix_clk);
  474. if (ret) {
  475. dev_err(&pdev->dev, "%s() error enabling ahbix_clk: %d\n",
  476. __func__, ret);
  477. return ret;
  478. }
  479. ret = devm_snd_soc_register_component(&pdev->dev,
  480. &lpass_cpu_comp_driver,
  481. variant->dai_driver,
  482. variant->num_dai);
  483. if (ret) {
  484. dev_err(&pdev->dev, "%s() error registering cpu driver: %d\n",
  485. __func__, ret);
  486. goto err_clk;
  487. }
  488. ret = asoc_qcom_lpass_platform_register(pdev);
  489. if (ret) {
  490. dev_err(&pdev->dev, "%s() error registering platform driver: %d\n",
  491. __func__, ret);
  492. goto err_clk;
  493. }
  494. return 0;
  495. err_clk:
  496. clk_disable_unprepare(drvdata->ahbix_clk);
  497. return ret;
  498. }
  499. EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_platform_probe);
  500. int asoc_qcom_lpass_cpu_platform_remove(struct platform_device *pdev)
  501. {
  502. struct lpass_data *drvdata = platform_get_drvdata(pdev);
  503. if (drvdata->variant->exit)
  504. drvdata->variant->exit(pdev);
  505. clk_disable_unprepare(drvdata->ahbix_clk);
  506. return 0;
  507. }
  508. EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_platform_remove);
  509. MODULE_DESCRIPTION("QTi LPASS CPU Driver");
  510. MODULE_LICENSE("GPL v2");