xref: /linux/include/linux/extcon/extcon-adc-jack.h (revision 8a522bf2d4f788306443d36b26b54f0aedcdfdbe)
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
23a75e1c73SChanwoo Choi  *			denotes the last adc_jack_cond element among the array)
24a7da72eeSChanwoo Choi  * @id:			the unique id of each external connector
25a75e1c73SChanwoo Choi  * @min_adc:		min adc value for this condition
26a75e1c73SChanwoo 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 {
36a7da72eeSChanwoo Choi 	unsigned int id;
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.
43a75e1c73SChanwoo Choi  * @name:		name of the extcon device. If null, "adc-jack" is used.
44a75e1c73SChanwoo 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'
472a9de9c0SChanwoo Choi  * @cable_names:	array of extcon id for supported cables.
48a75e1c73SChanwoo 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.
51a75e1c73SChanwoo Choi  * @irq_flags:		irq flags used for the @irq
52a75e1c73SChanwoo 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.
561b6cf310SVenkat Reddy Talla  * @wakeup_source:	flag to wake up the system for extcon events.
5719939860Sanish kumar  */
5819939860Sanish kumar struct adc_jack_pdata {
5919939860Sanish kumar 	const char *name;
6019939860Sanish kumar 	const char *consumer_channel;
61a75e1c73SChanwoo Choi 
62*8a522bf2SPeter Foley 	const unsigned int *cable_names;
63a75e1c73SChanwoo 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 */
691b6cf310SVenkat Reddy Talla 	bool wakeup_source;
7019939860Sanish kumar };
7119939860Sanish kumar 
7219939860Sanish kumar #endif /* _EXTCON_ADC_JACK_H */
73