extcon-arizona.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  1. /*
  2. * extcon-arizona.c - Extcon driver Wolfson Arizona devices
  3. *
  4. * Copyright (C) 2012-2014 Wolfson Microelectronics plc
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/i2c.h>
  19. #include <linux/slab.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/err.h>
  22. #include <linux/gpio/consumer.h>
  23. #include <linux/gpio.h>
  24. #include <linux/input.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/pm_runtime.h>
  27. #include <linux/property.h>
  28. #include <linux/regulator/consumer.h>
  29. #include <linux/extcon.h>
  30. #include <sound/soc.h>
  31. #include <linux/mfd/arizona/core.h>
  32. #include <linux/mfd/arizona/pdata.h>
  33. #include <linux/mfd/arizona/registers.h>
  34. #include <dt-bindings/mfd/arizona.h>
  35. #define ARIZONA_MAX_MICD_RANGE 8
  36. #define ARIZONA_MICD_CLAMP_MODE_JDL 0x4
  37. #define ARIZONA_MICD_CLAMP_MODE_JDH 0x5
  38. #define ARIZONA_MICD_CLAMP_MODE_JDL_GP5H 0x9
  39. #define ARIZONA_MICD_CLAMP_MODE_JDH_GP5H 0xb
  40. #define ARIZONA_TST_CAP_DEFAULT 0x3
  41. #define ARIZONA_TST_CAP_CLAMP 0x1
  42. #define ARIZONA_HPDET_MAX 10000
  43. #define HPDET_DEBOUNCE 500
  44. #define DEFAULT_MICD_TIMEOUT 2000
  45. #define ARIZONA_HPDET_WAIT_COUNT 15
  46. #define ARIZONA_HPDET_WAIT_DELAY_MS 20
  47. #define QUICK_HEADPHONE_MAX_OHM 3
  48. #define MICROPHONE_MIN_OHM 1257
  49. #define MICROPHONE_MAX_OHM 30000
  50. #define MICD_DBTIME_TWO_READINGS 2
  51. #define MICD_DBTIME_FOUR_READINGS 4
  52. #define MICD_LVL_1_TO_7 (ARIZONA_MICD_LVL_1 | ARIZONA_MICD_LVL_2 | \
  53. ARIZONA_MICD_LVL_3 | ARIZONA_MICD_LVL_4 | \
  54. ARIZONA_MICD_LVL_5 | ARIZONA_MICD_LVL_6 | \
  55. ARIZONA_MICD_LVL_7)
  56. #define MICD_LVL_0_TO_7 (ARIZONA_MICD_LVL_0 | MICD_LVL_1_TO_7)
  57. #define MICD_LVL_0_TO_8 (MICD_LVL_0_TO_7 | ARIZONA_MICD_LVL_8)
  58. struct arizona_extcon_info {
  59. struct device *dev;
  60. struct arizona *arizona;
  61. struct mutex lock;
  62. struct regulator *micvdd;
  63. struct input_dev *input;
  64. u16 last_jackdet;
  65. int micd_mode;
  66. const struct arizona_micd_config *micd_modes;
  67. int micd_num_modes;
  68. const struct arizona_micd_range *micd_ranges;
  69. int num_micd_ranges;
  70. int micd_timeout;
  71. bool micd_reva;
  72. bool micd_clamp;
  73. struct delayed_work hpdet_work;
  74. struct delayed_work micd_detect_work;
  75. struct delayed_work micd_timeout_work;
  76. bool hpdet_active;
  77. bool hpdet_done;
  78. bool hpdet_retried;
  79. int num_hpdet_res;
  80. unsigned int hpdet_res[3];
  81. bool mic;
  82. bool detecting;
  83. int jack_flips;
  84. int hpdet_ip_version;
  85. struct extcon_dev *edev;
  86. struct gpio_desc *micd_pol_gpio;
  87. };
  88. static const struct arizona_micd_config micd_default_modes[] = {
  89. { ARIZONA_ACCDET_SRC, 1, 0 },
  90. { 0, 2, 1 },
  91. };
  92. static const struct arizona_micd_range micd_default_ranges[] = {
  93. { .max = 11, .key = BTN_0 },
  94. { .max = 28, .key = BTN_1 },
  95. { .max = 54, .key = BTN_2 },
  96. { .max = 100, .key = BTN_3 },
  97. { .max = 186, .key = BTN_4 },
  98. { .max = 430, .key = BTN_5 },
  99. };
  100. /* The number of levels in arizona_micd_levels valid for button thresholds */
  101. #define ARIZONA_NUM_MICD_BUTTON_LEVELS 64
  102. static const int arizona_micd_levels[] = {
  103. 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 34, 36, 39, 41, 44, 46,
  104. 49, 52, 54, 57, 60, 62, 65, 67, 70, 73, 75, 78, 81, 83, 89, 94, 100,
  105. 105, 111, 116, 122, 127, 139, 150, 161, 173, 186, 196, 209, 220, 245,
  106. 270, 295, 321, 348, 375, 402, 430, 489, 550, 614, 681, 752, 903, 1071,
  107. 1257, 30000,
  108. };
  109. static const unsigned int arizona_cable[] = {
  110. EXTCON_MECHANICAL,
  111. EXTCON_JACK_MICROPHONE,
  112. EXTCON_JACK_HEADPHONE,
  113. EXTCON_JACK_LINE_OUT,
  114. EXTCON_NONE,
  115. };
  116. static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
  117. static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
  118. bool clamp)
  119. {
  120. struct arizona *arizona = info->arizona;
  121. unsigned int mask = 0, val = 0;
  122. unsigned int cap_sel = 0;
  123. int ret;
  124. switch (arizona->type) {
  125. case WM8998:
  126. case WM1814:
  127. mask = 0;
  128. break;
  129. case WM5110:
  130. case WM8280:
  131. mask = ARIZONA_HP1L_SHRTO | ARIZONA_HP1L_FLWR |
  132. ARIZONA_HP1L_SHRTI;
  133. if (clamp) {
  134. val = ARIZONA_HP1L_SHRTO;
  135. cap_sel = ARIZONA_TST_CAP_CLAMP;
  136. } else {
  137. val = ARIZONA_HP1L_FLWR | ARIZONA_HP1L_SHRTI;
  138. cap_sel = ARIZONA_TST_CAP_DEFAULT;
  139. }
  140. ret = regmap_update_bits(arizona->regmap,
  141. ARIZONA_HP_TEST_CTRL_1,
  142. ARIZONA_HP1_TST_CAP_SEL_MASK,
  143. cap_sel);
  144. if (ret != 0)
  145. dev_warn(arizona->dev,
  146. "Failed to set TST_CAP_SEL: %d\n", ret);
  147. break;
  148. default:
  149. mask = ARIZONA_RMV_SHRT_HP1L;
  150. if (clamp)
  151. val = ARIZONA_RMV_SHRT_HP1L;
  152. break;
  153. }
  154. snd_soc_dapm_mutex_lock(arizona->dapm);
  155. arizona->hpdet_clamp = clamp;
  156. /* Keep the HP output stages disabled while doing the clamp */
  157. if (clamp) {
  158. ret = regmap_update_bits(arizona->regmap,
  159. ARIZONA_OUTPUT_ENABLES_1,
  160. ARIZONA_OUT1L_ENA |
  161. ARIZONA_OUT1R_ENA, 0);
  162. if (ret != 0)
  163. dev_warn(arizona->dev,
  164. "Failed to disable headphone outputs: %d\n",
  165. ret);
  166. }
  167. if (mask) {
  168. ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
  169. mask, val);
  170. if (ret != 0)
  171. dev_warn(arizona->dev, "Failed to do clamp: %d\n",
  172. ret);
  173. ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
  174. mask, val);
  175. if (ret != 0)
  176. dev_warn(arizona->dev, "Failed to do clamp: %d\n",
  177. ret);
  178. }
  179. /* Restore the desired state while not doing the clamp */
  180. if (!clamp) {
  181. ret = regmap_update_bits(arizona->regmap,
  182. ARIZONA_OUTPUT_ENABLES_1,
  183. ARIZONA_OUT1L_ENA |
  184. ARIZONA_OUT1R_ENA, arizona->hp_ena);
  185. if (ret != 0)
  186. dev_warn(arizona->dev,
  187. "Failed to restore headphone outputs: %d\n",
  188. ret);
  189. }
  190. snd_soc_dapm_mutex_unlock(arizona->dapm);
  191. }
  192. static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
  193. {
  194. struct arizona *arizona = info->arizona;
  195. mode %= info->micd_num_modes;
  196. gpiod_set_value_cansleep(info->micd_pol_gpio,
  197. info->micd_modes[mode].gpio);
  198. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  199. ARIZONA_MICD_BIAS_SRC_MASK,
  200. info->micd_modes[mode].bias <<
  201. ARIZONA_MICD_BIAS_SRC_SHIFT);
  202. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  203. ARIZONA_ACCDET_SRC, info->micd_modes[mode].src);
  204. info->micd_mode = mode;
  205. dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode);
  206. }
  207. static const char *arizona_extcon_get_micbias(struct arizona_extcon_info *info)
  208. {
  209. switch (info->micd_modes[0].bias) {
  210. case 1:
  211. return "MICBIAS1";
  212. case 2:
  213. return "MICBIAS2";
  214. case 3:
  215. return "MICBIAS3";
  216. default:
  217. return "MICVDD";
  218. }
  219. }
  220. static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
  221. {
  222. struct arizona *arizona = info->arizona;
  223. const char *widget = arizona_extcon_get_micbias(info);
  224. struct snd_soc_dapm_context *dapm = arizona->dapm;
  225. struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
  226. int ret;
  227. ret = snd_soc_component_force_enable_pin(component, widget);
  228. if (ret != 0)
  229. dev_warn(arizona->dev, "Failed to enable %s: %d\n",
  230. widget, ret);
  231. snd_soc_dapm_sync(dapm);
  232. if (!arizona->pdata.micd_force_micbias) {
  233. ret = snd_soc_component_disable_pin(component, widget);
  234. if (ret != 0)
  235. dev_warn(arizona->dev, "Failed to disable %s: %d\n",
  236. widget, ret);
  237. snd_soc_dapm_sync(dapm);
  238. }
  239. }
  240. static void arizona_start_mic(struct arizona_extcon_info *info)
  241. {
  242. struct arizona *arizona = info->arizona;
  243. bool change;
  244. int ret;
  245. unsigned int mode;
  246. /* Microphone detection can't use idle mode */
  247. pm_runtime_get(info->dev);
  248. if (info->detecting) {
  249. ret = regulator_allow_bypass(info->micvdd, false);
  250. if (ret != 0) {
  251. dev_err(arizona->dev,
  252. "Failed to regulate MICVDD: %d\n",
  253. ret);
  254. }
  255. }
  256. ret = regulator_enable(info->micvdd);
  257. if (ret != 0) {
  258. dev_err(arizona->dev, "Failed to enable MICVDD: %d\n",
  259. ret);
  260. }
  261. if (info->micd_reva) {
  262. regmap_write(arizona->regmap, 0x80, 0x3);
  263. regmap_write(arizona->regmap, 0x294, 0);
  264. regmap_write(arizona->regmap, 0x80, 0x0);
  265. }
  266. if (info->detecting && arizona->pdata.micd_software_compare)
  267. mode = ARIZONA_ACCDET_MODE_ADC;
  268. else
  269. mode = ARIZONA_ACCDET_MODE_MIC;
  270. regmap_update_bits(arizona->regmap,
  271. ARIZONA_ACCESSORY_DETECT_MODE_1,
  272. ARIZONA_ACCDET_MODE_MASK, mode);
  273. arizona_extcon_pulse_micbias(info);
  274. regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
  275. ARIZONA_MICD_ENA, ARIZONA_MICD_ENA,
  276. &change);
  277. if (!change) {
  278. regulator_disable(info->micvdd);
  279. pm_runtime_put_autosuspend(info->dev);
  280. }
  281. }
  282. static void arizona_stop_mic(struct arizona_extcon_info *info)
  283. {
  284. struct arizona *arizona = info->arizona;
  285. const char *widget = arizona_extcon_get_micbias(info);
  286. struct snd_soc_dapm_context *dapm = arizona->dapm;
  287. struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
  288. bool change;
  289. int ret;
  290. regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
  291. ARIZONA_MICD_ENA, 0,
  292. &change);
  293. ret = snd_soc_component_disable_pin(component, widget);
  294. if (ret != 0)
  295. dev_warn(arizona->dev,
  296. "Failed to disable %s: %d\n",
  297. widget, ret);
  298. snd_soc_dapm_sync(dapm);
  299. if (info->micd_reva) {
  300. regmap_write(arizona->regmap, 0x80, 0x3);
  301. regmap_write(arizona->regmap, 0x294, 2);
  302. regmap_write(arizona->regmap, 0x80, 0x0);
  303. }
  304. ret = regulator_allow_bypass(info->micvdd, true);
  305. if (ret != 0) {
  306. dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
  307. ret);
  308. }
  309. if (change) {
  310. regulator_disable(info->micvdd);
  311. pm_runtime_mark_last_busy(info->dev);
  312. pm_runtime_put_autosuspend(info->dev);
  313. }
  314. }
  315. static struct {
  316. unsigned int threshold;
  317. unsigned int factor_a;
  318. unsigned int factor_b;
  319. } arizona_hpdet_b_ranges[] = {
  320. { 100, 5528, 362464 },
  321. { 169, 11084, 6186851 },
  322. { 169, 11065, 65460395 },
  323. };
  324. #define ARIZONA_HPDET_B_RANGE_MAX 0x3fb
  325. static struct {
  326. int min;
  327. int max;
  328. } arizona_hpdet_c_ranges[] = {
  329. { 0, 30 },
  330. { 8, 100 },
  331. { 100, 1000 },
  332. { 1000, 10000 },
  333. };
  334. static int arizona_hpdet_read(struct arizona_extcon_info *info)
  335. {
  336. struct arizona *arizona = info->arizona;
  337. unsigned int val, range;
  338. int ret;
  339. ret = regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_2, &val);
  340. if (ret != 0) {
  341. dev_err(arizona->dev, "Failed to read HPDET status: %d\n",
  342. ret);
  343. return ret;
  344. }
  345. switch (info->hpdet_ip_version) {
  346. case 0:
  347. if (!(val & ARIZONA_HP_DONE)) {
  348. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  349. val);
  350. return -EAGAIN;
  351. }
  352. val &= ARIZONA_HP_LVL_MASK;
  353. break;
  354. case 1:
  355. if (!(val & ARIZONA_HP_DONE_B)) {
  356. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  357. val);
  358. return -EAGAIN;
  359. }
  360. ret = regmap_read(arizona->regmap, ARIZONA_HP_DACVAL, &val);
  361. if (ret != 0) {
  362. dev_err(arizona->dev, "Failed to read HP value: %d\n",
  363. ret);
  364. return -EAGAIN;
  365. }
  366. regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  367. &range);
  368. range = (range & ARIZONA_HP_IMPEDANCE_RANGE_MASK)
  369. >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
  370. if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 &&
  371. (val < arizona_hpdet_b_ranges[range].threshold ||
  372. val >= ARIZONA_HPDET_B_RANGE_MAX)) {
  373. range++;
  374. dev_dbg(arizona->dev, "Moving to HPDET range %d\n",
  375. range);
  376. regmap_update_bits(arizona->regmap,
  377. ARIZONA_HEADPHONE_DETECT_1,
  378. ARIZONA_HP_IMPEDANCE_RANGE_MASK,
  379. range <<
  380. ARIZONA_HP_IMPEDANCE_RANGE_SHIFT);
  381. return -EAGAIN;
  382. }
  383. /* If we go out of range report top of range */
  384. if (val < arizona_hpdet_b_ranges[range].threshold ||
  385. val >= ARIZONA_HPDET_B_RANGE_MAX) {
  386. dev_dbg(arizona->dev, "Measurement out of range\n");
  387. return ARIZONA_HPDET_MAX;
  388. }
  389. dev_dbg(arizona->dev, "HPDET read %d in range %d\n",
  390. val, range);
  391. val = arizona_hpdet_b_ranges[range].factor_b
  392. / ((val * 100) -
  393. arizona_hpdet_b_ranges[range].factor_a);
  394. break;
  395. case 2:
  396. if (!(val & ARIZONA_HP_DONE_B)) {
  397. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  398. val);
  399. return -EAGAIN;
  400. }
  401. val &= ARIZONA_HP_LVL_B_MASK;
  402. /* Convert to ohms, the value is in 0.5 ohm increments */
  403. val /= 2;
  404. regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  405. &range);
  406. range = (range & ARIZONA_HP_IMPEDANCE_RANGE_MASK)
  407. >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
  408. /* Skip up a range, or report? */
  409. if (range < ARRAY_SIZE(arizona_hpdet_c_ranges) - 1 &&
  410. (val >= arizona_hpdet_c_ranges[range].max)) {
  411. range++;
  412. dev_dbg(arizona->dev, "Moving to HPDET range %d-%d\n",
  413. arizona_hpdet_c_ranges[range].min,
  414. arizona_hpdet_c_ranges[range].max);
  415. regmap_update_bits(arizona->regmap,
  416. ARIZONA_HEADPHONE_DETECT_1,
  417. ARIZONA_HP_IMPEDANCE_RANGE_MASK,
  418. range <<
  419. ARIZONA_HP_IMPEDANCE_RANGE_SHIFT);
  420. return -EAGAIN;
  421. }
  422. if (range && (val < arizona_hpdet_c_ranges[range].min)) {
  423. dev_dbg(arizona->dev, "Reporting range boundary %d\n",
  424. arizona_hpdet_c_ranges[range].min);
  425. val = arizona_hpdet_c_ranges[range].min;
  426. }
  427. break;
  428. default:
  429. dev_warn(arizona->dev, "Unknown HPDET IP revision %d\n",
  430. info->hpdet_ip_version);
  431. return -EINVAL;
  432. }
  433. dev_dbg(arizona->dev, "HP impedance %d ohms\n", val);
  434. return val;
  435. }
  436. static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading,
  437. bool *mic)
  438. {
  439. struct arizona *arizona = info->arizona;
  440. int id_gpio = arizona->pdata.hpdet_id_gpio;
  441. /*
  442. * If we're using HPDET for accessory identification we need
  443. * to take multiple measurements, step through them in sequence.
  444. */
  445. if (arizona->pdata.hpdet_acc_id) {
  446. info->hpdet_res[info->num_hpdet_res++] = *reading;
  447. /* Only check the mic directly if we didn't already ID it */
  448. if (id_gpio && info->num_hpdet_res == 1) {
  449. dev_dbg(arizona->dev, "Measuring mic\n");
  450. regmap_update_bits(arizona->regmap,
  451. ARIZONA_ACCESSORY_DETECT_MODE_1,
  452. ARIZONA_ACCDET_MODE_MASK |
  453. ARIZONA_ACCDET_SRC,
  454. ARIZONA_ACCDET_MODE_HPR |
  455. info->micd_modes[0].src);
  456. gpio_set_value_cansleep(id_gpio, 1);
  457. regmap_update_bits(arizona->regmap,
  458. ARIZONA_HEADPHONE_DETECT_1,
  459. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  460. return -EAGAIN;
  461. }
  462. /* OK, got both. Now, compare... */
  463. dev_dbg(arizona->dev, "HPDET measured %d %d\n",
  464. info->hpdet_res[0], info->hpdet_res[1]);
  465. /* Take the headphone impedance for the main report */
  466. *reading = info->hpdet_res[0];
  467. /* Sometimes we get false readings due to slow insert */
  468. if (*reading >= ARIZONA_HPDET_MAX && !info->hpdet_retried) {
  469. dev_dbg(arizona->dev, "Retrying high impedance\n");
  470. info->num_hpdet_res = 0;
  471. info->hpdet_retried = true;
  472. arizona_start_hpdet_acc_id(info);
  473. pm_runtime_put(info->dev);
  474. return -EAGAIN;
  475. }
  476. /*
  477. * If we measure the mic as high impedance
  478. */
  479. if (!id_gpio || info->hpdet_res[1] > 50) {
  480. dev_dbg(arizona->dev, "Detected mic\n");
  481. *mic = true;
  482. info->detecting = true;
  483. } else {
  484. dev_dbg(arizona->dev, "Detected headphone\n");
  485. }
  486. /* Make sure everything is reset back to the real polarity */
  487. regmap_update_bits(arizona->regmap,
  488. ARIZONA_ACCESSORY_DETECT_MODE_1,
  489. ARIZONA_ACCDET_SRC,
  490. info->micd_modes[0].src);
  491. }
  492. return 0;
  493. }
  494. static irqreturn_t arizona_hpdet_irq(int irq, void *data)
  495. {
  496. struct arizona_extcon_info *info = data;
  497. struct arizona *arizona = info->arizona;
  498. int id_gpio = arizona->pdata.hpdet_id_gpio;
  499. unsigned int report = EXTCON_JACK_HEADPHONE;
  500. int ret, reading, state;
  501. bool mic = false;
  502. mutex_lock(&info->lock);
  503. /* If we got a spurious IRQ for some reason then ignore it */
  504. if (!info->hpdet_active) {
  505. dev_warn(arizona->dev, "Spurious HPDET IRQ\n");
  506. mutex_unlock(&info->lock);
  507. return IRQ_NONE;
  508. }
  509. /* If the cable was removed while measuring ignore the result */
  510. state = extcon_get_state(info->edev, EXTCON_MECHANICAL);
  511. if (state < 0) {
  512. dev_err(arizona->dev, "Failed to check cable state: %d\n", state);
  513. goto out;
  514. } else if (!state) {
  515. dev_dbg(arizona->dev, "Ignoring HPDET for removed cable\n");
  516. goto done;
  517. }
  518. ret = arizona_hpdet_read(info);
  519. if (ret == -EAGAIN)
  520. goto out;
  521. else if (ret < 0)
  522. goto done;
  523. reading = ret;
  524. /* Reset back to starting range */
  525. regmap_update_bits(arizona->regmap,
  526. ARIZONA_HEADPHONE_DETECT_1,
  527. ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
  528. 0);
  529. ret = arizona_hpdet_do_id(info, &reading, &mic);
  530. if (ret == -EAGAIN)
  531. goto out;
  532. else if (ret < 0)
  533. goto done;
  534. /* Report high impedence cables as line outputs */
  535. if (reading >= 5000)
  536. report = EXTCON_JACK_LINE_OUT;
  537. else
  538. report = EXTCON_JACK_HEADPHONE;
  539. ret = extcon_set_state_sync(info->edev, report, true);
  540. if (ret != 0)
  541. dev_err(arizona->dev, "Failed to report HP/line: %d\n",
  542. ret);
  543. done:
  544. /* Reset back to starting range */
  545. regmap_update_bits(arizona->regmap,
  546. ARIZONA_HEADPHONE_DETECT_1,
  547. ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
  548. 0);
  549. arizona_extcon_hp_clamp(info, false);
  550. if (id_gpio)
  551. gpio_set_value_cansleep(id_gpio, 0);
  552. /* Revert back to MICDET mode */
  553. regmap_update_bits(arizona->regmap,
  554. ARIZONA_ACCESSORY_DETECT_MODE_1,
  555. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  556. /* If we have a mic then reenable MICDET */
  557. if (state && (mic || info->mic))
  558. arizona_start_mic(info);
  559. if (info->hpdet_active) {
  560. pm_runtime_put_autosuspend(info->dev);
  561. info->hpdet_active = false;
  562. }
  563. /* Do not set hp_det done when the cable has been unplugged */
  564. if (state)
  565. info->hpdet_done = true;
  566. out:
  567. mutex_unlock(&info->lock);
  568. return IRQ_HANDLED;
  569. }
  570. static void arizona_identify_headphone(struct arizona_extcon_info *info)
  571. {
  572. struct arizona *arizona = info->arizona;
  573. int ret;
  574. if (info->hpdet_done)
  575. return;
  576. dev_dbg(arizona->dev, "Starting HPDET\n");
  577. /* Make sure we keep the device enabled during the measurement */
  578. pm_runtime_get(info->dev);
  579. info->hpdet_active = true;
  580. if (info->mic)
  581. arizona_stop_mic(info);
  582. arizona_extcon_hp_clamp(info, true);
  583. ret = regmap_update_bits(arizona->regmap,
  584. ARIZONA_ACCESSORY_DETECT_MODE_1,
  585. ARIZONA_ACCDET_MODE_MASK,
  586. arizona->pdata.hpdet_channel);
  587. if (ret != 0) {
  588. dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
  589. goto err;
  590. }
  591. ret = regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  592. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  593. if (ret != 0) {
  594. dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n",
  595. ret);
  596. goto err;
  597. }
  598. return;
  599. err:
  600. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  601. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  602. /* Just report headphone */
  603. ret = extcon_set_state_sync(info->edev, EXTCON_JACK_HEADPHONE, true);
  604. if (ret != 0)
  605. dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
  606. if (info->mic)
  607. arizona_start_mic(info);
  608. info->hpdet_active = false;
  609. }
  610. static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
  611. {
  612. struct arizona *arizona = info->arizona;
  613. int hp_reading = 32;
  614. bool mic;
  615. int ret;
  616. dev_dbg(arizona->dev, "Starting identification via HPDET\n");
  617. /* Make sure we keep the device enabled during the measurement */
  618. pm_runtime_get_sync(info->dev);
  619. info->hpdet_active = true;
  620. arizona_extcon_hp_clamp(info, true);
  621. ret = regmap_update_bits(arizona->regmap,
  622. ARIZONA_ACCESSORY_DETECT_MODE_1,
  623. ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK,
  624. info->micd_modes[0].src |
  625. arizona->pdata.hpdet_channel);
  626. if (ret != 0) {
  627. dev_err(arizona->dev, "Failed to set HPDET mode: %d\n", ret);
  628. goto err;
  629. }
  630. if (arizona->pdata.hpdet_acc_id_line) {
  631. ret = regmap_update_bits(arizona->regmap,
  632. ARIZONA_HEADPHONE_DETECT_1,
  633. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  634. if (ret != 0) {
  635. dev_err(arizona->dev,
  636. "Can't start HPDETL measurement: %d\n",
  637. ret);
  638. goto err;
  639. }
  640. } else {
  641. arizona_hpdet_do_id(info, &hp_reading, &mic);
  642. }
  643. return;
  644. err:
  645. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  646. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  647. /* Just report headphone */
  648. ret = extcon_set_state_sync(info->edev, EXTCON_JACK_HEADPHONE, true);
  649. if (ret != 0)
  650. dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
  651. info->hpdet_active = false;
  652. }
  653. static void arizona_micd_timeout_work(struct work_struct *work)
  654. {
  655. struct arizona_extcon_info *info = container_of(work,
  656. struct arizona_extcon_info,
  657. micd_timeout_work.work);
  658. mutex_lock(&info->lock);
  659. dev_dbg(info->arizona->dev, "MICD timed out, reporting HP\n");
  660. info->detecting = false;
  661. arizona_identify_headphone(info);
  662. arizona_stop_mic(info);
  663. mutex_unlock(&info->lock);
  664. }
  665. static void arizona_micd_detect(struct work_struct *work)
  666. {
  667. struct arizona_extcon_info *info = container_of(work,
  668. struct arizona_extcon_info,
  669. micd_detect_work.work);
  670. struct arizona *arizona = info->arizona;
  671. unsigned int val = 0, lvl;
  672. int ret, i, key;
  673. cancel_delayed_work_sync(&info->micd_timeout_work);
  674. mutex_lock(&info->lock);
  675. /* If the cable was removed while measuring ignore the result */
  676. ret = extcon_get_state(info->edev, EXTCON_MECHANICAL);
  677. if (ret < 0) {
  678. dev_err(arizona->dev, "Failed to check cable state: %d\n",
  679. ret);
  680. mutex_unlock(&info->lock);
  681. return;
  682. } else if (!ret) {
  683. dev_dbg(arizona->dev, "Ignoring MICDET for removed cable\n");
  684. mutex_unlock(&info->lock);
  685. return;
  686. }
  687. if (info->detecting && arizona->pdata.micd_software_compare) {
  688. /* Must disable MICD before we read the ADCVAL */
  689. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  690. ARIZONA_MICD_ENA, 0);
  691. ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_4, &val);
  692. if (ret != 0) {
  693. dev_err(arizona->dev,
  694. "Failed to read MICDET_ADCVAL: %d\n",
  695. ret);
  696. mutex_unlock(&info->lock);
  697. return;
  698. }
  699. dev_dbg(arizona->dev, "MICDET_ADCVAL: %x\n", val);
  700. val &= ARIZONA_MICDET_ADCVAL_MASK;
  701. if (val < ARRAY_SIZE(arizona_micd_levels))
  702. val = arizona_micd_levels[val];
  703. else
  704. val = INT_MAX;
  705. if (val <= QUICK_HEADPHONE_MAX_OHM)
  706. val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_0;
  707. else if (val <= MICROPHONE_MIN_OHM)
  708. val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_1;
  709. else if (val <= MICROPHONE_MAX_OHM)
  710. val = ARIZONA_MICD_STS | ARIZONA_MICD_LVL_8;
  711. else
  712. val = ARIZONA_MICD_LVL_8;
  713. }
  714. for (i = 0; i < 10 && !(val & MICD_LVL_0_TO_8); i++) {
  715. ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
  716. if (ret != 0) {
  717. dev_err(arizona->dev,
  718. "Failed to read MICDET: %d\n", ret);
  719. mutex_unlock(&info->lock);
  720. return;
  721. }
  722. dev_dbg(arizona->dev, "MICDET: %x\n", val);
  723. if (!(val & ARIZONA_MICD_VALID)) {
  724. dev_warn(arizona->dev,
  725. "Microphone detection state invalid\n");
  726. mutex_unlock(&info->lock);
  727. return;
  728. }
  729. }
  730. if (i == 10 && !(val & MICD_LVL_0_TO_8)) {
  731. dev_err(arizona->dev, "Failed to get valid MICDET value\n");
  732. mutex_unlock(&info->lock);
  733. return;
  734. }
  735. /* Due to jack detect this should never happen */
  736. if (!(val & ARIZONA_MICD_STS)) {
  737. dev_warn(arizona->dev, "Detected open circuit\n");
  738. info->mic = false;
  739. arizona_stop_mic(info);
  740. info->detecting = false;
  741. arizona_identify_headphone(info);
  742. goto handled;
  743. }
  744. /* If we got a high impedence we should have a headset, report it. */
  745. if (info->detecting && (val & ARIZONA_MICD_LVL_8)) {
  746. info->mic = true;
  747. info->detecting = false;
  748. arizona_identify_headphone(info);
  749. ret = extcon_set_state_sync(info->edev,
  750. EXTCON_JACK_MICROPHONE, true);
  751. if (ret != 0)
  752. dev_err(arizona->dev, "Headset report failed: %d\n",
  753. ret);
  754. /* Don't need to regulate for button detection */
  755. ret = regulator_allow_bypass(info->micvdd, true);
  756. if (ret != 0) {
  757. dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
  758. ret);
  759. }
  760. goto handled;
  761. }
  762. /* If we detected a lower impedence during initial startup
  763. * then we probably have the wrong polarity, flip it. Don't
  764. * do this for the lowest impedences to speed up detection of
  765. * plain headphones. If both polarities report a low
  766. * impedence then give up and report headphones.
  767. */
  768. if (info->detecting && (val & MICD_LVL_1_TO_7)) {
  769. if (info->jack_flips >= info->micd_num_modes * 10) {
  770. dev_dbg(arizona->dev, "Detected HP/line\n");
  771. info->detecting = false;
  772. arizona_identify_headphone(info);
  773. arizona_stop_mic(info);
  774. } else {
  775. info->micd_mode++;
  776. if (info->micd_mode == info->micd_num_modes)
  777. info->micd_mode = 0;
  778. arizona_extcon_set_mode(info, info->micd_mode);
  779. info->jack_flips++;
  780. }
  781. goto handled;
  782. }
  783. /*
  784. * If we're still detecting and we detect a short then we've
  785. * got a headphone. Otherwise it's a button press.
  786. */
  787. if (val & MICD_LVL_0_TO_7) {
  788. if (info->mic) {
  789. dev_dbg(arizona->dev, "Mic button detected\n");
  790. lvl = val & ARIZONA_MICD_LVL_MASK;
  791. lvl >>= ARIZONA_MICD_LVL_SHIFT;
  792. for (i = 0; i < info->num_micd_ranges; i++)
  793. input_report_key(info->input,
  794. info->micd_ranges[i].key, 0);
  795. WARN_ON(!lvl);
  796. WARN_ON(ffs(lvl) - 1 >= info->num_micd_ranges);
  797. if (lvl && ffs(lvl) - 1 < info->num_micd_ranges) {
  798. key = info->micd_ranges[ffs(lvl) - 1].key;
  799. input_report_key(info->input, key, 1);
  800. input_sync(info->input);
  801. }
  802. } else if (info->detecting) {
  803. dev_dbg(arizona->dev, "Headphone detected\n");
  804. info->detecting = false;
  805. arizona_stop_mic(info);
  806. arizona_identify_headphone(info);
  807. } else {
  808. dev_warn(arizona->dev, "Button with no mic: %x\n",
  809. val);
  810. }
  811. } else {
  812. dev_dbg(arizona->dev, "Mic button released\n");
  813. for (i = 0; i < info->num_micd_ranges; i++)
  814. input_report_key(info->input,
  815. info->micd_ranges[i].key, 0);
  816. input_sync(info->input);
  817. arizona_extcon_pulse_micbias(info);
  818. }
  819. handled:
  820. if (info->detecting) {
  821. if (arizona->pdata.micd_software_compare)
  822. regmap_update_bits(arizona->regmap,
  823. ARIZONA_MIC_DETECT_1,
  824. ARIZONA_MICD_ENA,
  825. ARIZONA_MICD_ENA);
  826. queue_delayed_work(system_power_efficient_wq,
  827. &info->micd_timeout_work,
  828. msecs_to_jiffies(info->micd_timeout));
  829. }
  830. pm_runtime_mark_last_busy(info->dev);
  831. mutex_unlock(&info->lock);
  832. }
  833. static irqreturn_t arizona_micdet(int irq, void *data)
  834. {
  835. struct arizona_extcon_info *info = data;
  836. struct arizona *arizona = info->arizona;
  837. int debounce = arizona->pdata.micd_detect_debounce;
  838. cancel_delayed_work_sync(&info->micd_detect_work);
  839. cancel_delayed_work_sync(&info->micd_timeout_work);
  840. mutex_lock(&info->lock);
  841. if (!info->detecting)
  842. debounce = 0;
  843. mutex_unlock(&info->lock);
  844. if (debounce)
  845. queue_delayed_work(system_power_efficient_wq,
  846. &info->micd_detect_work,
  847. msecs_to_jiffies(debounce));
  848. else
  849. arizona_micd_detect(&info->micd_detect_work.work);
  850. return IRQ_HANDLED;
  851. }
  852. static void arizona_hpdet_work(struct work_struct *work)
  853. {
  854. struct arizona_extcon_info *info = container_of(work,
  855. struct arizona_extcon_info,
  856. hpdet_work.work);
  857. mutex_lock(&info->lock);
  858. arizona_start_hpdet_acc_id(info);
  859. mutex_unlock(&info->lock);
  860. }
  861. static int arizona_hpdet_wait(struct arizona_extcon_info *info)
  862. {
  863. struct arizona *arizona = info->arizona;
  864. unsigned int val;
  865. int i, ret;
  866. for (i = 0; i < ARIZONA_HPDET_WAIT_COUNT; i++) {
  867. ret = regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_2,
  868. &val);
  869. if (ret) {
  870. dev_err(arizona->dev,
  871. "Failed to read HPDET state: %d\n", ret);
  872. return ret;
  873. }
  874. switch (info->hpdet_ip_version) {
  875. case 0:
  876. if (val & ARIZONA_HP_DONE)
  877. return 0;
  878. break;
  879. default:
  880. if (val & ARIZONA_HP_DONE_B)
  881. return 0;
  882. break;
  883. }
  884. msleep(ARIZONA_HPDET_WAIT_DELAY_MS);
  885. }
  886. dev_warn(arizona->dev, "HPDET did not appear to complete\n");
  887. return -ETIMEDOUT;
  888. }
  889. static irqreturn_t arizona_jackdet(int irq, void *data)
  890. {
  891. struct arizona_extcon_info *info = data;
  892. struct arizona *arizona = info->arizona;
  893. unsigned int val, present, mask;
  894. bool cancelled_hp, cancelled_mic;
  895. int ret, i;
  896. cancelled_hp = cancel_delayed_work_sync(&info->hpdet_work);
  897. cancelled_mic = cancel_delayed_work_sync(&info->micd_timeout_work);
  898. pm_runtime_get_sync(info->dev);
  899. mutex_lock(&info->lock);
  900. if (info->micd_clamp) {
  901. mask = ARIZONA_MICD_CLAMP_STS;
  902. present = 0;
  903. } else {
  904. mask = ARIZONA_JD1_STS;
  905. if (arizona->pdata.jd_invert)
  906. present = 0;
  907. else
  908. present = ARIZONA_JD1_STS;
  909. }
  910. ret = regmap_read(arizona->regmap, ARIZONA_AOD_IRQ_RAW_STATUS, &val);
  911. if (ret != 0) {
  912. dev_err(arizona->dev, "Failed to read jackdet status: %d\n",
  913. ret);
  914. mutex_unlock(&info->lock);
  915. pm_runtime_put_autosuspend(info->dev);
  916. return IRQ_NONE;
  917. }
  918. val &= mask;
  919. if (val == info->last_jackdet) {
  920. dev_dbg(arizona->dev, "Suppressing duplicate JACKDET\n");
  921. if (cancelled_hp)
  922. queue_delayed_work(system_power_efficient_wq,
  923. &info->hpdet_work,
  924. msecs_to_jiffies(HPDET_DEBOUNCE));
  925. if (cancelled_mic) {
  926. int micd_timeout = info->micd_timeout;
  927. queue_delayed_work(system_power_efficient_wq,
  928. &info->micd_timeout_work,
  929. msecs_to_jiffies(micd_timeout));
  930. }
  931. goto out;
  932. }
  933. info->last_jackdet = val;
  934. if (info->last_jackdet == present) {
  935. dev_dbg(arizona->dev, "Detected jack\n");
  936. ret = extcon_set_state_sync(info->edev,
  937. EXTCON_MECHANICAL, true);
  938. if (ret != 0)
  939. dev_err(arizona->dev, "Mechanical report failed: %d\n",
  940. ret);
  941. if (!arizona->pdata.hpdet_acc_id) {
  942. info->detecting = true;
  943. info->mic = false;
  944. info->jack_flips = 0;
  945. arizona_start_mic(info);
  946. } else {
  947. queue_delayed_work(system_power_efficient_wq,
  948. &info->hpdet_work,
  949. msecs_to_jiffies(HPDET_DEBOUNCE));
  950. }
  951. if (info->micd_clamp || !arizona->pdata.jd_invert)
  952. regmap_update_bits(arizona->regmap,
  953. ARIZONA_JACK_DETECT_DEBOUNCE,
  954. ARIZONA_MICD_CLAMP_DB |
  955. ARIZONA_JD1_DB, 0);
  956. } else {
  957. dev_dbg(arizona->dev, "Detected jack removal\n");
  958. arizona_stop_mic(info);
  959. info->num_hpdet_res = 0;
  960. for (i = 0; i < ARRAY_SIZE(info->hpdet_res); i++)
  961. info->hpdet_res[i] = 0;
  962. info->mic = false;
  963. info->hpdet_done = false;
  964. info->hpdet_retried = false;
  965. for (i = 0; i < info->num_micd_ranges; i++)
  966. input_report_key(info->input,
  967. info->micd_ranges[i].key, 0);
  968. input_sync(info->input);
  969. for (i = 0; i < ARRAY_SIZE(arizona_cable) - 1; i++) {
  970. ret = extcon_set_state_sync(info->edev,
  971. arizona_cable[i], false);
  972. if (ret != 0)
  973. dev_err(arizona->dev,
  974. "Removal report failed: %d\n", ret);
  975. }
  976. /*
  977. * If the jack was removed during a headphone detection we
  978. * need to wait for the headphone detection to finish, as
  979. * it can not be aborted. We don't want to be able to start
  980. * a new headphone detection from a fresh insert until this
  981. * one is finished.
  982. */
  983. arizona_hpdet_wait(info);
  984. regmap_update_bits(arizona->regmap,
  985. ARIZONA_JACK_DETECT_DEBOUNCE,
  986. ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB,
  987. ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB);
  988. }
  989. if (arizona->pdata.micd_timeout)
  990. info->micd_timeout = arizona->pdata.micd_timeout;
  991. else
  992. info->micd_timeout = DEFAULT_MICD_TIMEOUT;
  993. out:
  994. /* Clear trig_sts to make sure DCVDD is not forced up */
  995. regmap_write(arizona->regmap, ARIZONA_AOD_WKUP_AND_TRIG,
  996. ARIZONA_MICD_CLAMP_FALL_TRIG_STS |
  997. ARIZONA_MICD_CLAMP_RISE_TRIG_STS |
  998. ARIZONA_JD1_FALL_TRIG_STS |
  999. ARIZONA_JD1_RISE_TRIG_STS);
  1000. mutex_unlock(&info->lock);
  1001. pm_runtime_mark_last_busy(info->dev);
  1002. pm_runtime_put_autosuspend(info->dev);
  1003. return IRQ_HANDLED;
  1004. }
  1005. /* Map a level onto a slot in the register bank */
  1006. static void arizona_micd_set_level(struct arizona *arizona, int index,
  1007. unsigned int level)
  1008. {
  1009. int reg;
  1010. unsigned int mask;
  1011. reg = ARIZONA_MIC_DETECT_LEVEL_4 - (index / 2);
  1012. if (!(index % 2)) {
  1013. mask = 0x3f00;
  1014. level <<= 8;
  1015. } else {
  1016. mask = 0x3f;
  1017. }
  1018. /* Program the level itself */
  1019. regmap_update_bits(arizona->regmap, reg, mask, level);
  1020. }
  1021. static int arizona_extcon_get_micd_configs(struct device *dev,
  1022. struct arizona *arizona)
  1023. {
  1024. const char * const prop = "wlf,micd-configs";
  1025. const int entries_per_config = 3;
  1026. struct arizona_micd_config *micd_configs;
  1027. int nconfs, ret;
  1028. int i, j;
  1029. u32 *vals;
  1030. nconfs = device_property_read_u32_array(arizona->dev, prop, NULL, 0);
  1031. if (nconfs <= 0)
  1032. return 0;
  1033. vals = kcalloc(nconfs, sizeof(u32), GFP_KERNEL);
  1034. if (!vals)
  1035. return -ENOMEM;
  1036. ret = device_property_read_u32_array(arizona->dev, prop, vals, nconfs);
  1037. if (ret < 0)
  1038. goto out;
  1039. nconfs /= entries_per_config;
  1040. micd_configs = devm_kcalloc(dev, nconfs, sizeof(*micd_configs),
  1041. GFP_KERNEL);
  1042. if (!micd_configs) {
  1043. ret = -ENOMEM;
  1044. goto out;
  1045. }
  1046. for (i = 0, j = 0; i < nconfs; ++i) {
  1047. micd_configs[i].src = vals[j++] ? ARIZONA_ACCDET_SRC : 0;
  1048. micd_configs[i].bias = vals[j++];
  1049. micd_configs[i].gpio = vals[j++];
  1050. }
  1051. arizona->pdata.micd_configs = micd_configs;
  1052. arizona->pdata.num_micd_configs = nconfs;
  1053. out:
  1054. kfree(vals);
  1055. return ret;
  1056. }
  1057. static int arizona_extcon_device_get_pdata(struct device *dev,
  1058. struct arizona *arizona)
  1059. {
  1060. struct arizona_pdata *pdata = &arizona->pdata;
  1061. unsigned int val = ARIZONA_ACCDET_MODE_HPL;
  1062. int ret;
  1063. device_property_read_u32(arizona->dev, "wlf,hpdet-channel", &val);
  1064. switch (val) {
  1065. case ARIZONA_ACCDET_MODE_HPL:
  1066. case ARIZONA_ACCDET_MODE_HPR:
  1067. pdata->hpdet_channel = val;
  1068. break;
  1069. default:
  1070. dev_err(arizona->dev,
  1071. "Wrong wlf,hpdet-channel DT value %d\n", val);
  1072. pdata->hpdet_channel = ARIZONA_ACCDET_MODE_HPL;
  1073. }
  1074. device_property_read_u32(arizona->dev, "wlf,micd-detect-debounce",
  1075. &pdata->micd_detect_debounce);
  1076. device_property_read_u32(arizona->dev, "wlf,micd-bias-start-time",
  1077. &pdata->micd_bias_start_time);
  1078. device_property_read_u32(arizona->dev, "wlf,micd-rate",
  1079. &pdata->micd_rate);
  1080. device_property_read_u32(arizona->dev, "wlf,micd-dbtime",
  1081. &pdata->micd_dbtime);
  1082. device_property_read_u32(arizona->dev, "wlf,micd-timeout-ms",
  1083. &pdata->micd_timeout);
  1084. pdata->micd_force_micbias = device_property_read_bool(arizona->dev,
  1085. "wlf,micd-force-micbias");
  1086. pdata->micd_software_compare = device_property_read_bool(arizona->dev,
  1087. "wlf,micd-software-compare");
  1088. pdata->jd_invert = device_property_read_bool(arizona->dev,
  1089. "wlf,jd-invert");
  1090. device_property_read_u32(arizona->dev, "wlf,gpsw", &pdata->gpsw);
  1091. pdata->jd_gpio5 = device_property_read_bool(arizona->dev,
  1092. "wlf,use-jd2");
  1093. pdata->jd_gpio5_nopull = device_property_read_bool(arizona->dev,
  1094. "wlf,use-jd2-nopull");
  1095. ret = arizona_extcon_get_micd_configs(dev, arizona);
  1096. if (ret < 0)
  1097. dev_err(arizona->dev, "Failed to read micd configs: %d\n", ret);
  1098. return 0;
  1099. }
  1100. static int arizona_extcon_probe(struct platform_device *pdev)
  1101. {
  1102. struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
  1103. struct arizona_pdata *pdata = &arizona->pdata;
  1104. struct arizona_extcon_info *info;
  1105. unsigned int val;
  1106. unsigned int clamp_mode;
  1107. int jack_irq_fall, jack_irq_rise;
  1108. int ret, mode, i, j;
  1109. if (!arizona->dapm || !arizona->dapm->card)
  1110. return -EPROBE_DEFER;
  1111. info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
  1112. if (!info)
  1113. return -ENOMEM;
  1114. if (!dev_get_platdata(arizona->dev))
  1115. arizona_extcon_device_get_pdata(&pdev->dev, arizona);
  1116. info->micvdd = devm_regulator_get(&pdev->dev, "MICVDD");
  1117. if (IS_ERR(info->micvdd)) {
  1118. ret = PTR_ERR(info->micvdd);
  1119. dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
  1120. return ret;
  1121. }
  1122. mutex_init(&info->lock);
  1123. info->arizona = arizona;
  1124. info->dev = &pdev->dev;
  1125. info->last_jackdet = ~(ARIZONA_MICD_CLAMP_STS | ARIZONA_JD1_STS);
  1126. INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work);
  1127. INIT_DELAYED_WORK(&info->micd_detect_work, arizona_micd_detect);
  1128. INIT_DELAYED_WORK(&info->micd_timeout_work, arizona_micd_timeout_work);
  1129. platform_set_drvdata(pdev, info);
  1130. switch (arizona->type) {
  1131. case WM5102:
  1132. switch (arizona->rev) {
  1133. case 0:
  1134. info->micd_reva = true;
  1135. break;
  1136. default:
  1137. info->micd_clamp = true;
  1138. info->hpdet_ip_version = 1;
  1139. break;
  1140. }
  1141. break;
  1142. case WM5110:
  1143. case WM8280:
  1144. switch (arizona->rev) {
  1145. case 0 ... 2:
  1146. break;
  1147. default:
  1148. info->micd_clamp = true;
  1149. info->hpdet_ip_version = 2;
  1150. break;
  1151. }
  1152. break;
  1153. case WM8998:
  1154. case WM1814:
  1155. info->micd_clamp = true;
  1156. info->hpdet_ip_version = 2;
  1157. break;
  1158. default:
  1159. break;
  1160. }
  1161. info->edev = devm_extcon_dev_allocate(&pdev->dev, arizona_cable);
  1162. if (IS_ERR(info->edev)) {
  1163. dev_err(&pdev->dev, "failed to allocate extcon device\n");
  1164. return -ENOMEM;
  1165. }
  1166. ret = devm_extcon_dev_register(&pdev->dev, info->edev);
  1167. if (ret < 0) {
  1168. dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
  1169. ret);
  1170. return ret;
  1171. }
  1172. info->input = devm_input_allocate_device(&pdev->dev);
  1173. if (!info->input) {
  1174. dev_err(arizona->dev, "Can't allocate input dev\n");
  1175. ret = -ENOMEM;
  1176. goto err_register;
  1177. }
  1178. info->input->name = "Headset";
  1179. info->input->phys = "arizona/extcon";
  1180. if (pdata->num_micd_configs) {
  1181. info->micd_modes = pdata->micd_configs;
  1182. info->micd_num_modes = pdata->num_micd_configs;
  1183. } else {
  1184. info->micd_modes = micd_default_modes;
  1185. info->micd_num_modes = ARRAY_SIZE(micd_default_modes);
  1186. }
  1187. if (arizona->pdata.gpsw > 0)
  1188. regmap_update_bits(arizona->regmap, ARIZONA_GP_SWITCH_1,
  1189. ARIZONA_SW1_MODE_MASK, arizona->pdata.gpsw);
  1190. if (pdata->micd_pol_gpio > 0) {
  1191. if (info->micd_modes[0].gpio)
  1192. mode = GPIOF_OUT_INIT_HIGH;
  1193. else
  1194. mode = GPIOF_OUT_INIT_LOW;
  1195. ret = devm_gpio_request_one(&pdev->dev, pdata->micd_pol_gpio,
  1196. mode, "MICD polarity");
  1197. if (ret != 0) {
  1198. dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
  1199. pdata->micd_pol_gpio, ret);
  1200. goto err_register;
  1201. }
  1202. info->micd_pol_gpio = gpio_to_desc(pdata->micd_pol_gpio);
  1203. } else {
  1204. if (info->micd_modes[0].gpio)
  1205. mode = GPIOD_OUT_HIGH;
  1206. else
  1207. mode = GPIOD_OUT_LOW;
  1208. /* We can't use devm here because we need to do the get
  1209. * against the MFD device, as that is where the of_node
  1210. * will reside, but if we devm against that the GPIO
  1211. * will not be freed if the extcon driver is unloaded.
  1212. */
  1213. info->micd_pol_gpio = gpiod_get_optional(arizona->dev,
  1214. "wlf,micd-pol",
  1215. GPIOD_OUT_LOW);
  1216. if (IS_ERR(info->micd_pol_gpio)) {
  1217. ret = PTR_ERR(info->micd_pol_gpio);
  1218. dev_err(arizona->dev,
  1219. "Failed to get microphone polarity GPIO: %d\n",
  1220. ret);
  1221. goto err_register;
  1222. }
  1223. }
  1224. if (arizona->pdata.hpdet_id_gpio > 0) {
  1225. ret = devm_gpio_request_one(&pdev->dev,
  1226. arizona->pdata.hpdet_id_gpio,
  1227. GPIOF_OUT_INIT_LOW,
  1228. "HPDET");
  1229. if (ret != 0) {
  1230. dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
  1231. arizona->pdata.hpdet_id_gpio, ret);
  1232. goto err_gpio;
  1233. }
  1234. }
  1235. if (arizona->pdata.micd_bias_start_time)
  1236. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  1237. ARIZONA_MICD_BIAS_STARTTIME_MASK,
  1238. arizona->pdata.micd_bias_start_time
  1239. << ARIZONA_MICD_BIAS_STARTTIME_SHIFT);
  1240. if (arizona->pdata.micd_rate)
  1241. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  1242. ARIZONA_MICD_RATE_MASK,
  1243. arizona->pdata.micd_rate
  1244. << ARIZONA_MICD_RATE_SHIFT);
  1245. switch (arizona->pdata.micd_dbtime) {
  1246. case MICD_DBTIME_FOUR_READINGS:
  1247. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  1248. ARIZONA_MICD_DBTIME_MASK,
  1249. ARIZONA_MICD_DBTIME);
  1250. break;
  1251. case MICD_DBTIME_TWO_READINGS:
  1252. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  1253. ARIZONA_MICD_DBTIME_MASK, 0);
  1254. break;
  1255. default:
  1256. break;
  1257. }
  1258. BUILD_BUG_ON(ARRAY_SIZE(arizona_micd_levels) <
  1259. ARIZONA_NUM_MICD_BUTTON_LEVELS);
  1260. if (arizona->pdata.num_micd_ranges) {
  1261. info->micd_ranges = pdata->micd_ranges;
  1262. info->num_micd_ranges = pdata->num_micd_ranges;
  1263. } else {
  1264. info->micd_ranges = micd_default_ranges;
  1265. info->num_micd_ranges = ARRAY_SIZE(micd_default_ranges);
  1266. }
  1267. if (arizona->pdata.num_micd_ranges > ARIZONA_MAX_MICD_RANGE) {
  1268. dev_err(arizona->dev, "Too many MICD ranges: %d\n",
  1269. arizona->pdata.num_micd_ranges);
  1270. }
  1271. if (info->num_micd_ranges > 1) {
  1272. for (i = 1; i < info->num_micd_ranges; i++) {
  1273. if (info->micd_ranges[i - 1].max >
  1274. info->micd_ranges[i].max) {
  1275. dev_err(arizona->dev,
  1276. "MICD ranges must be sorted\n");
  1277. ret = -EINVAL;
  1278. goto err_gpio;
  1279. }
  1280. }
  1281. }
  1282. /* Disable all buttons by default */
  1283. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_2,
  1284. ARIZONA_MICD_LVL_SEL_MASK, 0x81);
  1285. /* Set up all the buttons the user specified */
  1286. for (i = 0; i < info->num_micd_ranges; i++) {
  1287. for (j = 0; j < ARIZONA_NUM_MICD_BUTTON_LEVELS; j++)
  1288. if (arizona_micd_levels[j] >= info->micd_ranges[i].max)
  1289. break;
  1290. if (j == ARIZONA_NUM_MICD_BUTTON_LEVELS) {
  1291. dev_err(arizona->dev, "Unsupported MICD level %d\n",
  1292. info->micd_ranges[i].max);
  1293. ret = -EINVAL;
  1294. goto err_gpio;
  1295. }
  1296. dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n",
  1297. arizona_micd_levels[j], i);
  1298. arizona_micd_set_level(arizona, i, j);
  1299. input_set_capability(info->input, EV_KEY,
  1300. info->micd_ranges[i].key);
  1301. /* Enable reporting of that range */
  1302. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_2,
  1303. 1 << i, 1 << i);
  1304. }
  1305. /* Set all the remaining keys to a maximum */
  1306. for (; i < ARIZONA_MAX_MICD_RANGE; i++)
  1307. arizona_micd_set_level(arizona, i, 0x3f);
  1308. /*
  1309. * If we have a clamp use it, activating in conjunction with
  1310. * GPIO5 if that is connected for jack detect operation.
  1311. */
  1312. if (info->micd_clamp) {
  1313. if (arizona->pdata.jd_gpio5) {
  1314. /* Put the GPIO into input mode with optional pull */
  1315. val = 0xc101;
  1316. if (arizona->pdata.jd_gpio5_nopull)
  1317. val &= ~ARIZONA_GPN_PU;
  1318. regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL,
  1319. val);
  1320. if (arizona->pdata.jd_invert)
  1321. clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH_GP5H;
  1322. else
  1323. clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL_GP5H;
  1324. } else {
  1325. if (arizona->pdata.jd_invert)
  1326. clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDH;
  1327. else
  1328. clamp_mode = ARIZONA_MICD_CLAMP_MODE_JDL;
  1329. }
  1330. regmap_update_bits(arizona->regmap,
  1331. ARIZONA_MICD_CLAMP_CONTROL,
  1332. ARIZONA_MICD_CLAMP_MODE_MASK, clamp_mode);
  1333. regmap_update_bits(arizona->regmap,
  1334. ARIZONA_JACK_DETECT_DEBOUNCE,
  1335. ARIZONA_MICD_CLAMP_DB,
  1336. ARIZONA_MICD_CLAMP_DB);
  1337. }
  1338. arizona_extcon_set_mode(info, 0);
  1339. pm_runtime_enable(&pdev->dev);
  1340. pm_runtime_idle(&pdev->dev);
  1341. pm_runtime_get_sync(&pdev->dev);
  1342. if (info->micd_clamp) {
  1343. jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
  1344. jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
  1345. } else {
  1346. jack_irq_rise = ARIZONA_IRQ_JD_RISE;
  1347. jack_irq_fall = ARIZONA_IRQ_JD_FALL;
  1348. }
  1349. ret = arizona_request_irq(arizona, jack_irq_rise,
  1350. "JACKDET rise", arizona_jackdet, info);
  1351. if (ret != 0) {
  1352. dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
  1353. ret);
  1354. goto err_gpio;
  1355. }
  1356. ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
  1357. if (ret != 0) {
  1358. dev_err(&pdev->dev, "Failed to set JD rise IRQ wake: %d\n",
  1359. ret);
  1360. goto err_rise;
  1361. }
  1362. ret = arizona_request_irq(arizona, jack_irq_fall,
  1363. "JACKDET fall", arizona_jackdet, info);
  1364. if (ret != 0) {
  1365. dev_err(&pdev->dev, "Failed to get JD fall IRQ: %d\n", ret);
  1366. goto err_rise_wake;
  1367. }
  1368. ret = arizona_set_irq_wake(arizona, jack_irq_fall, 1);
  1369. if (ret != 0) {
  1370. dev_err(&pdev->dev, "Failed to set JD fall IRQ wake: %d\n",
  1371. ret);
  1372. goto err_fall;
  1373. }
  1374. ret = arizona_request_irq(arizona, ARIZONA_IRQ_MICDET,
  1375. "MICDET", arizona_micdet, info);
  1376. if (ret != 0) {
  1377. dev_err(&pdev->dev, "Failed to get MICDET IRQ: %d\n", ret);
  1378. goto err_fall_wake;
  1379. }
  1380. ret = arizona_request_irq(arizona, ARIZONA_IRQ_HPDET,
  1381. "HPDET", arizona_hpdet_irq, info);
  1382. if (ret != 0) {
  1383. dev_err(&pdev->dev, "Failed to get HPDET IRQ: %d\n", ret);
  1384. goto err_micdet;
  1385. }
  1386. arizona_clk32k_enable(arizona);
  1387. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE,
  1388. ARIZONA_JD1_DB, ARIZONA_JD1_DB);
  1389. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
  1390. ARIZONA_JD1_ENA, ARIZONA_JD1_ENA);
  1391. ret = regulator_allow_bypass(info->micvdd, true);
  1392. if (ret != 0)
  1393. dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n",
  1394. ret);
  1395. pm_runtime_put(&pdev->dev);
  1396. ret = input_register_device(info->input);
  1397. if (ret) {
  1398. dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
  1399. goto err_hpdet;
  1400. }
  1401. return 0;
  1402. err_hpdet:
  1403. arizona_free_irq(arizona, ARIZONA_IRQ_HPDET, info);
  1404. err_micdet:
  1405. arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
  1406. err_fall_wake:
  1407. arizona_set_irq_wake(arizona, jack_irq_fall, 0);
  1408. err_fall:
  1409. arizona_free_irq(arizona, jack_irq_fall, info);
  1410. err_rise_wake:
  1411. arizona_set_irq_wake(arizona, jack_irq_rise, 0);
  1412. err_rise:
  1413. arizona_free_irq(arizona, jack_irq_rise, info);
  1414. err_gpio:
  1415. gpiod_put(info->micd_pol_gpio);
  1416. err_register:
  1417. pm_runtime_disable(&pdev->dev);
  1418. return ret;
  1419. }
  1420. static int arizona_extcon_remove(struct platform_device *pdev)
  1421. {
  1422. struct arizona_extcon_info *info = platform_get_drvdata(pdev);
  1423. struct arizona *arizona = info->arizona;
  1424. int jack_irq_rise, jack_irq_fall;
  1425. bool change;
  1426. regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
  1427. ARIZONA_MICD_ENA, 0,
  1428. &change);
  1429. if (change) {
  1430. regulator_disable(info->micvdd);
  1431. pm_runtime_put(info->dev);
  1432. }
  1433. gpiod_put(info->micd_pol_gpio);
  1434. pm_runtime_disable(&pdev->dev);
  1435. regmap_update_bits(arizona->regmap,
  1436. ARIZONA_MICD_CLAMP_CONTROL,
  1437. ARIZONA_MICD_CLAMP_MODE_MASK, 0);
  1438. if (info->micd_clamp) {
  1439. jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
  1440. jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
  1441. } else {
  1442. jack_irq_rise = ARIZONA_IRQ_JD_RISE;
  1443. jack_irq_fall = ARIZONA_IRQ_JD_FALL;
  1444. }
  1445. arizona_set_irq_wake(arizona, jack_irq_rise, 0);
  1446. arizona_set_irq_wake(arizona, jack_irq_fall, 0);
  1447. arizona_free_irq(arizona, ARIZONA_IRQ_HPDET, info);
  1448. arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
  1449. arizona_free_irq(arizona, jack_irq_rise, info);
  1450. arizona_free_irq(arizona, jack_irq_fall, info);
  1451. cancel_delayed_work_sync(&info->hpdet_work);
  1452. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
  1453. ARIZONA_JD1_ENA, 0);
  1454. arizona_clk32k_disable(arizona);
  1455. return 0;
  1456. }
  1457. static struct platform_driver arizona_extcon_driver = {
  1458. .driver = {
  1459. .name = "arizona-extcon",
  1460. },
  1461. .probe = arizona_extcon_probe,
  1462. .remove = arizona_extcon_remove,
  1463. };
  1464. module_platform_driver(arizona_extcon_driver);
  1465. MODULE_DESCRIPTION("Arizona Extcon driver");
  1466. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  1467. MODULE_LICENSE("GPL");
  1468. MODULE_ALIAS("platform:extcon-arizona");