Skip to content

Commit 92d3360

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: nau8824: Add DMI quirk mechanism for active-high jack-detect
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>
1 parent d316597 commit 92d3360

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);
@@ -1845,6 +1852,34 @@ static int nau8824_read_device_properties(struct device *dev,
18451852
return 0;
18461853
}
18471854

1855+
/* Please keep this list alphabetically sorted */
1856+
static const struct dmi_system_id nau8824_quirk_table[] = {
1857+
{
1858+
/* Cyberbook T116 rugged tablet */
1859+
.matches = {
1860+
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Default string"),
1861+
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
1862+
DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "20170531"),
1863+
},
1864+
.driver_data = (void *)(NAU8824_JD_ACTIVE_HIGH),
1865+
},
1866+
{}
1867+
};
1868+
1869+
static void nau8824_check_quirks(void)
1870+
{
1871+
const struct dmi_system_id *dmi_id;
1872+
1873+
if (quirk_override != -1) {
1874+
nau8824_quirk = quirk_override;
1875+
return;
1876+
}
1877+
1878+
dmi_id = dmi_first_match(nau8824_quirk_table);
1879+
if (dmi_id)
1880+
nau8824_quirk = (unsigned long)dmi_id->driver_data;
1881+
}
1882+
18481883
static int nau8824_i2c_probe(struct i2c_client *i2c,
18491884
const struct i2c_device_id *id)
18501885
{
@@ -1869,6 +1904,11 @@ static int nau8824_i2c_probe(struct i2c_client *i2c,
18691904
nau8824->irq = i2c->irq;
18701905
sema_init(&nau8824->jd_sem, 1);
18711906

1907+
nau8824_check_quirks();
1908+
1909+
if (nau8824_quirk & NAU8824_JD_ACTIVE_HIGH)
1910+
nau8824->jkdet_polarity = 0;
1911+
18721912
nau8824_print_device_properties(nau8824);
18731913

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

0 commit comments

Comments
 (0)