Lines Matching +full:adc +full:- +full:delay +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec.
16 #include <linux/delay.h>
35 * This is used to increase the range of values returned by the adc
52 * Set adc sample delay.
56 * touchpanel plate and the ADC sampling the signal.
58 * This delay can be set by setting delay = n, where n is the array
59 * position of the delay in the array delay_table below.
60 * Long delays > 1ms are supported for completeness, but are not
63 static int delay = 4; variable
64 module_param(delay, int, 0);
65 MODULE_PARM_DESC(delay, "Set adc sample delay.");
82 * Set adc mask function.
86 * order to minimise this, a signal may be applied to the MASK pin to delay or
89 * 0 = No delay or sync
91 * 2 = Edge triggered, edge on pin delays conversion by delay param (above)
92 * 3 = Edge triggered, edge on pin starts conversion after delay param
96 MODULE_PARM_DESC(mask, "Set adc mask function.");
99 * ADC sample delay times in uS
117 0 /* No delay, switch matrix always on */
121 * Delay after issuing a POLL command.
123 * The delay is 3 AC97 link frames + the touchpanel settling delay
147 dev_dbg(wm->dev, in wm9705_phy_init()
150 dev_dbg(wm->dev, in wm9705_phy_init()
155 /* polling mode sample settling delay */ in wm9705_phy_init()
156 if (delay != 4) { in wm9705_phy_init()
157 if (delay < 0 || delay > 15) { in wm9705_phy_init()
158 dev_dbg(wm->dev, "supplied delay out of range."); in wm9705_phy_init()
159 delay = 4; in wm9705_phy_init()
163 dig1 |= WM97XX_DELAY(delay); in wm9705_phy_init()
164 dev_dbg(wm->dev, "setting adc sample delay to %d u Secs.", in wm9705_phy_init()
165 delay_table[delay]); in wm9705_phy_init()
169 dev_dbg(wm->dev, "setting pdd to Vmid/%d", 1 - (pdd & 0x000f)); in wm9705_phy_init()
182 wm->dig[2] | WM97XX_PRP_DET_DIG); in wm9705_dig_enable()
186 wm->dig[2] & ~WM97XX_PRP_DET_DIG); in wm9705_dig_enable()
191 memcpy(wm->dig_save, wm->dig, sizeof(wm->dig)); in wm9705_aux_prepare()
198 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig_save[1]); in wm9705_dig_restore()
199 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig_save[2]); in wm9705_dig_restore()
204 return wm->dig[2] & WM9705_PDEN; in is_pden()
208 * Read a sample from the WM9705 adc in polling mode.
212 int timeout = 5 * delay; in wm9705_poll_sample()
215 if (wants_pen && !wm->pen_probably_down) { in wm9705_poll_sample()
219 wm->pen_probably_down = 1; in wm9705_poll_sample()
223 if (wm->mach_ops && wm->mach_ops->pre_sample) in wm9705_poll_sample()
224 wm->mach_ops->pre_sample(adcsel); in wm9705_poll_sample()
226 | WM97XX_POLL | WM97XX_DELAY(delay)); in wm9705_poll_sample()
228 /* wait 3 AC97 time slots + delay for conversion */ in wm9705_poll_sample()
229 poll_delay(delay); in wm9705_poll_sample()
235 timeout--; in wm9705_poll_sample()
241 wm->pen_probably_down = 0; in wm9705_poll_sample()
243 dev_dbg(wm->dev, "adc sample timeout"); in wm9705_poll_sample()
248 if (wm->mach_ops && wm->mach_ops->post_sample) in wm9705_poll_sample()
249 wm->mach_ops->post_sample(adcsel); in wm9705_poll_sample()
253 dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x", in wm9705_poll_sample()
260 wm->pen_probably_down = 0; in wm9705_poll_sample()
274 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_X | WM97XX_PEN_DOWN, &data->x); in wm9705_poll_touch()
277 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_Y | WM97XX_PEN_DOWN, &data->y); in wm9705_poll_touch()
281 rc = wm9705_poll_sample(wm, WM97XX_ADCSEL_PRES | WM97XX_PEN_DOWN, &data->p); in wm9705_poll_touch()
285 data->p = DEFAULT_PRESSURE; in wm9705_poll_touch()
299 dig1 = wm->dig[1]; in wm9705_acc_enable()
300 dig2 = wm->dig[2]; in wm9705_acc_enable()
304 if (wm->mach_ops->acc_startup && in wm9705_acc_enable()
305 (ret = wm->mach_ops->acc_startup(wm)) < 0) in wm9705_acc_enable()
310 WM97XX_DELAY(delay) | in wm9705_acc_enable()
311 WM97XX_SLT(wm->acc_slot) | in wm9705_acc_enable()
312 WM97XX_RATE(wm->acc_rate); in wm9705_acc_enable()
319 if (wm->mach_ops->acc_shutdown) in wm9705_acc_enable()
320 wm->mach_ops->acc_shutdown(wm); in wm9705_acc_enable()