Lines Matching +full:pvdd +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0
5 // Author: Andy Liu <andy-liu@ti.com>
11 // https://e2e.ti.com/support/audio-group/audio/f/audio-forum/722027/linux-tas5825m-linux-drivers
33 /* Datasheet-defined registers on page 0, book 0 */
71 0x0000001B, /* 0, -110dB */ 0x0000001E, /* 1, -109dB */
72 0x00000021, /* 2, -108dB */ 0x00000025, /* 3, -107dB */
73 0x0000002A, /* 4, -106dB */ 0x0000002F, /* 5, -105dB */
74 0x00000035, /* 6, -104dB */ 0x0000003B, /* 7, -103dB */
75 0x00000043, /* 8, -102dB */ 0x0000004B, /* 9, -101dB */
76 0x00000054, /* 10, -100dB */ 0x0000005E, /* 11, -99dB */
77 0x0000006A, /* 12, -98dB */ 0x00000076, /* 13, -97dB */
78 0x00000085, /* 14, -96dB */ 0x00000095, /* 15, -95dB */
79 0x000000A7, /* 16, -94dB */ 0x000000BC, /* 17, -93dB */
80 0x000000D3, /* 18, -92dB */ 0x000000EC, /* 19, -91dB */
81 0x00000109, /* 20, -90dB */ 0x0000012A, /* 21, -89dB */
82 0x0000014E, /* 22, -88dB */ 0x00000177, /* 23, -87dB */
83 0x000001A4, /* 24, -86dB */ 0x000001D8, /* 25, -85dB */
84 0x00000211, /* 26, -84dB */ 0x00000252, /* 27, -83dB */
85 0x0000029A, /* 28, -82dB */ 0x000002EC, /* 29, -81dB */
86 0x00000347, /* 30, -80dB */ 0x000003AD, /* 31, -79dB */
87 0x00000420, /* 32, -78dB */ 0x000004A1, /* 33, -77dB */
88 0x00000532, /* 34, -76dB */ 0x000005D4, /* 35, -75dB */
89 0x0000068A, /* 36, -74dB */ 0x00000756, /* 37, -73dB */
90 0x0000083B, /* 38, -72dB */ 0x0000093C, /* 39, -71dB */
91 0x00000A5D, /* 40, -70dB */ 0x00000BA0, /* 41, -69dB */
92 0x00000D0C, /* 42, -68dB */ 0x00000EA3, /* 43, -67dB */
93 0x0000106C, /* 44, -66dB */ 0x0000126D, /* 45, -65dB */
94 0x000014AD, /* 46, -64dB */ 0x00001733, /* 47, -63dB */
95 0x00001A07, /* 48, -62dB */ 0x00001D34, /* 49, -61dB */
96 0x000020C5, /* 50, -60dB */ 0x000024C4, /* 51, -59dB */
97 0x00002941, /* 52, -58dB */ 0x00002E49, /* 53, -57dB */
98 0x000033EF, /* 54, -56dB */ 0x00003A45, /* 55, -55dB */
99 0x00004161, /* 56, -54dB */ 0x0000495C, /* 57, -53dB */
100 0x0000524F, /* 58, -52dB */ 0x00005C5A, /* 59, -51dB */
101 0x0000679F, /* 60, -50dB */ 0x00007444, /* 61, -49dB */
102 0x00008274, /* 62, -48dB */ 0x0000925F, /* 63, -47dB */
103 0x0000A43B, /* 64, -46dB */ 0x0000B845, /* 65, -45dB */
104 0x0000CEC1, /* 66, -44dB */ 0x0000E7FB, /* 67, -43dB */
105 0x00010449, /* 68, -42dB */ 0x0001240C, /* 69, -41dB */
106 0x000147AE, /* 70, -40dB */ 0x00016FAA, /* 71, -39dB */
107 0x00019C86, /* 72, -38dB */ 0x0001CEDC, /* 73, -37dB */
108 0x00020756, /* 74, -36dB */ 0x000246B5, /* 75, -35dB */
109 0x00028DCF, /* 76, -34dB */ 0x0002DD96, /* 77, -33dB */
110 0x00033718, /* 78, -32dB */ 0x00039B87, /* 79, -31dB */
111 0x00040C37, /* 80, -30dB */ 0x00048AA7, /* 81, -29dB */
112 0x00051884, /* 82, -28dB */ 0x0005B7B1, /* 83, -27dB */
113 0x00066A4A, /* 84, -26dB */ 0x000732AE, /* 85, -25dB */
114 0x00081385, /* 86, -24dB */ 0x00090FCC, /* 87, -23dB */
115 0x000A2ADB, /* 88, -22dB */ 0x000B6873, /* 89, -21dB */
116 0x000CCCCD, /* 90, -20dB */ 0x000E5CA1, /* 91, -19dB */
117 0x00101D3F, /* 92, -18dB */ 0x0012149A, /* 93, -17dB */
118 0x00144961, /* 94, -16dB */ 0x0016C311, /* 95, -15dB */
119 0x00198A13, /* 96, -14dB */ 0x001CA7D7, /* 97, -13dB */
120 0x002026F3, /* 98, -12dB */ 0x00241347, /* 99, -11dB */
121 0x00287A27, /* 100, -10dB */ 0x002D6A86, /* 101, -9dB */
122 0x0032F52D, /* 102, -8dB */ 0x00392CEE, /* 103, -7dB */
123 0x004026E7, /* 104, -6dB */ 0x0047FACD, /* 105, -5dB */
124 0x0050C336, /* 106, -4dB */ 0x005A9DF8, /* 107, -3dB */
125 0x0065AC8C, /* 108, -2dB */ 0x00721483, /* 109, -1dB */
153 #define TAS5805M_VOLUME_MAX ((int)ARRAY_SIZE(tas5805m_volume) - 1)
158 struct regulator *pvdd; member
181 v[3 - i] = x; in set_dsp_scale()
190 struct regmap *rm = tas5805m->regmap; in tas5805m_refresh()
192 dev_dbg(&tas5805m->i2c->dev, "refresh: is_muted=%d, vol=%d/%d\n", in tas5805m_refresh()
193 tas5805m->is_muted, tas5805m->vol[0], tas5805m->vol[1]); in tas5805m_refresh()
203 set_dsp_scale(rm, 0x24, tas5805m->vol[0]); in tas5805m_refresh()
204 set_dsp_scale(rm, 0x28, tas5805m->vol[1]); in tas5805m_refresh()
209 /* Set/clear digital soft-mute */ in tas5805m_refresh()
211 (tas5805m->is_muted ? DCTRL2_MUTE : 0) | in tas5805m_refresh()
218 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in tas5805m_vol_info()
219 uinfo->count = 2; in tas5805m_vol_info()
221 uinfo->value.integer.min = TAS5805M_VOLUME_MIN; in tas5805m_vol_info()
222 uinfo->value.integer.max = TAS5805M_VOLUME_MAX; in tas5805m_vol_info()
234 mutex_lock(&tas5805m->lock); in tas5805m_vol_get()
235 ucontrol->value.integer.value[0] = tas5805m->vol[0]; in tas5805m_vol_get()
236 ucontrol->value.integer.value[1] = tas5805m->vol[1]; in tas5805m_vol_get()
237 mutex_unlock(&tas5805m->lock); in tas5805m_vol_get()
256 if (!(volume_is_valid(ucontrol->value.integer.value[0]) && in tas5805m_vol_put()
257 volume_is_valid(ucontrol->value.integer.value[1]))) in tas5805m_vol_put()
258 return -EINVAL; in tas5805m_vol_put()
260 mutex_lock(&tas5805m->lock); in tas5805m_vol_put()
261 if (tas5805m->vol[0] != ucontrol->value.integer.value[0] || in tas5805m_vol_put()
262 tas5805m->vol[1] != ucontrol->value.integer.value[1]) { in tas5805m_vol_put()
263 tas5805m->vol[0] = ucontrol->value.integer.value[0]; in tas5805m_vol_put()
264 tas5805m->vol[1] = ucontrol->value.integer.value[1]; in tas5805m_vol_put()
265 dev_dbg(component->dev, "set vol=%d/%d (is_powered=%d)\n", in tas5805m_vol_put()
266 tas5805m->vol[0], tas5805m->vol[1], in tas5805m_vol_put()
267 tas5805m->is_powered); in tas5805m_vol_put()
268 if (tas5805m->is_powered) in tas5805m_vol_put()
272 mutex_unlock(&tas5805m->lock); in tas5805m_vol_put()
305 struct snd_soc_component *component = dai->component; in tas5805m_trigger()
313 dev_dbg(component->dev, "clock start\n"); in tas5805m_trigger()
314 schedule_work(&tas5805m->work); in tas5805m_trigger()
323 return -EINVAL; in tas5805m_trigger()
333 struct regmap *rm = tas5805m->regmap; in do_work()
335 dev_dbg(&tas5805m->i2c->dev, "DSP startup\n"); in do_work()
337 mutex_lock(&tas5805m->lock); in do_work()
346 send_cfg(rm, tas5805m->dsp_cfg_data, tas5805m->dsp_cfg_len); in do_work()
348 tas5805m->is_powered = true; in do_work()
350 mutex_unlock(&tas5805m->lock); in do_work()
356 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas5805m_dac_event()
359 struct regmap *rm = tas5805m->regmap; in tas5805m_dac_event()
364 dev_dbg(component->dev, "DSP shutdown\n"); in tas5805m_dac_event()
365 cancel_work_sync(&tas5805m->work); in tas5805m_dac_event()
367 mutex_lock(&tas5805m->lock); in tas5805m_dac_event()
368 if (tas5805m->is_powered) { in tas5805m_dac_event()
369 tas5805m->is_powered = false; in tas5805m_dac_event()
378 dev_dbg(component->dev, "fault regs: CHAN=%02x, " in tas5805m_dac_event()
384 mutex_unlock(&tas5805m->lock); in tas5805m_dac_event()
415 struct snd_soc_component *component = dai->component; in tas5805m_mute()
419 mutex_lock(&tas5805m->lock); in tas5805m_mute()
420 dev_dbg(component->dev, "set mute=%d (is_powered=%d)\n", in tas5805m_mute()
421 mute, tas5805m->is_powered); in tas5805m_mute()
423 tas5805m->is_muted = mute; in tas5805m_mute()
424 if (tas5805m->is_powered) in tas5805m_mute()
426 mutex_unlock(&tas5805m->lock); in tas5805m_mute()
438 .name = "tas5805m-amplifier",
453 /* We have quite a lot of multi-level bank switching and a
462 struct device *dev = &i2c->dev; in tas5805m_i2c_probe()
479 return -ENOMEM; in tas5805m_i2c_probe()
481 tas5805m->i2c = i2c; in tas5805m_i2c_probe()
482 tas5805m->pvdd = devm_regulator_get(dev, "pvdd"); in tas5805m_i2c_probe()
483 if (IS_ERR(tas5805m->pvdd)) { in tas5805m_i2c_probe()
484 dev_err(dev, "failed to get pvdd supply: %ld\n", in tas5805m_i2c_probe()
485 PTR_ERR(tas5805m->pvdd)); in tas5805m_i2c_probe()
486 return PTR_ERR(tas5805m->pvdd); in tas5805m_i2c_probe()
490 tas5805m->regmap = regmap; in tas5805m_i2c_probe()
491 tas5805m->gpio_pdn_n = devm_gpiod_get(dev, "pdn", GPIOD_OUT_LOW); in tas5805m_i2c_probe()
492 if (IS_ERR(tas5805m->gpio_pdn_n)) { in tas5805m_i2c_probe()
494 PTR_ERR(tas5805m->gpio_pdn_n)); in tas5805m_i2c_probe()
495 return PTR_ERR(tas5805m->gpio_pdn_n); in tas5805m_i2c_probe()
506 if (device_property_read_string(dev, "ti,dsp-config-name", in tas5805m_i2c_probe()
516 if ((fw->size < 2) || (fw->size & 1)) { in tas5805m_i2c_probe()
519 return -EINVAL; in tas5805m_i2c_probe()
522 tas5805m->dsp_cfg_len = fw->size; in tas5805m_i2c_probe()
523 tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL); in tas5805m_i2c_probe()
524 if (!tas5805m->dsp_cfg_data) { in tas5805m_i2c_probe()
526 return -ENOMEM; in tas5805m_i2c_probe()
531 /* Do the first part of the power-on here, while we can expect in tas5805m_i2c_probe()
537 * after PVDD is applied, or else the ADR pin is sampled in tas5805m_i2c_probe()
541 tas5805m->vol[0] = TAS5805M_VOLUME_MIN; in tas5805m_i2c_probe()
542 tas5805m->vol[1] = TAS5805M_VOLUME_MIN; in tas5805m_i2c_probe()
544 ret = regulator_enable(tas5805m->pvdd); in tas5805m_i2c_probe()
546 dev_err(dev, "failed to enable pvdd: %d\n", ret); in tas5805m_i2c_probe()
551 gpiod_set_value(tas5805m->gpio_pdn_n, 1); in tas5805m_i2c_probe()
554 INIT_WORK(&tas5805m->work, do_work); in tas5805m_i2c_probe()
555 mutex_init(&tas5805m->lock); in tas5805m_i2c_probe()
564 gpiod_set_value(tas5805m->gpio_pdn_n, 0); in tas5805m_i2c_probe()
565 regulator_disable(tas5805m->pvdd); in tas5805m_i2c_probe()
574 struct device *dev = &i2c->dev; in tas5805m_i2c_remove()
577 cancel_work_sync(&tas5805m->work); in tas5805m_i2c_remove()
579 gpiod_set_value(tas5805m->gpio_pdn_n, 0); in tas5805m_i2c_remove()
581 regulator_disable(tas5805m->pvdd); in tas5805m_i2c_remove()
610 MODULE_AUTHOR("Andy Liu <andy-liu@ti.com>");