Commit 9c8bec3b authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: es83xx: add ACPI DSM helper module

Most of the ES83xx codec configuration is exposed in the DSDT table
and accessible via a _DSM method. Start adding basic definitions and
helpers to dump the information.
Reviewed-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
Co-developed-by: default avatarDavid Yang <yangxiaohua@everest-semi.com>
Signed-off-by: default avatarDavid Yang <yangxiaohua@everest-semi.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20231202123946.54347-2-hdegoede@redhat.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4978d3f8
......@@ -1076,6 +1076,10 @@ config SND_SOC_ES7134
config SND_SOC_ES7241
tristate "Everest Semi ES7241 CODEC"
config SND_SOC_ES83XX_DSM_COMMON
depends on ACPI
tristate
config SND_SOC_ES8316
tristate "Everest Semi ES8316 CODEC"
depends on I2C
......
......@@ -116,6 +116,7 @@ snd-soc-da9055-objs := da9055.o
snd-soc-dmic-objs := dmic.o
snd-soc-es7134-objs := es7134.o
snd-soc-es7241-objs := es7241.o
snd-soc-es83xx-dsm-common-objs := es83xx-dsm-common.o
snd-soc-es8316-objs := es8316.o
snd-soc-es8326-objs := es8326.o
snd-soc-es8328-objs := es8328.o
......@@ -505,6 +506,7 @@ obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o
obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o
obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o
obj-$(CONFIG_SND_SOC_ES7241) += snd-soc-es7241.o
obj-$(CONFIG_SND_SOC_ES83XX_DSM_COMMON) += snd-soc-es83xx-dsm-common.o
obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.o
obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o
obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o
......
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright (c) Intel Corporation, 2022
// Copyright Everest Semiconductor Co.,Ltd
#include <linux/module.h>
#include <linux/acpi.h>
#include "es83xx-dsm-common.h"
/* UUID ("a9800c04-e016-343e-41f4-6bcce70f4332") */
static const guid_t es83xx_dsm_guid =
GUID_INIT(0xa9800c04, 0xe016, 0x343e,
0x41, 0xf4, 0x6b, 0xcc, 0xe7, 0x0f, 0x43, 0x32);
#define ES83xx_DSM_REVID 1
int es83xx_dsm(struct device *dev, int arg, int *value)
{
acpi_handle dhandle;
union acpi_object *obj;
int ret = 0;
dhandle = ACPI_HANDLE(dev);
if (!dhandle)
return -ENOENT;
obj = acpi_evaluate_dsm(dhandle, &es83xx_dsm_guid, ES83xx_DSM_REVID,
arg, NULL);
if (!obj) {
dev_err(dev, "%s: acpi_evaluate_dsm() failed\n", __func__);
ret = -EINVAL;
goto out;
}
if (obj->type != ACPI_TYPE_INTEGER) {
dev_err(dev, "%s: object is not ACPI_TYPE_INTEGER\n", __func__);
ret = -EINVAL;
goto err;
}
*value = obj->integer.value;
err:
ACPI_FREE(obj);
out:
return ret;
}
EXPORT_SYMBOL_GPL(es83xx_dsm);
int es83xx_dsm_dump(struct device *dev)
{
int value;
int ret;
ret = es83xx_dsm(dev, PLATFORM_MAINMIC_TYPE_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_MAINMIC_TYPE %#x\n", value);
ret = es83xx_dsm(dev, PLATFORM_HPMIC_TYPE_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_HPMIC_TYPE %#x\n", value);
ret = es83xx_dsm(dev, PLATFORM_SPK_TYPE_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_SPK_TYPE %#x\n", value);
ret = es83xx_dsm(dev, PLATFORM_HPDET_INV_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_HPDET_INV %#x\n", value);
ret = es83xx_dsm(dev, PLATFORM_PCM_TYPE_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_PCM_TYPE %#x\n", value);
ret = es83xx_dsm(dev, PLATFORM_MIC_DE_POP_ARG, &value);
if (ret < 0)
return ret;
dev_info(dev, "PLATFORM_MIC_DE_POP %#x\n", value);
return 0;
}
EXPORT_SYMBOL_GPL(es83xx_dsm_dump);
MODULE_DESCRIPTION("Everest Semi ES83xx DSM helpers");
MODULE_LICENSE("GPL");
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment