Skip to contentSkip to conversation

SOC Codecs: TLV320AIC3X add SPI support

PATCH In review Jiri Prchal 3 participants 16 messages Apr 6, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover SOC Codecs: TLV320AIC3X add SPI support

This patches add support of SPI to TLV320AIC3X codecs.

Jiri Prchal (5):
SOC Codecs: TLV320AIC3X add SPI: move thinks to header file SOC Codecs: TLV320AIC3X add SPI: main source code for I2C and SPI SOC Codecs: TLV320AIC3X add SPI: I2C code
SOC Codecs: TLV320AIC3X add SPI: SPI code
SOC Codecs: TLV320AIC3X add SPI: configuration and compile

 sound/soc/codecs/Kconfig           |  11 +++
 sound/soc/codecs/Makefile          |   4 ++
 sound/soc/codecs/tlv320aic3x-i2c.c |  72 ++++++++++++++++++++
 sound/soc/codecs/tlv320aic3x-spi.c |  77 +++++++++++++++++++++
 sound/soc/codecs/tlv320aic3x.c     | 105 ++++++++---------------------
 sound/soc/codecs/tlv320aic3x.h     |  13 ++++
 6 files changed, 204 insertions(+), 78 deletions(-)
 create mode 100644 sound/soc/codecs/tlv320aic3x-i2c.c
 create mode 100644 sound/soc/codecs/tlv320aic3x-spi.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/5 SOC Codecs: TLV320AIC3X add SPI: move thinks to header file

Move shered definitions and defines to header file.

---
 sound/soc/codecs/tlv320aic3x.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
sound/soc/codecs/tlv320aic3x.h +13 -0
index 66d3580cf2b1..5d2195f009a9 100644
@@ -9,6 +9,19 @@
 #ifndef _AIC3X_H
 #define _AIC3X_H
 
+struct device;
+struct regmap_config;
+
+extern const struct regmap_config aic3x_regmap_config;
+int aic3x_probe(struct device *dev, struct regmap *regmap, kernel_ulong_t driver_data);
+int aic3x_remove(struct device *dev);
+
+#define AIC3X_MODEL_3X 0
+#define AIC3X_MODEL_33 1
+#define AIC3X_MODEL_3007 2
+#define AIC3X_MODEL_3104 3
+#define AIC3X_MODEL_3106 4
+
 /* AIC3X register space */
 #define AIC3X_CACHEREGNUM		110
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 1/5] SOC Codecs: TLV320AIC3X add SPI: move thinks to header file

Quoted 6 lines · Jiri Prchal

Move shered definitions and defines to header file.

---
 sound/soc/codecs/tlv320aic3x.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

This isn't moving things, this is copying the definitions into the header file without removing the original copies. There's also typos in the subject and commit log.

#3 lore raw

PATCH 2/5 SOC Codecs: TLV320AIC3X add SPI: main source code for I2C and SPI

In reply to Jiri Prchal

Removed things which are in header file. Renamed functions and removed their I2C related code. Moved I2C code to separate file.

---
 sound/soc/codecs/tlv320aic3x.c | 105 +++++++++------------------------
 1 file changed, 27 insertions(+), 78 deletions(-)
sound/soc/codecs/tlv320aic3x.c +27 -78
index db1444127444..727e3cc78d88 100644
@@ -82,10 +82,6 @@ struct aic3x_priv {
 	int master;
 	int gpio_reset;
 	int power;
-#define AIC3X_MODEL_3X 0
-#define AIC3X_MODEL_33 1
-#define AIC3X_MODEL_3007 2
-#define AIC3X_MODEL_3104 3
 	u16 model;
 
 	/* Selects the micbias voltage */
@@ -135,10 +131,7 @@ static bool aic3x_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static const struct regmap_config aic3x_regmap = {
-	.reg_bits = 8,
-	.val_bits = 8,
-
+const struct regmap_config aic3x_regmap_config = {
 	.max_register = DAC_ICC_ADJ,
 	.reg_defaults = aic3x_reg,
 	.num_reg_defaults = ARRAY_SIZE(aic3x_reg),
@@ -147,6 +140,7 @@ static const struct regmap_config aic3x_regmap = {
 
 	.cache_type = REGCACHE_RBTREE,
 };
+EXPORT_SYMBOL(aic3x_regmap_config);
 
 #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \
 	SOC_SINGLE_EXT(xname, reg, shift, mask, invert, \
@@ -1614,7 +1608,7 @@ static bool aic3x_is_shared_reset(struct aic3x_priv *aic3x)
 	return false;
 }
 
-static int aic3x_probe(struct snd_soc_component *component)
+static int aic3x_component_probe(struct snd_soc_component *component)
 {
 	struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component);
 	int ret, i;
@@ -1693,7 +1687,7 @@ static int aic3x_probe(struct snd_soc_component *component)
 
 static const struct snd_soc_component_driver soc_component_dev_aic3x = {
 	.set_bias_level		= aic3x_set_bias_level,
-	.probe			= aic3x_probe,
+	.probe			= aic3x_component_probe,
 	.controls		= aic3x_snd_controls,
 	.num_controls		= ARRAY_SIZE(aic3x_snd_controls),
 	.dapm_widgets		= aic3x_dapm_widgets,
@@ -1705,10 +1699,9 @@ static const struct snd_soc_component_driver soc_component_dev_aic3x = {
 	.non_legacy_dai_naming	= 1,
 };
 
-static void aic3x_configure_ocmv(struct i2c_client *client)
+static void aic3x_configure_ocmv(struct device *dev, struct aic3x_priv *aic3x)
 {
-	struct device_node *np = client->dev.of_node;
-	struct aic3x_priv *aic3x = i2c_get_clientdata(client);
+	struct device_node *np = dev->of_node;
 	u32 value;
 	int dvdd, avdd;
 
@@ -1724,7 +1717,7 @@ static void aic3x_configure_ocmv(struct i2c_client *client)
 	avdd = regulator_get_voltage(aic3x->supplies[2].consumer);
 
 	if (avdd > 3600000 || dvdd > 1950000) {
-		dev_warn(&client->dev,
+		dev_warn(dev,
 			 "Too high supply voltage(s) AVDD: %d, DVDD: %d\n",
 			 avdd, dvdd);
 	} else if (avdd == 3600000 && dvdd == 1950000) {
@@ -1736,26 +1729,12 @@ static void aic3x_configure_ocmv(struct i2c_client *client)
 	} else if (avdd >= 2700000 && dvdd >= 1525000) {
 		aic3x->ocmv = HPOUT_SC_OCMV_1_35V;
 	} else {
-		dev_warn(&client->dev,
+		dev_warn(dev,
 			 "Invalid supply voltage(s) AVDD: %d, DVDD: %d\n",
 			 avdd, dvdd);
 	}
 }
 
-/*
- * AIC3X 2 wire address can be up to 4 devices with device addresses
- * 0x18, 0x19, 0x1A, 0x1B
- */
-
-static const struct i2c_device_id aic3x_i2c_id[] = {
-	{ "tlv320aic3x", AIC3X_MODEL_3X },
-	{ "tlv320aic33", AIC3X_MODEL_33 },
-	{ "tlv320aic3007", AIC3X_MODEL_3007 },
-	{ "tlv320aic3106", AIC3X_MODEL_3X },
-	{ "tlv320aic3104", AIC3X_MODEL_3104 },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
 
 static const struct reg_sequence aic3007_class_d[] = {
 	/* Class-D speaker driver init; datasheet p. 46 */
@@ -1767,25 +1746,20 @@ static const struct reg_sequence aic3007_class_d[] = {
 	{ AIC3X_PAGE_SELECT, 0x00 },
 };
 
-/*
- * If the i2c layer weren't so broken, we could pass this kind of data
- * around
- */
-static int aic3x_i2c_probe(struct i2c_client *i2c,
-			   const struct i2c_device_id *id)
+int aic3x_probe(struct device *dev, struct regmap *regmap, kernel_ulong_t driver_data)
 {
-	struct aic3x_pdata *pdata = i2c->dev.platform_data;
+	struct aic3x_pdata *pdata = dev->platform_data;
 	struct aic3x_priv *aic3x;
 	struct aic3x_setup_data *ai3x_setup;
-	struct device_node *np = i2c->dev.of_node;
+	struct device_node *np = dev->of_node;
 	int ret, i;
 	u32 value;
 
-	aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL);
+	aic3x = devm_kzalloc(dev, sizeof(struct aic3x_priv), GFP_KERNEL);
 	if (!aic3x)
 		return -ENOMEM;
 
-	aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap);
+	aic3x->regmap = regmap;
 	if (IS_ERR(aic3x->regmap)) {
 		ret = PTR_ERR(aic3x->regmap);
 		return ret;
@@ -1793,14 +1767,13 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 
 	regcache_cache_only(aic3x->regmap, true);
 
-	i2c_set_clientdata(i2c, aic3x);
+	dev_set_drvdata(dev, aic3x);
 	if (pdata) {
 		aic3x->gpio_reset = pdata->gpio_reset;
 		aic3x->setup = pdata->setup;
 		aic3x->micbias_vg = pdata->micbias_vg;
 	} else if (np) {
-		ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup),
-								GFP_KERNEL);
+		ai3x_setup = devm_kzalloc(dev, sizeof(*ai3x_setup), GFP_KERNEL);
 		if (!ai3x_setup)
 			return -ENOMEM;
 
@@ -1810,7 +1783,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 		} else {
 			ret = of_get_named_gpio(np, "gpio-reset", 0);
 			if (ret > 0) {
-				dev_warn(&i2c->dev, "Using deprecated property \"gpio-reset\", please update your DT");
+				dev_warn(dev, "Using deprecated property \"gpio-reset\", please update your DT");
 				aic3x->gpio_reset = ret;
 			} else {
 				aic3x->gpio_reset = -1;
@@ -1835,7 +1808,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 				break;
 			default :
 				aic3x->micbias_vg = AIC3X_MICBIAS_OFF;
-				dev_err(&i2c->dev, "Unsuitable MicBias voltage "
+				dev_err(dev, "Unsuitable MicBias voltage "
 							"found in DT\n");
 			}
 		} else {
@@ -1846,7 +1819,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 		aic3x->gpio_reset = -1;
 	}
 
-	aic3x->model = id->driver_data;
+	aic3x->model = driver_data;
 
 	if (gpio_is_valid(aic3x->gpio_reset) &&
 	    !aic3x_is_shared_reset(aic3x)) {
@@ -1859,25 +1832,24 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 	for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
 		aic3x->supplies[i].supply = aic3x_supply_names[i];
 
-	ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies),
+	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(aic3x->supplies),
 				      aic3x->supplies);
 	if (ret != 0) {
-		dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+		dev_err(dev, "Failed to request supplies: %d\n", ret);
 		goto err_gpio;
 	}
 
-	aic3x_configure_ocmv(i2c);
+	aic3x_configure_ocmv(dev, aic3x);
 
 	if (aic3x->model == AIC3X_MODEL_3007) {
 		ret = regmap_register_patch(aic3x->regmap, aic3007_class_d,
 					    ARRAY_SIZE(aic3007_class_d));
 		if (ret != 0)
-			dev_err(&i2c->dev, "Failed to init class D: %d\n",
+			dev_err(dev, "Failed to init class D: %d\n",
 				ret);
 	}
 
-	ret = devm_snd_soc_register_component(&i2c->dev,
-			&soc_component_dev_aic3x, &aic3x_dai, 1);
+	ret = devm_snd_soc_register_component(dev, &soc_component_dev_aic3x, &aic3x_dai, 1);
 
 	if (ret != 0)
 		goto err_gpio;
@@ -1894,10 +1866,11 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
 err:
 	return ret;
 }
+EXPORT_SYMBOL(aic3x_probe);
 
-static int aic3x_i2c_remove(struct i2c_client *client)
+int aic3x_remove(struct device *dev)
 {
-	struct aic3x_priv *aic3x = i2c_get_clientdata(client);
+	struct aic3x_priv *aic3x = dev_get_drvdata(dev);
 
 	list_del(&aic3x->list);
 
@@ -1908,31 +1881,7 @@ static int aic3x_i2c_remove(struct i2c_client *client)
 	}
 	return 0;
 }
-
-#if defined(CONFIG_OF)
-static const struct of_device_id tlv320aic3x_of_match[] = {
-	{ .compatible = "ti,tlv320aic3x", },
-	{ .compatible = "ti,tlv320aic33" },
-	{ .compatible = "ti,tlv320aic3007" },
-	{ .compatible = "ti,tlv320aic3106" },
-	{ .compatible = "ti,tlv320aic3104" },
-	{},
-};
-MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match);
-#endif
-
-/* machine i2c codec control layer */
-static struct i2c_driver aic3x_i2c_driver = {
-	.driver = {
-		.name = "tlv320aic3x-codec",
-		.of_match_table = of_match_ptr(tlv320aic3x_of_match),
-	},
-	.probe	= aic3x_i2c_probe,
-	.remove = aic3x_i2c_remove,
-	.id_table = aic3x_i2c_id,
-};
-
-module_i2c_driver(aic3x_i2c_driver);
+EXPORT_SYMBOL(aic3x_remove);
 
 MODULE_DESCRIPTION("ASoC TLV320AIC3X codec driver");
 MODULE_AUTHOR("Vladimir Barinov");
Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH 2/5] SOC Codecs: TLV320AIC3X add SPI: main source code for I2C and SPI

Quoted 8 lines · Jiri Prchal

Removed things which are in header file. Renamed functions and removed their I2C related code. Moved I2C code to separate file.

---
 sound/soc/codecs/tlv320aic3x.c | 105 +++++++++------------------------
 1 file changed, 27 insertions(+), 78 deletions(-)

This is not moving the I2C code, this is just plain deleting it which will leave things broken after this patch - things should build and run after each patch in the series. As covered in submitting-patches.rst each commit should do one thing as a standalone patch, and the changelog for the patch should clearly describe what the patch does.

You probably want something like a patch to factor the I2C stuff out to a separate file and another to add the SPI support. Look at how other drivers have done this transition.

sound/soc/codecs/tlv320aic3x.c static const struct regmap_config aic3x_regmap = { · line 144

Quoted 6 lines
sound/soc/codecs/tlv320aic3x.c +1 -0
@@ -147,6 +140,7 @@ static const struct regmap_config aic3x_regmap = {
 
 	.cache_type = REGCACHE_RBTREE,
 };
+EXPORT_SYMBOL(aic3x_regmap_config);
 

Everything else in ASoC is EXPORT_SYMBOL_GPL(), why is this EXPORT_SYMBOL()?

#5 lore raw

PATCH 3/5 SOC Codecs: TLV320AIC3X add SPI: I2C code

In reply to Jiri Prchal

Things related to I2C in separate file.

---
 sound/soc/codecs/tlv320aic3x-i2c.c | 72 ++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 sound/soc/codecs/tlv320aic3x-i2c.c
sound/soc/codecs/tlv320aic3x-i2c.c new file +72 -0
new file mode 100644
index 000000000000..f77c76d25112
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ALSA SoC TLV320AIC3x codec driver I2C interface
+ *
+ * Author:      Arun KS, <[email protected]>
+ * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd.,
+ *
+ * Based on sound/soc/codecs/wm8731.c by Richard Purdie
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include <sound/soc.h>
+
+#include "tlv320aic3x.h"
+
+static int aic3x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
+{
+	struct regmap *regmap;
+	struct regmap_config config;
+
+	config = aic3x_regmap_config;
+	config.reg_bits = 8;
+	config.val_bits = 8;
+
+	regmap = devm_regmap_init_i2c(i2c, &config);
+	return aic3x_probe(&i2c->dev, regmap, id->driver_data);
+}
+
+static int aic3x_i2c_remove(struct i2c_client *i2c)
+{
+	return aic3x_remove(&i2c->dev);
+}
+
+static const struct i2c_device_id aic3x_i2c_id[] = {
+	{ "tlv320aic3x", AIC3X_MODEL_3X },
+	{ "tlv320aic33", AIC3X_MODEL_33 },
+	{ "tlv320aic3007", AIC3X_MODEL_3007 },
+	{ "tlv320aic3104", AIC3X_MODEL_3104 },
+	{ "tlv320aic3106", AIC3X_MODEL_3106 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
+
+static const struct of_device_id aic3x_of_id[] = {
+	{ .compatible = "ti,tlv320aic3x", },
+	{ .compatible = "ti,tlv320aic33" },
+	{ .compatible = "ti,tlv320aic3007" },
+	{ .compatible = "ti,tlv320aic3104" },
+	{ .compatible = "ti,tlv320aic3106" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, aic3x_of_id);
+
+static struct i2c_driver aic3x_i2c_driver = {
+	.driver = {
+		.name = "tlv320aic3x",
+		.of_match_table = aic3x_of_id),
+	},
+	.probe = aic3x_i2c_probe,
+	.remove = aic3x_i2c_remove,
+	.id_table = aic3x_i2c_id,
+};
+
+module_i2c_driver(aic3x_i2c_driver);
+
+MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver I2C");
+MODULE_AUTHOR("Arun KS <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.25.1
maintainer
#6 lore raw

Re: [PATCH 3/5] SOC Codecs: TLV320AIC3X add SPI: I2C code

sound/soc/codecs/tlv320aic3x-i2c.c line 3

Quoted 5 lines · Jiri Prchal

+++ b/sound/soc/codecs/tlv320aic3x-i2c.c

sound/soc/codecs/tlv320aic3x-i2c.c new file +3 -0
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ALSA SoC TLV320AIC3x codec driver I2C interface

Please make the entire comment a C++ one so things look more intentional.

#7 lore raw

Re: [PATCH 3/5] SOC Codecs: TLV320AIC3X add SPI: I2C code

Quoted 10 lines · Mark Brown

sound/soc/codecs/tlv320aic3x-i2c.c line 3

Quoted 5 lines · Jiri Prchal

+++ b/sound/soc/codecs/tlv320aic3x-i2c.c

sound/soc/codecs/tlv320aic3x-i2c.c new file +3 -0
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ALSA SoC TLV320AIC3x codec driver I2C interface

Please make the entire comment a C++ one so things look more intentional.

OK,
but coding style checker complains:
WARNING: Improper SPDX comment style for 'sound/soc/codecs/tlv320aic3x-i2c.c', please use '//' instead #64: FILE: sound/soc/codecs/tlv320aic3x-i2c.c:1:
+/* SPDX-License-Identifier: GPL-2.0-only

maintainer
#8 lore raw

Re: [PATCH 3/5] SOC Codecs: TLV320AIC3X add SPI: I2C code

Quoted 12 lines · Jiří Prchal
Quoted 10 lines · Mark Brown

sound/soc/codecs/tlv320aic3x-i2c.c line 3

Quoted 5 lines · Jiri Prchal

+++ b/sound/soc/codecs/tlv320aic3x-i2c.c

sound/soc/codecs/tlv320aic3x-i2c.c new file +3 -0
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ALSA SoC TLV320AIC3x codec driver I2C interface

Please make the entire comment a C++ one so things look more intentional.

Quoted 6 lines

OK,
but coding style checker complains:
WARNING: Improper SPDX comment style for 'sound/soc/codecs/tlv320aic3x-i2c.c', please use '//' instead #64: FILE: sound/soc/codecs/tlv320aic3x-i2c.c:1:
+/* SPDX-License-Identifier: GPL-2.0-only

That's a C style comment not a C++ one.

#9 lore raw

PATCH 4/5 SOC Codecs: TLV320AIC3X add SPI: SPI code

In reply to Jiri Prchal

Things related to SPI in separate file.
Please help with getting model value, line 34. I didn't find out where to get "driver_data".

---
 sound/soc/codecs/tlv320aic3x-spi.c | 77 ++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 sound/soc/codecs/tlv320aic3x-spi.c
sound/soc/codecs/tlv320aic3x-spi.c new file +77 -0
new file mode 100644
index 000000000000..611d53e1bdf2
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ALSA SoC TLV320AIC3x codec driver SPI interface
+ *
+ * Author:      Arun KS, <[email protected]>
+ * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd.,
+ *
+ * Based on sound/soc/codecs/wm8731.c by Richard Purdie
+ *
+ */
+
+#include <linux/spi/spi.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include <sound/soc.h>
+
+#include "tlv320aic3x.h"
+
+static int aic3x_spi_probe(struct spi_device *spi)
+{
+	struct regmap *regmap;
+	struct regmap_config config;
+
+	config = aic3x_regmap_config;
+	config.reg_bits = 7;
+	config.pad_bits = 1;
+	config.val_bits = 8;
+	config.read_flag_mask = 0x01;
+
+	dev_dbg(&spi->dev, "probing tlv320aic3x spi device\n");
+
+	regmap = devm_regmap_init_spi(spi, &config);
+	return aic3x_probe(&spi->dev, regmap, AIC3X_MODEL_3X); /*FIXME: where to get id->driver_data?*/
+}
+
+static int aic3x_spi_remove(struct spi_device *spi)
+{
+	return aic3x_remove(&spi->dev);
+}
+
+static const struct spi_device_id aic3x_spi_id[] = {
+	{ "tlv320aic3x", AIC3X_MODEL_3X },
+	{ "tlv320aic33", AIC3X_MODEL_33 },
+	{ "tlv320aic3007", AIC3X_MODEL_3007 },
+	{ "tlv320aic3104", AIC3X_MODEL_3104 },
+	{ "tlv320aic3106", AIC3X_MODEL_3106 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, aic3x_spi_id);
+
+static const struct of_device_id aic3x_of_id[] = {
+	{ .compatible = "ti,tlv320aic3x", },
+	{ .compatible = "ti,tlv320aic33" },
+	{ .compatible = "ti,tlv320aic3007" },
+	{ .compatible = "ti,tlv320aic3104" },
+	{ .compatible = "ti,tlv320aic3106" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, aic3x_of_id);
+
+static struct spi_driver aic3x_spi_driver = {
+	.driver = {
+		.name = "tlv320aic3x",
+		.owner = THIS_MODULE,
+		.of_match_table = aic3x_of_id,
+	},
+	.probe = aic3x_spi_probe,
+	.remove = aic3x_spi_remove,
+	.id_table = aic3x_spi_id,
+};
+
+module_spi_driver(aic3x_spi_driver);
+
+MODULE_DESCRIPTION("ASoC TLV320AIC3x codec driver SPI");
+MODULE_AUTHOR("Arun KS <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.25.1
maintainer
#10 lore raw

Re: [PATCH 4/5] SOC Codecs: TLV320AIC3X add SPI: SPI code

Quoted 2 lines · Jiri Prchal

Things related to SPI in separate file.
Please help with getting model value, line 34. I didn't find out where to get "driver_data".

Look at how adau1977 does this - spi_get_devicde_id().

#11 lore raw

PATCH 5/5 SOC Codecs: TLV320AIC3X add SPI: configuration and compile

In reply to Jiri Prchal

Adds configuration option for SPI.
Compile new sources.

---
 sound/soc/codecs/Kconfig  | 11 +++++++++++
 sound/soc/codecs/Makefile |  4 ++++
 2 files changed, 15 insertions(+)
sound/soc/codecs/Kconfig +11 -0
index 1c87b42606c9..d1fecf3b17c6 100644
@@ -215,6 +215,8 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_TLV320AIC32X4_I2C
 	imply SND_SOC_TLV320AIC32X4_SPI
 	imply SND_SOC_TLV320AIC3X
+	imply SND_SOC_TLV320AIC3X_I2C
+	imply SND_SOC_TLV320AIC3X_SPI
 	imply SND_SOC_TPA6130A2
 	imply SND_SOC_TLV320DAC33
 	imply SND_SOC_TSCS42XX
@@ -1420,7 +1422,16 @@ config SND_SOC_TLV320AIC32X4_SPI
 
 config SND_SOC_TLV320AIC3X
 	tristate "Texas Instruments TLV320AIC3x CODECs"
+
+config SND_SOC_TLV320AIC3X_I2C
+	tristate "Texas Instruments TLV320AIC3x audio CODECs - I2C"
 	depends on I2C
+	select SND_SOC_TLV320AIC3X
+
+config SND_SOC_TLV320AIC3X_SPI
+	tristate "Texas Instruments TLV320AIC3x audio CODECs - SPI"
+	depends on SPI_MASTER
+	select SND_SOC_TLV320AIC3X
 
 config SND_SOC_TLV320DAC33
 	tristate
sound/soc/codecs/Makefile +4 -0
index 81357dc62ea0..022b3801d964 100644
@@ -233,6 +233,8 @@ snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o tlv320aic32x4-clk.o
 snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
+snd-soc-tlv320aic3x-i2c-objs := tlv320aic3x-i2c.o
+snd-soc-tlv320aic3x-spi-objs := tlv320aic3x-spi.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
 snd-soc-tlv320adcx140-objs := tlv320adcx140.o
 snd-soc-tscs42xx-objs := tscs42xx.o
@@ -548,6 +550,8 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4)     += snd-soc-tlv320aic32x4.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C)	+= snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)	+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)	+= snd-soc-tlv320aic3x.o
+obj-$(CONFIG_SND_SOC_TLV320AIC3X_I2C)	+= snd-soc-tlv320aic3x-i2c.o
+obj-$(CONFIG_SND_SOC_TLV320AIC3X_SPI)	+= snd-soc-tlv320aic3x-spi.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)	+= snd-soc-tlv320dac33.o
 obj-$(CONFIG_SND_SOC_TLV320ADCX140)	+= snd-soc-tlv320adcx140.o
 obj-$(CONFIG_SND_SOC_TSCS42XX)	+= snd-soc-tscs42xx.o
Signature · 1 line
2.25.1
maintainer
#12 lore raw

Re: [PATCH 5/5] SOC Codecs: TLV320AIC3X add SPI: configuration and compile

sound/soc/codecs/Kconfig config SND_SOC_TLV320AIC32X4_SPI · line 1426

Quoted 4 lines · Jiri Prchal

config SND_SOC_TLV320AIC3X

sound/soc/codecs/Kconfig +2 -0
 	tristate "Texas Instruments TLV320AIC3x CODECs"
+
+config SND_SOC_TLV320AIC3X_I2C

The old single option should not be user selectable when there are bus specific options so the help text should be removed from it.

#13 lore raw

Re: [PATCH 5/5] SOC Codecs: TLV320AIC3X add SPI: configuration and compile

In reply to Jiri Prchal
Thank you for the patch! Yet something to improve:

Hi Jiri,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v5.12-rc6 next-20210406]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jiri-Prchal/SOC-Codecs-TLV320AIC3X-add-SPI-support/20210406-185528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: s390-randconfig-r011-20210406 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a46f59a747a7273cc439efaf3b4f98d8b63d2f20)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/0day-ci/linux/commit/8001328cfb49d6387002a8314bc25241e46a969d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Prchal/SOC-Codecs-TLV320AIC3X-add-SPI-support/20210406-185528 git checkout 8001328cfb49d6387002a8314bc25241e46a969d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from sound/soc/codecs/tlv320aic3x-i2c.c:15:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:80:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                             ^
   include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
   #define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
                                                        ^
   In file included from sound/soc/codecs/tlv320aic3x-i2c.c:15:
   In file included from include/linux/regmap.h:20:
   In file included from include/linux/iopoll.h:14:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
                                                             ^
   include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
   #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
                                                        ^
   In file included from sound/soc/codecs/tlv320aic3x-i2c.c:15:
   In file included from include/linux/regmap.h:20:
   In file included from include/linux/iopoll.h:14:
   In file included from include/linux/io.h:13:
   In file included from arch/s390/include/asm/io.h:80:
   include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsb(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsw(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           readsl(PCI_IOBASE + addr, buffer, count);
                  ~~~~~~~~~~ ^
   include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesb(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesw(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
   include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           writesl(PCI_IOBASE + addr, buffer, count);
                   ~~~~~~~~~~ ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:61:32: error: expected '}'
                   .of_match_table = aic3x_of_id),
                                                ^
   sound/soc/codecs/tlv320aic3x-i2c.c:59:12: note: to match this '{'
           .driver = {
                     ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:62:3: error: expected ';' at end of declaration
           },
            ^
            ;
>> sound/soc/codecs/tlv320aic3x-i2c.c:63:2: error: expected identifier or '('
           .probe = aic3x_i2c_probe,
           ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:66:1: error: extraneous closing brace ('}')

};
^
12 warnings and 4 errors generated.

vim +61 sound/soc/codecs/tlv320aic3x-i2c.c

eab5358b511ef2 Jiri Prchal 2021-04-06  57  
eab5358b511ef2 Jiri Prchal 2021-04-06  58  static struct i2c_driver aic3x_i2c_driver = {
eab5358b511ef2 Jiri Prchal 2021-04-06  59  	.driver = {
eab5358b511ef2 Jiri Prchal 2021-04-06  60  		.name = "tlv320aic3x",
eab5358b511ef2 Jiri Prchal 2021-04-06 @61  		.of_match_table = aic3x_of_id),
eab5358b511ef2 Jiri Prchal 2021-04-06 @62  	},
eab5358b511ef2 Jiri Prchal 2021-04-06 @63  	.probe = aic3x_i2c_probe,
eab5358b511ef2 Jiri Prchal 2021-04-06  64  	.remove = aic3x_i2c_remove,
eab5358b511ef2 Jiri Prchal 2021-04-06  65  	.id_table = aic3x_i2c_id,
eab5358b511ef2 Jiri Prchal 2021-04-06 @66  };

eab5358b511ef2 Jiri Prchal 2021-04-06 67

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#14 lore raw

Re: [PATCH 5/5] SOC Codecs: TLV320AIC3X add SPI: configuration and compile

In reply to Jiri Prchal
Thank you for the patch! Yet something to improve:

Hi Jiri,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v5.12-rc6 next-20210406]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Jiri-Prchal/SOC-Codecs-TLV320AIC3X-add-SPI-support/20210406-185528
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/8001328cfb49d6387002a8314bc25241e46a969d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiri-Prchal/SOC-Codecs-TLV320AIC3X-add-SPI-support/20210406-185528 git checkout 8001328cfb49d6387002a8314bc25241e46a969d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> sound/soc/codecs/tlv320aic3x-i2c.c:61:32: error: expected '}' before ')' token
      61 |   .of_match_table = aic3x_of_id),
         |                                ^
   sound/soc/codecs/tlv320aic3x-i2c.c:59:12: note: to match this '{'
      59 |  .driver = {
         |            ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:61:32: error: expected '}' before ')' token
      61 |   .of_match_table = aic3x_of_id),
         |                                ^
   sound/soc/codecs/tlv320aic3x-i2c.c:58:45: note: to match this '{'
      58 | static struct i2c_driver aic3x_i2c_driver = {
         |                                             ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:61:32: error: expected ',' or ';' before ')' token
      61 |   .of_match_table = aic3x_of_id),
         |                                ^
>> sound/soc/codecs/tlv320aic3x-i2c.c:62:3: error: expected identifier or '(' before ',' token
      62 |  },
         |   ^
   sound/soc/codecs/tlv320aic3x-i2c.c:38:35: warning: 'aic3x_i2c_id' defined but not used [-Wunused-const-variable=]
      38 | static const struct i2c_device_id aic3x_i2c_id[] = {
         |                                   ^~~~~~~~~~~~

sound/soc/codecs/tlv320aic3x-i2c.c:33:12: warning: 'aic3x_i2c_remove' defined but not used [-Wunused-function]
33 | static int aic3x_i2c_remove(struct i2c_client *i2c)
| ^~~~~~~~~~~~~~~~
sound/soc/codecs/tlv320aic3x-i2c.c:20:12: warning: 'aic3x_i2c_probe' defined but not used [-Wunused-function]
20 | static int aic3x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
| ^~~~~~~~~~~~~~~

vim +61 sound/soc/codecs/tlv320aic3x-i2c.c

eab5358b511ef2 Jiri Prchal 2021-04-06  57  
eab5358b511ef2 Jiri Prchal 2021-04-06  58  static struct i2c_driver aic3x_i2c_driver = {
eab5358b511ef2 Jiri Prchal 2021-04-06  59  	.driver = {
eab5358b511ef2 Jiri Prchal 2021-04-06  60  		.name = "tlv320aic3x",
eab5358b511ef2 Jiri Prchal 2021-04-06 @61  		.of_match_table = aic3x_of_id),
eab5358b511ef2 Jiri Prchal 2021-04-06 @62  	},
eab5358b511ef2 Jiri Prchal 2021-04-06  63  	.probe = aic3x_i2c_probe,
eab5358b511ef2 Jiri Prchal 2021-04-06  64  	.remove = aic3x_i2c_remove,
eab5358b511ef2 Jiri Prchal 2021-04-06  65  	.id_table = aic3x_i2c_id,
eab5358b511ef2 Jiri Prchal 2021-04-06  66  };

eab5358b511ef2 Jiri Prchal 2021-04-06 67

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#15 lore raw
In reply to Jiri Prchal
Quoted 8 lines · Jiri Prchal

This patches add support of SPI to TLV320AIC3X codecs.

Jiri Prchal (5):
SOC Codecs: TLV320AIC3X add SPI: move thinks to header file SOC Codecs: TLV320AIC3X add SPI: main source code for I2C and SPI SOC Codecs: TLV320AIC3X add SPI: I2C code
SOC Codecs: TLV320AIC3X add SPI: SPI code
SOC Codecs: TLV320AIC3X add SPI: configuration and compile

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.