Merge series "Add mediatek MT6359 ASoC accdet jack driver" from Argus Lin <argus.lin@mediatek.com>:

All of 3-pole and 4-pole jack are supported.

change since v2:
  - fixs missing blank at Kconfig.
  - fixs comment format and spelling mistake.
  - changes private structure mt6359_accdet to mt6359-accdet.h and uses this
    data as function parameter.
  - removes compatible string declaration.
  - uses regmap_read_poll_timeout as polling timer.
  - simplify jack detection and key detection report function.
  - adds mt6359_accdet_enable_jack_detect for sound card jack initialization.

change since v1:
  - adds mt6359 accdet binding document
  - adds mt6359 accdet driver

*** BLURB HERE ***

Argus Lin (2):
  dt-bindings: mediatek: mt6359: add ASoC mt6359 ASoC accdet jack
    document
  ASoC: mediatek: mt6359: add MT6359 accdet jack driver

 .../bindings/sound/mt6359-accdet.yaml         |  164 ++
 sound/soc/codecs/Kconfig                      |    8 +
 sound/soc/codecs/Makefile                     |    2 +
 sound/soc/codecs/mt6359-accdet.c              | 1080 ++++++++++
 sound/soc/codecs/mt6359-accdet.h              |  128 ++
 sound/soc/codecs/mt6359.h                     | 1864 ++++++++++++++++-
 6 files changed, 3139 insertions(+), 107 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/mt6359-accdet.yaml
 create mode 100644 sound/soc/codecs/mt6359-accdet.c
 create mode 100644 sound/soc/codecs/mt6359-accdet.h

--
2.18.0
This commit is contained in:
Mark Brown 2021-03-29 20:30:51 +01:00
commit 3de72d6a28
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
6 changed files with 3136 additions and 104 deletions

View File

@ -0,0 +1,164 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/mt6359-accdet.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Mediatek Technologies Inc. MT6359 ASoC accdet jack driver bindings
maintainers:
- Chipeng Chang <chipeng.chang@mediatek.com>
description: |
This binding describes the Mediatek Technologies MT6359 ASoC
accdet jack driver.
properties:
mediatek,accdet-name:
maxItems: 1
description: named as "mt6359-accdet" jack.
mediatek,mic-vol:
maxItems: 1
description: |
accdet micbias1 voltage.
enum:
- 0x00 # 1.7v - micbias1 volage is 1.7v.
- 0x01 # 1.8v - micbias1 volage is 1.8v.
- 0x02 # 1.9v - micbias1 volage is 1.9v.
- 0x03 # 2.0v - micbias1 volage is 2.0v.
- 0x04 # 2.1v - micbias1 volage is 2.1v.
- 0x05 # 2.5v - micbias1 volage is 2.5v.
- 0x06 # 2.6v - micbias1 volage is 2.6v.
- 0x07 # 2.7v - micbias1 volage is 2.7v.
- 0x08 # 2.8v - micbias1 volage is 2.8v.
- 0x09 # 2.85v - micbias1 volage is 2.85v.
mediatek,mic-mode:
maxItems: 1
description: |
value as 1, 2, 6 to indicate ACC/DCC mode. default is DCC mode 2.
enum:
- 0x01 # ACC - ACC mode.
- 0x02 # DCC - low cost without in bias.
- 0x06 # DCC - low cost with in bias.
mediatek,pwm-deb-setting:
maxItems: 15
description: |
headset-mode-setting : Indicates customized pwm, debounce setting
accdet pwm_width, pwm_thresh, fall_delay, rise_delay
debounce0, debounce1, debounce3, debounce4
eint pwm_width, eint pwm_thresh
eint deb(debounce0, debounce1, debounce2, debounce3), inv_debounce.
mediatek,eint-use-ap:
maxItems: 1
description: |
indicates to use ap gpio.
enum:
- 0x00 # MT6359 eint detection mode.
- 0x01 # SoC GPIO detection mode.
mediatek,eint-detect-mode:
maxItems: 1
description: |
indicates to use ap gpio.
enum:
- 0x00 # detection mode with higher detection power.
- 0x01 # detection mode with lower detection power.
- 0x02 # detection mode with sw moisture detection mode.
- 0x03 # detection mode with hw moisture detection mode1.
- 0x04 # detection mode with hw moisture detection mode2.
mediatek,eint-num:
maxItems: 1
description: |
incicates pmic eint usage.
enum:
- 0x0 # PMIC_EINT0 - use pmic eint0 to trigger plug interrupt.
- 0x1 # PMIC_EINT1 - use pmic eint1 to trigger plug interrupt.
- 0x2 # PMIC_BI_EINT - use pmic eint0/1 to trigger plug interrupt.
mediatek,eint-trig-mode:
maxItems: 1
description: |
incicates pmic eint trigger mode.
enum:
- 0x0 # PMIC_GPIO - use pmic gpio to detect plug status.
- 0x1 # PMIC_INVERTER - use pmic inverter to detect plug status.
mediatek,eint-use-ext-res:
maxItems: 1
description: |
select HP_EINT pull up resistance, default 0 use internal resistance.
enum:
- 0x0 # use internal resistor.
- 0x1 # use external resistor.
mediatek,eint-comp-vth:
maxItems: 1
description: |
indicates comparator detection voltage.
enum:
- 0x00 # 2.8v.
- 0x01 # 2.4v.
- 0x02 # 2.0v.
- 0x03 # 0.7v.
mediatek,key-mode:
maxItems: 1
description: |
incicates key mode type.
enum:
- 0x0 # THREE_KEY - support 3-key key mode.
- 0x1 # FOUR_KEY - support 4-key key mode.
- 0x2 # TRI_KEY_CDD - support 3-key google CDD key mode.
mediatek,three-key-thr:
maxItems: 4
description: |
3 key device detection threshold: 0--MD_MAX--UP_MAX--DW_MAX.
mediatek,tri-key-cdd-thr:
maxItems: 4
description: |
3 key CDD device detection threshold: 0--MD_MAX--UP_MAX--DW_MAX.
mediatek,four-key-thr:
maxItems: 4
description: |
4 key device detection threshold: 0--MD_MAX--VOICE_MAX--UP_MAX--DW_MAX.
additionalProperties: false
examples:
- |
accdet: accdet {
mediatek,accdet-name = "mt6359-accdet";
mediatek,mic-vol = <8>;
mediatek,mic-mode = <2>;
mediatek,pwm-deb-setting = <0x500 0x500 1 0x1f0
0x800 0x800 0x20 0x44
0x4 0x1
0x5 0x3 0x3 0x5 0xe>;
mediatek,eint-use-ap = <0>;
mediatek,eint-detect-mode = <4>;
mediatek,eint-num = <0>;
mediatek,eint-trig-mode = <1>;
mediatek,eint-use-ext-res = <0>;
mediatek,eint-comp-vth = <2>;
mediatek,key-mode = <0>;
mediatek,three-key-thr = <0 80 220 400>;
status = "okay";
};
...

View File

@ -1812,6 +1812,14 @@ config SND_SOC_MT6359
Enable support for the platform which uses MT6359 as
external codec device.
config SND_SOC_MT6359_ACCDET
tristate "MediaTek MT6359 ACCDET driver"
depends on MTK_PMIC_WRAP
help
ACCDET means Accessory Detection technology, MediaTek develop it
for ASoC codec soc-jack detection mechanism.
Select N if you don't have jack on board.
config SND_SOC_MT6660
tristate "Mediatek MT6660 Speaker Amplifier"
depends on I2C

View File

@ -136,6 +136,7 @@ snd-soc-msm8916-digital-objs := msm8916-wcd-digital.o
snd-soc-mt6351-objs := mt6351.o
snd-soc-mt6358-objs := mt6358.o
snd-soc-mt6359-objs := mt6359.o
snd-soc-mt6359-accdet-objs := mt6359-accdet.o
snd-soc-mt6660-objs := mt6660.o
snd-soc-nau8315-objs := nau8315.o
snd-soc-nau8540-objs := nau8540.o
@ -454,6 +455,7 @@ obj-$(CONFIG_SND_SOC_MSM8916_WCD_DIGITAL) +=snd-soc-msm8916-digital.o
obj-$(CONFIG_SND_SOC_MT6351) += snd-soc-mt6351.o
obj-$(CONFIG_SND_SOC_MT6358) += snd-soc-mt6358.o
obj-$(CONFIG_SND_SOC_MT6359) += snd-soc-mt6359.o
obj-$(CONFIG_SND_SOC_MT6359_ACCDET) += mt6359-accdet.o
obj-$(CONFIG_SND_SOC_MT6660) += snd-soc-mt6660.o
obj-$(CONFIG_SND_SOC_NAU8315) += snd-soc-nau8315.o
obj-$(CONFIG_SND_SOC_NAU8540) += snd-soc-nau8540.o

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2021 MediaTek Inc.
* Author: Argus Lin <argus.lin@mediatek.com>
*/
#ifndef _ACCDET_H_
#define _ACCDET_H_
#include <linux/ctype.h>
#include <linux/string.h>
#define ACCDET_DEVNAME "accdet"
#define HEADSET_MODE_1 (1)
#define HEADSET_MODE_2 (2)
#define HEADSET_MODE_6 (6)
#define MT6359_ACCDET_NUM_BUTTONS 4
#define MT6359_ACCDET_JACK_MASK (SND_JACK_HEADPHONE | \
SND_JACK_HEADSET | \
SND_JACK_BTN_0 | \
SND_JACK_BTN_1 | \
SND_JACK_BTN_2 | \
SND_JACK_BTN_3)
#define MT6359_ACCDET_BTN_MASK (SND_JACK_BTN_0 | \
SND_JACK_BTN_1 | \
SND_JACK_BTN_2 | \
SND_JACK_BTN_3)
enum eint_moisture_status {
M_PLUG_IN = 0,
M_WATER_IN = 1,
M_HP_PLUG_IN = 2,
M_PLUG_OUT = 3,
M_NO_ACT = 4,
M_UNKNOWN = 5,
};
enum {
accdet_state000 = 0,
accdet_state001,
accdet_state010,
accdet_state011,
accdet_auxadc,
eint_state000,
eint_state001,
eint_state010,
eint_state011,
eint_inverter_state000,
};
struct three_key_threshold {
unsigned int mid;
unsigned int up;
unsigned int down;
};
struct four_key_threshold {
unsigned int mid;
unsigned int voice;
unsigned int up;
unsigned int down;
};
struct pwm_deb_settings {
unsigned int pwm_width;
unsigned int pwm_thresh;
unsigned int fall_delay;
unsigned int rise_delay;
unsigned int debounce0;
unsigned int debounce1;
unsigned int debounce3;
unsigned int debounce4;
unsigned int eint_pwm_width;
unsigned int eint_pwm_thresh;
unsigned int eint_debounce0;
unsigned int eint_debounce1;
unsigned int eint_debounce2;
unsigned int eint_debounce3;
unsigned int eint_inverter_debounce;
};
struct dts_data {
unsigned int mic_vol;
unsigned int mic_mode;
unsigned int plugout_deb;
unsigned int eint_pol;
struct pwm_deb_settings *pwm_deb;
struct three_key_threshold three_key;
struct four_key_threshold four_key;
unsigned int moisture_detect_enable;
unsigned int eint_detect_mode;
unsigned int eint_use_ext_res;
unsigned int eint_comp_vth;
unsigned int moisture_detect_mode;
unsigned int moisture_comp_vth;
unsigned int moisture_comp_vref2;
unsigned int moisture_use_ext_res;
};
struct mt6359_accdet {
struct snd_soc_jack *jack;
struct device *dev;
struct regmap *regmap;
struct dts_data *data;
unsigned int caps;
int accdet_irq;
int accdet_eint0;
int accdet_eint1;
struct mutex res_lock; /* lock protection */
bool jack_plugged;
unsigned int jack_type;
unsigned int btn_type;
unsigned int accdet_status;
unsigned int pre_accdet_status;
unsigned int cali_voltage;
unsigned int jd_sts;
struct work_struct accdet_work;
struct workqueue_struct *accdet_workqueue;
struct work_struct jd_work;
struct workqueue_struct *jd_workqueue;
};
int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *jack);
#endif

File diff suppressed because it is too large Load Diff