Skip to content

Commit

Permalink
ASoC: nau8821: Add DMI quirk mechanism for active-high jack-detect
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
drosdeck authored and broonie committed Jul 23, 2023
1 parent 1477c79 commit 1bc40ef
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions sound/soc/codecs/nau8821.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dmi.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/module.h>
Expand All @@ -25,6 +26,13 @@
#include <sound/tlv.h>
#include "nau8821.h"

#define NAU8821_JD_ACTIVE_HIGH BIT(0)

static int nau8821_quirk;
static int quirk_override = -1;
module_param_named(quirk, quirk_override, uint, 0444);
MODULE_PARM_DESC(quirk, "Board-specific quirk override");

#define NAU_FREF_MAX 13500000
#define NAU_FVCO_MAX 100000000
#define NAU_FVCO_MIN 90000000
Expand Down Expand Up @@ -1792,6 +1800,33 @@ static int nau8821_setup_irq(struct nau8821 *nau8821)
return 0;
}

/* Please keep this list alphabetically sorted */
static const struct dmi_system_id nau8821_quirk_table[] = {
{
/* Positivo CW14Q01P-V2 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Positivo Tecnologia SA"),
DMI_MATCH(DMI_BOARD_NAME, "CW14Q01P-V2"),
},
.driver_data = (void *)(NAU8821_JD_ACTIVE_HIGH),
},
{}
};

static void nau8821_check_quirks(void)
{
const struct dmi_system_id *dmi_id;

if (quirk_override != -1) {
nau8821_quirk = quirk_override;
return;
}

dmi_id = dmi_first_match(nau8821_quirk_table);
if (dmi_id)
nau8821_quirk = (unsigned long)dmi_id->driver_data;
}

static int nau8821_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
Expand All @@ -1812,6 +1847,12 @@ static int nau8821_i2c_probe(struct i2c_client *i2c)

nau8821->dev = dev;
nau8821->irq = i2c->irq;

nau8821_check_quirks();

if (nau8821_quirk & NAU8821_JD_ACTIVE_HIGH)
nau8821->jkdet_polarity = 0;

nau8821_print_device_properties(nau8821);

nau8821_reset_chip(nau8821->regmap);
Expand Down

0 comments on commit 1bc40ef

Please sign in to comment.