ASoC: tlv320aic32x4: remove global header with platform data
Subsystems (3)
PATCH 1/7 ASoC: tlv320aic32x4: remove global header with platform data
Commit 69d5b62c4bde ("ASoC: codec: tlv320aic32x4: Drop aic32x4_pdata usage") removed support for platform data, but left a global header file with #defines and platform data structure.
Move the contents to the driver-private header.
--- include/sound/tlv320aic32x4.h | 43 -------------------------------- sound/soc/codecs/tlv320aic32x4.c | 5 +++- sound/soc/codecs/tlv320aic32x4.h | 27 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 44 deletions(-) delete mode 100644 include/sound/tlv320aic32x4.h
include/sound/tlv320aic32x4.h deleted +0 -43
@@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* tlv320aic32x4.h -- TLV320AIC32X4 Soc Audio driver platform data -* -* Copyright 2011 Vista Silicon S.L. -* -* Author: Javier Martin <[email protected]> -*/ - -#ifndef _AIC32X4_PDATA_H -#define _AIC32X4_PDATA_H - -#define AIC32X4_PWR_MICBIAS_2075_LDOIN 0x00000001 -#define AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE 0x00000002 -#define AIC32X4_PWR_AIC32X4_LDO_ENABLE 0x00000004 -#define AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 0x00000008 -#define AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED 0x00000010 - -#define AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K 0x00000001 -#define AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K 0x00000002 - -/* GPIO API */ -#define AIC32X4_MFPX_DEFAULT_VALUE 0xff - -#define AIC32X4_MFP1_DIN_DISABLED 0 -#define AIC32X4_MFP1_DIN_ENABLED 0x2 -#define AIC32X4_MFP1_GPIO_IN 0x4 - -#define AIC32X4_MFP2_GPIO_OUT_LOW 0x0 -#define AIC32X4_MFP2_GPIO_OUT_HIGH 0x1 - -#define AIC32X4_MFP_GPIO_ENABLED 0x4 - -#define AIC32X4_MFP5_GPIO_DISABLED 0x0 -#define AIC32X4_MFP5_GPIO_INPUT 0x8 -#define AIC32X4_MFP5_GPIO_OUTPUT 0xc -#define AIC32X4_MFP5_GPIO_OUT_LOW 0x0 -#define AIC32X4_MFP5_GPIO_OUT_HIGH 0x1 - -struct aic32x4_setup_data { -unsigned int gpio_func[5 ]; -}; -#endif
sound/soc/codecs/tlv320aic32x4.c +4 -1
@@ -28,10 +28,13 @@#include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> -#include <sound/tlv320aic32x4.h> #include "tlv320aic32x4.h" +struct aic32x4_setup_data { +unsigned int gpio_func[5 ]; +}; +struct aic32x4_priv {struct regmap *regmap;u32 power_cfg;
sound/soc/codecs/tlv320aic32x4.h +27 -0
@@ -234,4 +234,31 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name);#define AIC32X4_MAX_CODEC_CLKIN_FREQ 110000000#define AIC32X4_MAX_PLL_CLKIN 20000000 +#define AIC32X4_PWR_MICBIAS_2075_LDOIN 0x00000001 +#define AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE 0x00000002 +#define AIC32X4_PWR_AIC32X4_LDO_ENABLE 0x00000004 +#define AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 0x00000008 +#define AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED 0x00000010 + +#define AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K 0x00000001 +#define AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K 0x00000002 + +/* GPIO API */ +#define AIC32X4_MFPX_DEFAULT_VALUE 0xff + +#define AIC32X4_MFP1_DIN_DISABLED 0 +#define AIC32X4_MFP1_DIN_ENABLED 0x2 +#define AIC32X4_MFP1_GPIO_IN 0x4 + +#define AIC32X4_MFP2_GPIO_OUT_LOW 0x0 +#define AIC32X4_MFP2_GPIO_OUT_HIGH 0x1 + +#define AIC32X4_MFP_GPIO_ENABLED 0x4 + +#define AIC32X4_MFP5_GPIO_DISABLED 0x0 +#define AIC32X4_MFP5_GPIO_INPUT 0x8 +#define AIC32X4_MFP5_GPIO_OUTPUT 0xc +#define AIC32X4_MFP5_GPIO_OUT_LOW 0x0 +#define AIC32X4_MFP5_GPIO_OUT_HIGH 0x1 +#endif /* _TLV320AIC32X4_H */
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 2/7 ASoC: tlv320aic32x4: do not allocate gpio config separately
Now that the driver only works with device tree we do not need to keep GPIO config separate from the driver structure.
--- sound/soc/codecs/tlv320aic32x4.c | 47 +++++++++++++------------------- 1 file changed, 19 insertions(+), 28 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +19 -28
@@ -31,10 +31,6 @@#include "tlv320aic32x4.h" -struct aic32x4_setup_data { -unsigned int gpio_func[5 ]; -}; -struct aic32x4_priv {struct regmap *regmap;u32 power_cfg;
@@ -48,7 +44,8 @@ struct aic32x4_priv {struct regulator *supply_dv;struct regulator *supply_av; -struct aic32x4_setup_data *setup; +unsigned int gpio_func[5 ]; +struct device *dev;enum aic32x4_type type;
@@ -959,41 +956,41 @@ static void aic32x4_setup_gpios(struct snd_soc_component *component)/* setup GPIO functions */ /* MFP1 */ -if (aic32x4->setup->gpio_func[0 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { +if (aic32x4->gpio_func[0 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) {snd_soc_component_write (component,AIC32X4_DINCTL , - aic32x4->setup->gpio_func[0 ]); + aic32x4->gpio_func[0 ]);snd_soc_add_component_controls (component, aic32x4_mfp1,ARRAY_SIZE (aic32x4_mfp1)); }/* MFP2 */ -if (aic32x4->setup->gpio_func[1 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { +if (aic32x4->gpio_func[1 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) {snd_soc_component_write (component,AIC32X4_DOUTCTL , - aic32x4->setup->gpio_func[1 ]); + aic32x4->gpio_func[1 ]);snd_soc_add_component_controls (component, aic32x4_mfp2,ARRAY_SIZE (aic32x4_mfp2)); }/* MFP3 */ -if (aic32x4->setup->gpio_func[2 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { +if (aic32x4->gpio_func[2 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) {snd_soc_component_write (component,AIC32X4_SCLKCTL , - aic32x4->setup->gpio_func[2 ]); + aic32x4->gpio_func[2 ]);snd_soc_add_component_controls (component, aic32x4_mfp3,ARRAY_SIZE (aic32x4_mfp3)); }/* MFP4 */ -if (aic32x4->setup->gpio_func[3 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { +if (aic32x4->gpio_func[3 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) {snd_soc_component_write (component,AIC32X4_MISOCTL , - aic32x4->setup->gpio_func[3 ]); + aic32x4->gpio_func[3 ]);snd_soc_add_component_controls (component, aic32x4_mfp4,ARRAY_SIZE (aic32x4_mfp4)); }/* MFP5 */ -if (aic32x4->setup->gpio_func[4 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { +if (aic32x4->gpio_func[4 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) {snd_soc_component_write (component,AIC32X4_GPIOCTL , - aic32x4->setup->gpio_func[4 ]); + aic32x4->gpio_func[4 ]);snd_soc_add_component_controls (component, aic32x4_mfp5,ARRAY_SIZE (aic32x4_mfp5)); }
@@ -1016,8 +1013,7 @@ static int aic32x4_component_probe(struct snd_soc_component *component)if (ret)return ret; -if (aic32x4->setup) -aic32x4_setup_gpios (component); +aic32x4_setup_gpios (component);clk_set_parent (clocks[0 ].clk, clocks[1 ].clk);clk_set_parent (clocks[2 ].clk, clocks[3 ].clk);
@@ -1173,8 +1169,7 @@ static int aic32x4_tas2505_component_probe(struct snd_soc_component *component)if (ret)return ret; -if (aic32x4->setup) -aic32x4_setup_gpios (component); +aic32x4_setup_gpios (component);clk_set_parent (clocks[0 ].clk, clocks[1 ].clk);clk_set_parent (clocks[2 ].clk, clocks[3 ].clk);
@@ -1224,14 +1219,8 @@ static const struct snd_soc_component_driver soc_component_dev_aic32x4_tas2505 =static int aic32x4_parse_dt (struct aic32x4_priv *aic32x4,struct device_node *np) { -struct aic32x4_setup_data *aic32x4_setup;int ret; - aic32x4_setup =devm_kzalloc (aic32x4->dev,sizeof (*aic32x4_setup), -GFP_KERNEL ); -if (!aic32x4_setup) -return -ENOMEM ; - ret =of_property_match_string (np,"clock-names" ,"mclk" );if (ret <0 )return -EINVAL ;
@@ -1248,9 +1237,11 @@ static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4,gpiod_set_consumer_name (aic32x4->rstn_gpio,"tlv320aic32x4_rstn" ); } -if (of_property_read_u32_array (np,"aic32x4-gpio-func" , - aic32x4_setup->gpio_func,5 ) >=0 ) - aic32x4->setup = aic32x4_setup; +for (int i =0 ; i <ARRAY_SIZE (aic32x4->gpio_func); i++) + aic32x4->gpio_func[i] =AIC32X4_MFPX_DEFAULT_VALUE ; +of_property_read_u32_array (np,"aic32x4-gpio-func" , + aic32x4->gpio_func,ARRAY_SIZE (aic32x4->gpio_func)); +return 0 ; }
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 3/7 ASoC: tlv320aic32x4: consolidate programming functions
In reply to Dmitry TorokhovConsolidate setting up of GPIO functions instead of repeating almost the same code block 5 times.
--- sound/soc/codecs/tlv320aic32x4.c | 90 ++++++++++++-------------------- 1 file changed, 33 insertions(+), 57 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +33 -57
@@ -222,25 +222,31 @@ static int aic32x4_set_mfp5_gpio(struct snd_kcontrol *kcontrol,return 0 ; }; -static const struct snd_kcontrol_new aic32x4_mfp1[] = { -SOC_SINGLE_BOOL_EXT ("MFP1 GPIO" ,0 , aic32x4_get_mfp1_gpio,NULL ), -}; - -static const struct snd_kcontrol_new aic32x4_mfp2[] = { -SOC_SINGLE_BOOL_EXT ("MFP2 GPIO" ,0 ,NULL , aic32x4_set_mfp2_gpio), -}; - -static const struct snd_kcontrol_new aic32x4_mfp3[] = { -SOC_SINGLE_BOOL_EXT ("MFP3 GPIO" ,0 , aic32x4_get_mfp3_gpio,NULL ), -}; - -static const struct snd_kcontrol_new aic32x4_mfp4[] = { -SOC_SINGLE_BOOL_EXT ("MFP4 GPIO" ,0 ,NULL , aic32x4_set_mfp4_gpio), -}; - -static const struct snd_kcontrol_new aic32x4_mfp5[] = { -SOC_SINGLE_BOOL_EXT ("MFP5 GPIO" ,0 , aic32x4_get_mfp5_gpio, - aic32x4_set_mfp5_gpio), +static const struct { +unsigned int reg; +struct snd_kcontrol_new ctrl; +} aic32x4_mfp_cfg[] = { + { + .reg =AIC32X4_DINCTL , + .ctrl =SOC_SINGLE_BOOL_EXT ("MFP1 GPIO" ,0 , aic32x4_get_mfp1_gpio,NULL ), + }, + { + .reg =AIC32X4_DOUTCTL , + .ctrl =SOC_SINGLE_BOOL_EXT ("MFP2 GPIO" ,0 ,NULL , aic32x4_set_mfp2_gpio), + }, + { + .reg =AIC32X4_SCLKCTL , + .ctrl =SOC_SINGLE_BOOL_EXT ("MFP3 GPIO" ,0 , aic32x4_get_mfp3_gpio,NULL ), + }, + { + .reg =AIC32X4_MISOCTL , + .ctrl =SOC_SINGLE_BOOL_EXT ("MFP4 GPIO" ,0 ,NULL , aic32x4_set_mfp4_gpio), + }, + { + .reg =AIC32X4_GPIOCTL , + .ctrl =SOC_SINGLE_BOOL_EXT ("MFP5 GPIO" ,0 , aic32x4_get_mfp5_gpio, + aic32x4_set_mfp5_gpio), + }, };/* 0dB min, 0.5dB steps */
@@ -955,44 +961,14 @@ static void aic32x4_setup_gpios(struct snd_soc_component *component)struct aic32x4_priv *aic32x4 =snd_soc_component_get_drvdata (component);/* setup GPIO functions */ -/* MFP1 */ -if (aic32x4->gpio_func[0 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { -snd_soc_component_write (component,AIC32X4_DINCTL , - aic32x4->gpio_func[0 ]); -snd_soc_add_component_controls (component, aic32x4_mfp1, -ARRAY_SIZE (aic32x4_mfp1)); - } - -/* MFP2 */ -if (aic32x4->gpio_func[1 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { -snd_soc_component_write (component,AIC32X4_DOUTCTL , - aic32x4->gpio_func[1 ]); -snd_soc_add_component_controls (component, aic32x4_mfp2, -ARRAY_SIZE (aic32x4_mfp2)); - } - -/* MFP3 */ -if (aic32x4->gpio_func[2 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { -snd_soc_component_write (component,AIC32X4_SCLKCTL , - aic32x4->gpio_func[2 ]); -snd_soc_add_component_controls (component, aic32x4_mfp3, -ARRAY_SIZE (aic32x4_mfp3)); - } - -/* MFP4 */ -if (aic32x4->gpio_func[3 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { -snd_soc_component_write (component,AIC32X4_MISOCTL , - aic32x4->gpio_func[3 ]); -snd_soc_add_component_controls (component, aic32x4_mfp4, -ARRAY_SIZE (aic32x4_mfp4)); - } - -/* MFP5 */ -if (aic32x4->gpio_func[4 ] !=AIC32X4_MFPX_DEFAULT_VALUE ) { -snd_soc_component_write (component,AIC32X4_GPIOCTL , - aic32x4->gpio_func[4 ]); -snd_soc_add_component_controls (component, aic32x4_mfp5, -ARRAY_SIZE (aic32x4_mfp5)); +BUILD_BUG_ON (ARRAY_SIZE (aic32x4->gpio_func) !=ARRAY_SIZE (aic32x4_mfp_cfg)); +for (int i =0 ; i <ARRAY_SIZE (aic32x4->gpio_func); i++) { +if (aic32x4->gpio_func[i] ==AIC32X4_MFPX_DEFAULT_VALUE ) +continue ; + +snd_soc_component_write (component, aic32x4_mfp_cfg[i].reg, + aic32x4->gpio_func[i]); +snd_soc_add_component_controls (component, &aic32x4_mfp_cfg[i].ctrl,1 ); } }
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 4/7 ASoC: tlv320aic32x4: move regmap_config into i2c and spi drivers
In reply to Dmitry TorokhovMove regmap_config definitions to be static const structures in tlv320aic32x4-i2c.c and tlv320aic32x4-spi.c instead of dynamically modifying a shared base regmap_config at runtime during probe. Export aic32x4_regmap_pages so both bus drivers can reference page ranges.
In addition, validate regmap initialization immediately upon creation in both bus probe routines and remove the redundant error check from core aic32x4_probe.
--- sound/soc/codecs/tlv320aic32x4-i2c.c | 16 +++++++++++----- sound/soc/codecs/tlv320aic32x4-spi.c | 20 +++++++++++++------- sound/soc/codecs/tlv320aic32x4.c | 13 ++----------- sound/soc/codecs/tlv320aic32x4.h | 2 +- 4 files changed, 27 insertions(+), 24 deletions(-)
sound/soc/codecs/tlv320aic32x4-i2c.c +11 -5
@@ -16,17 +16,23 @@#include "tlv320aic32x4.h" +static const struct regmap_config aic32x4_i2c_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .max_register =AIC32X4_REFPOWERUP , + .ranges = aic32x4_regmap_pages, + .num_ranges =1 , +}; +static int aic32x4_i2c_probe (struct i2c_client *i2c) {struct regmap *regmap; -struct regmap_config config;enum aic32x4_type type; - config = aic32x4_regmap_config; - config.reg_bits =8 ; - config.val_bits =8 ; + regmap =devm_regmap_init_i2c (i2c, &aic32x4_i2c_regmap_config); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); - regmap =devm_regmap_init_i2c (i2c, &config); type = (uintptr_t )i2c_get_match_data (i2c);return aic32x4_probe (&i2c->dev, regmap, type);
sound/soc/codecs/tlv320aic32x4-spi.c +13 -7
@@ -16,19 +16,25 @@#include "tlv320aic32x4.h" +static const struct regmap_config aic32x4_spi_regmap_config = { + .reg_bits =7 , + .pad_bits =1 , + .val_bits =8 , + .read_flag_mask =0x01 , + .max_register =AIC32X4_REFPOWERUP , + .ranges = aic32x4_regmap_pages, + .num_ranges =1 , +}; +static int aic32x4_spi_probe (struct spi_device *spi) {struct regmap *regmap; -struct regmap_config config;enum aic32x4_type type; - config = aic32x4_regmap_config; - config.reg_bits =7 ; - config.pad_bits =1 ; - config.val_bits =8 ; - config.read_flag_mask =0x01 ; + regmap =devm_regmap_init_spi (spi, &aic32x4_spi_regmap_config); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); - regmap =devm_regmap_init_spi (spi, &config); type = (uintptr_t )spi_get_device_match_data (spi);return aic32x4_probe (&spi->dev, regmap, type);
sound/soc/codecs/tlv320aic32x4.c +2 -11
@@ -581,7 +581,7 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { {"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"}, }; -static const struct regmap_range_cfg aic32x4_regmap_pages[] = { +const struct regmap_range_cfg aic32x4_regmap_pages[] = { { .selector_reg = 0, .selector_mask = 0xff,
@@ -591,13 +591,7 @@ static const struct regmap_range_cfg aic32x4_regmap_pages[] = { .range_max = AIC32X4_REFPOWERUP, }, }; - -const struct regmap_config aic32x4_regmap_config = { - .max_register =AIC32X4_REFPOWERUP , - .ranges = aic32x4_regmap_pages, - .num_ranges =ARRAY_SIZE (aic32x4_regmap_pages), -}; -EXPORT_SYMBOL (aic32x4_regmap_config); +EXPORT_SYMBOL_GPL (aic32x4_regmap_pages);static int aic32x4_set_dai_sysclk (struct snd_soc_dai *codec_dai,int clk_id,unsigned int freq,int dir)
@@ -1326,9 +1320,6 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap,struct device_node *np = dev->of_node;int ret; -if (IS_ERR (regmap)) -return PTR_ERR (regmap); - aic32x4 =devm_kzalloc (dev,sizeof (struct aic32x4_priv ),GFP_KERNEL );if (aic32x4 ==NULL )
sound/soc/codecs/tlv320aic32x4.h +1 -1
@@ -16,7 +16,7 @@ enum aic32x4_type { AIC32X4_TYPE_TAS2505, }; -extern const struct regmap_config aic32x4_regmap_config; +extern const struct regmap_range_cfg aic32x4_regmap_pages[];int aic32x4_probe (struct device *dev,struct regmap *regmap,enum aic32x4_type type);void aic32x4_remove (struct device *dev);
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 5/7 ASoC: tlv320aic32x4: do not make clocks bulk data static
In reply to Dmitry TorokhovDeclaring local clk_bulk_data structures as static inside functions is bad practice even if the driver is currently a singleton, because it relies on mutable function-static state and interferes with multi-instance safety or clean re-probing.
Remove static from the clocks bulk data arrays across the driver.
--- sound/soc/codecs/tlv320aic32x4.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +4 -4
@@ -717,7 +717,7 @@ static int aic32x4_setup_clocks(struct snd_soc_component *component,unsigned long adc_clock_rate, dac_clock_rate;int ret; -static struct clk_bulk_data clocks[] = { +struct clk_bulk_data clocks[] = { { .id ="pll" }, { .id ="nadc" }, { .id ="madc" },
@@ -886,7 +886,7 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component);int ret; -static struct clk_bulk_data clocks[] = { +struct clk_bulk_data clocks[] = { { .id ="madc" }, { .id ="mdac" }, { .id ="bdiv" },
@@ -972,7 +972,7 @@ static int aic32x4_component_probe(struct snd_soc_component *component)u32 tmp_reg;int ret; -static struct clk_bulk_data clocks[] = { +struct clk_bulk_data clocks[] = { { .id ="codec_clkin" }, { .id ="pll" }, { .id ="bdiv" },
@@ -1128,7 +1128,7 @@ static int aic32x4_tas2505_component_probe(struct snd_soc_component *component)u32 tmp_reg;int ret; -static struct clk_bulk_data clocks[] = { +struct clk_bulk_data clocks[] = { { .id ="codec_clkin" }, { .id ="pll" }, { .id ="bdiv" },
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 6/7 ASoC: tlv320aic32x4: factor out rate configuration helper
In reply to Dmitry TorokhovFactor out sample-rate dependent parameter setup and processing block configuration into a separate helper function aic32x4_configure_rate.
--- sound/soc/codecs/tlv320aic32x4.c | 75 +++++++++++++++++++------------- 1 file changed, 44 insertions(+), 31 deletions(-)
sound/soc/codecs/tlv320aic32x4.c +44 -31
@@ -703,6 +703,45 @@ static int aic32x4_set_processing_blocks(struct snd_soc_component *component,return 0 ; } +static int aic32x4_configure_rate (struct snd_soc_component *component, +unsigned int rate,u8 *aosr,u8 *adc_rc, +u8 *dac_rc,u8 *dosr_inc) +{ +struct aic32x4_priv *aic32x4 =snd_soc_component_get_drvdata (component); +u8 prb_rx, prb_tx; + +if (rate <=48000 ) { + *aosr =128 ; + *adc_rc =6 ; + *dac_rc =8 ; + *dosr_inc =8 ; + prb_rx =1 ; + prb_tx =1 ; + }else if (rate <=96000 ) { + *aosr =64 ; + *adc_rc =6 ; + *dac_rc =8 ; + *dosr_inc =4 ; + prb_rx =1 ; + prb_tx = (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) ?1 :9 ; + }else if (rate ==192000 ) { + *aosr =32 ; + *adc_rc =3 ; + *dac_rc =4 ; + *dosr_inc =2 ; + prb_rx =13 ; + prb_tx = (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) ?1 :19 ; + }else { +dev_err (component->dev,"Sampling rate %u not supported\n" , rate); +return -EINVAL ; + } + +if (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) + prb_rx =0 ; + +return aic32x4_set_processing_blocks (component, prb_rx, prb_tx); +} +static int aic32x4_setup_clocks (struct snd_soc_component *component,unsigned int sample_rate,unsigned int channels,unsigned int bit_depth)
@@ -729,37 +768,11 @@ static int aic32x4_setup_clocks(struct snd_soc_component *component,if (ret)return ret; -if (sample_rate <=48000 ) { - aosr =128 ; - adc_resource_class =6 ; - dac_resource_class =8 ; - dosr_increment =8 ; -if (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) -aic32x4_set_processing_blocks (component,0 ,1 ); -else -aic32x4_set_processing_blocks (component,1 ,1 ); - }else if (sample_rate <=96000 ) { - aosr =64 ; - adc_resource_class =6 ; - dac_resource_class =8 ; - dosr_increment =4 ; -if (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) -aic32x4_set_processing_blocks (component,0 ,1 ); -else -aic32x4_set_processing_blocks (component,1 ,9 ); - }else if (sample_rate ==192000 ) { - aosr =32 ; - adc_resource_class =3 ; - dac_resource_class =4 ; - dosr_increment =2 ; -if (aic32x4->type ==AIC32X4_TYPE_TAS2505 ) -aic32x4_set_processing_blocks (component,0 ,1 ); -else -aic32x4_set_processing_blocks (component,13 ,19 ); - }else { -dev_err (component->dev,"Sampling rate not supported\n" ); -return -EINVAL ; - } + ret =aic32x4_configure_rate (component, sample_rate, &aosr, + &adc_resource_class, &dac_resource_class, + &dosr_increment); +if (ret) +return ret;/* PCM over I2S is always 2-channel */ if ((aic32x4->fmt &SND_SOC_DAIFMT_FORMAT_MASK ) ==SND_SOC_DAIFMT_I2S )
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH 7/7 ASoC: tlv320aic32x4: clean up driver code formatting and logging
In reply to Dmitry TorokhovClean up coding style, SPDX comments, logging calls, and macro definitions across the tlv320aic32x4 driver files:
- Convert SPDX comment blocks to // style in bus and clk drivers.
- Replace printk(KERN_ERR/DEBUG ...) calls with dev_err/dev_dbg.
- Replace msleep(10) with usleep_range(10000, 20000) in the clock driver.
- Parenthesize parameters in AIC32X4_REG macro.
- Clean up double blank lines and null pointer checks.
--- sound/soc/codecs/tlv320aic32x4-clk.c | 68 ++++--- sound/soc/codecs/tlv320aic32x4-i2c.c | 5 +- sound/soc/codecs/tlv320aic32x4-spi.c | 5 +- sound/soc/codecs/tlv320aic32x4.c | 270 +++++++++++++-------------- sound/soc/codecs/tlv320aic32x4.h | 3 +- 5 files changed, 163 insertions(+), 188 deletions(-)
sound/soc/codecs/tlv320aic32x4-clk.c +33 -35
@@ -1,5 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0 -* +// SPDX-License-Identifier: GPL-2.0 +/* * Clock Tree for the Texas Instruments TLV320AIC32x4 * * Copyright 2019 Annaliese McDermond
@@ -9,6 +9,7 @@#include <linux/clk-provider.h> #include <linux/clkdev.h> +#include <linux/delay.h> #include <linux/regmap.h> #include <linux/device.h>
@@ -57,7 +58,7 @@ static void clk_aic32x4_pll_unprepare(struct clk_hw *hw)struct clk_aic32x4 *pll =to_clk_aic32x4 (hw);regmap_update_bits (pll->regmap,AIC32X4_PLLPR , -AIC32X4_PLLEN ,0 ); +AIC32X4_PLLEN ,0 ); }static int clk_aic32x4_pll_is_prepared (struct clk_hw *hw)
@@ -75,7 +76,7 @@ static int clk_aic32x4_pll_is_prepared(struct clk_hw *hw) }static int clk_aic32x4_pll_get_muldiv (struct clk_aic32x4 *pll, -struct clk_aic32x4_pll_muldiv *settings) +struct clk_aic32x4_pll_muldiv *settings) {/* Change to use regmap_bulk_read? */ unsigned int val;
@@ -106,19 +107,19 @@ static int clk_aic32x4_pll_get_muldiv(struct clk_aic32x4 *pll, }static int clk_aic32x4_pll_set_muldiv (struct clk_aic32x4 *pll, -struct clk_aic32x4_pll_muldiv *settings) +struct clk_aic32x4_pll_muldiv *settings) {int ret;/* Change to use regmap_bulk_write for some if not all? */ ret =regmap_update_bits (pll->regmap,AIC32X4_PLLPR , -AIC32X4_PLL_R_MASK , settings->r); +AIC32X4_PLL_R_MASK , settings->r);if (ret <0 )return ret; ret =regmap_update_bits (pll->regmap,AIC32X4_PLLPR , -AIC32X4_PLL_P_MASK , - settings->p <<AIC32X4_PLL_P_SHIFT ); +AIC32X4_PLL_P_MASK , + settings->p <<AIC32X4_PLL_P_SHIFT );if (ret <0 )return ret;
@@ -136,23 +137,21 @@ static int clk_aic32x4_pll_set_muldiv(struct clk_aic32x4 *pll,return 0 ; } -static unsigned long clk_aic32x4_pll_calc_rate ( -struct clk_aic32x4_pll_muldiv *settings, -unsigned long parent_rate) +static unsigned long clk_aic32x4_pll_calc_rate (struct clk_aic32x4_pll_muldiv *settings, +unsigned long parent_rate) {u64 rate;/* * We scale j by 10000 to account for the decimal part of P and divide * it back out later. */ - rate = (u64 ) parent_rate * settings->r * - ((settings->j *10000 ) + settings->d); + rate = (u64 )parent_rate * settings->r * ((settings->j *10000 ) + settings->d); -return (unsigned long )DIV_ROUND_UP_ULL (rate, settings->p *10000 ); +return (unsigned long )DIV_ROUND_UP_ULL (rate, settings->p *10000 ); }static int clk_aic32x4_pll_calc_muldiv (struct clk_aic32x4_pll_muldiv *settings, -unsigned long rate,unsigned long parent_rate) +unsigned long rate,unsigned long parent_rate) {u64 multiplier;
@@ -165,14 +164,14 @@ static int clk_aic32x4_pll_calc_muldiv(struct clk_aic32x4_pll_muldiv *settings,* of the multiplier. This is because we can't do floating point * math in the kernel. */ - multiplier = (u64 ) rate * settings->p *10000 ; + multiplier = (u64 )rate * settings->p *10000 ;do_div (multiplier, parent_rate);/* * J can't be over 64, so R can scale this. * R can't be greater than 4. */ - settings->r = ((u32 ) multiplier /640000 ) +1 ; + settings->r = ((u32 )multiplier /640000 ) +1 ;if (settings->r >4 )return -1 ;do_div (multiplier, settings->r);
@@ -184,14 +183,14 @@ static int clk_aic32x4_pll_calc_muldiv(struct clk_aic32x4_pll_muldiv *settings,return -1 ;/* Figure out the integer part, J, and the fractional part, D. */ - settings->j = (u32 ) multiplier /10000 ; - settings->d = (u32 ) multiplier %10000 ; + settings->j = (u32 )multiplier /10000 ; + settings->d = (u32 )multiplier %10000 ;return 0 ; }static unsigned long clk_aic32x4_pll_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) +unsigned long parent_rate) {struct clk_aic32x4 *pll =to_clk_aic32x4 (hw);struct clk_aic32x4_pll_muldiv settings;
@@ -220,8 +219,8 @@ static int clk_aic32x4_pll_determine_rate(struct clk_hw *hw, }static int clk_aic32x4_pll_set_rate (struct clk_hw *hw, -unsigned long rate, -unsigned long parent_rate) +unsigned long rate, +unsigned long parent_rate) {struct clk_aic32x4 *pll =to_clk_aic32x4 (hw);struct clk_aic32x4_pll_muldiv settings;
@@ -236,7 +235,7 @@ static int clk_aic32x4_pll_set_rate(struct clk_hw *hw,return ret;/* 10ms is the delay to wait before the clocks are stable */ -msleep (10 ); +usleep_range (10000 ,20000 );return 0 ; }
@@ -261,7 +260,6 @@ static u8 clk_aic32x4_pll_get_parent(struct clk_hw *hw)return (val &AIC32X4_PLL_CLKIN_MASK ) >>AIC32X4_PLL_CLKIN_SHIFT ; } -static const struct clk_ops aic32x4_pll_ops = { .prepare = clk_aic32x4_pll_prepare, .unprepare = clk_aic32x4_pll_unprepare,
@@ -311,11 +309,11 @@ static void clk_aic32x4_div_unprepare(struct clk_hw *hw)struct clk_aic32x4 *div =to_clk_aic32x4 (hw);regmap_update_bits (div->regmap, div->reg, -AIC32X4_DIVEN ,0 ); +AIC32X4_DIVEN ,0 ); }static int clk_aic32x4_div_set_rate (struct clk_hw *hw,unsigned long rate, -unsigned long parent_rate) +unsigned long parent_rate) {struct clk_aic32x4 *div =to_clk_aic32x4 (hw);u8 divisor;
@@ -342,7 +340,7 @@ static int clk_aic32x4_div_determine_rate(struct clk_hw *hw, }static unsigned long clk_aic32x4_div_recalc_rate (struct clk_hw *hw, -unsigned long parent_rate) +unsigned long parent_rate) {struct clk_aic32x4 *div =to_clk_aic32x4 (hw);unsigned int val;
@@ -399,7 +397,7 @@ static struct aic32x4_clkdesc aic32x4_clkdesc_array[] = { { .name = "pll", .parent_names = - (const char* []) { "mclk", "bclk", "gpio", "din" }, + (const char *[]) { "mclk", "bclk", "gpio", "din" }, .num_parents = 4, .ops = &aic32x4_pll_ops, .reg = 0,
@@ -414,28 +412,28 @@ static struct aic32x4_clkdesc aic32x4_clkdesc_array[] = { }, { .name = "ndac", - .parent_names = (const char * []) { "codec_clkin" }, + .parent_names = (const char *[]) { "codec_clkin" }, .num_parents = 1, .ops = &aic32x4_div_ops, .reg = AIC32X4_NDAC, }, { .name = "mdac", - .parent_names = (const char * []) { "ndac" }, + .parent_names = (const char *[]) { "ndac" }, .num_parents = 1, .ops = &aic32x4_div_ops, .reg = AIC32X4_MDAC, }, { .name = "nadc", - .parent_names = (const char * []) { "codec_clkin" }, + .parent_names = (const char *[]) { "codec_clkin" }, .num_parents = 1, .ops = &aic32x4_div_ops, .reg = AIC32X4_NADC, }, { .name = "madc", - .parent_names = (const char * []) { "nadc" }, + .parent_names = (const char *[]) { "nadc" }, .num_parents = 1, .ops = &aic32x4_div_ops, .reg = AIC32X4_MADC,
@@ -451,7 +449,7 @@ static struct aic32x4_clkdesc aic32x4_clkdesc_array[] = { };static struct clk *aic32x4_register_clk (struct device *dev, -struct aic32x4_clkdesc *desc) +struct aic32x4_clkdesc *desc) {struct clk_init_data init;struct clk_aic32x4 *priv;
@@ -464,8 +462,8 @@ static struct clk *aic32x4_register_clk(struct device *dev, init.flags =0 ; priv =devm_kzalloc (dev,sizeof (struct clk_aic32x4 ),GFP_KERNEL ); -if (priv ==NULL ) -return (struct clk *) -ENOMEM ; +if (!priv) +return ERR_PTR (-ENOMEM ); priv->dev = dev; priv->hw.init = &init;
sound/soc/codecs/tlv320aic32x4-i2c.c +2 -3
@@ -1,11 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0 -* +// SPDX-License-Identifier: GPL-2.0 +/* * Copyright 2011-2019 NW Digital Radio * * Author: Annaliese McDermond <[email protected]> * * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27. -* */ #include <linux/i2c.h>
sound/soc/codecs/tlv320aic32x4-spi.c +2 -3
@@ -1,11 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0 -* +// SPDX-License-Identifier: GPL-2.0 +/* * Copyright 2011-2019 NW Digital Radio * * Author: Annaliese McDermond <[email protected]> * * Based on sound/soc/codecs/wm8974 and TI driver for kernel 2.6.27. -* */ #include <linux/spi/spi.h>
sound/soc/codecs/tlv320aic32x4.c +125 -145
581 lines not on this page · raw message
sound/soc/codecs/tlv320aic32x4.h +1 -2
@@ -3,7 +3,6 @@* tlv320aic32x4.h */ -#ifndef _TLV320AIC32X4_H#define _TLV320AIC32X4_H
@@ -24,7 +23,7 @@ int aic32x4_register_clocks(struct device *dev, const char *mclk_name);/* tlv320aic32x4 register space (in decimal to match datasheet) */ -#define AIC32X4_REG (page, reg) ((page * 128) + reg) +#define AIC32X4_REG (page, reg) (((page) * 128) + (reg))#define AIC32X4_PSEL AIC32X4_REG(0, 0)
Signature · 1 line
2.55.0.229.g6434b31f56-goog
Mark Brown
maintainerQuoted 1 line · Dmitry Torokhov
ASoC: tlv320aic32x4: remove global header with platform data
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/7] ASoC: tlv320aic32x4: remove global header with platform data
https://git.kernel.org/broonie/sound/c/3906ea776a08 [2/7] ASoC: tlv320aic32x4: do not allocate gpio config separately https://git.kernel.org/broonie/sound/c/5143ae134636 [3/7] ASoC: tlv320aic32x4: consolidate programming functions https://git.kernel.org/broonie/sound/c/4ef61518b03d [4/7] ASoC: tlv320aic32x4: move regmap_config into i2c and spi drivers https://git.kernel.org/broonie/sound/c/2ba6a4dba620 [5/7] ASoC: tlv320aic32x4: do not make clocks bulk data static https://git.kernel.org/broonie/sound/c/dfefa7dc25ee [6/7] ASoC: tlv320aic32x4: factor out rate configuration helper https://git.kernel.org/broonie/sound/c/e86ba7c5f24f [7/7] ASoC: tlv320aic32x4: clean up driver code formatting and logging https://git.kernel.org/broonie/sound/c/c3ac0aa6c310
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark