extcon-arizona.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216
  1. /*
  2. * extcon-arizona.c - Extcon driver Wolfson Arizona devices
  3. *
  4. * Copyright (C) 2012 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.h>
  23. #include <linux/input.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/pm_runtime.h>
  26. #include <linux/regulator/consumer.h>
  27. #include <linux/extcon.h>
  28. #include <sound/soc.h>
  29. #include <linux/mfd/arizona/core.h>
  30. #include <linux/mfd/arizona/pdata.h>
  31. #include <linux/mfd/arizona/registers.h>
  32. #define ARIZONA_NUM_BUTTONS 6
  33. #define ARIZONA_ACCDET_MODE_MIC 0
  34. #define ARIZONA_ACCDET_MODE_HPL 1
  35. #define ARIZONA_ACCDET_MODE_HPR 2
  36. struct arizona_extcon_info {
  37. struct device *dev;
  38. struct arizona *arizona;
  39. struct mutex lock;
  40. struct regulator *micvdd;
  41. struct input_dev *input;
  42. int micd_mode;
  43. const struct arizona_micd_config *micd_modes;
  44. int micd_num_modes;
  45. bool micd_reva;
  46. bool micd_clamp;
  47. struct delayed_work hpdet_work;
  48. bool hpdet_active;
  49. int num_hpdet_res;
  50. unsigned int hpdet_res[3];
  51. bool mic;
  52. bool detecting;
  53. int jack_flips;
  54. int hpdet_ip;
  55. struct extcon_dev edev;
  56. };
  57. static const struct arizona_micd_config micd_default_modes[] = {
  58. { 0, 2 << ARIZONA_MICD_BIAS_SRC_SHIFT, 1 },
  59. { ARIZONA_ACCDET_SRC, 1 << ARIZONA_MICD_BIAS_SRC_SHIFT, 0 },
  60. };
  61. static struct {
  62. u16 status;
  63. int report;
  64. } arizona_lvl_to_key[ARIZONA_NUM_BUTTONS] = {
  65. { 0x1, BTN_0 },
  66. { 0x2, BTN_1 },
  67. { 0x4, BTN_2 },
  68. { 0x8, BTN_3 },
  69. { 0x10, BTN_4 },
  70. { 0x20, BTN_5 },
  71. };
  72. #define ARIZONA_CABLE_MECHANICAL 0
  73. #define ARIZONA_CABLE_MICROPHONE 1
  74. #define ARIZONA_CABLE_HEADPHONE 2
  75. #define ARIZONA_CABLE_LINEOUT 3
  76. static const char *arizona_cable[] = {
  77. "Mechanical",
  78. "Microphone",
  79. "Headphone",
  80. "Line-out",
  81. NULL,
  82. };
  83. static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
  84. {
  85. struct arizona *arizona = info->arizona;
  86. if (arizona->pdata.micd_pol_gpio > 0)
  87. gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
  88. info->micd_modes[mode].gpio);
  89. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  90. ARIZONA_MICD_BIAS_SRC_MASK,
  91. info->micd_modes[mode].bias);
  92. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  93. ARIZONA_ACCDET_SRC, info->micd_modes[mode].src);
  94. info->micd_mode = mode;
  95. dev_dbg(arizona->dev, "Set jack polarity to %d\n", mode);
  96. }
  97. static const char *arizona_extcon_get_micbias(struct arizona_extcon_info *info)
  98. {
  99. switch (info->micd_modes[0].bias >> ARIZONA_MICD_BIAS_SRC_SHIFT) {
  100. case 1:
  101. return "MICBIAS1";
  102. case 2:
  103. return "MICBIAS2";
  104. case 3:
  105. return "MICBIAS3";
  106. default:
  107. return "MICVDD";
  108. }
  109. }
  110. static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
  111. {
  112. struct arizona *arizona = info->arizona;
  113. const char *widget = arizona_extcon_get_micbias(info);
  114. struct snd_soc_dapm_context *dapm = arizona->dapm;
  115. int ret;
  116. mutex_lock(&dapm->card->dapm_mutex);
  117. ret = snd_soc_dapm_force_enable_pin(dapm, widget);
  118. if (ret != 0)
  119. dev_warn(arizona->dev, "Failed to enable %s: %d\n",
  120. widget, ret);
  121. mutex_unlock(&dapm->card->dapm_mutex);
  122. snd_soc_dapm_sync(dapm);
  123. if (!arizona->pdata.micd_force_micbias) {
  124. mutex_lock(&dapm->card->dapm_mutex);
  125. ret = snd_soc_dapm_disable_pin(arizona->dapm, widget);
  126. if (ret != 0)
  127. dev_warn(arizona->dev, "Failed to disable %s: %d\n",
  128. widget, ret);
  129. mutex_unlock(&dapm->card->dapm_mutex);
  130. snd_soc_dapm_sync(dapm);
  131. }
  132. }
  133. static void arizona_start_mic(struct arizona_extcon_info *info)
  134. {
  135. struct arizona *arizona = info->arizona;
  136. bool change;
  137. int ret;
  138. /* Microphone detection can't use idle mode */
  139. pm_runtime_get(info->dev);
  140. if (info->detecting) {
  141. ret = regulator_allow_bypass(info->micvdd, false);
  142. if (ret != 0) {
  143. dev_err(arizona->dev,
  144. "Failed to regulate MICVDD: %d\n",
  145. ret);
  146. }
  147. }
  148. ret = regulator_enable(info->micvdd);
  149. if (ret != 0) {
  150. dev_err(arizona->dev, "Failed to enable MICVDD: %d\n",
  151. ret);
  152. }
  153. if (info->micd_reva) {
  154. regmap_write(arizona->regmap, 0x80, 0x3);
  155. regmap_write(arizona->regmap, 0x294, 0);
  156. regmap_write(arizona->regmap, 0x80, 0x0);
  157. }
  158. regmap_update_bits(arizona->regmap,
  159. ARIZONA_ACCESSORY_DETECT_MODE_1,
  160. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  161. arizona_extcon_pulse_micbias(info);
  162. regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
  163. ARIZONA_MICD_ENA, ARIZONA_MICD_ENA,
  164. &change);
  165. if (!change) {
  166. regulator_disable(info->micvdd);
  167. pm_runtime_put_autosuspend(info->dev);
  168. }
  169. }
  170. static void arizona_stop_mic(struct arizona_extcon_info *info)
  171. {
  172. struct arizona *arizona = info->arizona;
  173. const char *widget = arizona_extcon_get_micbias(info);
  174. struct snd_soc_dapm_context *dapm = arizona->dapm;
  175. bool change;
  176. int ret;
  177. regmap_update_bits_check(arizona->regmap, ARIZONA_MIC_DETECT_1,
  178. ARIZONA_MICD_ENA, 0,
  179. &change);
  180. mutex_lock(&dapm->card->dapm_mutex);
  181. ret = snd_soc_dapm_disable_pin(dapm, widget);
  182. if (ret != 0)
  183. dev_warn(arizona->dev,
  184. "Failed to disable %s: %d\n",
  185. widget, ret);
  186. mutex_unlock(&dapm->card->dapm_mutex);
  187. snd_soc_dapm_sync(dapm);
  188. if (info->micd_reva) {
  189. regmap_write(arizona->regmap, 0x80, 0x3);
  190. regmap_write(arizona->regmap, 0x294, 2);
  191. regmap_write(arizona->regmap, 0x80, 0x0);
  192. }
  193. ret = regulator_allow_bypass(info->micvdd, true);
  194. if (ret != 0) {
  195. dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
  196. ret);
  197. }
  198. if (change) {
  199. regulator_disable(info->micvdd);
  200. pm_runtime_mark_last_busy(info->dev);
  201. pm_runtime_put_autosuspend(info->dev);
  202. }
  203. }
  204. static struct {
  205. unsigned int factor_a;
  206. unsigned int factor_b;
  207. } arizona_hpdet_b_ranges[] = {
  208. { 5528, 362464 },
  209. { 11084, 6186851 },
  210. { 11065, 65460395 },
  211. };
  212. static struct {
  213. int min;
  214. int max;
  215. } arizona_hpdet_c_ranges[] = {
  216. { 0, 30 },
  217. { 8, 100 },
  218. { 100, 1000 },
  219. { 1000, 10000 },
  220. };
  221. static int arizona_hpdet_read(struct arizona_extcon_info *info)
  222. {
  223. struct arizona *arizona = info->arizona;
  224. unsigned int val, range;
  225. int ret;
  226. ret = regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_2, &val);
  227. if (ret != 0) {
  228. dev_err(arizona->dev, "Failed to read HPDET status: %d\n",
  229. ret);
  230. return ret;
  231. }
  232. switch (info->hpdet_ip) {
  233. case 0:
  234. if (!(val & ARIZONA_HP_DONE)) {
  235. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  236. val);
  237. return -EAGAIN;
  238. }
  239. val &= ARIZONA_HP_LVL_MASK;
  240. break;
  241. case 1:
  242. if (!(val & ARIZONA_HP_DONE_B)) {
  243. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  244. val);
  245. return -EAGAIN;
  246. }
  247. ret = regmap_read(arizona->regmap, ARIZONA_HP_DACVAL, &val);
  248. if (ret != 0) {
  249. dev_err(arizona->dev, "Failed to read HP value: %d\n",
  250. ret);
  251. return -EAGAIN;
  252. }
  253. regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  254. &range);
  255. range = (range & ARIZONA_HP_IMPEDANCE_RANGE_MASK)
  256. >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
  257. if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 &&
  258. (val < 100 || val > 0x3fb)) {
  259. range++;
  260. dev_dbg(arizona->dev, "Moving to HPDET range %d\n",
  261. range);
  262. regmap_update_bits(arizona->regmap,
  263. ARIZONA_HEADPHONE_DETECT_1,
  264. ARIZONA_HP_IMPEDANCE_RANGE_MASK,
  265. range <<
  266. ARIZONA_HP_IMPEDANCE_RANGE_SHIFT);
  267. return -EAGAIN;
  268. }
  269. /* If we go out of range report top of range */
  270. if (val < 100 || val > 0x3fb) {
  271. dev_dbg(arizona->dev, "Measurement out of range\n");
  272. return 10000;
  273. }
  274. dev_dbg(arizona->dev, "HPDET read %d in range %d\n",
  275. val, range);
  276. val = arizona_hpdet_b_ranges[range].factor_b
  277. / ((val * 100) -
  278. arizona_hpdet_b_ranges[range].factor_a);
  279. break;
  280. default:
  281. dev_warn(arizona->dev, "Unknown HPDET IP revision %d\n",
  282. info->hpdet_ip);
  283. case 2:
  284. if (!(val & ARIZONA_HP_DONE_B)) {
  285. dev_err(arizona->dev, "HPDET did not complete: %x\n",
  286. val);
  287. return -EAGAIN;
  288. }
  289. val &= ARIZONA_HP_LVL_B_MASK;
  290. regmap_read(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  291. &range);
  292. range = (range & ARIZONA_HP_IMPEDANCE_RANGE_MASK)
  293. >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT;
  294. /* Skip up or down a range? */
  295. if (range && (val < arizona_hpdet_c_ranges[range].min)) {
  296. range--;
  297. dev_dbg(arizona->dev, "Moving to HPDET range %d-%d\n",
  298. arizona_hpdet_c_ranges[range].min,
  299. arizona_hpdet_c_ranges[range].max);
  300. regmap_update_bits(arizona->regmap,
  301. ARIZONA_HEADPHONE_DETECT_1,
  302. ARIZONA_HP_IMPEDANCE_RANGE_MASK,
  303. range <<
  304. ARIZONA_HP_IMPEDANCE_RANGE_SHIFT);
  305. return -EAGAIN;
  306. }
  307. if (range < ARRAY_SIZE(arizona_hpdet_c_ranges) - 1 &&
  308. (val >= arizona_hpdet_c_ranges[range].max)) {
  309. range++;
  310. dev_dbg(arizona->dev, "Moving to HPDET range %d-%d\n",
  311. arizona_hpdet_c_ranges[range].min,
  312. arizona_hpdet_c_ranges[range].max);
  313. regmap_update_bits(arizona->regmap,
  314. ARIZONA_HEADPHONE_DETECT_1,
  315. ARIZONA_HP_IMPEDANCE_RANGE_MASK,
  316. range <<
  317. ARIZONA_HP_IMPEDANCE_RANGE_SHIFT);
  318. return -EAGAIN;
  319. }
  320. }
  321. dev_dbg(arizona->dev, "HP impedance %d ohms\n", val);
  322. return val;
  323. }
  324. static int arizona_hpdet_do_id(struct arizona_extcon_info *info, int *reading)
  325. {
  326. struct arizona *arizona = info->arizona;
  327. int id_gpio = arizona->pdata.hpdet_id_gpio;
  328. int ret;
  329. /*
  330. * If we're using HPDET for accessory identification we need
  331. * to take multiple measurements, step through them in sequence.
  332. */
  333. if (arizona->pdata.hpdet_acc_id) {
  334. info->hpdet_res[info->num_hpdet_res++] = *reading;
  335. /*
  336. * If the impedence is too high don't measure the
  337. * second ground.
  338. */
  339. if (info->num_hpdet_res == 1 && *reading >= 45) {
  340. dev_dbg(arizona->dev, "Skipping ground flip\n");
  341. info->hpdet_res[info->num_hpdet_res++] = *reading;
  342. }
  343. if (info->num_hpdet_res == 1) {
  344. dev_dbg(arizona->dev, "Flipping ground\n");
  345. regmap_update_bits(arizona->regmap,
  346. ARIZONA_ACCESSORY_DETECT_MODE_1,
  347. ARIZONA_ACCDET_SRC,
  348. ~info->micd_modes[0].src);
  349. regmap_update_bits(arizona->regmap,
  350. ARIZONA_HEADPHONE_DETECT_1,
  351. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  352. return -EAGAIN;
  353. }
  354. /* Only check the mic directly if we didn't already ID it */
  355. if (id_gpio && info->num_hpdet_res == 2 &&
  356. !((info->hpdet_res[0] > info->hpdet_res[1] * 2))) {
  357. dev_dbg(arizona->dev, "Measuring mic\n");
  358. regmap_update_bits(arizona->regmap,
  359. ARIZONA_ACCESSORY_DETECT_MODE_1,
  360. ARIZONA_ACCDET_MODE_MASK |
  361. ARIZONA_ACCDET_SRC,
  362. ARIZONA_ACCDET_MODE_HPR |
  363. info->micd_modes[0].src);
  364. gpio_set_value_cansleep(id_gpio, 1);
  365. regmap_update_bits(arizona->regmap,
  366. ARIZONA_HEADPHONE_DETECT_1,
  367. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  368. return -EAGAIN;
  369. }
  370. /* OK, got both. Now, compare... */
  371. dev_dbg(arizona->dev, "HPDET measured %d %d %d\n",
  372. info->hpdet_res[0], info->hpdet_res[1],
  373. info->hpdet_res[2]);
  374. /*
  375. * Either the two grounds measure differently or we
  376. * measure the mic as high impedance.
  377. */
  378. if ((info->hpdet_res[0] > info->hpdet_res[1] * 2) ||
  379. (id_gpio && info->hpdet_res[2] > 10)) {
  380. dev_dbg(arizona->dev, "Detected mic\n");
  381. info->mic = true;
  382. ret = extcon_set_cable_state_(&info->edev,
  383. ARIZONA_CABLE_MICROPHONE,
  384. true);
  385. if (ret != 0) {
  386. dev_err(arizona->dev,
  387. "Failed to report mic: %d\n", ret);
  388. }
  389. /* Take the headphone impedance for the main report */
  390. *reading = info->hpdet_res[1];
  391. } else {
  392. dev_dbg(arizona->dev, "Detected headphone\n");
  393. }
  394. /* Make sure everything is reset back to the real polarity */
  395. regmap_update_bits(arizona->regmap,
  396. ARIZONA_ACCESSORY_DETECT_MODE_1,
  397. ARIZONA_ACCDET_SRC,
  398. info->micd_modes[0].src);
  399. }
  400. return 0;
  401. }
  402. static irqreturn_t arizona_hpdet_irq(int irq, void *data)
  403. {
  404. struct arizona_extcon_info *info = data;
  405. struct arizona *arizona = info->arizona;
  406. int id_gpio = arizona->pdata.hpdet_id_gpio;
  407. int report = ARIZONA_CABLE_HEADPHONE;
  408. int ret, reading;
  409. mutex_lock(&info->lock);
  410. /* If we got a spurious IRQ for some reason then ignore it */
  411. if (!info->hpdet_active) {
  412. dev_warn(arizona->dev, "Spurious HPDET IRQ\n");
  413. mutex_unlock(&info->lock);
  414. return IRQ_NONE;
  415. }
  416. /* If the cable was removed while measuring ignore the result */
  417. ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL);
  418. if (ret < 0) {
  419. dev_err(arizona->dev, "Failed to check cable state: %d\n",
  420. ret);
  421. goto out;
  422. } else if (!ret) {
  423. dev_dbg(arizona->dev, "Ignoring HPDET for removed cable\n");
  424. goto done;
  425. }
  426. ret = arizona_hpdet_read(info);
  427. if (ret == -EAGAIN) {
  428. goto out;
  429. } else if (ret < 0) {
  430. goto done;
  431. }
  432. reading = ret;
  433. /* Reset back to starting range */
  434. regmap_update_bits(arizona->regmap,
  435. ARIZONA_HEADPHONE_DETECT_1,
  436. ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
  437. 0);
  438. ret = arizona_hpdet_do_id(info, &reading);
  439. if (ret == -EAGAIN) {
  440. goto out;
  441. } else if (ret < 0) {
  442. goto done;
  443. }
  444. /* Report high impedence cables as line outputs */
  445. if (reading >= 5000)
  446. report = ARIZONA_CABLE_LINEOUT;
  447. else
  448. report = ARIZONA_CABLE_HEADPHONE;
  449. ret = extcon_set_cable_state_(&info->edev, report, true);
  450. if (ret != 0)
  451. dev_err(arizona->dev, "Failed to report HP/line: %d\n",
  452. ret);
  453. ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0);
  454. if (ret != 0)
  455. dev_warn(arizona->dev, "Failed to undo magic: %d\n", ret);
  456. ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0);
  457. if (ret != 0)
  458. dev_warn(arizona->dev, "Failed to undo magic: %d\n", ret);
  459. done:
  460. if (id_gpio)
  461. gpio_set_value_cansleep(id_gpio, 0);
  462. /* Revert back to MICDET mode */
  463. regmap_update_bits(arizona->regmap,
  464. ARIZONA_ACCESSORY_DETECT_MODE_1,
  465. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  466. /* If we have a mic then reenable MICDET */
  467. if (info->mic)
  468. arizona_start_mic(info);
  469. if (info->hpdet_active) {
  470. pm_runtime_put_autosuspend(info->dev);
  471. info->hpdet_active = false;
  472. }
  473. out:
  474. mutex_unlock(&info->lock);
  475. return IRQ_HANDLED;
  476. }
  477. static void arizona_identify_headphone(struct arizona_extcon_info *info)
  478. {
  479. struct arizona *arizona = info->arizona;
  480. int ret;
  481. dev_dbg(arizona->dev, "Starting HPDET\n");
  482. /* Make sure we keep the device enabled during the measurement */
  483. pm_runtime_get(info->dev);
  484. info->hpdet_active = true;
  485. if (info->mic)
  486. arizona_stop_mic(info);
  487. ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000);
  488. if (ret != 0)
  489. dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
  490. ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0x4000);
  491. if (ret != 0)
  492. dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
  493. ret = regmap_update_bits(arizona->regmap,
  494. ARIZONA_ACCESSORY_DETECT_MODE_1,
  495. ARIZONA_ACCDET_MODE_MASK,
  496. ARIZONA_ACCDET_MODE_HPL);
  497. if (ret != 0) {
  498. dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
  499. goto err;
  500. }
  501. ret = regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  502. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  503. if (ret != 0) {
  504. dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n",
  505. ret);
  506. goto err;
  507. }
  508. return;
  509. err:
  510. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  511. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  512. /* Just report headphone */
  513. ret = extcon_update_state(&info->edev,
  514. 1 << ARIZONA_CABLE_HEADPHONE,
  515. 1 << ARIZONA_CABLE_HEADPHONE);
  516. if (ret != 0)
  517. dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
  518. if (info->mic)
  519. arizona_start_mic(info);
  520. info->hpdet_active = false;
  521. }
  522. static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
  523. {
  524. struct arizona *arizona = info->arizona;
  525. int ret;
  526. dev_dbg(arizona->dev, "Starting identification via HPDET\n");
  527. /* Make sure we keep the device enabled during the measurement */
  528. pm_runtime_get_sync(info->dev);
  529. info->hpdet_active = true;
  530. arizona_extcon_pulse_micbias(info);
  531. ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000, 0x4000);
  532. if (ret != 0)
  533. dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
  534. ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000, 0x4000);
  535. if (ret != 0)
  536. dev_warn(arizona->dev, "Failed to do magic: %d\n", ret);
  537. ret = regmap_update_bits(arizona->regmap,
  538. ARIZONA_ACCESSORY_DETECT_MODE_1,
  539. ARIZONA_ACCDET_SRC | ARIZONA_ACCDET_MODE_MASK,
  540. info->micd_modes[0].src |
  541. ARIZONA_ACCDET_MODE_HPL);
  542. if (ret != 0) {
  543. dev_err(arizona->dev, "Failed to set HPDETL mode: %d\n", ret);
  544. goto err;
  545. }
  546. ret = regmap_update_bits(arizona->regmap, ARIZONA_HEADPHONE_DETECT_1,
  547. ARIZONA_HP_POLL, ARIZONA_HP_POLL);
  548. if (ret != 0) {
  549. dev_err(arizona->dev, "Can't start HPDETL measurement: %d\n",
  550. ret);
  551. goto err;
  552. }
  553. return;
  554. err:
  555. regmap_update_bits(arizona->regmap, ARIZONA_ACCESSORY_DETECT_MODE_1,
  556. ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
  557. /* Just report headphone */
  558. ret = extcon_update_state(&info->edev,
  559. 1 << ARIZONA_CABLE_HEADPHONE,
  560. 1 << ARIZONA_CABLE_HEADPHONE);
  561. if (ret != 0)
  562. dev_err(arizona->dev, "Failed to report headphone: %d\n", ret);
  563. info->hpdet_active = false;
  564. }
  565. static irqreturn_t arizona_micdet(int irq, void *data)
  566. {
  567. struct arizona_extcon_info *info = data;
  568. struct arizona *arizona = info->arizona;
  569. unsigned int val, lvl;
  570. int ret, i;
  571. mutex_lock(&info->lock);
  572. ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
  573. if (ret != 0) {
  574. dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret);
  575. mutex_unlock(&info->lock);
  576. return IRQ_NONE;
  577. }
  578. dev_dbg(arizona->dev, "MICDET: %x\n", val);
  579. if (!(val & ARIZONA_MICD_VALID)) {
  580. dev_warn(arizona->dev, "Microphone detection state invalid\n");
  581. mutex_unlock(&info->lock);
  582. return IRQ_NONE;
  583. }
  584. /* Due to jack detect this should never happen */
  585. if (!(val & ARIZONA_MICD_STS)) {
  586. dev_warn(arizona->dev, "Detected open circuit\n");
  587. info->detecting = false;
  588. goto handled;
  589. }
  590. /* If we got a high impedence we should have a headset, report it. */
  591. if (info->detecting && (val & 0x400)) {
  592. arizona_identify_headphone(info);
  593. ret = extcon_update_state(&info->edev,
  594. 1 << ARIZONA_CABLE_MICROPHONE,
  595. 1 << ARIZONA_CABLE_MICROPHONE);
  596. if (ret != 0)
  597. dev_err(arizona->dev, "Headset report failed: %d\n",
  598. ret);
  599. /* Don't need to regulate for button detection */
  600. ret = regulator_allow_bypass(info->micvdd, false);
  601. if (ret != 0) {
  602. dev_err(arizona->dev, "Failed to bypass MICVDD: %d\n",
  603. ret);
  604. }
  605. info->mic = true;
  606. info->detecting = false;
  607. goto handled;
  608. }
  609. /* If we detected a lower impedence during initial startup
  610. * then we probably have the wrong polarity, flip it. Don't
  611. * do this for the lowest impedences to speed up detection of
  612. * plain headphones. If both polarities report a low
  613. * impedence then give up and report headphones.
  614. */
  615. if (info->detecting && (val & 0x3f8)) {
  616. if (info->jack_flips >= info->micd_num_modes) {
  617. dev_dbg(arizona->dev, "Detected HP/line\n");
  618. arizona_identify_headphone(info);
  619. info->detecting = false;
  620. arizona_stop_mic(info);
  621. } else {
  622. info->micd_mode++;
  623. if (info->micd_mode == info->micd_num_modes)
  624. info->micd_mode = 0;
  625. arizona_extcon_set_mode(info, info->micd_mode);
  626. info->jack_flips++;
  627. }
  628. goto handled;
  629. }
  630. /*
  631. * If we're still detecting and we detect a short then we've
  632. * got a headphone. Otherwise it's a button press.
  633. */
  634. if (val & 0x3fc) {
  635. if (info->mic) {
  636. dev_dbg(arizona->dev, "Mic button detected\n");
  637. lvl = val & ARIZONA_MICD_LVL_MASK;
  638. lvl >>= ARIZONA_MICD_LVL_SHIFT;
  639. for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
  640. if (lvl & arizona_lvl_to_key[i].status)
  641. input_report_key(info->input,
  642. arizona_lvl_to_key[i].report,
  643. 1);
  644. input_sync(info->input);
  645. } else if (info->detecting) {
  646. dev_dbg(arizona->dev, "Headphone detected\n");
  647. info->detecting = false;
  648. arizona_stop_mic(info);
  649. arizona_identify_headphone(info);
  650. } else {
  651. dev_warn(arizona->dev, "Button with no mic: %x\n",
  652. val);
  653. }
  654. } else {
  655. dev_dbg(arizona->dev, "Mic button released\n");
  656. for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
  657. input_report_key(info->input,
  658. arizona_lvl_to_key[i].report, 0);
  659. input_sync(info->input);
  660. arizona_extcon_pulse_micbias(info);
  661. }
  662. handled:
  663. pm_runtime_mark_last_busy(info->dev);
  664. mutex_unlock(&info->lock);
  665. return IRQ_HANDLED;
  666. }
  667. static void arizona_hpdet_work(struct work_struct *work)
  668. {
  669. struct arizona_extcon_info *info = container_of(work,
  670. struct arizona_extcon_info,
  671. hpdet_work.work);
  672. mutex_lock(&info->lock);
  673. arizona_start_hpdet_acc_id(info);
  674. mutex_unlock(&info->lock);
  675. }
  676. static irqreturn_t arizona_jackdet(int irq, void *data)
  677. {
  678. struct arizona_extcon_info *info = data;
  679. struct arizona *arizona = info->arizona;
  680. unsigned int val, present, mask;
  681. int ret, i;
  682. pm_runtime_get_sync(info->dev);
  683. cancel_delayed_work_sync(&info->hpdet_work);
  684. mutex_lock(&info->lock);
  685. if (arizona->pdata.jd_gpio5) {
  686. mask = ARIZONA_MICD_CLAMP_STS;
  687. present = 0;
  688. } else {
  689. mask = ARIZONA_JD1_STS;
  690. present = ARIZONA_JD1_STS;
  691. }
  692. ret = regmap_read(arizona->regmap, ARIZONA_AOD_IRQ_RAW_STATUS, &val);
  693. if (ret != 0) {
  694. dev_err(arizona->dev, "Failed to read jackdet status: %d\n",
  695. ret);
  696. mutex_unlock(&info->lock);
  697. pm_runtime_put_autosuspend(info->dev);
  698. return IRQ_NONE;
  699. }
  700. if ((val & mask) == present) {
  701. dev_dbg(arizona->dev, "Detected jack\n");
  702. ret = extcon_set_cable_state_(&info->edev,
  703. ARIZONA_CABLE_MECHANICAL, true);
  704. if (ret != 0)
  705. dev_err(arizona->dev, "Mechanical report failed: %d\n",
  706. ret);
  707. if (!arizona->pdata.hpdet_acc_id) {
  708. info->detecting = true;
  709. info->mic = false;
  710. info->jack_flips = 0;
  711. arizona_start_mic(info);
  712. } else {
  713. schedule_delayed_work(&info->hpdet_work,
  714. msecs_to_jiffies(250));
  715. }
  716. regmap_update_bits(arizona->regmap,
  717. ARIZONA_JACK_DETECT_DEBOUNCE,
  718. ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB, 0);
  719. } else {
  720. dev_dbg(arizona->dev, "Detected jack removal\n");
  721. arizona_stop_mic(info);
  722. info->num_hpdet_res = 0;
  723. for (i = 0; i < ARRAY_SIZE(info->hpdet_res); i++)
  724. info->hpdet_res[i] = 0;
  725. info->mic = false;
  726. for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
  727. input_report_key(info->input,
  728. arizona_lvl_to_key[i].report, 0);
  729. input_sync(info->input);
  730. ret = extcon_update_state(&info->edev, 0xffffffff, 0);
  731. if (ret != 0)
  732. dev_err(arizona->dev, "Removal report failed: %d\n",
  733. ret);
  734. regmap_update_bits(arizona->regmap,
  735. ARIZONA_JACK_DETECT_DEBOUNCE,
  736. ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB,
  737. ARIZONA_MICD_CLAMP_DB | ARIZONA_JD1_DB);
  738. }
  739. mutex_unlock(&info->lock);
  740. pm_runtime_mark_last_busy(info->dev);
  741. pm_runtime_put_autosuspend(info->dev);
  742. return IRQ_HANDLED;
  743. }
  744. static int arizona_extcon_probe(struct platform_device *pdev)
  745. {
  746. struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
  747. struct arizona_pdata *pdata;
  748. struct arizona_extcon_info *info;
  749. int jack_irq_fall, jack_irq_rise;
  750. int ret, mode, i;
  751. if (!arizona->dapm || !arizona->dapm->card)
  752. return -EPROBE_DEFER;
  753. pdata = dev_get_platdata(arizona->dev);
  754. info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
  755. if (!info) {
  756. dev_err(&pdev->dev, "Failed to allocate memory\n");
  757. ret = -ENOMEM;
  758. goto err;
  759. }
  760. info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
  761. if (IS_ERR(info->micvdd)) {
  762. ret = PTR_ERR(info->micvdd);
  763. dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
  764. goto err;
  765. }
  766. mutex_init(&info->lock);
  767. info->arizona = arizona;
  768. info->dev = &pdev->dev;
  769. INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work);
  770. platform_set_drvdata(pdev, info);
  771. switch (arizona->type) {
  772. case WM5102:
  773. switch (arizona->rev) {
  774. case 0:
  775. info->micd_reva = true;
  776. break;
  777. default:
  778. info->micd_clamp = true;
  779. info->hpdet_ip = 1;
  780. break;
  781. }
  782. break;
  783. default:
  784. break;
  785. }
  786. info->edev.name = "Headset Jack";
  787. info->edev.supported_cable = arizona_cable;
  788. ret = extcon_dev_register(&info->edev, arizona->dev);
  789. if (ret < 0) {
  790. dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
  791. ret);
  792. goto err;
  793. }
  794. if (pdata->num_micd_configs) {
  795. info->micd_modes = pdata->micd_configs;
  796. info->micd_num_modes = pdata->num_micd_configs;
  797. } else {
  798. info->micd_modes = micd_default_modes;
  799. info->micd_num_modes = ARRAY_SIZE(micd_default_modes);
  800. }
  801. if (arizona->pdata.micd_pol_gpio > 0) {
  802. if (info->micd_modes[0].gpio)
  803. mode = GPIOF_OUT_INIT_HIGH;
  804. else
  805. mode = GPIOF_OUT_INIT_LOW;
  806. ret = devm_gpio_request_one(&pdev->dev,
  807. arizona->pdata.micd_pol_gpio,
  808. mode,
  809. "MICD polarity");
  810. if (ret != 0) {
  811. dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
  812. arizona->pdata.micd_pol_gpio, ret);
  813. goto err_register;
  814. }
  815. }
  816. if (arizona->pdata.hpdet_id_gpio > 0) {
  817. ret = devm_gpio_request_one(&pdev->dev,
  818. arizona->pdata.hpdet_id_gpio,
  819. GPIOF_OUT_INIT_LOW,
  820. "HPDET");
  821. if (ret != 0) {
  822. dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
  823. arizona->pdata.hpdet_id_gpio, ret);
  824. goto err_register;
  825. }
  826. }
  827. if (arizona->pdata.micd_bias_start_time)
  828. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  829. ARIZONA_MICD_BIAS_STARTTIME_MASK,
  830. arizona->pdata.micd_bias_start_time
  831. << ARIZONA_MICD_BIAS_STARTTIME_SHIFT);
  832. if (arizona->pdata.micd_rate)
  833. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  834. ARIZONA_MICD_RATE_MASK,
  835. arizona->pdata.micd_rate
  836. << ARIZONA_MICD_RATE_SHIFT);
  837. if (arizona->pdata.micd_dbtime)
  838. regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
  839. ARIZONA_MICD_DBTIME_MASK,
  840. arizona->pdata.micd_dbtime
  841. << ARIZONA_MICD_DBTIME_SHIFT);
  842. /*
  843. * If we have a clamp use it, activating in conjunction with
  844. * GPIO5 if that is connected for jack detect operation.
  845. */
  846. if (info->micd_clamp) {
  847. if (arizona->pdata.jd_gpio5) {
  848. /* Put the GPIO into input mode */
  849. regmap_write(arizona->regmap, ARIZONA_GPIO5_CTRL,
  850. 0xc101);
  851. regmap_update_bits(arizona->regmap,
  852. ARIZONA_MICD_CLAMP_CONTROL,
  853. ARIZONA_MICD_CLAMP_MODE_MASK, 0x9);
  854. } else {
  855. regmap_update_bits(arizona->regmap,
  856. ARIZONA_MICD_CLAMP_CONTROL,
  857. ARIZONA_MICD_CLAMP_MODE_MASK, 0x4);
  858. }
  859. regmap_update_bits(arizona->regmap,
  860. ARIZONA_JACK_DETECT_DEBOUNCE,
  861. ARIZONA_MICD_CLAMP_DB,
  862. ARIZONA_MICD_CLAMP_DB);
  863. }
  864. arizona_extcon_set_mode(info, 0);
  865. info->input = devm_input_allocate_device(&pdev->dev);
  866. if (!info->input) {
  867. dev_err(arizona->dev, "Can't allocate input dev\n");
  868. ret = -ENOMEM;
  869. goto err_register;
  870. }
  871. for (i = 0; i < ARIZONA_NUM_BUTTONS; i++)
  872. input_set_capability(info->input, EV_KEY,
  873. arizona_lvl_to_key[i].report);
  874. info->input->name = "Headset";
  875. info->input->phys = "arizona/extcon";
  876. info->input->dev.parent = &pdev->dev;
  877. pm_runtime_enable(&pdev->dev);
  878. pm_runtime_idle(&pdev->dev);
  879. pm_runtime_get_sync(&pdev->dev);
  880. if (arizona->pdata.jd_gpio5) {
  881. jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
  882. jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
  883. } else {
  884. jack_irq_rise = ARIZONA_IRQ_JD_RISE;
  885. jack_irq_fall = ARIZONA_IRQ_JD_FALL;
  886. }
  887. ret = arizona_request_irq(arizona, jack_irq_rise,
  888. "JACKDET rise", arizona_jackdet, info);
  889. if (ret != 0) {
  890. dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
  891. ret);
  892. goto err_input;
  893. }
  894. ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
  895. if (ret != 0) {
  896. dev_err(&pdev->dev, "Failed to set JD rise IRQ wake: %d\n",
  897. ret);
  898. goto err_rise;
  899. }
  900. ret = arizona_request_irq(arizona, jack_irq_fall,
  901. "JACKDET fall", arizona_jackdet, info);
  902. if (ret != 0) {
  903. dev_err(&pdev->dev, "Failed to get JD fall IRQ: %d\n", ret);
  904. goto err_rise_wake;
  905. }
  906. ret = arizona_set_irq_wake(arizona, jack_irq_fall, 1);
  907. if (ret != 0) {
  908. dev_err(&pdev->dev, "Failed to set JD fall IRQ wake: %d\n",
  909. ret);
  910. goto err_fall;
  911. }
  912. ret = arizona_request_irq(arizona, ARIZONA_IRQ_MICDET,
  913. "MICDET", arizona_micdet, info);
  914. if (ret != 0) {
  915. dev_err(&pdev->dev, "Failed to get MICDET IRQ: %d\n", ret);
  916. goto err_fall_wake;
  917. }
  918. ret = arizona_request_irq(arizona, ARIZONA_IRQ_HPDET,
  919. "HPDET", arizona_hpdet_irq, info);
  920. if (ret != 0) {
  921. dev_err(&pdev->dev, "Failed to get HPDET IRQ: %d\n", ret);
  922. goto err_micdet;
  923. }
  924. arizona_clk32k_enable(arizona);
  925. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_DEBOUNCE,
  926. ARIZONA_JD1_DB, ARIZONA_JD1_DB);
  927. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
  928. ARIZONA_JD1_ENA, ARIZONA_JD1_ENA);
  929. ret = regulator_allow_bypass(info->micvdd, true);
  930. if (ret != 0)
  931. dev_warn(arizona->dev, "Failed to set MICVDD to bypass: %d\n",
  932. ret);
  933. pm_runtime_put(&pdev->dev);
  934. ret = input_register_device(info->input);
  935. if (ret) {
  936. dev_err(&pdev->dev, "Can't register input device: %d\n", ret);
  937. goto err_hpdet;
  938. }
  939. return 0;
  940. err_hpdet:
  941. arizona_free_irq(arizona, ARIZONA_IRQ_HPDET, info);
  942. err_micdet:
  943. arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
  944. err_fall_wake:
  945. arizona_set_irq_wake(arizona, jack_irq_fall, 0);
  946. err_fall:
  947. arizona_free_irq(arizona, jack_irq_fall, info);
  948. err_rise_wake:
  949. arizona_set_irq_wake(arizona, jack_irq_rise, 0);
  950. err_rise:
  951. arizona_free_irq(arizona, jack_irq_rise, info);
  952. err_input:
  953. err_register:
  954. pm_runtime_disable(&pdev->dev);
  955. extcon_dev_unregister(&info->edev);
  956. err:
  957. return ret;
  958. }
  959. static int arizona_extcon_remove(struct platform_device *pdev)
  960. {
  961. struct arizona_extcon_info *info = platform_get_drvdata(pdev);
  962. struct arizona *arizona = info->arizona;
  963. int jack_irq_rise, jack_irq_fall;
  964. pm_runtime_disable(&pdev->dev);
  965. regmap_update_bits(arizona->regmap,
  966. ARIZONA_MICD_CLAMP_CONTROL,
  967. ARIZONA_MICD_CLAMP_MODE_MASK, 0);
  968. if (arizona->pdata.jd_gpio5) {
  969. jack_irq_rise = ARIZONA_IRQ_MICD_CLAMP_RISE;
  970. jack_irq_fall = ARIZONA_IRQ_MICD_CLAMP_FALL;
  971. } else {
  972. jack_irq_rise = ARIZONA_IRQ_JD_RISE;
  973. jack_irq_fall = ARIZONA_IRQ_JD_FALL;
  974. }
  975. arizona_set_irq_wake(arizona, jack_irq_rise, 0);
  976. arizona_set_irq_wake(arizona, jack_irq_fall, 0);
  977. arizona_free_irq(arizona, ARIZONA_IRQ_HPDET, info);
  978. arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info);
  979. arizona_free_irq(arizona, jack_irq_rise, info);
  980. arizona_free_irq(arizona, jack_irq_fall, info);
  981. cancel_delayed_work_sync(&info->hpdet_work);
  982. regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
  983. ARIZONA_JD1_ENA, 0);
  984. arizona_clk32k_disable(arizona);
  985. extcon_dev_unregister(&info->edev);
  986. return 0;
  987. }
  988. static struct platform_driver arizona_extcon_driver = {
  989. .driver = {
  990. .name = "arizona-extcon",
  991. .owner = THIS_MODULE,
  992. },
  993. .probe = arizona_extcon_probe,
  994. .remove = arizona_extcon_remove,
  995. };
  996. module_platform_driver(arizona_extcon_driver);
  997. MODULE_DESCRIPTION("Arizona Extcon driver");
  998. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  999. MODULE_LICENSE("GPL");
  1000. MODULE_ALIAS("platform:extcon-arizona");