Skip to content

Commit 44125fd

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: Intel: bytcr_rt5640: Add support for external GPIO jack-detect
Some boards have the codec IRQ hooked-up as normally, so the driver can still do things like headset vs headphones and button-press detection, but instead of using one of the JD pins of the codec, an external GPIO is used to report the jack-presence switch status of the jack. Add support for boards which have this setup and which specify which external GPIO to use in the special Android AMCR0F28 ACPI device. And add a quirk for the Asus TF103C tablet which uses this setup. Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 45ed016 commit 44125fd

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ enum {
4040
BYT_RT5640_NO_INTERNAL_MIC_MAP,
4141
};
4242

43+
#define RT5640_JD_SRC_EXT_GPIO 0x0f
44+
4345
enum {
4446
BYT_RT5640_JD_SRC_GPIO1 = (RT5640_JD_SRC_GPIO1 << 4),
4547
BYT_RT5640_JD_SRC_JD1_IN4P = (RT5640_JD_SRC_JD1_IN4P << 4),
4648
BYT_RT5640_JD_SRC_JD2_IN4N = (RT5640_JD_SRC_JD2_IN4N << 4),
4749
BYT_RT5640_JD_SRC_GPIO2 = (RT5640_JD_SRC_GPIO2 << 4),
4850
BYT_RT5640_JD_SRC_GPIO3 = (RT5640_JD_SRC_GPIO3 << 4),
4951
BYT_RT5640_JD_SRC_GPIO4 = (RT5640_JD_SRC_GPIO4 << 4),
52+
BYT_RT5640_JD_SRC_EXT_GPIO = (RT5640_JD_SRC_EXT_GPIO << 4)
5053
};
5154

5255
enum {
@@ -627,6 +630,19 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
627630
BYT_RT5640_SSP0_AIF2 |
628631
BYT_RT5640_MCLK_EN),
629632
},
633+
{
634+
.matches = {
635+
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
636+
DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
637+
},
638+
.driver_data = (void *)(BYT_RT5640_IN1_MAP |
639+
BYT_RT5640_JD_SRC_EXT_GPIO |
640+
BYT_RT5640_OVCD_TH_2000UA |
641+
BYT_RT5640_OVCD_SF_0P75 |
642+
BYT_RT5640_SSP0_AIF1 |
643+
BYT_RT5640_MCLK_EN |
644+
BYT_RT5640_USE_AMCR0F28),
645+
},
630646
{ /* Chuwi Vi8 (CWI506) */
631647
.matches = {
632648
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Insyde"),
@@ -1083,9 +1099,11 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev,
10831099
}
10841100

10851101
if (BYT_RT5640_JDSRC(byt_rt5640_quirk)) {
1086-
props[cnt++] = PROPERTY_ENTRY_U32(
1087-
"realtek,jack-detect-source",
1088-
BYT_RT5640_JDSRC(byt_rt5640_quirk));
1102+
if (BYT_RT5640_JDSRC(byt_rt5640_quirk) != RT5640_JD_SRC_EXT_GPIO) {
1103+
props[cnt++] = PROPERTY_ENTRY_U32(
1104+
"realtek,jack-detect-source",
1105+
BYT_RT5640_JDSRC(byt_rt5640_quirk));
1106+
}
10891107

10901108
props[cnt++] = PROPERTY_ENTRY_U32(
10911109
"realtek,over-current-threshold-microamp",
@@ -1113,6 +1131,13 @@ static int byt_rt5640_add_codec_device_props(struct device *i2c_dev,
11131131
}
11141132

11151133
/* Some Android devs specify IRQs/GPIOS in a special AMCR0F28 ACPI device */
1134+
static const struct acpi_gpio_params amcr0f28_jd_gpio = { 1, 0, false };
1135+
1136+
static const struct acpi_gpio_mapping amcr0f28_gpios[] = {
1137+
{ "rt5640-jd-gpios", &amcr0f28_jd_gpio, 1 },
1138+
{ }
1139+
};
1140+
11161141
static int byt_rt5640_get_amcr0f28_settings(struct snd_soc_card *card)
11171142
{
11181143
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
@@ -1133,6 +1158,18 @@ static int byt_rt5640_get_amcr0f28_settings(struct snd_soc_card *card)
11331158
goto put_adev;
11341159
}
11351160

1161+
if (BYT_RT5640_JDSRC(byt_rt5640_quirk) == RT5640_JD_SRC_EXT_GPIO) {
1162+
acpi_dev_add_driver_gpios(adev, amcr0f28_gpios);
1163+
data->jd_gpio = devm_fwnode_gpiod_get(card->dev, acpi_fwnode_handle(adev),
1164+
"rt5640-jd", GPIOD_IN, "rt5640-jd");
1165+
acpi_dev_remove_driver_gpios(adev);
1166+
1167+
if (IS_ERR(data->jd_gpio)) {
1168+
ret = PTR_ERR(data->jd_gpio);
1169+
dev_err(card->dev, "error %d getting jd GPIO\n", ret);
1170+
}
1171+
}
1172+
11361173
put_adev:
11371174
acpi_dev_put(adev);
11381175
return ret;

0 commit comments

Comments
 (0)