blob: 19b437e9c080b6d3b651f119eb2621405fc28f51 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
anish kumar19939862012-08-17 09:57:22 -07002/*
3 * include/linux/extcon/extcon-adc-jack.h
4 *
5 * Analog Jack extcon driver with ADC-based detection capability.
6 *
7 * Copyright (C) 2012 Samsung Electronics
8 * MyungJoo Ham <myungjoo.ham@samsung.com>
anish kumar19939862012-08-17 09:57:22 -07009 */
10
11#ifndef _EXTCON_ADC_JACK_H_
12#define _EXTCON_ADC_JACK_H_ __FILE__
13
14#include <linux/module.h>
15#include <linux/extcon.h>
16
17/**
18 * struct adc_jack_cond - condition to use an extcon state
Chanwoo Choia75e1c72013-08-31 13:16:49 +090019 * denotes the last adc_jack_cond element among the array)
Chanwoo Choia7da72e2016-07-18 16:16:29 +090020 * @id: the unique id of each external connector
Chanwoo Choia75e1c72013-08-31 13:16:49 +090021 * @min_adc: min adc value for this condition
22 * @max_adc: max adc value for this condition
anish kumar19939862012-08-17 09:57:22 -070023 *
24 * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means
25 * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and
26 * 1 are attached (1<<0 | 1<<1 == 0x3)
27 *
28 * Note that you don't need to describe condition for "no cable attached"
29 * because when no adc_jack_cond is met, state = 0 is automatically chosen.
30 */
31struct adc_jack_cond {
Chanwoo Choia7da72e2016-07-18 16:16:29 +090032 unsigned int id;
anish kumar19939862012-08-17 09:57:22 -070033 u32 min_adc;
34 u32 max_adc;
35};
36
37/**
38 * struct adc_jack_pdata - platform data for adc jack device.
Chanwoo Choia75e1c72013-08-31 13:16:49 +090039 * @name: name of the extcon device. If null, "adc-jack" is used.
40 * @consumer_channel: Unique name to identify the channel on the consumer
41 * side. This typically describes the channels used within
42 * the consumer. E.g. 'battery_voltage'
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +090043 * @cable_names: array of extcon id for supported cables.
Chanwoo Choia75e1c72013-08-31 13:16:49 +090044 * @adc_contitions: array of struct adc_jack_cond conditions ending
45 * with .state = 0 entry. This describes how to decode
46 * adc values into extcon state.
47 * @irq_flags: irq flags used for the @irq
48 * @handling_delay_ms: in some devices, we need to read ADC value some
49 * milli-seconds after the interrupt occurs. You may
50 * describe such delays with @handling_delay_ms, which
51 * is rounded-off by jiffies.
Venkat Reddy Talla1b6cf312016-06-30 17:54:00 +090052 * @wakeup_source: flag to wake up the system for extcon events.
anish kumar19939862012-08-17 09:57:22 -070053 */
54struct adc_jack_pdata {
55 const char *name;
56 const char *consumer_channel;
Chanwoo Choia75e1c72013-08-31 13:16:49 +090057
Peter Foley8a522bf2016-11-27 21:37:20 -050058 const unsigned int *cable_names;
Chanwoo Choia75e1c72013-08-31 13:16:49 +090059
anish kumar19939862012-08-17 09:57:22 -070060 /* The last entry's state should be 0 */
61 struct adc_jack_cond *adc_conditions;
62
63 unsigned long irq_flags;
64 unsigned long handling_delay_ms; /* in ms */
Venkat Reddy Talla1b6cf312016-06-30 17:54:00 +090065 bool wakeup_source;
anish kumar19939862012-08-17 09:57:22 -070066};
67
68#endif /* _EXTCON_ADC_JACK_H */