Skip to content

Commit

Permalink
ASoC: cs35l41: Convert tables to shared source code
Browse files Browse the repository at this point in the history
To support CS35L41 in HDA systems the HDA driver
for CS35L41 would have to duplicate some functions
that already exist on ASoC driver
So instead of duplicate the code, use the new lib
source as a shared resource for both ASoC and HDA

Also, change the way CONFIG_SND_SOC_CS35L41 is
selected, as reported by Intel Kernel test robot,
it is possible to build SND_SOC_CS35L41_SPI/I2C
without the main driver, which would lead to build
failures.

Signed-off-by: Lucas Tanure <tanureal@opensource.cirrus.com>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20211217115708.882525-2-tanureal@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Lucas Tanure authored and broonie committed Dec 31, 2021
1 parent cc5c978 commit a87d422
Show file tree
Hide file tree
Showing 7 changed files with 755 additions and 743 deletions.
733 changes: 733 additions & 0 deletions include/sound/cs35l41.h

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions sound/soc/codecs/Kconfig
Expand Up @@ -624,21 +624,24 @@ config SND_SOC_CS35L36
tristate "Cirrus Logic CS35L36 CODEC"
depends on I2C

config SND_SOC_CS35L41_LIB
tristate

config SND_SOC_CS35L41
tristate
default y if SND_SOC_CS35L41_SPI=y
default y if SND_SOC_CS35L41_I2C=y
default m if SND_SOC_CS35L41_SPI=m
default m if SND_SOC_CS35L41_I2C=m

config SND_SOC_CS35L41_SPI
tristate "Cirrus Logic CS35L41 CODEC (SPI)"
depends on SPI_MASTER
select SND_SOC_CS35L41_LIB
select SND_SOC_CS35L41
select REGMAP_SPI

config SND_SOC_CS35L41_I2C
tristate "Cirrus Logic CS35L41 CODEC (I2C)"
depends on I2C
select SND_SOC_CS35L41_LIB
select SND_SOC_CS35L41
select REGMAP_I2C

config SND_SOC_CS42L42
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/codecs/Makefile
Expand Up @@ -55,7 +55,8 @@ snd-soc-cs35l33-objs := cs35l33.o
snd-soc-cs35l34-objs := cs35l34.o
snd-soc-cs35l35-objs := cs35l35.o
snd-soc-cs35l36-objs := cs35l36.o
snd-soc-cs35l41-objs := cs35l41.o cs35l41-tables.o
snd-soc-cs35l41-lib-objs := cs35l41-lib.o
snd-soc-cs35l41-objs := cs35l41.o
snd-soc-cs35l41-spi-objs := cs35l41-spi.o
snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o
snd-soc-cs42l42-objs := cs42l42.o
Expand Down Expand Up @@ -396,6 +397,7 @@ obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o
obj-$(CONFIG_SND_SOC_CS35L35) += snd-soc-cs35l35.o
obj-$(CONFIG_SND_SOC_CS35L36) += snd-soc-cs35l36.o
obj-$(CONFIG_SND_SOC_CS35L41) += snd-soc-cs35l41.o
obj-$(CONFIG_SND_SOC_CS35L41_LIB) += snd-soc-cs35l41-lib.o
obj-$(CONFIG_SND_SOC_CS35L41_SPI) += snd-soc-cs35l41-spi.o
obj-$(CONFIG_SND_SOC_CS35L41_I2C) += snd-soc-cs35l41-i2c.o
obj-$(CONFIG_SND_SOC_CS42L42) += snd-soc-cs42l42.o
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/cs35l41-i2c.c
Expand Up @@ -17,7 +17,6 @@
#include <linux/platform_device.h>
#include <linux/slab.h>

#include <sound/cs35l41.h>
#include "cs35l41.h"

static const struct i2c_device_id cs35l41_id_i2c[] = {
Expand Down
@@ -1,12 +1,16 @@
// SPDX-License-Identifier: GPL-2.0
//
// cs35l41-tables.c -- CS35L41 ALSA SoC audio driver
// cs35l41-lib.c -- CS35L41 Common functions for HDA and ASoC Audio drivers
//
// Copyright 2017-2021 Cirrus Logic, Inc.
//
// Author: David Rhodes <david.rhodes@cirrus.com>
// Author: Lucas Tanure <lucas.tanure@cirrus.com>

#include "cs35l41.h"
#include <linux/module.h>
#include <linux/regmap.h>

#include <sound/cs35l41.h>

static const struct reg_default cs35l41_reg[] = {
{ CS35L41_PWR_CTRL1, 0x00000000 },
Expand Down Expand Up @@ -688,6 +692,7 @@ const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS]
.word_offset = 2,
},
};
EXPORT_SYMBOL_GPL(cs35l41_otp_map_map);

struct regmap_config cs35l41_regmap_i2c = {
.reg_bits = 32,
Expand Down Expand Up @@ -721,3 +726,8 @@ struct regmap_config cs35l41_regmap_spi = {
.cache_type = REGCACHE_RBTREE,
};
EXPORT_SYMBOL_GPL(cs35l41_regmap_spi);

MODULE_DESCRIPTION("CS35L41 library");
MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, <david.rhodes@cirrus.com>");
MODULE_AUTHOR("Lucas Tanure, Cirrus Logic Inc, <tanureal@opensource.cirrus.com>");
MODULE_LICENSE("GPL");
1 change: 0 additions & 1 deletion sound/soc/codecs/cs35l41-spi.c
Expand Up @@ -15,7 +15,6 @@
#include <linux/platform_device.h>
#include <linux/spi/spi.h>

#include <sound/cs35l41.h>
#include "cs35l41.h"

static const struct spi_device_id cs35l41_id_spi[] = {
Expand Down

0 comments on commit a87d422

Please sign in to comment.