Skip to contentSkip to conversation

ASoC: rt5682: Add option to select pulse IRQ in jack detect

PATCH In review Akshu Agrawal 4 participants 4 messages Dec 20, 2019 – Dec 23, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt5682: Add option to select pulse IRQ in jack detect

Some SoC need to set IRQ type as pulse along with other JD1 options.

---
 include/sound/rt5682.h    | 1 +
 sound/soc/codecs/rt5682.c | 3 +++
 sound/soc/codecs/rt5682.h | 2 ++
 3 files changed, 6 insertions(+)
include/sound/rt5682.h +1 -0
index bc2c31734df1..64cfa77ec9ee 100644
@@ -22,6 +22,7 @@ enum rt5682_dmic1_clk_pin {
 enum rt5682_jd_src {
 	RT5682_JD_NULL,
 	RT5682_JD1,
+	RT5682_JD2,
 };
 
 struct rt5682_platform_data {
sound/soc/codecs/rt5682.c +3 -0
index ae6f6121bc1b..5135d7757361 100644
@@ -1009,6 +1009,9 @@ static int rt5682_set_jack_detect(struct snd_soc_component *component,
 	}
 
 	switch (rt5682->pdata.jd_src) {
+	case RT5682_JD2:
+		regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
+			RT5682_JD1_PULSE_MASK, RT5682_JD1_PULSE_EN);
 	case RT5682_JD1:
 		snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_2,
 			RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL);
sound/soc/codecs/rt5682.h +2 -0
index 18faaa2a49a0..434b1c9778b2 100644
@@ -1091,6 +1091,8 @@
 #define RT5682_JD1_POL_MASK			(0x1 << 13)
 #define RT5682_JD1_POL_NOR			(0x0 << 13)
 #define RT5682_JD1_POL_INV			(0x1 << 13)
+#define RT5682_JD1_PULSE_MASK			(0x1 << 10)
+#define RT5682_JD1_PULSE_EN			(0x1 << 10)
 
 /* IRQ Control 3 (0x00b8) */
 #define RT5682_IL_IRQ_MASK			(0x1 << 7)
Signature · 1 line
2.17.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Akshu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on sound/for-next v5.5-rc3 next-20191220] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Akshu-Agrawal/ASoC-rt5682-Add-option-to-select-pulse-IRQ-in-jack-detect/20191223-123630
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.5.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sparc64

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

In file included from include/sound/soc.h:20:0,

                    from sound/soc/codecs/rt5682.c:26:
   sound/soc/codecs/rt5682.c: In function 'rt5682_set_jack_detect':
>> include/linux/regmap.h:75:2: warning: this statement may fall through [-Wimplicit-fallthrough=]
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682.c:1013:3: note: in expansion of macro 'regmap_update_bits'
      regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
      ^~~~~~~~~~~~~~~~~~
   sound/soc/codecs/rt5682.c:1015:2: note: here
     case RT5682_JD1:
     ^~~~
--
   In file included from include/sound/soc.h:20:0,
                    from sound/soc//codecs/rt5682.c:26:
   sound/soc//codecs/rt5682.c: In function 'rt5682_set_jack_detect':
>> include/linux/regmap.h:75:2: warning: this statement may fall through [-Wimplicit-fallthrough=]
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc//codecs/rt5682.c:1013:3: note: in expansion of macro 'regmap_update_bits'
      regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
      ^~~~~~~~~~~~~~~~~~
   sound/soc//codecs/rt5682.c:1015:2: note: here
     case RT5682_JD1:
     ^~~~

vim +/regmap_update_bits +1013 sound/soc/codecs/rt5682.c

994
995 static int rt5682_set_jack_detect(struct snd_soc_component *component,
996 struct snd_soc_jack *hs_jack, void *data)
997 {
998 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
999
1000 rt5682->hs_jack = hs_jack;
1001
1002 if (!hs_jack) {
1003 regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
1004 RT5682_JD1_EN_MASK, RT5682_JD1_DIS);
1005 regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL,
1006 RT5682_POW_JDH | RT5682_POW_JDL, 0);
1007 cancel_delayed_work_sync(&rt5682->jack_detect_work);
1008 return 0;
1009 }
1010
1011 switch (rt5682->pdata.jd_src) {
1012 case RT5682_JD2:

> 1013			regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,

1014 RT5682_JD1_PULSE_MASK, RT5682_JD1_PULSE_EN);
1015 case RT5682_JD1:
1016 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_2,
1017 RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL);
1018 snd_soc_component_write(component, RT5682_CBJ_CTRL_1, 0xd042);
1019 snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_3,
1020 RT5682_CBJ_IN_BUF_EN, RT5682_CBJ_IN_BUF_EN);
1021 snd_soc_component_update_bits(component, RT5682_SAR_IL_CMD_1,
1022 RT5682_SAR_POW_MASK, RT5682_SAR_POW_EN);
1023 regmap_update_bits(rt5682->regmap, RT5682_GPIO_CTRL_1,
1024 RT5682_GP1_PIN_MASK, RT5682_GP1_PIN_IRQ);
1025 regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL,
1026 RT5682_POW_IRQ | RT5682_POW_JDH |
1027 RT5682_POW_ANA, RT5682_POW_IRQ |
1028 RT5682_POW_JDH | RT5682_POW_ANA);
1029 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_2,
1030 RT5682_PWR_JDH | RT5682_PWR_JDL,
1031 RT5682_PWR_JDH | RT5682_PWR_JDL);
1032 regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
1033 RT5682_JD1_EN_MASK | RT5682_JD1_POL_MASK,
1034 RT5682_JD1_EN | RT5682_JD1_POL_NOR);
1035 regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_4,
1036 0x7f7f, (rt5682->pdata.btndet_delay << 8 |
1037 rt5682->pdata.btndet_delay));
1038 regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_5,
1039 0x7f7f, (rt5682->pdata.btndet_delay << 8 |
1040 rt5682->pdata.btndet_delay));
1041 regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_6,
1042 0x7f7f, (rt5682->pdata.btndet_delay << 8 |
1043 rt5682->pdata.btndet_delay));
1044 regmap_update_bits(rt5682->regmap, RT5682_4BTN_IL_CMD_7,
1045 0x7f7f, (rt5682->pdata.btndet_delay << 8 |
1046 rt5682->pdata.btndet_delay));
1047 mod_delayed_work(system_power_efficient_wq,
1048 &rt5682->jack_detect_work, msecs_to_jiffies(250));
1049 break;
1050
1051 case RT5682_JD_NULL:
1052 regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
1053 RT5682_JD1_EN_MASK, RT5682_JD1_DIS);
1054 regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL,
1055 RT5682_POW_JDH | RT5682_POW_JDL, 0);
1056 break;
1057
1058 default:
1059 dev_warn(component->dev, "Wrong JD source\n");
1060 break;
1061 }
1062
1063 return 0;
1064 }
1065

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#2 lore raw
In reply to Akshu Agrawal
Quoted 4 lines

Subject: [alsa-devel] [PATCH] ASoC: rt5682: Add option to select pulse IRQ in jack detect

Some SoC need to set IRQ type as pulse along with other JD1 options.

Could you configure GPIO IRQ by edge trigger(both rising/falling) and try again? BTW, the modification doesn't make sense to name JD2.

Quoted 50 lines
---
 include/sound/rt5682.h    | 1 +
 sound/soc/codecs/rt5682.c | 3 +++
 sound/soc/codecs/rt5682.h | 2 ++
 3 files changed, 6 insertions(+)
include/sound/rt5682.h +1 -0
index bc2c31734df1..64cfa77ec9ee 100644
@@ -22,6 +22,7 @@ enum rt5682_dmic1_clk_pin {
 enum rt5682_jd_src {
 	RT5682_JD_NULL,
 	RT5682_JD1,
+	RT5682_JD2,
 };
 
 struct rt5682_platform_data {
sound/soc/codecs/rt5682.c +3 -0
index ae6f6121bc1b..5135d7757361 100644
@@ -1009,6 +1009,9 @@ static int rt5682_set_jack_detect(struct
 snd_soc_component *component,
 	}
 
 	switch (rt5682->pdata.jd_src) {
+	case RT5682_JD2:
+		regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2,
+			RT5682_JD1_PULSE_MASK, RT5682_JD1_PULSE_EN);
 	case RT5682_JD1:
 		snd_soc_component_update_bits(component, RT5682_CBJ_CTRL_2,
sound/soc/codecs/rt5682.c +0 -0
 			RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL);
sound/soc/codecs/rt5682.h +2 -1
index 18faaa2a49a0..434b1c9778b2 100644
@@ -1091,6 +1091,8 @@
 #define RT5682_JD1_POL_MASK			(0x1 << 13)
 #define RT5682_JD1_POL_NOR			(0x0 << 13)
 #define RT5682_JD1_POL_INV			(0x1 << 13)
+#define RT5682_JD1_PULSE_MASK			(0x1 << 10)
+#define RT5682_JD1_PULSE_EN			(0x1 << 10)
 
 /* IRQ Control 3 (0x00b8) */
 #define RT5682_IL_IRQ_MASK			(0x1 << 7)
--

2.17.1

#3 lore raw
Quoted 6 lines · Shuming [范書銘]
Quoted 4 lines

Subject: [alsa-devel] [PATCH] ASoC: rt5682: Add option to select pulse IRQ in jack detect

Some SoC need to set IRQ type as pulse along with other JD1 options.

Could you configure GPIO IRQ by edge trigger(both rising/falling) and try again? BTW, the modification doesn't make sense to name JD2.

Thanks Shuming, was about to send a mail to abandon this patch request.

The GPIO connected to codec is not a traditional one, but a wake event. Hence, it took us time to figure out the way to set it active on both the edges.

Regards,

Akshu