2012-08-18 00:57:22 +08:00
|
|
|
/*
|
|
|
|
* include/linux/extcon/extcon-adc-jack.h
|
|
|
|
*
|
|
|
|
* Analog Jack extcon driver with ADC-based detection capability.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Samsung Electronics
|
|
|
|
* MyungJoo Ham <myungjoo.ham@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _EXTCON_ADC_JACK_H_
|
|
|
|
#define _EXTCON_ADC_JACK_H_ __FILE__
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/extcon.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct adc_jack_cond - condition to use an extcon state
|
2013-08-31 12:16:49 +08:00
|
|
|
* denotes the last adc_jack_cond element among the array)
|
2016-07-18 15:16:29 +08:00
|
|
|
* @id: the unique id of each external connector
|
2013-08-31 12:16:49 +08:00
|
|
|
* @min_adc: min adc value for this condition
|
|
|
|
* @max_adc: max adc value for this condition
|
2012-08-18 00:57:22 +08:00
|
|
|
*
|
|
|
|
* For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means
|
|
|
|
* that if ADC value is between (inclusive) 100 and 200, than the cable 0 and
|
|
|
|
* 1 are attached (1<<0 | 1<<1 == 0x3)
|
|
|
|
*
|
|
|
|
* Note that you don't need to describe condition for "no cable attached"
|
|
|
|
* because when no adc_jack_cond is met, state = 0 is automatically chosen.
|
|
|
|
*/
|
|
|
|
struct adc_jack_cond {
|
2016-07-18 15:16:29 +08:00
|
|
|
unsigned int id;
|
2012-08-18 00:57:22 +08:00
|
|
|
u32 min_adc;
|
|
|
|
u32 max_adc;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct adc_jack_pdata - platform data for adc jack device.
|
2013-08-31 12:16:49 +08:00
|
|
|
* @name: name of the extcon device. If null, "adc-jack" is used.
|
|
|
|
* @consumer_channel: Unique name to identify the channel on the consumer
|
|
|
|
* side. This typically describes the channels used within
|
|
|
|
* the consumer. E.g. 'battery_voltage'
|
extcon: Use the unique id for external connector instead of string
This patch uses the unique id to identify the type of external connector instead
of string name. The string name have the many potential issues. So, this patch
defines the 'extcon' enumeration which includes all supported external connector
on EXTCON subsystem. If new external connector is necessary, the unique id of
new connector have to be added in 'extcon' enumeration. There are current
supported external connector in 'enum extcon' as following:
enum extcon {
EXTCON_NONE = 0x0,
/* USB external connector */
EXTCON_USB = 0x1,
EXTCON_USB_HOST = 0x2,
/* Charger external connector */
EXTCON_TA = 0x10,
EXTCON_FAST_CHARGER = 0x11,
EXTCON_SLOW_CHARGER = 0x12,
EXTCON_CHARGE_DOWNSTREAM = 0x13,
/* Audio and video external connector */
EXTCON_LINE_IN = 0x20,
EXTCON_LINE_OUT = 0x21,
EXTCON_MICROPHONE = 0x22,
EXTCON_HEADPHONE = 0x23,
EXTCON_HDMI = 0x30,
EXTCON_MHL = 0x31,
EXTCON_DVI = 0x32,
EXTCON_VGA = 0x33,
EXTCON_SPDIF_IN = 0x34,
EXTCON_SPDIF_OUT = 0x35,
EXTCON_VIDEO_IN = 0x36,
EXTCON_VIDEO_OUT = 0x37,
/* Miscellaneous external connector */
EXTCON_DOCK = 0x50,
EXTCON_JIG = 0x51,
EXTCON_MECHANICAL = 0x52,
EXTCON_END,
};
For example in extcon-arizona.c:
To use unique id removes the potential issue about handling
the inconsistent name of external connector with string.
- Previously, use the string to register the type of arizona jack connector
static const char *arizona_cable[] = {
"Mechanical",
"Microphone",
"Headphone",
"Line-out",
};
- Newly, use the unique id to register the type of arizona jack connector
static const enum extcon arizona_cable[] = {
EXTCON_MECHANICAL,
EXTCON_MICROPHONE,
EXTCON_HEADPHONE,
EXTCON_LINE_OUT,
EXTCON_NONE,
};
And this patch modify the prototype of extcon_{get|set}_cable_state_() which
uses the 'enum extcon id' instead of 'cable_index'. Because although one more
extcon drivers support USB cable, each extcon driver might has the differnt
'cable_index' for USB cable. All extcon drivers can use the unique id number
for same external connector with modified extcon_{get|set}_cable_state_().
- Previously, use 'cable_index' on these functions:
extcon_get_cable_state_(struct extcon_dev*, int cable_index)
extcon_set_cable_state_(struct extcon_dev*, int cable_index, bool state)
-Newly, use 'enum extcon id' on these functions:
extcon_get_cable_state_(struct extcon_dev*, enum extcon id)
extcon_set_cable_state_(struct extcon_dev*, enum extcon id, bool state)
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[arnd: Report the build break about drivers/usb/phy/phy-tahvo.c after using the
unique id for external connector insteadf of string]
Reported-by: Arnd Bergmann <arnd@arndb.de>
[dan.carpenter: Report the build warning of extcon_{set|get}_cable_state_()]
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
2015-04-24 18:16:05 +08:00
|
|
|
* @cable_names: array of extcon id for supported cables.
|
2013-08-31 12:16:49 +08:00
|
|
|
* @adc_contitions: array of struct adc_jack_cond conditions ending
|
|
|
|
* with .state = 0 entry. This describes how to decode
|
|
|
|
* adc values into extcon state.
|
|
|
|
* @irq_flags: irq flags used for the @irq
|
|
|
|
* @handling_delay_ms: in some devices, we need to read ADC value some
|
|
|
|
* milli-seconds after the interrupt occurs. You may
|
|
|
|
* describe such delays with @handling_delay_ms, which
|
|
|
|
* is rounded-off by jiffies.
|
2016-06-30 16:54:00 +08:00
|
|
|
* @wakeup_source: flag to wake up the system for extcon events.
|
2012-08-18 00:57:22 +08:00
|
|
|
*/
|
|
|
|
struct adc_jack_pdata {
|
|
|
|
const char *name;
|
|
|
|
const char *consumer_channel;
|
2013-08-31 12:16:49 +08:00
|
|
|
|
extcon: Use the unique id for external connector instead of string
This patch uses the unique id to identify the type of external connector instead
of string name. The string name have the many potential issues. So, this patch
defines the 'extcon' enumeration which includes all supported external connector
on EXTCON subsystem. If new external connector is necessary, the unique id of
new connector have to be added in 'extcon' enumeration. There are current
supported external connector in 'enum extcon' as following:
enum extcon {
EXTCON_NONE = 0x0,
/* USB external connector */
EXTCON_USB = 0x1,
EXTCON_USB_HOST = 0x2,
/* Charger external connector */
EXTCON_TA = 0x10,
EXTCON_FAST_CHARGER = 0x11,
EXTCON_SLOW_CHARGER = 0x12,
EXTCON_CHARGE_DOWNSTREAM = 0x13,
/* Audio and video external connector */
EXTCON_LINE_IN = 0x20,
EXTCON_LINE_OUT = 0x21,
EXTCON_MICROPHONE = 0x22,
EXTCON_HEADPHONE = 0x23,
EXTCON_HDMI = 0x30,
EXTCON_MHL = 0x31,
EXTCON_DVI = 0x32,
EXTCON_VGA = 0x33,
EXTCON_SPDIF_IN = 0x34,
EXTCON_SPDIF_OUT = 0x35,
EXTCON_VIDEO_IN = 0x36,
EXTCON_VIDEO_OUT = 0x37,
/* Miscellaneous external connector */
EXTCON_DOCK = 0x50,
EXTCON_JIG = 0x51,
EXTCON_MECHANICAL = 0x52,
EXTCON_END,
};
For example in extcon-arizona.c:
To use unique id removes the potential issue about handling
the inconsistent name of external connector with string.
- Previously, use the string to register the type of arizona jack connector
static const char *arizona_cable[] = {
"Mechanical",
"Microphone",
"Headphone",
"Line-out",
};
- Newly, use the unique id to register the type of arizona jack connector
static const enum extcon arizona_cable[] = {
EXTCON_MECHANICAL,
EXTCON_MICROPHONE,
EXTCON_HEADPHONE,
EXTCON_LINE_OUT,
EXTCON_NONE,
};
And this patch modify the prototype of extcon_{get|set}_cable_state_() which
uses the 'enum extcon id' instead of 'cable_index'. Because although one more
extcon drivers support USB cable, each extcon driver might has the differnt
'cable_index' for USB cable. All extcon drivers can use the unique id number
for same external connector with modified extcon_{get|set}_cable_state_().
- Previously, use 'cable_index' on these functions:
extcon_get_cable_state_(struct extcon_dev*, int cable_index)
extcon_set_cable_state_(struct extcon_dev*, int cable_index, bool state)
-Newly, use 'enum extcon id' on these functions:
extcon_get_cable_state_(struct extcon_dev*, enum extcon id)
extcon_set_cable_state_(struct extcon_dev*, enum extcon id, bool state)
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
[arnd: Report the build break about drivers/usb/phy/phy-tahvo.c after using the
unique id for external connector insteadf of string]
Reported-by: Arnd Bergmann <arnd@arndb.de>
[dan.carpenter: Report the build warning of extcon_{set|get}_cable_state_()]
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
2015-04-24 18:16:05 +08:00
|
|
|
const enum extcon *cable_names;
|
2013-08-31 12:16:49 +08:00
|
|
|
|
2012-08-18 00:57:22 +08:00
|
|
|
/* The last entry's state should be 0 */
|
|
|
|
struct adc_jack_cond *adc_conditions;
|
|
|
|
|
|
|
|
unsigned long irq_flags;
|
|
|
|
unsigned long handling_delay_ms; /* in ms */
|
2016-06-30 16:54:00 +08:00
|
|
|
bool wakeup_source;
|
2012-08-18 00:57:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _EXTCON_ADC_JACK_H */
|