da7219-aad.c (6f84981772535e670e4e2df051a672af229b6694) | da7219-aad.c (7fde88eda855952766a74026c181c6270b3392fc) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * da7219-aad.c - Dialog DA7219 ALSA SoC AAD Driver 4 * 5 * Copyright (c) 2015 Dialog Semiconductor Ltd. 6 * 7 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> 8 */ --- 325 unchanged lines hidden (view full) --- 334 * Only send report if jack hasn't been removed during process, 335 * otherwise it's invalid and we drop it. 336 */ 337 if (da7219_aad->jack_inserted) 338 snd_soc_jack_report(da7219_aad->jack, report, 339 SND_JACK_HEADSET | SND_JACK_LINEOUT); 340} 341 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * da7219-aad.c - Dialog DA7219 ALSA SoC AAD Driver 4 * 5 * Copyright (c) 2015 Dialog Semiconductor Ltd. 6 * 7 * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> 8 */ --- 325 unchanged lines hidden (view full) --- 334 * Only send report if jack hasn't been removed during process, 335 * otherwise it's invalid and we drop it. 336 */ 337 if (da7219_aad->jack_inserted) 338 snd_soc_jack_report(da7219_aad->jack, report, 339 SND_JACK_HEADSET | SND_JACK_LINEOUT); 340} 341 |
342static void da7219_aad_jack_det_work(struct work_struct *work) 343{ 344 struct da7219_aad_priv *da7219_aad = 345 container_of(work, struct da7219_aad_priv, jack_det_work); 346 struct snd_soc_component *component = da7219_aad->component; 347 u8 srm_st; |
|
342 | 348 |
349 mutex_lock(&da7219_aad->jack_det_mutex); 350 351 srm_st = snd_soc_component_read(component, DA7219_PLL_SRM_STS) & DA7219_PLL_SRM_STS_MCLK; 352 msleep(da7219_aad->gnd_switch_delay * ((srm_st == 0x0) ? 2 : 1) - 4); 353 /* Enable ground switch */ 354 snd_soc_component_update_bits(component, 0xFB, 0x01, 0x01); 355 356 mutex_unlock(&da7219_aad->jack_det_mutex); 357} 358 359 |
|
343/* 344 * IRQ 345 */ 346 | 360/* 361 * IRQ 362 */ 363 |
364static irqreturn_t da7219_aad_pre_irq_thread(int irq, void *data) 365{ 366 367 struct da7219_aad_priv *da7219_aad = data; 368 369 if (!da7219_aad->jack_inserted) 370 schedule_work(&da7219_aad->jack_det_work); 371 372 return IRQ_WAKE_THREAD; 373} 374 |
|
347static irqreturn_t da7219_aad_irq_thread(int irq, void *data) 348{ 349 struct da7219_aad_priv *da7219_aad = data; 350 struct snd_soc_component *component = da7219_aad->component; 351 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 352 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); 353 u8 events[DA7219_AAD_IRQ_REG_MAX]; | 375static irqreturn_t da7219_aad_irq_thread(int irq, void *data) 376{ 377 struct da7219_aad_priv *da7219_aad = data; 378 struct snd_soc_component *component = da7219_aad->component; 379 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 380 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); 381 u8 events[DA7219_AAD_IRQ_REG_MAX]; |
354 u8 statusa, srm_st; | 382 u8 statusa; |
355 int i, report = 0, mask = 0; 356 | 383 int i, report = 0, mask = 0; 384 |
357 srm_st = snd_soc_component_read(component, DA7219_PLL_SRM_STS) & DA7219_PLL_SRM_STS_MCLK; 358 msleep(da7219_aad->gnd_switch_delay * ((srm_st == 0x0) ? 2 : 1) - 4); 359 /* Enable ground switch */ 360 snd_soc_component_update_bits(component, 0xFB, 0x01, 0x01); 361 | |
362 /* Read current IRQ events */ 363 regmap_bulk_read(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, 364 events, DA7219_AAD_IRQ_REG_MAX); 365 366 if (!events[DA7219_AAD_IRQ_REG_A] && !events[DA7219_AAD_IRQ_REG_B]) 367 return IRQ_NONE; 368 369 /* Read status register for jack insertion & type status */ 370 statusa = snd_soc_component_read(component, DA7219_ACCDET_STATUS_A); 371 372 /* Clear events */ 373 regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, 374 events, DA7219_AAD_IRQ_REG_MAX); 375 376 dev_dbg(component->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", 377 events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], 378 statusa); 379 | 385 /* Read current IRQ events */ 386 regmap_bulk_read(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, 387 events, DA7219_AAD_IRQ_REG_MAX); 388 389 if (!events[DA7219_AAD_IRQ_REG_A] && !events[DA7219_AAD_IRQ_REG_B]) 390 return IRQ_NONE; 391 392 /* Read status register for jack insertion & type status */ 393 statusa = snd_soc_component_read(component, DA7219_ACCDET_STATUS_A); 394 395 /* Clear events */ 396 regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, 397 events, DA7219_AAD_IRQ_REG_MAX); 398 399 dev_dbg(component->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", 400 events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], 401 statusa); 402 |
403 if (!da7219_aad->jack_inserted) 404 cancel_work_sync(&da7219_aad->jack_det_work); 405 |
|
380 if (statusa & DA7219_JACK_INSERTION_STS_MASK) { 381 /* Jack Insertion */ 382 if (events[DA7219_AAD_IRQ_REG_A] & 383 DA7219_E_JACK_INSERTED_MASK) { 384 report |= SND_JACK_MECHANICAL; 385 mask |= SND_JACK_MECHANICAL; 386 da7219_aad->jack_inserted = true; 387 } --- 547 unchanged lines hidden (view full) --- 935 da7219_aad_handle_pdata(component); 936 937 /* Disable button detection */ 938 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, 939 DA7219_BUTTON_CONFIG_MASK, 0); 940 941 INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); 942 INIT_WORK(&da7219_aad->hptest_work, da7219_aad_hptest_work); | 406 if (statusa & DA7219_JACK_INSERTION_STS_MASK) { 407 /* Jack Insertion */ 408 if (events[DA7219_AAD_IRQ_REG_A] & 409 DA7219_E_JACK_INSERTED_MASK) { 410 report |= SND_JACK_MECHANICAL; 411 mask |= SND_JACK_MECHANICAL; 412 da7219_aad->jack_inserted = true; 413 } --- 547 unchanged lines hidden (view full) --- 961 da7219_aad_handle_pdata(component); 962 963 /* Disable button detection */ 964 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, 965 DA7219_BUTTON_CONFIG_MASK, 0); 966 967 INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); 968 INIT_WORK(&da7219_aad->hptest_work, da7219_aad_hptest_work); |
969 INIT_WORK(&da7219_aad->jack_det_work, da7219_aad_jack_det_work); |
|
943 | 970 |
944 ret = request_threaded_irq(da7219_aad->irq, NULL, | 971 ret = request_threaded_irq(da7219_aad->irq, da7219_aad_pre_irq_thread, |
945 da7219_aad_irq_thread, 946 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 947 "da7219-aad", da7219_aad); 948 if (ret) { 949 dev_err(component->dev, "Failed to request IRQ: %d\n", ret); 950 return ret; 951 } 952 --- 53 unchanged lines hidden --- | 972 da7219_aad_irq_thread, 973 IRQF_TRIGGER_LOW | IRQF_ONESHOT, 974 "da7219-aad", da7219_aad); 975 if (ret) { 976 dev_err(component->dev, "Failed to request IRQ: %d\n", ret); 977 return ret; 978 } 979 --- 53 unchanged lines hidden --- |