mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
ALSA: ctxfi: Add ADC helper functions for GPIO
Add helper functions hw_adc_stop(), hw_adc_start(), and hw_adc_reset() to encapsulate ADC reset sequence operations. These functions reduce duplication by centralizing the GPIO-based ADC control logic. Signed-off-by: Harin Lee <me@harin.net> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20251124180501.2760421-3-me@harin.net
This commit is contained in:
parent
5ebd054272
commit
4b490e0d10
|
|
@ -1826,6 +1826,32 @@ static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hw_adc_stop(struct hw *hw)
|
||||||
|
{
|
||||||
|
u32 data;
|
||||||
|
/* Reset the ADC (reset is active low). */
|
||||||
|
data = hw_read_20kx(hw, GPIO_DATA);
|
||||||
|
data &= ~(0x1 << 15);
|
||||||
|
hw_write_20kx(hw, GPIO_DATA, data);
|
||||||
|
usleep_range(10000, 11000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hw_adc_start(struct hw *hw)
|
||||||
|
{
|
||||||
|
u32 data;
|
||||||
|
/* Return the ADC to normal operation. */
|
||||||
|
data = hw_read_20kx(hw, GPIO_DATA);
|
||||||
|
data |= (0x1 << 15);
|
||||||
|
hw_write_20kx(hw, GPIO_DATA, data);
|
||||||
|
msleep(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __maybe_unused hw_adc_reset(struct hw *hw)
|
||||||
|
{
|
||||||
|
hw_adc_stop(hw);
|
||||||
|
hw_adc_start(hw);
|
||||||
|
}
|
||||||
|
|
||||||
static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
|
static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
@ -1843,10 +1869,7 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the ADC (reset is active low). */
|
hw_adc_stop(hw);
|
||||||
data = hw_read_20kx(hw, GPIO_DATA);
|
|
||||||
data &= ~(0x1 << 15);
|
|
||||||
hw_write_20kx(hw, GPIO_DATA, data);
|
|
||||||
|
|
||||||
if (hw->model == CTSB1270) {
|
if (hw->model == CTSB1270) {
|
||||||
/* Set up the PCM4220 ADC on Titanium HD */
|
/* Set up the PCM4220 ADC on Titanium HD */
|
||||||
|
|
@ -1860,11 +1883,7 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
|
||||||
hw_write_20kx(hw, GPIO_DATA, data);
|
hw_write_20kx(hw, GPIO_DATA, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep_range(10000, 11000);
|
hw_adc_start(hw);
|
||||||
/* Return the ADC to normal operation. */
|
|
||||||
data |= (0x1 << 15);
|
|
||||||
hw_write_20kx(hw, GPIO_DATA, data);
|
|
||||||
msleep(50);
|
|
||||||
|
|
||||||
/* I2C write to register offset 0x0B to set ADC LRCLK polarity */
|
/* I2C write to register offset 0x0B to set ADC LRCLK polarity */
|
||||||
/* invert bit, interface format to I2S, word length to 24-bit, */
|
/* invert bit, interface format to I2S, word length to 24-bit, */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user