From: Stephan Lensky <linux@slensky.com>
To: Takashi Iwai <tiwai@suse.com>
Cc: "Jaroslav Kysela" <perex@perex.cz>,
"Mark Brown" <broonie@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Hans de Goede" <hansg@kernel.org>, "Len Brown" <lenb@kernel.org>,
"Kevin Cuperus" <cuperus.kevin@hotmail.com>,
linux-sound@vger.kernel.org, linux-acpi@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
"Stephan Lensky" <linux@slensky.com>
Subject: [PATCH 3/4] ALSA: hda: Add MAX98390 side codec driver
Date: Tue, 1 Dec 2026 22:12:32 -0500 [thread overview]
Message-ID: <20261202031233.171555-4-linux@slensky.com> (raw)
In-Reply-To: <20261202031233.171555-1-linux@slensky.com>
The Samsung Galaxy Book4 Pro 360 (NP960QGK) pairs a Realtek ALC298 with
four MAX98390 boosted class-D amplifiers on I2C, a woofer and a tweeter
per channel. The platform firmware does not configure the amplifiers, so
the internal speakers stay silent.
Add an HDA side codec driver for them, structured like the existing
CS35L41, TAS2781 and AW88399 side codec drivers. It binds to the
"max98390-hda" clients created by serial-multi-instantiate and to the
HDA codec through the component framework. The PCM interface is fixed at
48 kHz, the only rate the SOF analog PCMs offer on this machine.
The amplifiers are enabled when a playback stream is opened, before the
codec starts the I2S clocks. This is safe because the clock monitor
restarts automatically: the amplifier stays off until valid BCLK and
LRCLK arrive. On close, the pre-playback hook clears the global enable
on all amplifiers first, so the 50 ms the datasheet requires before
clearing the speaker enable is paid once rather than per amplifier.
The speaker tuning lives in the amplifier's Dynamic Speaker Management
(DSM) block. On bind, the driver requests
maxim/max98390-hda-<codec subsystem ID>-<amplifier index>.bin
e.g. maxim/max98390-hda-144dc892-0.bin, in the format of the ASoC
driver's dsm_param.bin: a little-endian 16-bit start register, a 16-bit
payload size and the payload at offset 16. The payload must lie within
registers 0x2050 to 0x23e0, which excludes the DSP and global enables. A
valid file is written on top of the default tuning and reapplied on
resume.
No tuning files exist yet. The default is a second-order Butterworth
high-pass filter at 100 Hz on the woofers and 3 kHz on the tweeters, and
a DSM volume of -7.5 dB. Thermal and excursion protection stay disabled
because they need per-speaker parameters, which a tuning file can
provide. Without protection, the DSM volume is the only limit on output
power: -7.5 dB caps a full-scale signal at about 3-4 W per speaker, down
from roughly 17 W into the tweeters at 0 dB.
This driver is based on work by Kevin Cuperus in the SOF pull request
linked below. The rework and this commit message were done with the help
of an AI coding assistant (Claude Code). All changes were reviewed by
the submitter and tested on an NP960QGK.
Link: https://github.com/thesofproject/linux/pull/5616
Co-developed-by: Kevin Cuperus <cuperus.kevin@hotmail.com>
Signed-off-by: Kevin Cuperus <cuperus.kevin@hotmail.com>
Signed-off-by: Stephan Lensky <linux@slensky.com>
---
MAINTAINERS | 6 +
sound/hda/codecs/side-codecs/Kconfig | 18 +
sound/hda/codecs/side-codecs/Makefile | 4 +
sound/hda/codecs/side-codecs/max98390_hda.c | 435 ++++++++++++++++++
sound/hda/codecs/side-codecs/max98390_hda.h | 18 +
.../hda/codecs/side-codecs/max98390_hda_i2c.c | 80 ++++
6 files changed, 561 insertions(+)
create mode 100644 sound/hda/codecs/side-codecs/max98390_hda.c
create mode 100644 sound/hda/codecs/side-codecs/max98390_hda.h
create mode 100644 sound/hda/codecs/side-codecs/max98390_hda_i2c.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 2ce1f5b71db7..a17f6b45c8e7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16584,6 +16584,12 @@ S: Supported
F: Documentation/devicetree/bindings/power/supply/maxim,max77976.yaml
F: drivers/power/supply/max77976_charger.c
+MAXIM MAX98390 HDA SIDE CODEC DRIVER
+M: Stephan Lensky <linux@slensky.com>
+L: linux-sound@vger.kernel.org
+S: Maintained
+F: sound/hda/codecs/side-codecs/max98390_hda*
+
MAXIM MUIC CHARGER DRIVERS FOR EXYNOS BASED BOARDS
M: Krzysztof Kozlowski <krzk@kernel.org>
S: Maintained
diff --git a/sound/hda/codecs/side-codecs/Kconfig b/sound/hda/codecs/side-codecs/Kconfig
index b7e2a6fa4258..de9379a749a8 100644
--- a/sound/hda/codecs/side-codecs/Kconfig
+++ b/sound/hda/codecs/side-codecs/Kconfig
@@ -124,6 +124,24 @@ config SND_HDA_SCODEC_CS35L56_CAL_DEBUGFS
If unsure select "N".
endmenu
+config SND_HDA_SCODEC_MAX98390
+ tristate
+ select SND_HDA_GENERIC
+
+config SND_HDA_SCODEC_MAX98390_I2C
+ tristate "Build MAX98390 HD-audio side codec support for I2C Bus"
+ depends on I2C
+ depends on ACPI
+ imply SERIAL_MULTI_INSTANTIATE
+ select REGMAP_I2C
+ select SND_HDA_SCODEC_MAX98390
+ help
+ Say Y or M here to include MAX98390 I2C HD-audio side codec support
+ in snd-hda-intel driver, such as ALC298.
+
+comment "Set to Y if you want auto-loading the side codec driver"
+ depends on SND_HDA=y && SND_HDA_SCODEC_MAX98390_I2C=m
+
config SND_HDA_SCODEC_TAS2781
tristate
select SND_HDA_GENERIC
diff --git a/sound/hda/codecs/side-codecs/Makefile b/sound/hda/codecs/side-codecs/Makefile
index 7dd010c68f78..0e06573ab9c0 100644
--- a/sound/hda/codecs/side-codecs/Makefile
+++ b/sound/hda/codecs/side-codecs/Makefile
@@ -12,6 +12,8 @@ snd-hda-scodec-cs35l56-y := cs35l56_hda.o
snd-hda-scodec-cs35l56-i2c-y := cs35l56_hda_i2c.o
snd-hda-scodec-cs35l56-spi-y := cs35l56_hda_spi.o
snd-hda-scodec-component-y := hda_component.o
+snd-hda-scodec-max98390-y := max98390_hda.o
+snd-hda-scodec-max98390-i2c-y := max98390_hda_i2c.o
snd-hda-scodec-tas2781-y := tas2781_hda.o
snd-hda-scodec-tas2781-i2c-y := tas2781_hda_i2c.o
snd-hda-scodec-tas2781-spi-y := tas2781_hda_spi.o
@@ -27,6 +29,8 @@ obj-$(CONFIG_SND_HDA_SCODEC_CS35L56) += snd-hda-scodec-cs35l56.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_I2C) += snd-hda-scodec-cs35l56-i2c.o
obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o
obj-$(CONFIG_SND_HDA_SCODEC_COMPONENT) += snd-hda-scodec-component.o
+obj-$(CONFIG_SND_HDA_SCODEC_MAX98390) += snd-hda-scodec-max98390.o
+obj-$(CONFIG_SND_HDA_SCODEC_MAX98390_I2C) += snd-hda-scodec-max98390-i2c.o
obj-$(CONFIG_SND_HDA_SCODEC_TAS2781) += snd-hda-scodec-tas2781.o
obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_I2C) += snd-hda-scodec-tas2781-i2c.o
obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_SPI) += snd-hda-scodec-tas2781-spi.o
diff --git a/sound/hda/codecs/side-codecs/max98390_hda.c b/sound/hda/codecs/side-codecs/max98390_hda.c
new file mode 100644
index 000000000000..15ae3c5a9a67
--- /dev/null
+++ b/sound/hda/codecs/side-codecs/max98390_hda.c
@@ -0,0 +1,435 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// MAX98390 HDA driver
+//
+
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/cleanup.h>
+#include <linux/component.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/firmware.h>
+#include <linux/ktime.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/pm.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/sprintf.h>
+#include <linux/string.h>
+#include <linux/unaligned.h>
+#include <sound/hda_codec.h>
+#include <sound/max98390.h>
+#include "hda_component.h"
+#include "../generic.h"
+#include "max98390_hda.h"
+
+#define MAX98390_HDA_NUM_AMPS 4
+#define MAX98390_HDA_AMP_EN_DEM BIT(7)
+#define MAX98390_HDA_DSP_GLOBAL_EN BIT(0)
+#define MAX98390_HDA_DSMIG_EQ8_EN BIT(5)
+#define MAX98390_HDA_DSM_VOL_MINUS_7_5DB 0x91
+#define MAX98390_HDA_AMP_OFF_DELAY_US (50 * USEC_PER_MSEC)
+#define MAX98390_HDA_BIQUAD_COEFS 5
+#define MAX98390_HDA_COEF_STRIDE (DSM_EQ_BQ1_B1_BYTE0 - DSM_EQ_BQ1_B0_BYTE0)
+#define MAX98390_HDA_BIQUAD_STRIDE (DSM_EQ_BQ2_B0_BYTE0 - DSM_EQ_BQ1_B0_BYTE0)
+
+struct max98390_hda_priv {
+ struct device *dev;
+ struct regmap *regmap;
+ const struct firmware *dsm_fw;
+ struct mutex lock; /* Protects amp enable state, playback_started and dsm_fw */
+ ktime_t global_disable_time;
+ int index;
+ unsigned int channel;
+ bool is_tweeter;
+ bool playback_started;
+};
+
+static const struct reg_sequence max98390_hda_init_regs[] = {
+ { MAX98390_CLK_MON, 0x6f },
+ { MAX98390_DAT_MON, 0x00 },
+ { MAX98390_PWR_GATE_CTL, 0x00 },
+ { MAX98390_PCM_RX_EN_A, 0x03 },
+ { MAX98390_ENV_TRACK_VOUT_HEADROOM, 0x0e },
+ { MAX98390_BOOST_BYPASS1, 0x46 },
+ { MAX98390_FET_SCALING3, 0x03 },
+ { MAX98390_PCM_MODE_CFG, 0xc0 },
+ { MAX98390_PCM_MASTER_MODE, 0x1c },
+ { MAX98390_PCM_CLK_SETUP, 0x44 },
+ { MAX98390_PCM_SR_SETUP, 0x08 },
+ { MAX98390_R23FF_GLOBAL_EN, 0x00 },
+ { MAX98390_R203A_AMP_EN, MAX98390_HDA_AMP_EN_DEM },
+ { MAX98390_R23E1_DSP_GLOBAL_EN, 0x00 },
+};
+
+/* 2nd-order Butterworth high-pass at 100 Hz */
+static const u32 max98390_hda_hpf_100hz[MAX98390_HDA_BIQUAD_COEFS] = {
+ 0x0fda43, 0xe04b7a, 0x0fda43, 0xe04bd3, 0x0fb4df,
+};
+
+/* 2nd-order Butterworth high-pass at 3 kHz */
+static const u32 max98390_hda_hpf_3khz[MAX98390_HDA_BIQUAD_COEFS] = {
+ 0x0c1cfc, 0xe7c608, 0x0c1cfc, 0xe8bb6b, 0x092f5c,
+};
+
+static const u32 max98390_hda_unity[MAX98390_HDA_BIQUAD_COEFS] = {
+ 0x100000, 0, 0, 0, 0,
+};
+
+static int max98390_hda_set_global_enable(struct max98390_hda_priv *priv, bool enable)
+{
+ if (!enable)
+ priv->global_disable_time = ktime_get();
+
+ return regmap_write(priv->regmap, MAX98390_R23FF_GLOBAL_EN,
+ enable ? MAX98390_GLOBAL_EN_MASK : 0);
+}
+
+static int max98390_hda_set_speaker_enable(struct max98390_hda_priv *priv, bool enable)
+{
+ unsigned int val = MAX98390_HDA_AMP_EN_DEM;
+ s64 elapsed_us;
+
+ if (enable) {
+ val |= MAX98390_AMP_EN_MASK;
+ } else {
+ elapsed_us = ktime_us_delta(ktime_get(), priv->global_disable_time);
+ if (elapsed_us < MAX98390_HDA_AMP_OFF_DELAY_US)
+ fsleep(MAX98390_HDA_AMP_OFF_DELAY_US - elapsed_us);
+ }
+
+ return regmap_write(priv->regmap, MAX98390_R203A_AMP_EN, val);
+}
+
+static int max98390_hda_set_amp_enable(struct max98390_hda_priv *priv, bool enable)
+{
+ int ret;
+
+ if (enable) {
+ ret = max98390_hda_set_speaker_enable(priv, true);
+ if (ret)
+ return ret;
+
+ return max98390_hda_set_global_enable(priv, true);
+ }
+
+ ret = max98390_hda_set_global_enable(priv, false);
+ if (ret)
+ return ret;
+
+ return max98390_hda_set_speaker_enable(priv, false);
+}
+
+static void max98390_hda_pre_playback_hook(struct device *dev, int action)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ if (action != HDA_GEN_PCM_ACT_CLOSE)
+ return;
+
+ guard(mutex)(&priv->lock);
+
+ priv->playback_started = false;
+ ret = max98390_hda_set_global_enable(priv, false);
+ if (ret)
+ dev_err(dev, "Failed to disable amp: %d\n", ret);
+}
+
+static void max98390_hda_playback_hook(struct device *dev, int action)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ guard(mutex)(&priv->lock);
+
+ switch (action) {
+ case HDA_GEN_PCM_ACT_OPEN:
+ priv->playback_started = true;
+ ret = max98390_hda_set_amp_enable(priv, true);
+ break;
+ case HDA_GEN_PCM_ACT_CLOSE:
+ ret = max98390_hda_set_speaker_enable(priv, false);
+ break;
+ default:
+ return;
+ }
+
+ if (ret)
+ dev_err(dev, "Failed to set amp state: %d\n", ret);
+}
+
+static int max98390_hda_check_dsm_fw(const struct firmware *fw)
+{
+ unsigned int start, size;
+
+ if (fw->size < MAX98390_DSM_PAYLOAD_OFFSET)
+ return -EINVAL;
+
+ start = get_unaligned_le16(fw->data);
+ size = get_unaligned_le16(fw->data + 2);
+
+ if (!size || start < MAX98390_PWR_GATE_CTL || start + size - 1 > DSMIG_EN ||
+ fw->size < MAX98390_DSM_PAYLOAD_OFFSET + size)
+ return -EINVAL;
+
+ return 0;
+}
+
+static void max98390_hda_get_dsm_fw(struct max98390_hda_priv *priv, struct hda_codec *codec)
+{
+ const struct firmware *fw;
+ int ret;
+
+ char *name __free(kfree) = kasprintf(GFP_KERNEL, "maxim/max98390-hda-%08x-%d.bin",
+ codec->core.subsystem_id, priv->index);
+ if (!name)
+ return;
+
+ ret = firmware_request_nowarn(&fw, name, priv->dev);
+ if (ret) {
+ dev_dbg(priv->dev, "%s not found, using default tuning\n", name);
+ return;
+ }
+
+ if (max98390_hda_check_dsm_fw(fw)) {
+ dev_err(priv->dev, "Invalid %s, using default tuning\n", name);
+ release_firmware(fw);
+ return;
+ }
+
+ dev_info(priv->dev, "Loaded %s\n", name);
+ priv->dsm_fw = fw;
+}
+
+static int max98390_hda_set_biquad(struct max98390_hda_priv *priv, unsigned int reg,
+ const u32 *coefs)
+{
+ u8 buf[3];
+ int ret;
+ int i;
+
+ for (i = 0; i < MAX98390_HDA_BIQUAD_COEFS; i++) {
+ put_unaligned_le24(coefs[i], buf);
+ ret = regmap_bulk_write(priv->regmap, reg + i * MAX98390_HDA_COEF_STRIDE,
+ buf, sizeof(buf));
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int max98390_hda_set_default_dsm_params(struct max98390_hda_priv *priv)
+{
+ const u32 *hpf = priv->is_tweeter ? max98390_hda_hpf_3khz : max98390_hda_hpf_100hz;
+ unsigned int reg;
+ int ret;
+
+ ret = max98390_hda_set_biquad(priv, DSM_EQ_BQ1_B0_BYTE0, hpf);
+ if (ret)
+ return ret;
+
+ for (reg = DSM_EQ_BQ2_B0_BYTE0; reg <= DSM_EQ_BQ8_B0_BYTE0;
+ reg += MAX98390_HDA_BIQUAD_STRIDE) {
+ ret = max98390_hda_set_biquad(priv, reg, max98390_hda_unity);
+ if (ret)
+ return ret;
+ }
+
+ ret = regmap_write(priv->regmap, DSM_VOL_CTRL, MAX98390_HDA_DSM_VOL_MINUS_7_5DB);
+ if (ret)
+ return ret;
+
+ return regmap_write(priv->regmap, DSMIG_EN, MAX98390_HDA_DSMIG_EQ8_EN);
+}
+
+static int max98390_hda_set_dsm_params(struct max98390_hda_priv *priv)
+{
+ const u8 *data;
+ int ret;
+
+ ret = max98390_hda_set_default_dsm_params(priv);
+ if (ret)
+ return ret;
+
+ if (priv->dsm_fw) {
+ data = priv->dsm_fw->data;
+ ret = regmap_bulk_write(priv->regmap, get_unaligned_le16(data),
+ data + MAX98390_DSM_PAYLOAD_OFFSET,
+ get_unaligned_le16(data + 2));
+ if (ret)
+ return ret;
+ }
+
+ return regmap_write(priv->regmap, MAX98390_R23E1_DSP_GLOBAL_EN, MAX98390_HDA_DSP_GLOBAL_EN);
+}
+
+static int max98390_hda_init(struct max98390_hda_priv *priv)
+{
+ int ret;
+
+ ret = regmap_write(priv->regmap, MAX98390_SOFTWARE_RESET, MAX98390_SOFT_RESET_MASK);
+ if (ret)
+ return ret;
+
+ msleep(20);
+
+ ret = regmap_multi_reg_write(priv->regmap, max98390_hda_init_regs,
+ ARRAY_SIZE(max98390_hda_init_regs));
+ if (ret)
+ return ret;
+
+ ret = regmap_write(priv->regmap, MAX98390_PCM_CH_SRC_1,
+ priv->channel << MAX98390_PCM_RX_CH_SRC_SHIFT);
+ if (ret)
+ return ret;
+
+ return max98390_hda_set_dsm_params(priv);
+}
+
+static int max98390_hda_bind(struct device *dev, struct device *master, void *master_data)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ struct hda_component_parent *parent = master_data;
+ struct hda_component *comp;
+ int ret;
+
+ comp = hda_component_from_index(parent, priv->index);
+ if (!comp)
+ return -EINVAL;
+
+ if (comp->dev)
+ return -EBUSY;
+
+ scoped_guard(mutex, &priv->lock) {
+ max98390_hda_get_dsm_fw(priv, parent->codec);
+ ret = max98390_hda_init(priv);
+ if (ret) {
+ release_firmware(priv->dsm_fw);
+ priv->dsm_fw = NULL;
+ return ret;
+ }
+ }
+
+ comp->dev = dev;
+ strscpy(comp->name, dev_name(dev), sizeof(comp->name));
+ comp->pre_playback_hook = max98390_hda_pre_playback_hook;
+ comp->playback_hook = max98390_hda_playback_hook;
+
+ return 0;
+}
+
+static void max98390_hda_unbind(struct device *dev, struct device *master, void *master_data)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ struct hda_component_parent *parent = master_data;
+ struct hda_component *comp;
+
+ comp = hda_component_from_index(parent, priv->index);
+ if (comp && comp->dev == dev)
+ memset(comp, 0, sizeof(*comp));
+
+ guard(mutex)(&priv->lock);
+
+ release_firmware(priv->dsm_fw);
+ priv->dsm_fw = NULL;
+}
+
+static const struct component_ops max98390_hda_comp_ops = {
+ .bind = max98390_hda_bind,
+ .unbind = max98390_hda_unbind,
+};
+
+int max98390_hda_probe(struct device *dev, int index, struct regmap *regmap)
+{
+ struct max98390_hda_priv *priv;
+ unsigned int rev_id;
+ int ret;
+
+ if (IS_ERR(regmap))
+ return dev_err_probe(dev, PTR_ERR(regmap), "Failed to allocate regmap\n");
+
+ priv = devm_kzalloc_obj(dev, *priv);
+ if (!priv)
+ return -ENOMEM;
+
+ ret = devm_mutex_init(dev, &priv->lock);
+ if (ret)
+ return ret;
+
+ priv->dev = dev;
+ priv->regmap = regmap;
+ priv->index = index;
+ priv->channel = index % 2;
+ priv->is_tweeter = index >= MAX98390_HDA_NUM_AMPS / 2;
+ dev_set_drvdata(dev, priv);
+
+ ret = regmap_read(regmap, MAX98390_R24FF_REV_ID, &rev_id);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to read revision ID\n");
+
+ dev_dbg(dev, "Revision ID 0x%02x\n", rev_id);
+
+ return component_add(dev, &max98390_hda_comp_ops);
+}
+EXPORT_SYMBOL_NS_GPL(max98390_hda_probe, "SND_HDA_SCODEC_MAX98390");
+
+void max98390_hda_remove(struct device *dev)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+
+ component_del(dev, &max98390_hda_comp_ops);
+
+ guard(mutex)(&priv->lock);
+
+ if (priv->playback_started)
+ max98390_hda_set_amp_enable(priv, false);
+}
+EXPORT_SYMBOL_NS_GPL(max98390_hda_remove, "SND_HDA_SCODEC_MAX98390");
+
+static int max98390_hda_system_suspend(struct device *dev)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ guard(mutex)(&priv->lock);
+
+ if (!priv->playback_started)
+ return 0;
+
+ ret = max98390_hda_set_amp_enable(priv, false);
+ if (ret)
+ dev_err(dev, "Failed to disable amp: %d\n", ret);
+
+ return 0;
+}
+
+static int max98390_hda_system_resume(struct device *dev)
+{
+ struct max98390_hda_priv *priv = dev_get_drvdata(dev);
+ int ret;
+
+ guard(mutex)(&priv->lock);
+
+ ret = max98390_hda_init(priv);
+ if (ret)
+ return ret;
+
+ if (priv->playback_started)
+ return max98390_hda_set_amp_enable(priv, true);
+
+ return 0;
+}
+
+EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(max98390_hda_pm_ops, SND_HDA_SCODEC_MAX98390) = {
+ SYSTEM_SLEEP_PM_OPS(max98390_hda_system_suspend, max98390_hda_system_resume)
+};
+
+MODULE_DESCRIPTION("HDA MAX98390 side codec library");
+MODULE_AUTHOR("Kevin Cuperus <cuperus.kevin@hotmail.com>");
+MODULE_AUTHOR("Stephan Lensky <linux@slensky.com>");
+MODULE_LICENSE("GPL");
diff --git a/sound/hda/codecs/side-codecs/max98390_hda.h b/sound/hda/codecs/side-codecs/max98390_hda.h
new file mode 100644
index 000000000000..9dc7e056d4f4
--- /dev/null
+++ b/sound/hda/codecs/side-codecs/max98390_hda.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * MAX98390 HDA driver
+ */
+
+#ifndef __MAX98390_HDA_H__
+#define __MAX98390_HDA_H__
+
+struct device;
+struct dev_pm_ops;
+struct regmap;
+
+int max98390_hda_probe(struct device *dev, int index, struct regmap *regmap);
+void max98390_hda_remove(struct device *dev);
+
+extern const struct dev_pm_ops max98390_hda_pm_ops;
+
+#endif /* __MAX98390_HDA_H__ */
diff --git a/sound/hda/codecs/side-codecs/max98390_hda_i2c.c b/sound/hda/codecs/side-codecs/max98390_hda_i2c.c
new file mode 100644
index 000000000000..c628d0c4ab9c
--- /dev/null
+++ b/sound/hda/codecs/side-codecs/max98390_hda_i2c.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// MAX98390 HDA I2C driver
+//
+
+#include <linux/i2c.h>
+#include <linux/kstrtox.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/regmap.h>
+#include <linux/string.h>
+#include <sound/max98390.h>
+
+#include "max98390_hda.h"
+
+static const struct regmap_config max98390_hda_regmap = {
+ .reg_bits = 16,
+ .val_bits = 8,
+ .max_register = MAX98390_R24FF_REV_ID,
+ .cache_type = REGCACHE_NONE,
+};
+
+static int max98390_hda_i2c_probe(struct i2c_client *clt)
+{
+ const char *index_suffix;
+ int index;
+ int ret;
+
+ if (!strstr(dev_name(&clt->dev), "MAX98390"))
+ return -ENODEV;
+
+ index_suffix = strrchr(dev_name(&clt->dev), '.');
+ if (!index_suffix)
+ return dev_err_probe(&clt->dev, -EINVAL, "Missing index in %s\n",
+ dev_name(&clt->dev));
+
+ ret = kstrtoint(index_suffix + 1, 10, &index);
+ if (ret)
+ return dev_err_probe(&clt->dev, ret, "Failed to parse index from %s\n",
+ dev_name(&clt->dev));
+
+ return max98390_hda_probe(&clt->dev, index,
+ devm_regmap_init_i2c(clt, &max98390_hda_regmap));
+}
+
+static void max98390_hda_i2c_remove(struct i2c_client *clt)
+{
+ max98390_hda_remove(&clt->dev);
+}
+
+static const struct i2c_device_id max98390_hda_i2c_id[] = {
+ { .name = "max98390-hda" },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, max98390_hda_i2c_id);
+
+static const struct acpi_device_id max98390_acpi_hda_match[] = {
+ { .id = "MAX98390" },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, max98390_acpi_hda_match);
+
+static struct i2c_driver max98390_hda_i2c_driver = {
+ .driver = {
+ .name = "max98390-hda",
+ .acpi_match_table = max98390_acpi_hda_match,
+ .pm = pm_sleep_ptr(&max98390_hda_pm_ops),
+ },
+ .id_table = max98390_hda_i2c_id,
+ .probe = max98390_hda_i2c_probe,
+ .remove = max98390_hda_i2c_remove,
+};
+module_i2c_driver(max98390_hda_i2c_driver);
+
+MODULE_DESCRIPTION("HDA MAX98390 I2C driver");
+MODULE_IMPORT_NS("SND_HDA_SCODEC_MAX98390");
+MODULE_AUTHOR("Kevin Cuperus <cuperus.kevin@hotmail.com>");
+MODULE_AUTHOR("Stephan Lensky <linux@slensky.com>");
+MODULE_LICENSE("GPL");
--
2.55.0
next prev parent reply other threads:[~2026-12-02 3:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 3:12 [PATCH 0/4] ALSA: hda: Add MAX98390 side codec support for Samsung Galaxy Book4 Pro 360 Stephan Lensky
2026-12-02 3:12 ` [PATCH 1/4] ASoC: max98390: Move register definitions to include/sound Stephan Lensky
2026-12-02 3:12 ` [PATCH 2/4] ACPI/platform: Add MAX98390 to serial-multi-instantiate Stephan Lensky
2026-12-02 3:12 ` Stephan Lensky [this message]
2026-12-02 3:23 ` [PATCH 3/4] ALSA: hda: Add MAX98390 side codec driver sashiko-bot
2026-12-02 3:12 ` [PATCH 4/4] ALSA: hda/realtek: Add MAX98390 fixup for Samsung Galaxy Book4 Pro 360 Stephan Lensky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202031233.171555-4-linux@slensky.com \
--to=linux@slensky.com \
--cc=broonie@kernel.org \
--cc=cuperus.kevin@hotmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lenb@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.