Skip to content

Commit 6617cff

Browse files
Dan Murphybroonie
authored andcommitted
ASoC: tlv320adcx140: Add GPO configuration and drive output config
Add General Purpose Output (GPO) configuration and driver output configuration. The GPOs can be configured as a GPO, IRQ, SDOUT or a PDMCLK output. In addition the output drive can be configured with various configurations. Signed-off-by: Dan Murphy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 63b0383 commit 6617cff

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

sound/soc/codecs/tlv320adcx140.c

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ struct adcx140_priv {
3737
unsigned int slot_width;
3838
};
3939

40+
static const char * const gpo_config_names[] = {
41+
"ti,gpo-config-1",
42+
"ti,gpo-config-2",
43+
"ti,gpo-config-3",
44+
"ti,gpo-config-4",
45+
};
46+
4047
static const struct reg_default adcx140_reg_defaults[] = {
4148
{ ADCX140_PAGE_SELECT, 0x00 },
4249
{ ADCX140_SW_RESET, 0x00 },
@@ -60,10 +67,10 @@ static const struct reg_default adcx140_reg_defaults[] = {
6067
{ ADCX140_PDMCLK_CFG, 0x40 },
6168
{ ADCX140_PDM_CFG, 0x00 },
6269
{ ADCX140_GPIO_CFG0, 0x22 },
70+
{ ADCX140_GPO_CFG0, 0x00 },
6371
{ ADCX140_GPO_CFG1, 0x00 },
6472
{ ADCX140_GPO_CFG2, 0x00 },
6573
{ ADCX140_GPO_CFG3, 0x00 },
66-
{ ADCX140_GPO_CFG4, 0x00 },
6774
{ ADCX140_GPO_VAL, 0x00 },
6875
{ ADCX140_GPIO_MON, 0x00 },
6976
{ ADCX140_GPI_CFG0, 0x00 },
@@ -756,6 +763,43 @@ static const struct snd_soc_dai_ops adcx140_dai_ops = {
756763
.set_tdm_slot = adcx140_set_dai_tdm_slot,
757764
};
758765

766+
static int adcx140_configure_gpo(struct adcx140_priv *adcx140)
767+
{
768+
u32 gpo_outputs[ADCX140_NUM_GPOS];
769+
u32 gpo_output_val = 0;
770+
int ret;
771+
int i;
772+
773+
for (i = 0; i < ADCX140_NUM_GPOS; i++) {
774+
ret = device_property_read_u32_array(adcx140->dev,
775+
gpo_config_names[i],
776+
gpo_outputs,
777+
ADCX140_NUM_GPO_CFGS);
778+
if (ret)
779+
continue;
780+
781+
if (gpo_outputs[0] > ADCX140_GPO_CFG_MAX) {
782+
dev_err(adcx140->dev, "GPO%d config out of range\n", i + 1);
783+
return -EINVAL;
784+
}
785+
786+
if (gpo_outputs[1] > ADCX140_GPO_DRV_MAX) {
787+
dev_err(adcx140->dev, "GPO%d drive out of range\n", i + 1);
788+
return -EINVAL;
789+
}
790+
791+
gpo_output_val = gpo_outputs[0] << ADCX140_GPO_SHIFT |
792+
gpo_outputs[1];
793+
ret = regmap_write(adcx140->regmap, ADCX140_GPO_CFG1 + i,
794+
gpo_output_val);
795+
if (ret)
796+
return ret;
797+
}
798+
799+
return 0;
800+
801+
}
802+
759803
static int adcx140_codec_probe(struct snd_soc_component *component)
760804
{
761805
struct adcx140_priv *adcx140 = snd_soc_component_get_drvdata(component);
@@ -837,6 +881,10 @@ static int adcx140_codec_probe(struct snd_soc_component *component)
837881
return ret;
838882
}
839883

884+
ret = adcx140_configure_gpo(adcx140);
885+
if (ret)
886+
goto out;
887+
840888
ret = adcx140_reset(adcx140);
841889
if (ret)
842890
goto out;

sound/soc/codecs/tlv320adcx140.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
#define ADCX140_PDMCLK_CFG 0x1f
3737
#define ADCX140_PDM_CFG 0x20
3838
#define ADCX140_GPIO_CFG0 0x21
39-
#define ADCX140_GPO_CFG1 0x22
40-
#define ADCX140_GPO_CFG2 0x23
41-
#define ADCX140_GPO_CFG3 0x24
42-
#define ADCX140_GPO_CFG4 0x25
39+
#define ADCX140_GPO_CFG0 0x22
40+
#define ADCX140_GPO_CFG1 0x23
41+
#define ADCX140_GPO_CFG2 0x24
42+
#define ADCX140_GPO_CFG3 0x25
4343
#define ADCX140_GPO_VAL 0x29
4444
#define ADCX140_GPIO_MON 0x2a
4545
#define ADCX140_GPI_CFG0 0x2b
@@ -139,4 +139,10 @@
139139
#define ADCX140_GPI3_INDEX 2
140140
#define ADCX140_GPI4_INDEX 3
141141

142+
#define ADCX140_NUM_GPOS 4
143+
#define ADCX140_NUM_GPO_CFGS 2
144+
#define ADCX140_GPO_SHIFT 4
145+
#define ADCX140_GPO_CFG_MAX 4
146+
#define ADCX140_GPO_DRV_MAX 5
147+
142148
#endif /* _TLV320ADCX140_ */

0 commit comments

Comments
 (0)