Commit 1c6579b5 authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: codecs: add MAX98373 Soundwire driver" from Pierre-Louis...

Merge series "ASoC: codecs: add MAX98373 Soundwire driver" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

V3:
Rebased on top of two fixes already merged from the v2 patchset - no
code changes
Added explicit commit reference in last commit message

V2 with a number of cleanups:
split between I2C and SoundWire modes, as done for rt5682, and updated
Kconfigs.
removed useless initializations common to both modes
removed idle_bias on
fixed register classified as volatile in error
fixed SPDX comments

Pierre-Louis Bossart (2):
  ASoC: codecs: max98373: split I2C and common parts
  ASoC: Intel: sof-sdw: add MAX98373 I2C dependencies

Ryan Lee (1):
  ASoC: codecs: max98373: add SoundWire support

randerwang (1):
  ASoC: Intel: sdw_max98373: add card_late_probe support

 sound/soc/codecs/Kconfig                  |  20 +-
 sound/soc/codecs/Makefile                 |   4 +
 sound/soc/codecs/max98373-i2c.c           | 612 +++++++++++++++
 sound/soc/codecs/max98373-sdw.c           | 887 ++++++++++++++++++++++
 sound/soc/codecs/max98373-sdw.h           |  72 ++
 sound/soc/codecs/max98373.c               | 611 +--------------
 sound/soc/codecs/max98373.h               |  17 +-
 sound/soc/intel/boards/Kconfig            |   7 +-
 sound/soc/intel/boards/sof_sdw.c          |  19 +-
 sound/soc/intel/boards/sof_sdw_common.h   |   6 +
 sound/soc/intel/boards/sof_sdw_max98373.c |  12 +
 11 files changed, 1668 insertions(+), 599 deletions(-)
 create mode 100644 sound/soc/codecs/max98373-i2c.c
 create mode 100644 sound/soc/codecs/max98373-sdw.c
 create mode 100644 sound/soc/codecs/max98373-sdw.h

base-commit: 6940701c
--
2.25.1
parents a8342389 be3afa12
......@@ -115,7 +115,8 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_MAX98925
imply SND_SOC_MAX98926
imply SND_SOC_MAX98927
imply SND_SOC_MAX98373
imply SND_SOC_MAX98373_I2C
imply SND_SOC_MAX98373_SDW
imply SND_SOC_MAX98390
imply SND_SOC_MAX9850
imply SND_SOC_MAX9860
......@@ -868,8 +869,25 @@ config SND_SOC_MAX98927
depends on I2C
config SND_SOC_MAX98373
tristate
config SND_SOC_MAX98373_I2C
tristate "Maxim Integrated MAX98373 Speaker Amplifier"
depends on I2C
select SND_SOC_MAX98373
config SND_SOC_MAX98373_SDW
tristate "Maxim Integrated MAX98373 Speaker Amplifier - SDW"
depends on SOUNDWIRE
select SND_SOC_MAX98373
select REGMAP_SOUNDWIRE
help
Enable support for Maxim Integrated MAX98373 Soundwire
amplifier. MAX98373 supports either the MIPI SoundWire
compatible interface for audio and control data, or
the PCM interface for audio data and a standard I2C
interface for control data. Select this if MAX98373 is
connected via soundwire.
config SND_SOC_MAX98390
tristate "Maxim Integrated MAX98390 Speaker Amplifier"
......
......@@ -115,6 +115,8 @@ snd-soc-max98925-objs := max98925.o
snd-soc-max98926-objs := max98926.o
snd-soc-max98927-objs := max98927.o
snd-soc-max98373-objs := max98373.o
snd-soc-max98373-i2c-objs := max98373-i2c.o
snd-soc-max98373-sdw-objs := max98373-sdw.o
snd-soc-max98390-objs := max98390.o
snd-soc-max9850-objs := max9850.o
snd-soc-max9860-objs := max9860.o
......@@ -418,6 +420,8 @@ obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o
obj-$(CONFIG_SND_SOC_MAX98926) += snd-soc-max98926.o
obj-$(CONFIG_SND_SOC_MAX98927) += snd-soc-max98927.o
obj-$(CONFIG_SND_SOC_MAX98373) += snd-soc-max98373.o
obj-$(CONFIG_SND_SOC_MAX98373_I2C) += snd-soc-max98373-i2c.o
obj-$(CONFIG_SND_SOC_MAX98373_SDW) += snd-soc-max98373-sdw.o
obj-$(CONFIG_SND_SOC_MAX98390) += snd-soc-max98390.o
obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
obj-$(CONFIG_SND_SOC_MAX9860) += snd-soc-max9860.o
......
This diff is collapsed.
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2020 Maxim Integrated */
#ifndef _MAX98373_SDW_H
#define _MAX98373_SDW_H
#include "max98373.h"
/* SoundWire Slave Control Port (SCP) */
#define MAX98373_R0040_SCP_INIT_STAT_1 0x0040
#define MAX98373_R0041_SCP_INIT_MASK_1 0x0041
#define MAX98373_R0042_SCP_INIT_STAT_2 0x0042
#define MAX98373_R0044_SCP_CTRL 0x0044
#define MAX98373_R0045_SCP_SYSTEM_CTRL 0x0045
#define MAX98373_R0046_SCP_DEV_NUMBER 0x0046
#define MAX98373_R0050_SCP_DEV_ID_0 0x0050
#define MAX98373_R0051_SCP_DEV_ID_1 0x0051
#define MAX98373_R0052_SCP_DEV_ID_2 0x0052
#define MAX98373_R0053_SCP_DEV_ID_3 0x0053
#define MAX98373_R0054_SCP_DEV_ID_4 0x0054
#define MAX98373_R0055_SCP_DEV_ID_5 0x0055
#define MAX98373_R0060_SCP_FRAME_CTLR 0x0060
#define MAX98373_R0070_SCP_FRAME_CTLR 0x0070
/* SoundWire Device Data Port (DP) */
/* Data Port 1 Registers */
#define MAX98373_R0100_DP1_INIT_STAT 0x0100
#define MAX98373_R0101_DP1_INIT_MASK 0x0101
#define MAX98373_R0102_DP1_PORT_CTRL 0x0102
#define MAX98373_R0103_DP1_BLOCK_CTRL_1 0x0103
#define MAX98373_R0104_DP1_PREPARE_STATUS 0x0104
#define MAX98373_R0105_DP1_PREPARE_CTRL 0x0105
/* Data Port 1 Bank 0 Registers */
#define MAX98373_R0120_DP1_CHANNEL_EN 0x0120
#define MAX98373_R0122_DP1_SAMPLE_CTRL1 0x0122
#define MAX98373_R0123_DP1_SAMPLE_CTRL2 0x0123
#define MAX98373_R0124_DP1_OFFSET_CTRL1 0x0124
#define MAX98373_R0125_DP1_OFFSET_CTRL2 0x0125
#define MAX98373_R0126_DP1_HCTRL 0x0126
#define MAX98373_R0127_DP1_BLOCK_CTRL3 0x0127
/* Data Port 1 Bank 1 Registers */
#define MAX98373_R0130_DP1_CHANNEL_EN 0x0130
#define MAX98373_R0132_DP1_SAMPLE_CTRL1 0x0132
#define MAX98373_R0133_DP1_SAMPLE_CTRL2 0x0133
#define MAX98373_R0134_DP1_OFFSET_CTRL1 0x0134
#define MAX98373_R0135_DP1_OFFSET_CTRL2 0x0135
#define MAX98373_R0136_DP1_HCTRL 0x0136
#define MAX98373_R0137_DP1_BLOCK_CTRL3 0x0137
/* Data Port 3 Registers */
#define MAX98373_R0300_DP3_INIT_STAT 0x0300
#define MAX98373_R0301_DP3_INIT_MASK 0x0301
#define MAX98373_R0302_DP3_PORT_CTRL 0x0302
#define MAX98373_R0303_DP3_BLOCK_CTRL_1 0x0303
#define MAX98373_R0304_DP3_PREPARE_STATUS 0x0304
#define MAX98373_R0305_DP3_PREPARE_CTRL 0x0305
/* Data Port 3 Bank 0 Registers */
#define MAX98373_R0320_DP3_CHANNEL_EN 0x0320
#define MAX98373_R0322_DP3_SAMPLE_CTRL1 0x0322
#define MAX98373_R0323_DP3_SAMPLE_CTRL2 0x0323
#define MAX98373_R0324_DP3_OFFSET_CTRL1 0x0324
#define MAX98373_R0325_DP3_OFFSET_CTRL2 0x0325
#define MAX98373_R0326_DP3_HCTRL 0x0326
#define MAX98373_R0327_DP3_BLOCK_CTRL3 0x0327
/* Data Port 3 Bank 1 Registers */
#define MAX98373_R0330_DP3_CHANNEL_EN 0x0330
#define MAX98373_R0332_DP3_SAMPLE_CTRL1 0x0332
#define MAX98373_R0333_DP3_SAMPLE_CTRL2 0x0333
#define MAX98373_R0334_DP3_OFFSET_CTRL1 0x0334
#define MAX98373_R0335_DP3_OFFSET_CTRL2 0x0335
#define MAX98373_R0336_DP3_HCTRL 0x0336
#define MAX98373_R0337_DP3_BLOCK_CTRL3 0x0337
#endif
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2017, Maxim Integrated
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2017 Maxim Integrated */
#ifndef _MAX98373_H
#define _MAX98373_H
......@@ -212,5 +212,18 @@ struct max98373_priv {
bool interleave_mode;
unsigned int ch_size;
bool tdm_mode;
/* variables to support soundwire */
struct sdw_slave *slave;
bool hw_init;
bool pm_init_once;
int slot;
unsigned int rx_mask;
};
extern const struct snd_soc_component_driver soc_codec_dev_max98373;
extern const struct snd_soc_component_driver soc_codec_dev_max98373_sdw;
void max98373_reset(struct max98373_priv *max98373, struct device *dev);
void max98373_slot_config(struct device *dev,
struct max98373_priv *max98373);
#endif
......@@ -390,7 +390,7 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98927_MACH
depends on MFD_INTEL_LPSS || COMPILE_TEST
select SND_SOC_DA7219
select SND_SOC_MAX98927
select SND_SOC_MAX98373
select SND_SOC_MAX98373_I2C
select SND_SOC_DMIC
select SND_SOC_HDAC_HDMI
help
......@@ -467,7 +467,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
depends on ((SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC) &&\
(MFD_INTEL_LPSS || COMPILE_TEST)) ||\
(SND_SOC_SOF_BAYTRAIL && (X86_INTEL_LPSS || COMPILE_TEST))
select SND_SOC_MAX98373
select SND_SOC_MAX98373_I2C
select SND_SOC_RT1015
select SND_SOC_RT5682_I2C
select SND_SOC_DMIC
......@@ -531,7 +531,7 @@ config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH
depends on MFD_INTEL_LPSS || COMPILE_TEST
depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
select SND_SOC_DA7219
select SND_SOC_MAX98373
select SND_SOC_MAX98373_I2C
select SND_SOC_DMIC
help
This adds support for ASoC machine driver for SOF platforms
......@@ -565,6 +565,7 @@ config SND_SOC_INTEL_SOUNDWIRE_SOF_MACH
depends on SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES || COMPILE_TEST
depends on SOUNDWIRE
depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
select SND_SOC_MAX98373_I2C
select SND_SOC_MAX98373_SDW
select SND_SOC_RT700_SDW
select SND_SOC_RT711_SDW
......
......@@ -237,6 +237,7 @@ static struct sof_sdw_codec_info codec_info_list[] = {
.direction = {true, true},
.dai_name = "max98373-aif1",
.init = sof_sdw_mx8373_init,
.codec_card_late_probe = sof_sdw_mx8373_late_probe,
},
{
.id = 0x5682,
......@@ -927,13 +928,29 @@ static int sof_card_dai_links_create(struct device *dev,
return 0;
}
static int sof_sdw_card_late_probe(struct snd_soc_card *card)
{
int i, ret;
for (i = 0; i < ARRAY_SIZE(codec_info_list); i++) {
if (!codec_info_list[i].late_probe)
continue;
ret = codec_info_list[i].codec_card_late_probe(card);
if (ret < 0)
return ret;
}
return sof_sdw_hdmi_card_late_probe(card);
}
/* SoC card */
static const char sdw_card_long_name[] = "Intel Soundwire SOF";
static struct snd_soc_card card_sof_sdw = {
.name = "soundwire",
.owner = THIS_MODULE,
.late_probe = sof_sdw_hdmi_card_late_probe,
.late_probe = sof_sdw_card_late_probe,
.codec_conf = codec_conf,
.num_configs = ARRAY_SIZE(codec_conf),
};
......
......@@ -11,6 +11,7 @@
#include <linux/bits.h>
#include <linux/types.h>
#include <sound/soc.h>
#define MAX_NO_PROPS 2
#define MAX_HDMI_NUM 4
......@@ -61,6 +62,9 @@ struct sof_sdw_codec_info {
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
bool late_probe;
int (*codec_card_late_probe)(struct snd_soc_card *card);
};
struct mc_private {
......@@ -114,6 +118,8 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
struct sof_sdw_codec_info *info,
bool playback);
int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
/* RT5682 support */
int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
......
......@@ -68,7 +68,19 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
if (info->amp_num == 2)
dai_links->init = spk_init;
info->late_probe = true;
dai_links->ops = &max_98373_sdw_ops;
return 0;
}
int sof_sdw_mx8373_late_probe(struct snd_soc_card *card)
{
struct snd_soc_dapm_context *dapm = &card->dapm;
/* Disable Left and Right Spk pin after boot */
snd_soc_dapm_disable_pin(dapm, "Left Spk");
snd_soc_dapm_disable_pin(dapm, "Right Spk");
return snd_soc_dapm_sync(dapm);
}
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