1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // Copyright (c) Intel Corporation, 2022 4 // Copyright Everest Semiconductor Co.,Ltd 5 6 #include <linux/module.h> 7 #include <linux/acpi.h> 8 #include "es83xx-dsm-common.h" 9 10 /* UUID ("a9800c04-e016-343e-41f4-6bcce70f4332") */ 11 static const guid_t es83xx_dsm_guid = 12 GUID_INIT(0xa9800c04, 0xe016, 0x343e, 13 0x41, 0xf4, 0x6b, 0xcc, 0xe7, 0x0f, 0x43, 0x32); 14 15 #define ES83xx_DSM_REVID 1 16 17 int es83xx_dsm(struct device *dev, int arg, int *value) 18 { 19 acpi_handle dhandle; 20 union acpi_object *obj; 21 int ret = 0; 22 23 dhandle = ACPI_HANDLE(dev); 24 if (!dhandle) 25 return -ENOENT; 26 27 obj = acpi_evaluate_dsm(dhandle, &es83xx_dsm_guid, ES83xx_DSM_REVID, 28 arg, NULL); 29 if (!obj) { 30 dev_err(dev, "%s: acpi_evaluate_dsm() failed\n", __func__); 31 ret = -EINVAL; 32 goto out; 33 } 34 35 if (obj->type != ACPI_TYPE_INTEGER) { 36 dev_err(dev, "%s: object is not ACPI_TYPE_INTEGER\n", __func__); 37 ret = -EINVAL; 38 goto err; 39 } 40 41 *value = obj->integer.value; 42 err: 43 ACPI_FREE(obj); 44 out: 45 return ret; 46 } 47 EXPORT_SYMBOL_GPL(es83xx_dsm); 48 49 int es83xx_dsm_dump(struct device *dev) 50 { 51 int value; 52 int ret; 53 54 ret = es83xx_dsm(dev, PLATFORM_MAINMIC_TYPE_ARG, &value); 55 if (ret < 0) 56 return ret; 57 dev_info(dev, "PLATFORM_MAINMIC_TYPE %#x\n", value); 58 59 ret = es83xx_dsm(dev, PLATFORM_HPMIC_TYPE_ARG, &value); 60 if (ret < 0) 61 return ret; 62 dev_info(dev, "PLATFORM_HPMIC_TYPE %#x\n", value); 63 64 ret = es83xx_dsm(dev, PLATFORM_SPK_TYPE_ARG, &value); 65 if (ret < 0) 66 return ret; 67 dev_info(dev, "PLATFORM_SPK_TYPE %#x\n", value); 68 69 ret = es83xx_dsm(dev, PLATFORM_HPDET_INV_ARG, &value); 70 if (ret < 0) 71 return ret; 72 dev_info(dev, "PLATFORM_HPDET_INV %#x\n", value); 73 74 ret = es83xx_dsm(dev, PLATFORM_PCM_TYPE_ARG, &value); 75 if (ret < 0) 76 return ret; 77 dev_info(dev, "PLATFORM_PCM_TYPE %#x\n", value); 78 79 ret = es83xx_dsm(dev, PLATFORM_MIC_DE_POP_ARG, &value); 80 if (ret < 0) 81 return ret; 82 dev_info(dev, "PLATFORM_MIC_DE_POP %#x\n", value); 83 84 return 0; 85 } 86 EXPORT_SYMBOL_GPL(es83xx_dsm_dump); 87 88 MODULE_DESCRIPTION("Everest Semi ES83xx DSM helpers"); 89 MODULE_LICENSE("GPL"); 90
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.