blob: ac85f2061351996e871da73a26fd0dcf81293bad [file] [log] [blame]
anish kumar19939862012-08-17 09:57:22 -07001/*
2 * include/linux/extcon/extcon-adc-jack.h
3 *
4 * Analog Jack extcon driver with ADC-based detection capability.
5 *
6 * Copyright (C) 2012 Samsung Electronics
7 * MyungJoo Ham <myungjoo.ham@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#ifndef _EXTCON_ADC_JACK_H_
16#define _EXTCON_ADC_JACK_H_ __FILE__
17
18#include <linux/module.h>
19#include <linux/extcon.h>
20
21/**
22 * struct adc_jack_cond - condition to use an extcon state
Chanwoo Choia75e1c72013-08-31 13:16:49 +090023 * @state: the corresponding extcon state (if 0, this struct
24 * denotes the last adc_jack_cond element among the array)
25 * @min_adc: min adc value for this condition
26 * @max_adc: max adc value for this condition
anish kumar19939862012-08-17 09:57:22 -070027 *
28 * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means
29 * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and
30 * 1 are attached (1<<0 | 1<<1 == 0x3)
31 *
32 * Note that you don't need to describe condition for "no cable attached"
33 * because when no adc_jack_cond is met, state = 0 is automatically chosen.
34 */
35struct adc_jack_cond {
Chanwoo Choia75e1c72013-08-31 13:16:49 +090036 u32 state; /* extcon state value. 0 if invalid */
anish kumar19939862012-08-17 09:57:22 -070037 u32 min_adc;
38 u32 max_adc;
39};
40
41/**
42 * struct adc_jack_pdata - platform data for adc jack device.
Chanwoo Choia75e1c72013-08-31 13:16:49 +090043 * @name: name of the extcon device. If null, "adc-jack" is used.
44 * @consumer_channel: Unique name to identify the channel on the consumer
45 * side. This typically describes the channels used within
46 * the consumer. E.g. 'battery_voltage'
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +090047 * @cable_names: array of extcon id for supported cables.
Chanwoo Choia75e1c72013-08-31 13:16:49 +090048 * @adc_contitions: array of struct adc_jack_cond conditions ending
49 * with .state = 0 entry. This describes how to decode
50 * adc values into extcon state.
51 * @irq_flags: irq flags used for the @irq
52 * @handling_delay_ms: in some devices, we need to read ADC value some
53 * milli-seconds after the interrupt occurs. You may
54 * describe such delays with @handling_delay_ms, which
55 * is rounded-off by jiffies.
Venkat Reddy Talla1b6cf312016-06-30 17:54:00 +090056 * @wakeup_source: flag to wake up the system for extcon events.
anish kumar19939862012-08-17 09:57:22 -070057 */
58struct adc_jack_pdata {
59 const char *name;
60 const char *consumer_channel;
Chanwoo Choia75e1c72013-08-31 13:16:49 +090061
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +090062 const enum extcon *cable_names;
Chanwoo Choia75e1c72013-08-31 13:16:49 +090063
anish kumar19939862012-08-17 09:57:22 -070064 /* The last entry's state should be 0 */
65 struct adc_jack_cond *adc_conditions;
66
67 unsigned long irq_flags;
68 unsigned long handling_delay_ms; /* in ms */
Venkat Reddy Talla1b6cf312016-06-30 17:54:00 +090069 bool wakeup_source;
anish kumar19939862012-08-17 09:57:22 -070070};
71
72#endif /* _EXTCON_ADC_JACK_H */