From 0324bf59a8810cadf35d67f71f5ee409834ec4ee Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 4 Feb 2014 00:23:35 +0100 Subject: imx233: make button-lradc drive able to handle VDDIO derived values In most devices, the button ladder is not actually derived from VDDIO but from a constant voltage source, making it very easy to read it. However on some devices like ther ZEN X-Fi Style, the ladder is wired to VDDIO we can be changed so it's crucial that the button driver correctly scales the values wrt VDDIO. Change-Id: Ifc11abe2838fa7d16d0d60ecd96964a8dc5ea6d7 --- firmware/target/arm/imx233/button-lradc-imx233.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'firmware/target/arm/imx233/button-lradc-imx233.h') diff --git a/firmware/target/arm/imx233/button-lradc-imx233.h b/firmware/target/arm/imx233/button-lradc-imx233.h index eac5517adf..d96823fcdc 100644 --- a/firmware/target/arm/imx233/button-lradc-imx233.h +++ b/firmware/target/arm/imx233/button-lradc-imx233.h @@ -30,7 +30,19 @@ * - imx233_button_lradc_mapping: target-defined table of adc values and mapping * - IMX233_BUTTON_LRADC_CHANNEL: lradc channel to use * - IMX233_BUTTON_LRADC_HOLD_DET: define hold detection method (ignored if !HAS_BUTTON_HOLD) + * - IMX233_BUTTON_LRADC_MODE: define the button lradc mode * + * The LRADC code supports two modes of operations: VDDIO relative or absolute. + * In the (default) absolute value mode, the LRADC channel is sampled and its value + * is compared to the one in the imx233_button_lradc_mapping table. This is + * appropriate when the resistor ladder is derived from a fixed voltage. + * In the VDDIO relative mode, the values in imx233_button_lradc_mapping are + * the values for a specific value of VDDIO which is given by + * IMX233_BUTTON_LRADC_VDDIO. In this mode, the code will also sample VDDIO + * and do the following comparison: + * lradc_value <=? imx233_button_lradc_mapping[i] * vddio_ref / vddio_value + * where vddio_ref is IMX233_BUTTON_LRADC_VDDIO. + * * The available values of IMX233_BUTTON_LRADC_HOLD are: * - BLH_ADC: detect hold using adc * - BLH_EXT: target button driver implements imx233_button_lradc_hold() using @@ -40,6 +52,10 @@ * + BLH_GPIO_PIN: pin in bank * + BLH_GPIO_INVERTED: define if inverted, default is active high * + BLH_GPIO_PULLUP: define if pins needs pullup + * + * WARNING + * There must always be entry in imx233_button_lradc_mapping whose value is the steady + * value of the channel when no button is pressed, and which maps to no button (.btn = 0) */ /* hold detect method */ @@ -74,5 +90,8 @@ int imx233_button_lradc_read(int others); bool imx233_button_lradc_hold(void); #endif int imx233_button_lradc_read_raw(void); // return raw adc value +#ifdef IMX233_BUTTON_LRADC_VDDIO +int imx233_button_lradc_read_vddio(void); +#endif #endif /* __button_lradc_imx233__ */ -- cgit v1.2.3