bolero-cdc.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/of_platform.h>
  5. #include <linux/module.h>
  6. #include <linux/io.h>
  7. #include <linux/init.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/printk.h>
  10. #include <linux/delay.h>
  11. #include <linux/kernel.h>
  12. #include <linux/clk.h>
  13. #include <soc/snd_event.h>
  14. #include <linux/pm_runtime.h>
  15. #include <soc/swr-common.h>
  16. #include "bolero-cdc.h"
  17. #include "internal.h"
  18. #include "bolero-clk-rsc.h"
  19. #define DRV_NAME "bolero_codec"
  20. #define BOLERO_VERSION_1_0 0x0001
  21. #define BOLERO_VERSION_1_1 0x0002
  22. #define BOLERO_VERSION_1_2 0x0003
  23. #define BOLERO_VERSION_ENTRY_SIZE 32
  24. #define BOLERO_CDC_STRING_LEN 80
  25. static const struct snd_soc_component_driver bolero;
  26. /* pm runtime auto suspend timer in msecs */
  27. #define BOLERO_AUTO_SUSPEND_DELAY 100 /* delay in msec */
  28. /* MCLK_MUX table for all macros */
  29. static u16 bolero_mclk_mux_tbl[MAX_MACRO][MCLK_MUX_MAX] = {
  30. {TX_MACRO, VA_MACRO},
  31. {TX_MACRO, RX_MACRO},
  32. {TX_MACRO, WSA_MACRO},
  33. {TX_MACRO, VA_MACRO},
  34. };
  35. static bool bolero_is_valid_codec_dev(struct device *dev);
  36. int bolero_set_port_map(struct snd_soc_component *component,
  37. u32 size, void *data)
  38. {
  39. struct bolero_priv *priv = NULL;
  40. struct swr_mstr_port_map *map = NULL;
  41. u16 idx;
  42. if (!component || (size == 0) || !data)
  43. return -EINVAL;
  44. priv = snd_soc_component_get_drvdata(component);
  45. if (!priv)
  46. return -EINVAL;
  47. if (!bolero_is_valid_codec_dev(priv->dev)) {
  48. dev_err(priv->dev, "%s: invalid codec\n", __func__);
  49. return -EINVAL;
  50. }
  51. map = (struct swr_mstr_port_map *)data;
  52. for (idx = 0; idx < size; idx++) {
  53. if (priv->macro_params[map->id].set_port_map)
  54. priv->macro_params[map->id].set_port_map(component,
  55. map->uc,
  56. SWR_MSTR_PORT_LEN,
  57. map->swr_port_params);
  58. map += 1;
  59. }
  60. return 0;
  61. }
  62. EXPORT_SYMBOL(bolero_set_port_map);
  63. static void bolero_ahb_write_device(char __iomem *io_base,
  64. u16 reg, u8 value)
  65. {
  66. u32 temp = (u32)(value) & 0x000000FF;
  67. iowrite32(temp, io_base + reg);
  68. }
  69. static void bolero_ahb_read_device(char __iomem *io_base,
  70. u16 reg, u8 *value)
  71. {
  72. u32 temp;
  73. temp = ioread32(io_base + reg);
  74. *value = (u8)temp;
  75. }
  76. static int __bolero_reg_read(struct bolero_priv *priv,
  77. u16 macro_id, u16 reg, u8 *val)
  78. {
  79. int ret = 0;
  80. mutex_lock(&priv->clk_lock);
  81. if (!priv->dev_up) {
  82. dev_dbg_ratelimited(priv->dev,
  83. "%s: SSR in progress, exit\n", __func__);
  84. ret = -EINVAL;
  85. goto ssr_err;
  86. }
  87. if (priv->macro_params[VA_MACRO].dev)
  88. pm_runtime_get_sync(priv->macro_params[VA_MACRO].dev);
  89. /* Request Clk before register access */
  90. ret = bolero_clk_rsc_request_clock(priv->macro_params[macro_id].dev,
  91. priv->macro_params[macro_id].default_clk_id,
  92. priv->macro_params[macro_id].clk_id_req,
  93. true);
  94. if (ret < 0) {
  95. dev_err_ratelimited(priv->dev,
  96. "%s: Failed to enable clock, ret:%d\n", __func__, ret);
  97. goto err;
  98. }
  99. bolero_ahb_read_device(
  100. priv->macro_params[macro_id].io_base, reg, val);
  101. bolero_clk_rsc_request_clock(priv->macro_params[macro_id].dev,
  102. priv->macro_params[macro_id].default_clk_id,
  103. priv->macro_params[macro_id].clk_id_req,
  104. false);
  105. err:
  106. if (priv->macro_params[VA_MACRO].dev) {
  107. pm_runtime_mark_last_busy(priv->macro_params[VA_MACRO].dev);
  108. pm_runtime_put_autosuspend(priv->macro_params[VA_MACRO].dev);
  109. }
  110. ssr_err:
  111. mutex_unlock(&priv->clk_lock);
  112. return ret;
  113. }
  114. static int __bolero_reg_write(struct bolero_priv *priv,
  115. u16 macro_id, u16 reg, u8 val)
  116. {
  117. int ret = 0;
  118. mutex_lock(&priv->clk_lock);
  119. if (!priv->dev_up) {
  120. dev_dbg_ratelimited(priv->dev,
  121. "%s: SSR in progress, exit\n", __func__);
  122. ret = -EINVAL;
  123. goto ssr_err;
  124. }
  125. if (priv->macro_params[VA_MACRO].dev)
  126. pm_runtime_get_sync(priv->macro_params[VA_MACRO].dev);
  127. /* Request Clk before register access */
  128. ret = bolero_clk_rsc_request_clock(priv->macro_params[macro_id].dev,
  129. priv->macro_params[macro_id].default_clk_id,
  130. priv->macro_params[macro_id].clk_id_req,
  131. true);
  132. if (ret < 0) {
  133. dev_err_ratelimited(priv->dev,
  134. "%s: Failed to enable clock, ret:%d\n", __func__, ret);
  135. goto err;
  136. }
  137. bolero_ahb_write_device(
  138. priv->macro_params[macro_id].io_base, reg, val);
  139. bolero_clk_rsc_request_clock(priv->macro_params[macro_id].dev,
  140. priv->macro_params[macro_id].default_clk_id,
  141. priv->macro_params[macro_id].clk_id_req,
  142. false);
  143. err:
  144. if (priv->macro_params[VA_MACRO].dev) {
  145. pm_runtime_mark_last_busy(priv->macro_params[VA_MACRO].dev);
  146. pm_runtime_put_autosuspend(priv->macro_params[VA_MACRO].dev);
  147. }
  148. ssr_err:
  149. mutex_unlock(&priv->clk_lock);
  150. return ret;
  151. }
  152. static int bolero_cdc_update_wcd_event(void *handle, u16 event, u32 data)
  153. {
  154. struct bolero_priv *priv = (struct bolero_priv *)handle;
  155. if (!priv) {
  156. pr_err("%s:Invalid bolero priv handle\n", __func__);
  157. return -EINVAL;
  158. }
  159. switch (event) {
  160. case WCD_BOLERO_EVT_RX_MUTE:
  161. if (priv->macro_params[RX_MACRO].event_handler)
  162. priv->macro_params[RX_MACRO].event_handler(
  163. priv->component,
  164. BOLERO_MACRO_EVT_RX_MUTE, data);
  165. break;
  166. case WCD_BOLERO_EVT_IMPED_TRUE:
  167. if (priv->macro_params[RX_MACRO].event_handler)
  168. priv->macro_params[RX_MACRO].event_handler(
  169. priv->component,
  170. BOLERO_MACRO_EVT_IMPED_TRUE, data);
  171. break;
  172. case WCD_BOLERO_EVT_IMPED_FALSE:
  173. if (priv->macro_params[RX_MACRO].event_handler)
  174. priv->macro_params[RX_MACRO].event_handler(
  175. priv->component,
  176. BOLERO_MACRO_EVT_IMPED_FALSE, data);
  177. break;
  178. case WCD_BOLERO_EVT_RX_COMPANDER_SOFT_RST:
  179. if (priv->macro_params[RX_MACRO].event_handler)
  180. priv->macro_params[RX_MACRO].event_handler(
  181. priv->component,
  182. BOLERO_MACRO_EVT_RX_COMPANDER_SOFT_RST, data);
  183. break;
  184. case WCD_BOLERO_EVT_BCS_CLK_OFF:
  185. if (priv->macro_params[TX_MACRO].event_handler)
  186. priv->macro_params[TX_MACRO].event_handler(
  187. priv->component,
  188. BOLERO_MACRO_EVT_BCS_CLK_OFF, data);
  189. break;
  190. default:
  191. dev_err(priv->dev, "%s: Invalid event %d trigger from wcd\n",
  192. __func__, event);
  193. return -EINVAL;
  194. }
  195. return 0;
  196. }
  197. static int bolero_cdc_register_notifier(void *handle,
  198. struct notifier_block *nblock,
  199. bool enable)
  200. {
  201. struct bolero_priv *priv = (struct bolero_priv *)handle;
  202. if (!priv) {
  203. pr_err("%s: bolero priv is null\n", __func__);
  204. return -EINVAL;
  205. }
  206. if (enable)
  207. return blocking_notifier_chain_register(&priv->notifier,
  208. nblock);
  209. return blocking_notifier_chain_unregister(&priv->notifier,
  210. nblock);
  211. }
  212. static void bolero_cdc_notifier_call(struct bolero_priv *priv,
  213. u32 data)
  214. {
  215. dev_dbg(priv->dev, "%s: notifier call, data:%d\n", __func__, data);
  216. blocking_notifier_call_chain(&priv->notifier,
  217. data, (void *)priv->wcd_dev);
  218. }
  219. static bool bolero_is_valid_child_dev(struct device *dev)
  220. {
  221. if (of_device_is_compatible(dev->parent->of_node, "qcom,bolero-codec"))
  222. return true;
  223. return false;
  224. }
  225. static bool bolero_is_valid_codec_dev(struct device *dev)
  226. {
  227. if (of_device_is_compatible(dev->of_node, "qcom,bolero-codec"))
  228. return true;
  229. return false;
  230. }
  231. /**
  232. * bolero_clear_amic_tx_hold - clears AMIC register on analog codec
  233. *
  234. * @dev: bolero device ptr.
  235. *
  236. */
  237. void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
  238. {
  239. struct bolero_priv *priv;
  240. u16 event;
  241. u16 amic = 0;
  242. if (!dev) {
  243. pr_err("%s: dev is null\n", __func__);
  244. return;
  245. }
  246. if (!bolero_is_valid_codec_dev(dev)) {
  247. pr_err("%s: invalid codec\n", __func__);
  248. return;
  249. }
  250. priv = dev_get_drvdata(dev);
  251. if (!priv) {
  252. dev_err(dev, "%s: priv is null\n", __func__);
  253. return;
  254. }
  255. event = BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR;
  256. if (adc_n == BOLERO_ADC0)
  257. amic = 0x1;
  258. else if (adc_n == BOLERO_ADC1)
  259. amic = 0x2;
  260. else if (adc_n == BOLERO_ADC2)
  261. amic = 0x2;
  262. else if (adc_n == BOLERO_ADC3)
  263. amic = 0x3;
  264. else
  265. return;
  266. bolero_cdc_notifier_call(priv, (amic << 0x10 | event));
  267. }
  268. EXPORT_SYMBOL(bolero_clear_amic_tx_hold);
  269. /**
  270. * bolero_get_device_ptr - Get child or macro device ptr
  271. *
  272. * @dev: bolero device ptr.
  273. * @macro_id: ID of macro calling this API.
  274. *
  275. * Returns dev ptr on success or NULL on error.
  276. */
  277. struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id)
  278. {
  279. struct bolero_priv *priv;
  280. if (!dev) {
  281. pr_err("%s: dev is null\n", __func__);
  282. return NULL;
  283. }
  284. if (!bolero_is_valid_codec_dev(dev)) {
  285. pr_err("%s: invalid codec\n", __func__);
  286. return NULL;
  287. }
  288. priv = dev_get_drvdata(dev);
  289. if (!priv || (macro_id >= MAX_MACRO)) {
  290. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  291. return NULL;
  292. }
  293. return priv->macro_params[macro_id].dev;
  294. }
  295. EXPORT_SYMBOL(bolero_get_device_ptr);
  296. /**
  297. * bolero_get_rsc_clk_device_ptr - Get rsc clk device ptr
  298. *
  299. * @dev: bolero device ptr.
  300. *
  301. * Returns dev ptr on success or NULL on error.
  302. */
  303. struct device *bolero_get_rsc_clk_device_ptr(struct device *dev)
  304. {
  305. struct bolero_priv *priv;
  306. if (!dev) {
  307. pr_err("%s: dev is null\n", __func__);
  308. return NULL;
  309. }
  310. if (!bolero_is_valid_codec_dev(dev)) {
  311. pr_err("%s: invalid codec\n", __func__);
  312. return NULL;
  313. }
  314. priv = dev_get_drvdata(dev);
  315. if (!priv) {
  316. dev_err(dev, "%s: priv is null\n", __func__);
  317. return NULL;
  318. }
  319. return priv->clk_dev;
  320. }
  321. EXPORT_SYMBOL(bolero_get_rsc_clk_device_ptr);
  322. static int bolero_copy_dais_from_macro(struct bolero_priv *priv)
  323. {
  324. struct snd_soc_dai_driver *dai_ptr;
  325. u16 macro_idx;
  326. /* memcpy into bolero_dais all macro dais */
  327. if (!priv->bolero_dais)
  328. priv->bolero_dais = devm_kzalloc(priv->dev,
  329. priv->num_dais *
  330. sizeof(
  331. struct snd_soc_dai_driver),
  332. GFP_KERNEL);
  333. if (!priv->bolero_dais)
  334. return -ENOMEM;
  335. dai_ptr = priv->bolero_dais;
  336. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  337. if (priv->macro_params[macro_idx].dai_ptr) {
  338. memcpy(dai_ptr,
  339. priv->macro_params[macro_idx].dai_ptr,
  340. priv->macro_params[macro_idx].num_dais *
  341. sizeof(struct snd_soc_dai_driver));
  342. dai_ptr += priv->macro_params[macro_idx].num_dais;
  343. }
  344. }
  345. return 0;
  346. }
  347. /**
  348. * bolero_register_res_clk - Registers rsc clk driver to bolero
  349. *
  350. * @dev: rsc clk device ptr.
  351. * @rsc_clk_cb: event handler callback for notifications like SSR
  352. *
  353. * Returns 0 on success or -EINVAL on error.
  354. */
  355. int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t rsc_clk_cb)
  356. {
  357. struct bolero_priv *priv;
  358. if (!dev || !rsc_clk_cb) {
  359. pr_err("%s: dev or rsc_clk_cb is null\n", __func__);
  360. return -EINVAL;
  361. }
  362. if (!bolero_is_valid_child_dev(dev)) {
  363. dev_err(dev, "%s: child device :%pK not added yet\n",
  364. __func__, dev);
  365. return -EINVAL;
  366. }
  367. priv = dev_get_drvdata(dev->parent);
  368. if (!priv) {
  369. dev_err(dev, "%s: priv is null\n", __func__);
  370. return -EINVAL;
  371. }
  372. priv->clk_dev = dev;
  373. priv->rsc_clk_cb = rsc_clk_cb;
  374. return 0;
  375. }
  376. EXPORT_SYMBOL(bolero_register_res_clk);
  377. /**
  378. * bolero_unregister_res_clk - Unregisters rsc clk driver from bolero
  379. *
  380. * @dev: resource clk device ptr.
  381. */
  382. void bolero_unregister_res_clk(struct device *dev)
  383. {
  384. struct bolero_priv *priv;
  385. if (!dev) {
  386. pr_err("%s: dev is NULL\n", __func__);
  387. return;
  388. }
  389. if (!bolero_is_valid_child_dev(dev)) {
  390. dev_err(dev, "%s: child device :%pK not added\n",
  391. __func__, dev);
  392. return;
  393. }
  394. priv = dev_get_drvdata(dev->parent);
  395. if (!priv) {
  396. dev_err(dev, "%s: priv is null\n", __func__);
  397. return;
  398. }
  399. priv->clk_dev = NULL;
  400. priv->rsc_clk_cb = NULL;
  401. }
  402. EXPORT_SYMBOL(bolero_unregister_res_clk);
  403. /**
  404. * bolero_register_macro - Registers macro to bolero
  405. *
  406. * @dev: macro device ptr.
  407. * @macro_id: ID of macro calling this API.
  408. * @ops: macro params to register.
  409. *
  410. * Returns 0 on success or -EINVAL on error.
  411. */
  412. int bolero_register_macro(struct device *dev, u16 macro_id,
  413. struct macro_ops *ops)
  414. {
  415. struct bolero_priv *priv;
  416. int ret = -EINVAL;
  417. if (!dev || !ops) {
  418. pr_err("%s: dev or ops is null\n", __func__);
  419. return -EINVAL;
  420. }
  421. if (!bolero_is_valid_child_dev(dev)) {
  422. dev_err(dev, "%s: child device for macro:%d not added yet\n",
  423. __func__, macro_id);
  424. return -EINVAL;
  425. }
  426. priv = dev_get_drvdata(dev->parent);
  427. if (!priv || (macro_id >= MAX_MACRO)) {
  428. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  429. return -EINVAL;
  430. }
  431. priv->macro_params[macro_id].clk_id_req = ops->clk_id_req;
  432. priv->macro_params[macro_id].default_clk_id = ops->default_clk_id;
  433. priv->macro_params[macro_id].init = ops->init;
  434. priv->macro_params[macro_id].exit = ops->exit;
  435. priv->macro_params[macro_id].io_base = ops->io_base;
  436. priv->macro_params[macro_id].num_dais = ops->num_dais;
  437. priv->macro_params[macro_id].dai_ptr = ops->dai_ptr;
  438. priv->macro_params[macro_id].event_handler = ops->event_handler;
  439. priv->macro_params[macro_id].set_port_map = ops->set_port_map;
  440. priv->macro_params[macro_id].dev = dev;
  441. priv->current_mclk_mux_macro[macro_id] =
  442. bolero_mclk_mux_tbl[macro_id][MCLK_MUX0];
  443. if (macro_id == TX_MACRO) {
  444. priv->macro_params[macro_id].reg_wake_irq = ops->reg_wake_irq;
  445. priv->macro_params[macro_id].clk_switch = ops->clk_switch;
  446. priv->macro_params[macro_id].reg_evt_listener =
  447. ops->reg_evt_listener;
  448. }
  449. priv->num_dais += ops->num_dais;
  450. priv->num_macros_registered++;
  451. priv->macros_supported[macro_id] = true;
  452. if (priv->num_macros_registered == priv->num_macros) {
  453. ret = bolero_copy_dais_from_macro(priv);
  454. if (ret < 0) {
  455. dev_err(dev, "%s: copy_dais failed\n", __func__);
  456. return ret;
  457. }
  458. if (priv->macros_supported[TX_MACRO] == false) {
  459. bolero_mclk_mux_tbl[WSA_MACRO][MCLK_MUX0] = WSA_MACRO;
  460. priv->current_mclk_mux_macro[WSA_MACRO] = WSA_MACRO;
  461. bolero_mclk_mux_tbl[VA_MACRO][MCLK_MUX0] = VA_MACRO;
  462. priv->current_mclk_mux_macro[VA_MACRO] = VA_MACRO;
  463. }
  464. ret = snd_soc_register_component(dev->parent, &bolero,
  465. priv->bolero_dais, priv->num_dais);
  466. if (ret < 0) {
  467. dev_err(dev, "%s: register codec failed\n", __func__);
  468. return ret;
  469. }
  470. }
  471. return 0;
  472. }
  473. EXPORT_SYMBOL(bolero_register_macro);
  474. /**
  475. * bolero_unregister_macro - De-Register macro from bolero
  476. *
  477. * @dev: macro device ptr.
  478. * @macro_id: ID of macro calling this API.
  479. *
  480. */
  481. void bolero_unregister_macro(struct device *dev, u16 macro_id)
  482. {
  483. struct bolero_priv *priv;
  484. if (!dev) {
  485. pr_err("%s: dev is null\n", __func__);
  486. return;
  487. }
  488. if (!bolero_is_valid_child_dev(dev)) {
  489. dev_err(dev, "%s: macro:%d not in valid registered macro-list\n",
  490. __func__, macro_id);
  491. return;
  492. }
  493. priv = dev_get_drvdata(dev->parent);
  494. if (!priv || (macro_id >= MAX_MACRO)) {
  495. dev_err(dev, "%s: priv is null or invalid macro\n", __func__);
  496. return;
  497. }
  498. priv->macro_params[macro_id].init = NULL;
  499. priv->macro_params[macro_id].num_dais = 0;
  500. priv->macro_params[macro_id].dai_ptr = NULL;
  501. priv->macro_params[macro_id].event_handler = NULL;
  502. priv->macro_params[macro_id].dev = NULL;
  503. if (macro_id == TX_MACRO) {
  504. priv->macro_params[macro_id].reg_wake_irq = NULL;
  505. priv->macro_params[macro_id].clk_switch = NULL;
  506. priv->macro_params[macro_id].reg_evt_listener = NULL;
  507. }
  508. priv->num_dais -= priv->macro_params[macro_id].num_dais;
  509. priv->num_macros_registered--;
  510. /* UNREGISTER CODEC HERE */
  511. if (priv->num_macros - 1 == priv->num_macros_registered)
  512. snd_soc_unregister_component(dev->parent);
  513. }
  514. EXPORT_SYMBOL(bolero_unregister_macro);
  515. void bolero_wsa_pa_on(struct device *dev)
  516. {
  517. struct bolero_priv *priv;
  518. if (!dev) {
  519. pr_err("%s: dev is null\n", __func__);
  520. return;
  521. }
  522. if (!bolero_is_valid_child_dev(dev)) {
  523. dev_err(dev, "%s: not a valid child dev\n",
  524. __func__);
  525. return;
  526. }
  527. priv = dev_get_drvdata(dev->parent);
  528. if (!priv) {
  529. dev_err(dev, "%s: priv is null\n", __func__);
  530. return;
  531. }
  532. bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_PA_ON_POST_FSCLK);
  533. }
  534. EXPORT_SYMBOL(bolero_wsa_pa_on);
  535. static ssize_t bolero_version_read(struct snd_info_entry *entry,
  536. void *file_private_data,
  537. struct file *file,
  538. char __user *buf, size_t count,
  539. loff_t pos)
  540. {
  541. struct bolero_priv *priv;
  542. char buffer[BOLERO_VERSION_ENTRY_SIZE];
  543. int len = 0;
  544. priv = (struct bolero_priv *) entry->private_data;
  545. if (!priv) {
  546. pr_err("%s: bolero priv is null\n", __func__);
  547. return -EINVAL;
  548. }
  549. switch (priv->version) {
  550. case BOLERO_VERSION_1_0:
  551. len = snprintf(buffer, sizeof(buffer), "BOLERO_1_0\n");
  552. break;
  553. case BOLERO_VERSION_1_1:
  554. len = snprintf(buffer, sizeof(buffer), "BOLERO_1_1\n");
  555. break;
  556. case BOLERO_VERSION_1_2:
  557. len = snprintf(buffer, sizeof(buffer), "BOLERO_1_2\n");
  558. break;
  559. default:
  560. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  561. }
  562. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  563. }
  564. static int bolero_ssr_enable(struct device *dev, void *data)
  565. {
  566. struct bolero_priv *priv = data;
  567. int macro_idx;
  568. if (priv->initial_boot) {
  569. priv->initial_boot = false;
  570. return 0;
  571. }
  572. if (priv->rsc_clk_cb)
  573. priv->rsc_clk_cb(priv->clk_dev, BOLERO_MACRO_EVT_SSR_UP);
  574. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  575. if (priv->macro_params[macro_idx].event_handler)
  576. priv->macro_params[macro_idx].event_handler(
  577. priv->component,
  578. BOLERO_MACRO_EVT_CLK_RESET, 0x0);
  579. }
  580. regcache_cache_only(priv->regmap, false);
  581. mutex_lock(&priv->clk_lock);
  582. priv->dev_up = true;
  583. mutex_unlock(&priv->clk_lock);
  584. regcache_mark_dirty(priv->regmap);
  585. regcache_sync(priv->regmap);
  586. /* call ssr event for supported macros */
  587. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  588. if (!priv->macro_params[macro_idx].event_handler)
  589. continue;
  590. priv->macro_params[macro_idx].event_handler(
  591. priv->component,
  592. BOLERO_MACRO_EVT_SSR_UP, 0x0);
  593. }
  594. bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_UP);
  595. return 0;
  596. }
  597. static void bolero_ssr_disable(struct device *dev, void *data)
  598. {
  599. struct bolero_priv *priv = data;
  600. int macro_idx;
  601. bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_PA_OFF_PRE_SSR);
  602. regcache_cache_only(priv->regmap, true);
  603. mutex_lock(&priv->clk_lock);
  604. priv->dev_up = false;
  605. mutex_unlock(&priv->clk_lock);
  606. if (priv->rsc_clk_cb)
  607. priv->rsc_clk_cb(priv->clk_dev, BOLERO_MACRO_EVT_SSR_DOWN);
  608. /* call ssr event for supported macros */
  609. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  610. if (!priv->macro_params[macro_idx].event_handler)
  611. continue;
  612. priv->macro_params[macro_idx].event_handler(
  613. priv->component,
  614. BOLERO_MACRO_EVT_SSR_DOWN, 0x0);
  615. }
  616. bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_DOWN);
  617. }
  618. static struct snd_info_entry_ops bolero_info_ops = {
  619. .read = bolero_version_read,
  620. };
  621. static const struct snd_event_ops bolero_ssr_ops = {
  622. .enable = bolero_ssr_enable,
  623. .disable = bolero_ssr_disable,
  624. };
  625. /*
  626. * bolero_info_create_codec_entry - creates bolero module
  627. * @codec_root: The parent directory
  628. * @component: Codec component instance
  629. *
  630. * Creates bolero module and version entry under the given
  631. * parent directory.
  632. *
  633. * Return: 0 on success or negative error code on failure.
  634. */
  635. int bolero_info_create_codec_entry(struct snd_info_entry *codec_root,
  636. struct snd_soc_component *component)
  637. {
  638. struct snd_info_entry *version_entry;
  639. struct bolero_priv *priv;
  640. struct snd_soc_card *card;
  641. if (!codec_root || !component)
  642. return -EINVAL;
  643. priv = snd_soc_component_get_drvdata(component);
  644. if (priv->entry) {
  645. dev_dbg(priv->dev,
  646. "%s:bolero module already created\n", __func__);
  647. return 0;
  648. }
  649. card = component->card;
  650. priv->entry = snd_info_create_subdir(codec_root->module,
  651. "bolero", codec_root);
  652. if (!priv->entry) {
  653. dev_dbg(component->dev, "%s: failed to create bolero entry\n",
  654. __func__);
  655. return -ENOMEM;
  656. }
  657. version_entry = snd_info_create_card_entry(card->snd_card,
  658. "version",
  659. priv->entry);
  660. if (!version_entry) {
  661. dev_err(component->dev, "%s: failed to create bolero version entry\n",
  662. __func__);
  663. return -ENOMEM;
  664. }
  665. version_entry->private_data = priv;
  666. version_entry->size = BOLERO_VERSION_ENTRY_SIZE;
  667. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  668. version_entry->c.ops = &bolero_info_ops;
  669. if (snd_info_register(version_entry) < 0) {
  670. snd_info_free_entry(version_entry);
  671. return -ENOMEM;
  672. }
  673. priv->version_entry = version_entry;
  674. return 0;
  675. }
  676. EXPORT_SYMBOL(bolero_info_create_codec_entry);
  677. /**
  678. * bolero_register_wake_irq - Register wake irq of Tx macro
  679. *
  680. * @component: codec component ptr.
  681. * @ipc_wakeup: bool to identify ipc_wakeup to be used or HW interrupt line.
  682. *
  683. * Return: 0 on success or negative error code on failure.
  684. */
  685. int bolero_register_wake_irq(struct snd_soc_component *component,
  686. u32 ipc_wakeup)
  687. {
  688. struct bolero_priv *priv = NULL;
  689. if (!component)
  690. return -EINVAL;
  691. priv = snd_soc_component_get_drvdata(component);
  692. if (!priv)
  693. return -EINVAL;
  694. if (!bolero_is_valid_codec_dev(priv->dev)) {
  695. dev_err(component->dev, "%s: invalid codec\n", __func__);
  696. return -EINVAL;
  697. }
  698. if (priv->macro_params[TX_MACRO].reg_wake_irq)
  699. priv->macro_params[TX_MACRO].reg_wake_irq(
  700. component, ipc_wakeup);
  701. return 0;
  702. }
  703. EXPORT_SYMBOL(bolero_register_wake_irq);
  704. /**
  705. * bolero_tx_clk_switch - Switch tx macro clock
  706. *
  707. * @component: pointer to codec component instance.
  708. *
  709. * Returns 0 on success or -EINVAL on error.
  710. */
  711. int bolero_tx_clk_switch(struct snd_soc_component *component)
  712. {
  713. struct bolero_priv *priv = NULL;
  714. int ret = 0;
  715. if (!component)
  716. return -EINVAL;
  717. priv = snd_soc_component_get_drvdata(component);
  718. if (!priv)
  719. return -EINVAL;
  720. if (!bolero_is_valid_codec_dev(priv->dev)) {
  721. dev_err(component->dev, "%s: invalid codec\n", __func__);
  722. return -EINVAL;
  723. }
  724. if (priv->macro_params[TX_MACRO].clk_switch)
  725. ret = priv->macro_params[TX_MACRO].clk_switch(component);
  726. return ret;
  727. }
  728. EXPORT_SYMBOL(bolero_tx_clk_switch);
  729. /**
  730. * bolero_register_event_listener - Register/Deregister to event listener
  731. *
  732. * @component: pointer to codec component instance.
  733. * @enable: when set to 1 registers to event listener otherwise, derigisters
  734. * from the event listener
  735. *
  736. * Returns 0 on success or -EINVAL on error.
  737. */
  738. int bolero_register_event_listener(struct snd_soc_component *component,
  739. bool enable)
  740. {
  741. struct bolero_priv *priv = NULL;
  742. int ret = 0;
  743. if (!component)
  744. return -EINVAL;
  745. priv = snd_soc_component_get_drvdata(component);
  746. if (!priv)
  747. return -EINVAL;
  748. if (!bolero_is_valid_codec_dev(priv->dev)) {
  749. dev_err(component->dev, "%s: invalid codec\n", __func__);
  750. return -EINVAL;
  751. }
  752. if (priv->macro_params[TX_MACRO].reg_evt_listener)
  753. ret = priv->macro_params[TX_MACRO].reg_evt_listener(component,
  754. enable);
  755. return ret;
  756. }
  757. EXPORT_SYMBOL(bolero_register_event_listener);
  758. static int bolero_soc_codec_probe(struct snd_soc_component *component)
  759. {
  760. struct bolero_priv *priv = dev_get_drvdata(component->dev);
  761. int macro_idx, ret = 0;
  762. snd_soc_component_init_regmap(component, priv->regmap);
  763. /* call init for supported macros */
  764. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) {
  765. if (priv->macro_params[macro_idx].init) {
  766. ret = priv->macro_params[macro_idx].init(component);
  767. if (ret < 0) {
  768. dev_err(component->dev,
  769. "%s: init for macro %d failed\n",
  770. __func__, macro_idx);
  771. goto err;
  772. }
  773. }
  774. }
  775. priv->component = component;
  776. /*
  777. * In order for the ADIE RTC to differentiate between targets
  778. * version info is used.
  779. * Assign 1.0 for target with only one macro
  780. * Assign 1.1 for target with two macros
  781. * Assign 1.2 for target with more than two macros
  782. */
  783. if (priv->num_macros_registered == 1)
  784. priv->version = BOLERO_VERSION_1_0;
  785. else if (priv->num_macros_registered == 2)
  786. priv->version = BOLERO_VERSION_1_1;
  787. else if (priv->num_macros_registered > 2)
  788. priv->version = BOLERO_VERSION_1_2;
  789. ret = snd_event_client_register(priv->dev, &bolero_ssr_ops, priv);
  790. if (!ret) {
  791. snd_event_notify(priv->dev, SND_EVENT_UP);
  792. } else {
  793. dev_err(component->dev,
  794. "%s: Registration with SND event FWK failed ret = %d\n",
  795. __func__, ret);
  796. goto err;
  797. }
  798. dev_dbg(component->dev, "%s: bolero soc codec probe success\n",
  799. __func__);
  800. err:
  801. return ret;
  802. }
  803. static void bolero_soc_codec_remove(struct snd_soc_component *component)
  804. {
  805. struct bolero_priv *priv = dev_get_drvdata(component->dev);
  806. int macro_idx;
  807. snd_event_client_deregister(priv->dev);
  808. /* call exit for supported macros */
  809. for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++)
  810. if (priv->macro_params[macro_idx].exit)
  811. priv->macro_params[macro_idx].exit(component);
  812. return;
  813. }
  814. static const struct snd_soc_component_driver bolero = {
  815. .name = DRV_NAME,
  816. .probe = bolero_soc_codec_probe,
  817. .remove = bolero_soc_codec_remove,
  818. };
  819. static void bolero_add_child_devices(struct work_struct *work)
  820. {
  821. struct bolero_priv *priv;
  822. bool split_codec = false;
  823. struct platform_device *pdev;
  824. struct device_node *node;
  825. int ret = 0, count = 0;
  826. struct wcd_ctrl_platform_data *platdata = NULL;
  827. char plat_dev_name[BOLERO_CDC_STRING_LEN] = "";
  828. priv = container_of(work, struct bolero_priv,
  829. bolero_add_child_devices_work);
  830. if (!priv) {
  831. pr_err("%s: Memory for bolero priv does not exist\n",
  832. __func__);
  833. return;
  834. }
  835. if (!priv->dev || !priv->dev->of_node) {
  836. dev_err(priv->dev, "%s: DT node for bolero does not exist\n",
  837. __func__);
  838. return;
  839. }
  840. platdata = &priv->plat_data;
  841. priv->child_count = 0;
  842. for_each_available_child_of_node(priv->dev->of_node, node) {
  843. split_codec = false;
  844. if (of_find_property(node, "qcom,split-codec", NULL)) {
  845. split_codec = true;
  846. dev_dbg(priv->dev, "%s: split codec slave exists\n",
  847. __func__);
  848. }
  849. strlcpy(plat_dev_name, node->name,
  850. (BOLERO_CDC_STRING_LEN - 1));
  851. pdev = platform_device_alloc(plat_dev_name, -1);
  852. if (!pdev) {
  853. dev_err(priv->dev, "%s: pdev memory alloc failed\n",
  854. __func__);
  855. ret = -ENOMEM;
  856. goto err;
  857. }
  858. pdev->dev.parent = priv->dev;
  859. pdev->dev.of_node = node;
  860. if (split_codec) {
  861. priv->dev->platform_data = platdata;
  862. priv->wcd_dev = &pdev->dev;
  863. }
  864. ret = platform_device_add(pdev);
  865. if (ret) {
  866. dev_err(&pdev->dev,
  867. "%s: Cannot add platform device\n",
  868. __func__);
  869. platform_device_put(pdev);
  870. goto fail_pdev_add;
  871. }
  872. if (priv->child_count < BOLERO_CDC_CHILD_DEVICES_MAX)
  873. priv->pdev_child_devices[priv->child_count++] = pdev;
  874. else
  875. goto err;
  876. }
  877. return;
  878. fail_pdev_add:
  879. for (count = 0; count < priv->child_count; count++)
  880. platform_device_put(priv->pdev_child_devices[count]);
  881. err:
  882. return;
  883. }
  884. static int bolero_probe(struct platform_device *pdev)
  885. {
  886. struct bolero_priv *priv;
  887. u32 num_macros = 0;
  888. int ret;
  889. struct clk *lpass_core_hw_vote = NULL;
  890. struct clk *lpass_audio_hw_vote = NULL;
  891. priv = devm_kzalloc(&pdev->dev, sizeof(struct bolero_priv),
  892. GFP_KERNEL);
  893. if (!priv)
  894. return -ENOMEM;
  895. ret = of_property_read_u32(pdev->dev.of_node, "qcom,num-macros",
  896. &num_macros);
  897. if (ret) {
  898. dev_err(&pdev->dev,
  899. "%s:num-macros property not found\n",
  900. __func__);
  901. return ret;
  902. }
  903. priv->num_macros = num_macros;
  904. if (priv->num_macros > MAX_MACRO) {
  905. dev_err(&pdev->dev,
  906. "%s:num_macros(%d) > MAX_MACRO(%d) than supported\n",
  907. __func__, priv->num_macros, MAX_MACRO);
  908. return -EINVAL;
  909. }
  910. priv->va_without_decimation = of_property_read_bool(pdev->dev.of_node,
  911. "qcom,va-without-decimation");
  912. if (priv->va_without_decimation)
  913. bolero_reg_access[VA_MACRO] = bolero_va_top_reg_access;
  914. priv->dev = &pdev->dev;
  915. priv->dev_up = true;
  916. priv->initial_boot = true;
  917. priv->regmap = bolero_regmap_init(priv->dev,
  918. &bolero_regmap_config);
  919. if (IS_ERR_OR_NULL((void *)(priv->regmap))) {
  920. dev_err(&pdev->dev, "%s:regmap init failed\n", __func__);
  921. return -EINVAL;
  922. }
  923. priv->read_dev = __bolero_reg_read;
  924. priv->write_dev = __bolero_reg_write;
  925. priv->plat_data.handle = (void *) priv;
  926. priv->plat_data.update_wcd_event = bolero_cdc_update_wcd_event;
  927. priv->plat_data.register_notifier = bolero_cdc_register_notifier;
  928. priv->core_hw_vote_count = 0;
  929. priv->core_audio_vote_count = 0;
  930. dev_set_drvdata(&pdev->dev, priv);
  931. mutex_init(&priv->io_lock);
  932. mutex_init(&priv->clk_lock);
  933. mutex_init(&priv->vote_lock);
  934. INIT_WORK(&priv->bolero_add_child_devices_work,
  935. bolero_add_child_devices);
  936. schedule_work(&priv->bolero_add_child_devices_work);
  937. /* Register LPASS core hw vote */
  938. lpass_core_hw_vote = devm_clk_get(&pdev->dev, "lpass_core_hw_vote");
  939. if (IS_ERR(lpass_core_hw_vote)) {
  940. ret = PTR_ERR(lpass_core_hw_vote);
  941. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  942. __func__, "lpass_core_hw_vote", ret);
  943. lpass_core_hw_vote = NULL;
  944. ret = 0;
  945. }
  946. priv->lpass_core_hw_vote = lpass_core_hw_vote;
  947. /* Register LPASS audio hw vote */
  948. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  949. if (IS_ERR(lpass_audio_hw_vote)) {
  950. ret = PTR_ERR(lpass_audio_hw_vote);
  951. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  952. __func__, "lpass_audio_hw_vote", ret);
  953. lpass_audio_hw_vote = NULL;
  954. ret = 0;
  955. }
  956. priv->lpass_audio_hw_vote = lpass_audio_hw_vote;
  957. return 0;
  958. }
  959. static int bolero_remove(struct platform_device *pdev)
  960. {
  961. struct bolero_priv *priv = dev_get_drvdata(&pdev->dev);
  962. if (!priv)
  963. return -EINVAL;
  964. of_platform_depopulate(&pdev->dev);
  965. mutex_destroy(&priv->io_lock);
  966. mutex_destroy(&priv->clk_lock);
  967. mutex_destroy(&priv->vote_lock);
  968. return 0;
  969. }
  970. int bolero_runtime_resume(struct device *dev)
  971. {
  972. struct bolero_priv *priv = dev_get_drvdata(dev->parent);
  973. int ret = 0;
  974. mutex_lock(&priv->vote_lock);
  975. if (priv->lpass_core_hw_vote == NULL) {
  976. dev_dbg(dev, "%s: Invalid lpass core hw node\n", __func__);
  977. goto audio_vote;
  978. }
  979. if (priv->core_hw_vote_count == 0) {
  980. ret = clk_prepare_enable(priv->lpass_core_hw_vote);
  981. if (ret < 0) {
  982. dev_err(dev, "%s:lpass core hw enable failed\n",
  983. __func__);
  984. goto audio_vote;
  985. }
  986. }
  987. priv->core_hw_vote_count++;
  988. audio_vote:
  989. if (priv->lpass_audio_hw_vote == NULL) {
  990. dev_dbg(dev, "%s: Invalid lpass audio hw node\n", __func__);
  991. goto done;
  992. }
  993. if (priv->core_audio_vote_count == 0) {
  994. ret = clk_prepare_enable(priv->lpass_audio_hw_vote);
  995. if (ret < 0) {
  996. dev_err(dev, "%s:lpass audio hw enable failed\n",
  997. __func__);
  998. goto done;
  999. }
  1000. }
  1001. priv->core_audio_vote_count++;
  1002. done:
  1003. mutex_unlock(&priv->vote_lock);
  1004. pm_runtime_set_autosuspend_delay(priv->dev, BOLERO_AUTO_SUSPEND_DELAY);
  1005. return 0;
  1006. }
  1007. EXPORT_SYMBOL(bolero_runtime_resume);
  1008. int bolero_runtime_suspend(struct device *dev)
  1009. {
  1010. struct bolero_priv *priv = dev_get_drvdata(dev->parent);
  1011. mutex_lock(&priv->vote_lock);
  1012. if (priv->lpass_core_hw_vote != NULL) {
  1013. if (--priv->core_hw_vote_count == 0)
  1014. clk_disable_unprepare(priv->lpass_core_hw_vote);
  1015. if (priv->core_hw_vote_count < 0)
  1016. priv->core_hw_vote_count = 0;
  1017. } else {
  1018. dev_dbg(dev, "%s: Invalid lpass core hw node\n",
  1019. __func__);
  1020. }
  1021. if (priv->lpass_audio_hw_vote != NULL) {
  1022. if (--priv->core_audio_vote_count == 0)
  1023. clk_disable_unprepare(priv->lpass_audio_hw_vote);
  1024. if (priv->core_audio_vote_count < 0)
  1025. priv->core_audio_vote_count = 0;
  1026. } else {
  1027. dev_dbg(dev, "%s: Invalid lpass audio hw node\n",
  1028. __func__);
  1029. }
  1030. mutex_unlock(&priv->vote_lock);
  1031. return 0;
  1032. }
  1033. EXPORT_SYMBOL(bolero_runtime_suspend);
  1034. bool bolero_check_core_votes(struct device *dev)
  1035. {
  1036. struct bolero_priv *priv = dev_get_drvdata(dev->parent);
  1037. bool ret = true;
  1038. mutex_lock(&priv->vote_lock);
  1039. if ((priv->lpass_core_hw_vote && !priv->core_hw_vote_count) ||
  1040. (priv->lpass_audio_hw_vote && !priv->core_audio_vote_count))
  1041. ret = false;
  1042. mutex_unlock(&priv->vote_lock);
  1043. return ret;
  1044. }
  1045. EXPORT_SYMBOL(bolero_check_core_votes);
  1046. static const struct of_device_id bolero_dt_match[] = {
  1047. {.compatible = "qcom,bolero-codec"},
  1048. {}
  1049. };
  1050. MODULE_DEVICE_TABLE(of, bolero_dt_match);
  1051. static struct platform_driver bolero_drv = {
  1052. .driver = {
  1053. .name = "bolero-codec",
  1054. .owner = THIS_MODULE,
  1055. .of_match_table = bolero_dt_match,
  1056. .suppress_bind_attrs = true,
  1057. },
  1058. .probe = bolero_probe,
  1059. .remove = bolero_remove,
  1060. };
  1061. static int bolero_drv_init(void)
  1062. {
  1063. return platform_driver_register(&bolero_drv);
  1064. }
  1065. static void bolero_drv_exit(void)
  1066. {
  1067. platform_driver_unregister(&bolero_drv);
  1068. }
  1069. static int __init bolero_init(void)
  1070. {
  1071. bolero_drv_init();
  1072. bolero_clk_rsc_mgr_init();
  1073. return 0;
  1074. }
  1075. module_init(bolero_init);
  1076. static void __exit bolero_exit(void)
  1077. {
  1078. bolero_clk_rsc_mgr_exit();
  1079. bolero_drv_exit();
  1080. }
  1081. module_exit(bolero_exit);
  1082. MODULE_DESCRIPTION("Bolero driver");
  1083. MODULE_LICENSE("GPL v2");