diff options
author | anish kumar <anish198519851985@gmail.com> | 2012-08-10 03:29:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 13:37:00 -0400 |
commit | 980d7929816236476967218645c30acc022042eb (patch) | |
tree | d1edebc580e332a34e56a9af0af326e049e274c8 /include/linux/extcon | |
parent | 34efe4dc47227264a38e60c878b4831d5f0d5a33 (diff) |
Extcon: adc_jack: adc-jack driver to support 3.5 pi or simliar devices
External connector devices that decides connection information based on
ADC values may use adc-jack device driver. The user simply needs to
provide a table of adc range and connection states. Then, extcon
framework will automatically notify others.
Changes in V1:
added Lars-Peter Clausen suggested changes:
Using macros to get rid of boiler plate code such as devm_kzalloc
and module_platform_driver.Other changes suggested are related to
coding guidelines.
Changes in V2:
Removed some unnecessary checks and changed the way we are un-regitering
extcon and freeing the irq while removing.
Changes in V3:
Renamed the files to comply with extcon naming.
Changes in V4:
Added the cancel_work_sync during removing of driver.
Changes in V5:
Added the dependency of IIO in Kconfig.
Changes in V6:
Some nitpicks related to naming.
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: anish kumar <anish.singh@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/extcon')
-rw-r--r-- | include/linux/extcon/extcon-adc-jack.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h new file mode 100644 index 000000000000..a1603cfc504f --- /dev/null +++ b/include/linux/extcon/extcon-adc-jack.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
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 | ||
23 | * @state - the corresponding extcon state (if 0, this struct denotes | ||
24 | * 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 | ||
27 | * | ||
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 | */ | ||
35 | struct adc_jack_cond { | ||
36 | u32 state; /* extcon state value. 0 if invalid */ | ||
37 | u32 min_adc; | ||
38 | u32 max_adc; | ||
39 | }; | ||
40 | |||
41 | /** | ||
42 | * struct adc_jack_pdata - platform data for adc jack device. | ||
43 | * @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' | ||
47 | * @cable_names - array of cable names ending with null. If the array itself | ||
48 | * if null, extcon standard cable names are chosen. | ||
49 | * @adc_contitions - array of struct adc_jack_cond conditions ending | ||
50 | * with .state = 0 entry. This describes how to decode | ||
51 | * adc values into extcon state. | ||
52 | * @irq_flags - irq flags used for the @irq | ||
53 | * @handling_delay_ms - in some devices, we need to read ADC value some | ||
54 | * milli-seconds after the interrupt occurs. You may | ||
55 | * describe such delays with @handling_delay_ms, which | ||
56 | * is rounded-off by jiffies. | ||
57 | */ | ||
58 | struct adc_jack_pdata { | ||
59 | const char *name; | ||
60 | const char *consumer_channel; | ||
61 | /* | ||
62 | * NULL if standard extcon names are used. | ||
63 | * The last entry should be NULL | ||
64 | */ | ||
65 | const char **cable_names; | ||
66 | /* The last entry's state should be 0 */ | ||
67 | struct adc_jack_cond *adc_conditions; | ||
68 | |||
69 | unsigned long irq_flags; | ||
70 | unsigned long handling_delay_ms; /* in ms */ | ||
71 | }; | ||
72 | |||
73 | #endif /* _EXTCON_ADC_JACK_H */ | ||