Skip to content

Commit 97f3cbb

Browse files
jwrdegoedegregkh
authored andcommitted
ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect
[ Upstream commit 92d3360 ] Add a quirk mechanism to allow specifying that active-high jack-detection should be used on platforms where this info is not available in devicetree. And add an entry for the Cyberbook T116 tablet to the DMI table, so that jack-detection will work properly on this tablet. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20211002211459.110124-2-hdegoede@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ae2207a commit 97f3cbb

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎sound/soc/codecs/nau8824.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/module.h>
1010
#include <linux/delay.h>
11+
#include <linux/dmi.h>
1112
#include <linux/init.h>
1213
#include <linux/i2c.h>
1314
#include <linux/regmap.h>
@@ -27,6 +28,12 @@
2728

2829
#include "nau8824.h"
2930

31+
#define NAU8824_JD_ACTIVE_HIGH BIT(0)
32+
33+
static int nau8824_quirk;
34+
static int quirk_override = -1;
35+
module_param_named(quirk, quirk_override, uint, 0444);
36+
MODULE_PARM_DESC(quirk, "Board-specific quirk override");
3037

3138
static int nau8824_config_sysclk(struct nau8824 *nau8824,
3239
int clk_id, unsigned int freq);
@@ -1875,6 +1882,34 @@ static int nau8824_read_device_properties(struct device *dev,
18751882
return 0;
18761883
}
18771884

1885+
/* Please keep this list alphabetically sorted */
1886+
static const struct dmi_system_id nau8824_quirk_table[] = {
1887+
{
1888+
/* Cyberbook T116 rugged tablet */
1889+
.matches = {
1890+
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
1891+
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
1892+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"),
1893+
},
1894+
.driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH),
1895+
},
1896+
{}
1897+
};
1898+
1899+
static void nau8824_check_quirks(void)
1900+
{
1901+
const struct dmi_system_id *dmi_id;
1902+
1903+
if (quirk_override != -1) {
1904+
nau8824_quirk = quirk_override;
1905+
return;
1906+
}
1907+
1908+
dmi_id = dmi_first_match(nau8824_quirk_table);
1909+
if (dmi_id)
1910+
nau8824_quirk = (unsigned long)dmi_id->driver_data;
1911+
}
1912+
18781913
static int nau8824_i2c_probe(struct i2c_client *i2c,
18791914
const struct i2c_device_id *id)
18801915
{
@@ -1899,6 +1934,11 @@ static int nau8824_i2c_probe(struct i2c_client *i2c,
18991934
nau8824->irq = i2c->irq;
19001935
sema_init(&nau8824->jd_sem, 1);
19011936

1937+
nau8824_check_quirks();
1938+
1939+
if (nau8824_quirk & NAU8824_JD_ACTIVE_HIGH)
1940+
nau8824->jkdet_polarity = 0;
1941+
19021942
nau8824_print_device_properties(nau8824);
19031943

19041944
ret = regmap_read(nau8824->regmap, NAU8824_REG_I2C_DEVICE_ID, &value);

0 commit comments

Comments
 (0)