Skip to content

Commit 1bc40ef

Browse files
drosdeckbroonie
authored andcommitted
ASoC: nau8821: 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 Positivo CW14Q01P-V2 to the DMI table, so that jack-detection will work properly on this laptop. Signed-off-by: Edson Juliano Drosdeck <edson.drosdeck@gmail.com> Link: https://lore.kernel.org/r/20230719200241.4865-1-edson.drosdeck@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1477c79 commit 1bc40ef

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

sound/soc/codecs/nau8821.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/acpi.h>
1111
#include <linux/clk.h>
1212
#include <linux/delay.h>
13+
#include <linux/dmi.h>
1314
#include <linux/init.h>
1415
#include <linux/i2c.h>
1516
#include <linux/module.h>
@@ -25,6 +26,13 @@
2526
#include <sound/tlv.h>
2627
#include "nau8821.h"
2728

29+
#define NAU8821_JD_ACTIVE_HIGH BIT(0)
30+
31+
static int nau8821_quirk;
32+
static int quirk_override = -1;
33+
module_param_named(quirk, quirk_override, uint, 0444);
34+
MODULE_PARM_DESC(quirk, "Board-specific quirk override");
35+
2836
#define NAU_FREF_MAX 13500000
2937
#define NAU_FVCO_MAX 100000000
3038
#define NAU_FVCO_MIN 90000000
@@ -1792,6 +1800,33 @@ static int nau8821_setup_irq(struct nau8821 *nau8821)
17921800
return 0;
17931801
}
17941802

1803+
/* Please keep this list alphabetically sorted */
1804+
static const struct dmi_system_id nau8821_quirk_table[] = {
1805+
{
1806+
/* Positivo CW14Q01P-V2 */
1807+
.matches = {
1808+
DMI_MATCH(DMI_SYS_VENDOR, "Positivo Tecnologia SA"),
1809+
DMI_MATCH(DMI_BOARD_NAME, "CW14Q01P-V2"),
1810+
},
1811+
.driver_data = (void *)(NAU8821_JD_ACTIVE_HIGH),
1812+
},
1813+
{}
1814+
};
1815+
1816+
static void nau8821_check_quirks(void)
1817+
{
1818+
const struct dmi_system_id *dmi_id;
1819+
1820+
if (quirk_override != -1) {
1821+
nau8821_quirk = quirk_override;
1822+
return;
1823+
}
1824+
1825+
dmi_id = dmi_first_match(nau8821_quirk_table);
1826+
if (dmi_id)
1827+
nau8821_quirk = (unsigned long)dmi_id->driver_data;
1828+
}
1829+
17951830
static int nau8821_i2c_probe(struct i2c_client *i2c)
17961831
{
17971832
struct device *dev = &i2c->dev;
@@ -1812,6 +1847,12 @@ static int nau8821_i2c_probe(struct i2c_client *i2c)
18121847

18131848
nau8821->dev = dev;
18141849
nau8821->irq = i2c->irq;
1850+
1851+
nau8821_check_quirks();
1852+
1853+
if (nau8821_quirk & NAU8821_JD_ACTIVE_HIGH)
1854+
nau8821->jkdet_polarity = 0;
1855+
18151856
nau8821_print_device_properties(nau8821);
18161857

18171858
nau8821_reset_chip(nau8821->regmap);

0 commit comments

Comments
 (0)