// SPDX-License-Identifier: GPL-2.0-or-later /* * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs. * * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC. * Author: Liam Girdwood <[email protected]> * Parts Copyright : Ian Molton <[email protected]> * Andrew Zabolotny <[email protected]> * Russell King <[email protected]> */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/input.h> #include <linux/delay.h> #include <linux/bitops.h> #include <linux/wm97xx.h> #define TS_NAME … #define WM9712_VERSION … #define DEFAULT_PRESSURE … /* * Module parameters */ /* * Set internal pull up for pen detect. * * Pull up is in the range 1.02k (least sensitive) to 64k (most sensitive) * i.e. pull up resistance = 64k Ohms / rpu. * * Adjust this value if you are having problems with pen detect not * detecting any down event. */ static int rpu = …; module_param(rpu, int, 0); MODULE_PARM_DESC(…) …; /* * Set current used for pressure measurement. * * Set pil = 2 to use 400uA * pil = 1 to use 200uA and * pil = 0 to disable pressure measurement. * * This is used to increase the range of values returned by the adc * when measureing touchpanel pressure. */ static int pil; module_param(pil, int, 0); MODULE_PARM_DESC(…) …; /* * Set threshold for pressure measurement. * * Pen down pressure below threshold is ignored. */ static int pressure = …; module_param(pressure, int, 0); MODULE_PARM_DESC(…) …; /* * Set adc sample delay. * * For accurate touchpanel measurements, some settling time may be * required between the switch matrix applying a voltage across the * touchpanel plate and the ADC sampling the signal. * * This delay can be set by setting delay = n, where n is the array * position of the delay in the array delay_table below. * Long delays > 1ms are supported for completeness, but are not * recommended. */ static int delay = …; module_param(delay, int, 0); MODULE_PARM_DESC(…) …; /* * Set five_wire = 1 to use a 5 wire touchscreen. * * NOTE: Five wire mode does not allow for readback of pressure. */ static int five_wire; module_param(five_wire, int, 0); MODULE_PARM_DESC(…) …; /* * Set adc mask function. * * Sources of glitch noise, such as signals driving an LCD display, may feed * through to the touch screen plates and affect measurement accuracy. In * order to minimise this, a signal may be applied to the MASK pin to delay or * synchronise the sampling. * * 0 = No delay or sync * 1 = High on pin stops conversions * 2 = Edge triggered, edge on pin delays conversion by delay param (above) * 3 = Edge triggered, edge on pin starts conversion after delay param */ static int mask; module_param(mask, int, 0); MODULE_PARM_DESC(…) …; /* * Coordinate Polling Enable. * * Set to 1 to enable coordinate polling. e.g. x,y[,p] is sampled together * for every poll. */ static int coord; module_param(coord, int, 0); MODULE_PARM_DESC(…) …; /* * ADC sample delay times in uS */ static const int delay_table[] = …; /* * Delay after issuing a POLL command. * * The delay is 3 AC97 link frames + the touchpanel settling delay */ static inline void poll_delay(int d) { … } /* * set up the physical settings of the WM9712 */ static void wm9712_phy_init(struct wm97xx *wm) { … } static void wm9712_dig_enable(struct wm97xx *wm, int enable) { … } static void wm9712_aux_prepare(struct wm97xx *wm) { … } static void wm9712_dig_restore(struct wm97xx *wm) { … } static inline int is_pden(struct wm97xx *wm) { … } /* * Read a sample from the WM9712 adc in polling mode. */ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) { … } /* * Read a coord from the WM9712 adc in polling mode. */ static int wm9712_poll_coord(struct wm97xx *wm, struct wm97xx_data *data) { … } /* * Sample the WM9712 touchscreen in polling mode */ static int wm9712_poll_touch(struct wm97xx *wm, struct wm97xx_data *data) { … } /* * Enable WM9712 continuous mode, i.e. touch data is streamed across * an AC97 slot */ static int wm9712_acc_enable(struct wm97xx *wm, int enable) { … } struct wm97xx_codec_drv wm9712_codec = …; EXPORT_SYMBOL_GPL(…); /* Module information */ MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;