Lines Matching +full:gpio1 +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0-only
8 // Copyright (C) 2014-2018, Ambarella, Inc.
15 #include <dt-bindings/sound/tlv320adc3xxx.h>
34 #include <sound/soc-dapm.h>
59 * Setting the clock source using simple-card (clocks or
60 * system-clock-frequency property) sets clk_id = 0 = ADC3XXX_PLL_AUTO.
78 /* 2-3 Reserved */
86 /* 9-17 Reserved */
93 /* 23-24 Reserved */
109 /* 39-41 Reserved */
122 /* 54-56 Reserved */
129 /* 63-79 Reserved */
152 /* 102-127 Reserved */
158 /* 1-25 Reserved */
160 /* 27-50 Reserved */
171 /* 63-127 Reserved */
484 * the non-PLL entries, so that the PLL modes are preferred unless
528 if ((pll_mode == ADC3XXX_PLL_BYPASS && mode->pll_p) || in adc3xxx_get_divs()
529 (pll_mode == ADC3XXX_PLL_ENABLE && !mode->pll_p)) in adc3xxx_get_divs()
532 if (mode->rate == rate && mode->mclk == mclk) in adc3xxx_get_divs()
538 return -EINVAL; in adc3xxx_get_divs()
544 /* 10msec delay needed after PLL power-up to allow in adc3xxx_pll_delay()
555 int numcoeff = kcontrol->private_value >> 16; in adc3xxx_coefficient_info()
557 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in adc3xxx_coefficient_info()
558 uinfo->count = numcoeff; in adc3xxx_coefficient_info()
559 uinfo->value.integer.min = 0; in adc3xxx_coefficient_info()
560 uinfo->value.integer.max = 0xffff; /* all coefficients are 16 bit */ in adc3xxx_coefficient_info()
568 int numcoeff = kcontrol->private_value >> 16; in adc3xxx_coefficient_get()
569 int reg = kcontrol->private_value & 0xffff; in adc3xxx_coefficient_get()
584 ucontrol->value.integer.value[index] = value; in adc3xxx_coefficient_get()
594 int numcoeff = kcontrol->private_value >> 16; in adc3xxx_coefficient_put()
595 int reg = kcontrol->private_value & 0xffff; in adc3xxx_coefficient_put()
600 unsigned int value = ucontrol->value.integer.value[index]; in adc3xxx_coefficient_put()
616 /* All on-chip filters have coefficients which are expressed in terms of
617 * 16 bit values, so represent them as strings of 16-bit integers.
645 "-15mV", "-30mV", "-45mV", "-60mV", "-75mV", "-90mV", "-105mV"
656 static const DECLARE_TLV_DB_SCALE(adc_tlv, -1200, 50, 0);
657 static const DECLARE_TLV_DB_SCALE(adc_fine_tlv, -40, 10, 0);
658 /* AGC target: 8 values: -5.5, -8, -10, -12, -14, -17, -20, -24 dB */
666 0, 0, TLV_DB_SCALE_ITEM(-2400, 0, 0),
667 1, 3, TLV_DB_SCALE_ITEM(-2000, 300, 0),
668 4, 6, TLV_DB_SCALE_ITEM(-1200, 200, 0),
669 7, 7, TLV_DB_SCALE_ITEM(-550, 0, 0));
671 * range (i.e. just before -32 dB) rather than the lowest, we need to resort
675 0, 30, TLV_DB_SCALE_ITEM(-9000, 200, 0),
683 /* Input attenuation: -6 dB or 0 dB */
684 static const DECLARE_TLV_DB_SCALE(input_attenuation_tlv, -600, 600, 0);
727 ADC3XXX_RIGHT_AGC_GAIN, 0, -24, 40, 6, 0, adc_tlv),
760 ADC3XXX_RADC_VOL, 0, -24, 40, 6, 0, adc_tlv),
762 * to. Values 0, -0.1, -0.2 and -0.3 dB result in the same level, and
763 * -0.4 dB drops about 0.12 dB on a specific chip.
961 return -EINVAL; in adc3xxx_gpio_request()
963 /* GPIO1 is offset 0, GPIO2 is offset 1 */ in adc3xxx_gpio_request()
968 if (adc3xxx->gpio_cfg[offset] != 0 && in adc3xxx_gpio_request()
969 adc3xxx->gpio_cfg[offset] != ADC3XXX_GPIO_GPO + 1) in adc3xxx_gpio_request()
970 return -EINVAL; in adc3xxx_gpio_request()
981 return regmap_update_bits(adc3xxx->regmap, in adc3xxx_gpio_direction_out()
1011 ret = regmap_read(adc3xxx->regmap, adc3xxx_gpio_ctrl_reg[offset], ®val); in adc3xxx_gpio_get()
1030 gpiochip_remove(&adc3xxx->gpio_chip); in adc3xxx_free_gpio()
1039 adc3xxx->gpio_chip = adc3xxx_gpio_chip; in adc3xxx_init_gpio()
1040 adc3xxx->gpio_chip.ngpio = ADC3XXX_GPIOS_MAX; in adc3xxx_init_gpio()
1041 adc3xxx->gpio_chip.parent = adc3xxx->dev; in adc3xxx_init_gpio()
1042 adc3xxx->gpio_chip.base = -1; in adc3xxx_init_gpio()
1044 ret = gpiochip_add_data(&adc3xxx->gpio_chip, adc3xxx); in adc3xxx_init_gpio()
1046 dev_err(adc3xxx->dev, "Failed to add gpios: %d\n", ret); in adc3xxx_init_gpio()
1053 unsigned int cfg = adc3xxx->gpio_cfg[gpio]; in adc3xxx_init_gpio() local
1055 if (cfg) { in adc3xxx_init_gpio()
1056 cfg--; /* actual value to use is stored +1 */ in adc3xxx_init_gpio()
1057 regmap_update_bits(adc3xxx->regmap, in adc3xxx_init_gpio()
1060 cfg << ADC3XXX_GPIO_CTRL_CFG_SHIFT); in adc3xxx_init_gpio()
1066 unsigned int vg = adc3xxx->micbias_vg[micbias]; in adc3xxx_init_gpio()
1068 regmap_update_bits(adc3xxx->regmap, in adc3xxx_init_gpio()
1076 const char *propname, unsigned int *cfg) in adc3xxx_parse_dt_gpio() argument
1078 struct device *dev = adc3xxx->dev; in adc3xxx_parse_dt_gpio()
1079 struct device_node *np = dev->of_node; in adc3xxx_parse_dt_gpio()
1085 return -EINVAL; in adc3xxx_parse_dt_gpio()
1089 *cfg = val + 1; /* 0 => not set up, all others shifted +1 */ in adc3xxx_parse_dt_gpio()
1097 struct device *dev = adc3xxx->dev; in adc3xxx_parse_dt_micbias()
1098 struct device_node *np = dev->of_node; in adc3xxx_parse_dt_micbias()
1104 return -EINVAL; in adc3xxx_parse_dt_micbias()
1115 return -EINVAL; in adc3xxx_parse_pll_mode()
1145 struct snd_soc_component *component = dai->component; in adc3xxx_hw_params()
1146 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component); in adc3xxx_hw_params()
1151 i = adc3xxx_get_divs(component->dev, adc3xxx->sysclk, in adc3xxx_hw_params()
1152 params_rate(params), adc3xxx->pll_mode); in adc3xxx_hw_params()
1176 dev_err(component->dev, "Unsupported serial data format\n"); in adc3xxx_hw_params()
1177 return -EINVAL; in adc3xxx_hw_params()
1184 if (!adc3xxx->use_pll) { in adc3xxx_hw_params()
1187 adc3xxx->use_pll = 1; in adc3xxx_hw_params()
1191 if (adc3xxx->use_pll) { in adc3xxx_hw_params()
1194 adc3xxx->use_pll = 0; in adc3xxx_hw_params()
1235 struct snd_soc_component *component = codec_dai->component; in adc3xxx_set_dai_sysclk()
1239 ret = adc3xxx_parse_pll_mode(clk_id, &adc3xxx->pll_mode); in adc3xxx_set_dai_sysclk()
1243 adc3xxx->sysclk = freq; in adc3xxx_set_dai_sysclk()
1244 dev_dbg(component->dev, "Set sysclk to %u Hz, %s\n", in adc3xxx_set_dai_sysclk()
1245 freq, adc3xxx_pll_mode_text(adc3xxx->pll_mode)); in adc3xxx_set_dai_sysclk()
1251 struct snd_soc_component *component = codec_dai->component; in adc3xxx_set_dai_fmt()
1267 dev_err(component->dev, "Invalid DAI clock setup\n"); in adc3xxx_set_dai_fmt()
1268 return -EINVAL; in adc3xxx_set_dai_fmt()
1292 dev_err(component->dev, "Invalid DAI format\n"); in adc3xxx_set_dai_fmt()
1293 return -EINVAL; in adc3xxx_set_dai_fmt()
1297 if (master && !adc3xxx->master) in adc3xxx_set_dai_fmt()
1300 else if (!master && adc3xxx->master) in adc3xxx_set_dai_fmt()
1303 adc3xxx->master = master; in adc3xxx_set_dai_fmt()
1322 .name = "tlv320adc3xxx-hifi",
1352 struct device *dev = &i2c->dev; in adc3xxx_i2c_probe()
1359 return -ENOMEM; in adc3xxx_i2c_probe()
1360 adc3xxx->dev = dev; in adc3xxx_i2c_probe()
1362 adc3xxx->rst_pin = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in adc3xxx_i2c_probe()
1363 if (IS_ERR(adc3xxx->rst_pin)) { in adc3xxx_i2c_probe()
1364 return dev_err_probe(dev, PTR_ERR(adc3xxx->rst_pin), in adc3xxx_i2c_probe()
1368 adc3xxx->mclk = devm_clk_get(dev, NULL); in adc3xxx_i2c_probe()
1369 if (IS_ERR(adc3xxx->mclk)) { in adc3xxx_i2c_probe()
1377 return dev_err_probe(dev, PTR_ERR(adc3xxx->mclk), in adc3xxx_i2c_probe()
1379 } else if (adc3xxx->mclk) { in adc3xxx_i2c_probe()
1380 ret = clk_prepare_enable(adc3xxx->mclk); in adc3xxx_i2c_probe()
1383 dev_dbg(dev, "Enabled MCLK, freq %lu Hz\n", clk_get_rate(adc3xxx->mclk)); in adc3xxx_i2c_probe()
1386 ret = adc3xxx_parse_dt_gpio(adc3xxx, "ti,dmdin-gpio1", &adc3xxx->gpio_cfg[0]); in adc3xxx_i2c_probe()
1389 ret = adc3xxx_parse_dt_gpio(adc3xxx, "ti,dmclk-gpio2", &adc3xxx->gpio_cfg[1]); in adc3xxx_i2c_probe()
1392 ret = adc3xxx_parse_dt_micbias(adc3xxx, "ti,micbias1-vg", &adc3xxx->micbias_vg[0]); in adc3xxx_i2c_probe()
1395 ret = adc3xxx_parse_dt_micbias(adc3xxx, "ti,micbias2-vg", &adc3xxx->micbias_vg[1]); in adc3xxx_i2c_probe()
1399 adc3xxx->regmap = devm_regmap_init_i2c(i2c, &adc3xxx_regmap); in adc3xxx_i2c_probe()
1400 if (IS_ERR(adc3xxx->regmap)) { in adc3xxx_i2c_probe()
1401 ret = PTR_ERR(adc3xxx->regmap); in adc3xxx_i2c_probe()
1408 adc3xxx->type = id->driver_data; in adc3xxx_i2c_probe()
1411 gpiod_set_value_cansleep(adc3xxx->rst_pin, 1); in adc3xxx_i2c_probe()
1413 gpiod_set_value_cansleep(adc3xxx->rst_pin, 0); in adc3xxx_i2c_probe()
1428 clk_disable_unprepare(adc3xxx->mclk); in adc3xxx_i2c_probe()
1436 if (adc3xxx->mclk) in adc3xxx_i2c_remove()
1437 clk_disable_unprepare(adc3xxx->mclk); in adc3xxx_i2c_remove()
1439 snd_soc_unregister_component(&client->dev); in adc3xxx_i2c_remove()
1451 .name = "tlv320adc3xxx-codec",