Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: codecs: rtq9128: Add TDM input source select

Merge series from cy_huang@richtek.com:

This patch series create a TDM source select property and use it to
decide which TDM data source is connected.

Following by the below patch disccuion
https://lore.kernel.org/lkml/1695780376-32301-1-git-send-email-cy_huang@richtek.com/#t
It may not be a good choice to add the user controlable mixer control
item. Since it follows the board design, make it as a device property.

+22 -1
+7
Documentation/devicetree/bindings/sound/richtek,rtq9128.yaml
··· 28 28 enable-gpios: 29 29 maxItems: 1 30 30 31 + richtek,tdm-input-data2-select: 32 + type: boolean 33 + description: 34 + By default, if TDM mode is used, TDM data input will select 'DATA1' pin 35 + as the data source. This option will configure TDM data input source from 36 + 'DATA1' to 'DATA2' pin. 37 + 31 38 '#sound-dai-cells': 32 39 const: 0 33 40
+15 -1
sound/soc/codecs/rtq9128.c
··· 14 14 #include <linux/mod_devicetable.h> 15 15 #include <linux/module.h> 16 16 #include <linux/pm_runtime.h> 17 + #include <linux/property.h> 17 18 #include <linux/regmap.h> 18 19 #include <sound/pcm_params.h> 19 20 #include <sound/soc.h> ··· 42 41 43 42 #define RTQ9128_CHSTAT_VAL_MASK GENMASK(1, 0) 44 43 #define RTQ9128_DOLEN_MASK GENMASK(7, 6) 44 + #define RTQ9128_TDMSRCIN_MASK GENMASK(5, 4) 45 45 #define RTQ9128_AUDBIT_MASK GENMASK(5, 4) 46 46 #define RTQ9128_AUDFMT_MASK GENMASK(3, 0) 47 47 #define RTQ9128_MSMUTE_MASK BIT(0) ··· 61 59 struct gpio_desc *enable; 62 60 int tdm_slots; 63 61 int tdm_slot_width; 62 + bool tdm_input_data2_select; 64 63 }; 65 64 66 65 struct rtq9128_init_reg { ··· 487 484 struct rtq9128_data *data = snd_soc_dai_get_drvdata(dai); 488 485 struct snd_soc_component *comp = dai->component; 489 486 struct device *dev = dai->dev; 490 - unsigned int mask, start_loc; 487 + unsigned int mask, start_loc, srcin_select; 491 488 int i, frame_length, ret; 492 489 493 490 dev_dbg(dev, "%s: slot %d slot_width %d, tx/rx mask 0x%x 0x%x\n", __func__, slots, ··· 531 528 dev_err(dev, "Failed to assign rx_loc %d (%d)\n", i, ret); 532 529 return ret; 533 530 } 531 + } 532 + 533 + srcin_select = data->tdm_input_data2_select ? RTQ9128_TDMSRCIN_MASK : 0; 534 + ret = snd_soc_component_update_bits(comp, RTQ9128_REG_SDO_SEL, RTQ9128_TDMSRCIN_MASK, 535 + srcin_select); 536 + if (ret < 0) { 537 + dev_err(dev, "Failed to configure TDM source input select\n"); 538 + return ret; 534 539 } 535 540 536 541 data->tdm_slots = slots; ··· 682 671 return dev_err_probe(dev, PTR_ERR(data->enable), "Failed to get 'enable' gpio\n"); 683 672 else if (data->enable) 684 673 usleep_range(10000, 11000); 674 + 675 + data->tdm_input_data2_select = device_property_read_bool(dev, 676 + "richtek,tdm-input-data2-select"); 685 677 686 678 i2c_set_clientdata(i2c, data); 687 679