119939860Sanish kumar /* 219939860Sanish kumar * include/linux/extcon/extcon-adc-jack.h 319939860Sanish kumar * 419939860Sanish kumar * Analog Jack extcon driver with ADC-based detection capability. 519939860Sanish kumar * 619939860Sanish kumar * Copyright (C) 2012 Samsung Electronics 719939860Sanish kumar * MyungJoo Ham <myungjoo.ham@samsung.com> 819939860Sanish kumar * 919939860Sanish kumar * This program is free software; you can redistribute it and/or modify 1019939860Sanish kumar * it under the terms of the GNU General Public License version 2 as 1119939860Sanish kumar * published by the Free Software Foundation. 1219939860Sanish kumar * 1319939860Sanish kumar */ 1419939860Sanish kumar 1519939860Sanish kumar #ifndef _EXTCON_ADC_JACK_H_ 1619939860Sanish kumar #define _EXTCON_ADC_JACK_H_ __FILE__ 1719939860Sanish kumar 1819939860Sanish kumar #include <linux/module.h> 1919939860Sanish kumar #include <linux/extcon.h> 2019939860Sanish kumar 2119939860Sanish kumar /** 2219939860Sanish kumar * struct adc_jack_cond - condition to use an extcon state 23*a75e1c73SChanwoo Choi * @state: the corresponding extcon state (if 0, this struct 24*a75e1c73SChanwoo Choi * denotes the last adc_jack_cond element among the array) 25*a75e1c73SChanwoo Choi * @min_adc: min adc value for this condition 26*a75e1c73SChanwoo Choi * @max_adc: max adc value for this condition 2719939860Sanish kumar * 2819939860Sanish kumar * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means 2919939860Sanish kumar * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and 3019939860Sanish kumar * 1 are attached (1<<0 | 1<<1 == 0x3) 3119939860Sanish kumar * 3219939860Sanish kumar * Note that you don't need to describe condition for "no cable attached" 3319939860Sanish kumar * because when no adc_jack_cond is met, state = 0 is automatically chosen. 3419939860Sanish kumar */ 3519939860Sanish kumar struct adc_jack_cond { 3619939860Sanish kumar u32 state; /* extcon state value. 0 if invalid */ 3719939860Sanish kumar u32 min_adc; 3819939860Sanish kumar u32 max_adc; 3919939860Sanish kumar }; 4019939860Sanish kumar 4119939860Sanish kumar /** 4219939860Sanish kumar * struct adc_jack_pdata - platform data for adc jack device. 43*a75e1c73SChanwoo Choi * @name: name of the extcon device. If null, "adc-jack" is used. 44*a75e1c73SChanwoo Choi * @consumer_channel: Unique name to identify the channel on the consumer 4519939860Sanish kumar * side. This typically describes the channels used within 4619939860Sanish kumar * the consumer. E.g. 'battery_voltage' 47*a75e1c73SChanwoo Choi * @cable_names: array of cable names ending with null. 48*a75e1c73SChanwoo Choi * @adc_contitions: array of struct adc_jack_cond conditions ending 4919939860Sanish kumar * with .state = 0 entry. This describes how to decode 5019939860Sanish kumar * adc values into extcon state. 51*a75e1c73SChanwoo Choi * @irq_flags: irq flags used for the @irq 52*a75e1c73SChanwoo Choi * @handling_delay_ms: in some devices, we need to read ADC value some 5319939860Sanish kumar * milli-seconds after the interrupt occurs. You may 5419939860Sanish kumar * describe such delays with @handling_delay_ms, which 5519939860Sanish kumar * is rounded-off by jiffies. 5619939860Sanish kumar */ 5719939860Sanish kumar struct adc_jack_pdata { 5819939860Sanish kumar const char *name; 5919939860Sanish kumar const char *consumer_channel; 60*a75e1c73SChanwoo Choi 61*a75e1c73SChanwoo Choi /* The last entry should be NULL */ 6219939860Sanish kumar const char **cable_names; 63*a75e1c73SChanwoo Choi 6419939860Sanish kumar /* The last entry's state should be 0 */ 6519939860Sanish kumar struct adc_jack_cond *adc_conditions; 6619939860Sanish kumar 6719939860Sanish kumar unsigned long irq_flags; 6819939860Sanish kumar unsigned long handling_delay_ms; /* in ms */ 6919939860Sanish kumar }; 7019939860Sanish kumar 7119939860Sanish kumar #endif /* _EXTCON_ADC_JACK_H */ 72