2012-04-20 12:16:22 +07:00
|
|
|
/*
|
|
|
|
* External connector (extcon) class driver
|
|
|
|
*
|
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 17:16:05 +07:00
|
|
|
* Copyright (C) 2015 Samsung Electronics
|
|
|
|
* Author: Chanwoo Choi <cw00.choi@samsung.com>
|
|
|
|
*
|
2012-04-20 12:16:22 +07:00
|
|
|
* Copyright (C) 2012 Samsung Electronics
|
|
|
|
* Author: Donggeun Kim <dg77.kim@samsung.com>
|
|
|
|
* Author: MyungJoo Ham <myungjoo.ham@samsung.com>
|
|
|
|
*
|
|
|
|
* based on switch class driver
|
|
|
|
* Copyright (C) 2008 Google, Inc.
|
|
|
|
* Author: Mike Lockwood <lockwood@android.com>
|
|
|
|
*
|
|
|
|
* This software is licensed under the terms of the GNU General Public
|
|
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
|
|
* may be copied, distributed, and modified under those terms.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_EXTCON_H__
|
|
|
|
#define __LINUX_EXTCON_H__
|
|
|
|
|
2012-11-08 16:39:41 +07:00
|
|
|
#include <linux/device.h>
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
|
2016-07-11 14:34:52 +07:00
|
|
|
/*
|
|
|
|
* Define the type of supported external connectors
|
|
|
|
*/
|
|
|
|
#define EXTCON_TYPE_USB BIT(0) /* USB connector */
|
|
|
|
#define EXTCON_TYPE_CHG BIT(1) /* Charger connector */
|
|
|
|
#define EXTCON_TYPE_JACK BIT(2) /* Jack connector */
|
|
|
|
#define EXTCON_TYPE_DISP BIT(3) /* Display connector */
|
|
|
|
#define EXTCON_TYPE_MISC BIT(4) /* Miscellaneous connector */
|
|
|
|
|
2015-06-12 09:10:06 +07:00
|
|
|
/*
|
|
|
|
* Define the unique id of supported external connectors
|
|
|
|
*/
|
2015-10-03 12:15:13 +07:00
|
|
|
#define EXTCON_NONE 0
|
2015-06-12 09:10:06 +07:00
|
|
|
|
2015-10-03 12:15:13 +07:00
|
|
|
/* USB external connector */
|
|
|
|
#define EXTCON_USB 1
|
|
|
|
#define EXTCON_USB_HOST 2
|
2015-06-12 09:10:06 +07:00
|
|
|
|
2015-10-03 12:15:13 +07:00
|
|
|
/* Charging external connector */
|
|
|
|
#define EXTCON_CHG_USB_SDP 5 /* Standard Downstream Port */
|
|
|
|
#define EXTCON_CHG_USB_DCP 6 /* Dedicated Charging Port */
|
|
|
|
#define EXTCON_CHG_USB_CDP 7 /* Charging Downstream Port */
|
|
|
|
#define EXTCON_CHG_USB_ACA 8 /* Accessory Charger Adapter */
|
|
|
|
#define EXTCON_CHG_USB_FAST 9
|
|
|
|
#define EXTCON_CHG_USB_SLOW 10
|
2016-08-05 16:15:46 +07:00
|
|
|
#define EXTCON_CHG_WPT 11 /* Wireless Power Transfer */
|
2015-06-12 09:10:06 +07:00
|
|
|
|
2015-10-03 12:15:13 +07:00
|
|
|
/* Jack external connector */
|
|
|
|
#define EXTCON_JACK_MICROPHONE 20
|
|
|
|
#define EXTCON_JACK_HEADPHONE 21
|
|
|
|
#define EXTCON_JACK_LINE_IN 22
|
|
|
|
#define EXTCON_JACK_LINE_OUT 23
|
|
|
|
#define EXTCON_JACK_VIDEO_IN 24
|
|
|
|
#define EXTCON_JACK_VIDEO_OUT 25
|
|
|
|
#define EXTCON_JACK_SPDIF_IN 26 /* Sony Philips Digital InterFace */
|
|
|
|
#define EXTCON_JACK_SPDIF_OUT 27
|
2015-06-12 09:10:06 +07:00
|
|
|
|
2015-10-03 12:15:13 +07:00
|
|
|
/* Display external connector */
|
|
|
|
#define EXTCON_DISP_HDMI 40 /* High-Definition Multimedia Interface */
|
|
|
|
#define EXTCON_DISP_MHL 41 /* Mobile High-Definition Link */
|
|
|
|
#define EXTCON_DISP_DVI 42 /* Digital Visual Interface */
|
|
|
|
#define EXTCON_DISP_VGA 43 /* Video Graphics Array */
|
2016-07-21 23:13:02 +07:00
|
|
|
#define EXTCON_DISP_DP 44 /* Display Port */
|
2016-08-05 15:49:23 +07:00
|
|
|
#define EXTCON_DISP_HMD 45 /* Head-Mounted Display */
|
2015-10-03 12:15:13 +07:00
|
|
|
|
|
|
|
/* Miscellaneous external connector */
|
|
|
|
#define EXTCON_DOCK 60
|
|
|
|
#define EXTCON_JIG 61
|
|
|
|
#define EXTCON_MECHANICAL 62
|
|
|
|
|
|
|
|
#define EXTCON_NUM 63
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
|
2016-07-11 17:30:43 +07:00
|
|
|
/*
|
|
|
|
* Define the property of supported external connectors.
|
|
|
|
*
|
|
|
|
* When adding the new extcon property, they *must* have
|
|
|
|
* the type/value/default information. Also, you *have to*
|
|
|
|
* modify the EXTCON_PROP_[type]_START/END definitions
|
|
|
|
* which mean the range of the supported properties
|
|
|
|
* for each extcon type.
|
|
|
|
*
|
|
|
|
* The naming style of property
|
|
|
|
* : EXTCON_PROP_[type]_[property name]
|
|
|
|
*
|
|
|
|
* EXTCON_PROP_USB_[property name] : USB property
|
|
|
|
* EXTCON_PROP_CHG_[property name] : Charger property
|
|
|
|
* EXTCON_PROP_JACK_[property name] : Jack property
|
|
|
|
* EXTCON_PROP_DISP_[property name] : Display property
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Properties of EXTCON_TYPE_USB.
|
|
|
|
*
|
|
|
|
* - EXTCON_PROP_USB_VBUS
|
|
|
|
* @type: integer (intval)
|
|
|
|
* @value: 0 (low) or 1 (high)
|
|
|
|
* @default: 0 (low)
|
2016-07-21 23:13:02 +07:00
|
|
|
* - EXTCON_PROP_USB_TYPEC_POLARITY
|
|
|
|
* @type: integer (intval)
|
|
|
|
* @value: 0 (normal) or 1 (flip)
|
|
|
|
* @default: 0 (normal)
|
2016-08-15 20:15:35 +07:00
|
|
|
* - EXTCON_PROP_USB_SS (SuperSpeed)
|
|
|
|
* @type: integer (intval)
|
|
|
|
* @value: 0 (USB/USB2) or 1 (USB3)
|
|
|
|
* @default: 0 (USB/USB2)
|
|
|
|
*
|
2016-07-11 17:30:43 +07:00
|
|
|
*/
|
|
|
|
#define EXTCON_PROP_USB_VBUS 0
|
2016-07-21 23:13:02 +07:00
|
|
|
#define EXTCON_PROP_USB_TYPEC_POLARITY 1
|
2016-08-15 20:15:35 +07:00
|
|
|
#define EXTCON_PROP_USB_SS 2
|
2016-07-11 17:30:43 +07:00
|
|
|
|
|
|
|
#define EXTCON_PROP_USB_MIN 0
|
2016-08-15 20:15:35 +07:00
|
|
|
#define EXTCON_PROP_USB_MAX 2
|
2016-07-11 17:30:43 +07:00
|
|
|
#define EXTCON_PROP_USB_CNT (EXTCON_PROP_USB_MAX - EXTCON_PROP_USB_MIN + 1)
|
|
|
|
|
|
|
|
/* Properties of EXTCON_TYPE_CHG. */
|
|
|
|
#define EXTCON_PROP_CHG_MIN 50
|
|
|
|
#define EXTCON_PROP_CHG_MAX 50
|
|
|
|
#define EXTCON_PROP_CHG_CNT (EXTCON_PROP_CHG_MAX - EXTCON_PROP_CHG_MIN + 1)
|
|
|
|
|
|
|
|
/* Properties of EXTCON_TYPE_JACK. */
|
|
|
|
#define EXTCON_PROP_JACK_MIN 100
|
|
|
|
#define EXTCON_PROP_JACK_MAX 100
|
|
|
|
#define EXTCON_PROP_JACK_CNT (EXTCON_PROP_JACK_MAX - EXTCON_PROP_JACK_MIN + 1)
|
|
|
|
|
2016-09-10 09:15:44 +07:00
|
|
|
/*
|
|
|
|
* Properties of EXTCON_TYPE_DISP.
|
|
|
|
*
|
|
|
|
* - EXTCON_PROP_DISP_HPD (Hot Plug Detect)
|
|
|
|
* @type: integer (intval)
|
|
|
|
* @value: 0 (no hpd) or 1 (hpd)
|
|
|
|
* @default: 0 (no hpd)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define EXTCON_PROP_DISP_HPD 150
|
|
|
|
|
2016-07-11 17:30:43 +07:00
|
|
|
/* Properties of EXTCON_TYPE_DISP. */
|
|
|
|
#define EXTCON_PROP_DISP_MIN 150
|
2016-09-10 09:15:44 +07:00
|
|
|
#define EXTCON_PROP_DISP_MAX 151
|
2016-07-11 17:30:43 +07:00
|
|
|
#define EXTCON_PROP_DISP_CNT (EXTCON_PROP_DISP_MAX - EXTCON_PROP_DISP_MIN + 1)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define the type of property's value.
|
|
|
|
*
|
|
|
|
* Define the property's value as union type. Because each property
|
|
|
|
* would need the different data type to store it.
|
|
|
|
*/
|
|
|
|
union extcon_property_value {
|
|
|
|
int intval; /* type : integer (intval) */
|
|
|
|
};
|
|
|
|
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
struct extcon_cable;
|
|
|
|
|
2012-04-20 12:16:22 +07:00
|
|
|
/**
|
|
|
|
* struct extcon_dev - An extcon device represents one external connector.
|
2013-08-31 11:16:49 +07:00
|
|
|
* @name: The name of this extcon device. Parent device name is
|
|
|
|
* used if NULL.
|
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 17:16:05 +07:00
|
|
|
* @supported_cable: Array of supported cable names ending with EXTCON_NONE.
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
* If supported_cable is NULL, cable name related APIs
|
|
|
|
* are disabled.
|
2012-11-20 17:22:33 +07:00
|
|
|
* @mutually_exclusive: Array of mutually exclusive set of cables that cannot
|
Extcon: support mutually exclusive relation between cables.
There could be cables that t recannot be attaches simulatenously. Extcon
device drivers may express such information via mutually_exclusive in
struct extcon_dev.
For example, for an extcon device with 16 cables (bits 0 to 15 are
available), if mutually_exclusive = { 0x7, 0xC0, 0x81, 0 }, then, the
following attachments are prohibitted.
{0, 1}
{0, 2}
{1, 2}
{6, 7}
{0, 7}
and every attachment set that are superset of one of the above.
For the detail, please refer to linux/include/linux/extcon.h.
The concept is suggested by NeilBrown <neilb@suse.de>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V5:
- Updated sysfs format
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:26 +07:00
|
|
|
* be attached simultaneously. The array should be
|
|
|
|
* ending with NULL or be NULL (no mutually exclusive
|
|
|
|
* cables). For example, if it is { 0x7, 0x30, 0}, then,
|
|
|
|
* {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot
|
|
|
|
* be attached simulataneously. {0x7, 0} is equivalent to
|
|
|
|
* {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
|
|
|
|
* can be no simultaneous connections.
|
2013-09-27 07:19:40 +07:00
|
|
|
* @dev: Device of this extcon.
|
2013-08-31 11:16:49 +07:00
|
|
|
* @state: Attach/detach state of this extcon. Do not provide at
|
|
|
|
* register-time.
|
|
|
|
* @nh: Notifier for the state change events from this extcon
|
2015-04-24 12:48:52 +07:00
|
|
|
* @entry: To support list of extcon devices so that users can
|
|
|
|
* search for extcon devices based on the extcon name.
|
2012-11-20 17:22:33 +07:00
|
|
|
* @lock:
|
|
|
|
* @max_supported: Internal value to store the number of cables.
|
|
|
|
* @extcon_dev_type: Device_type struct to provide attribute_groups
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
* customized for each extcon device.
|
2013-08-31 11:16:49 +07:00
|
|
|
* @cables: Sysfs subdirectories. Each represents one cable.
|
2012-04-20 12:16:22 +07:00
|
|
|
*
|
|
|
|
* In most cases, users only need to provide "User initializing data" of
|
|
|
|
* this struct when registering an extcon. In some exceptional cases,
|
|
|
|
* optional callbacks may be needed. However, the values in "internal data"
|
|
|
|
* are overwritten by register function.
|
|
|
|
*/
|
|
|
|
struct extcon_dev {
|
2013-08-31 11:16:49 +07:00
|
|
|
/* Optional user initializing data */
|
|
|
|
const char *name;
|
2015-06-12 09:10:06 +07:00
|
|
|
const unsigned int *supported_cable;
|
2013-08-31 11:16:49 +07:00
|
|
|
const u32 *mutually_exclusive;
|
2012-04-20 12:16:22 +07:00
|
|
|
|
2013-08-31 11:16:49 +07:00
|
|
|
/* Internal data. Please do not set. */
|
2013-09-27 07:19:40 +07:00
|
|
|
struct device dev;
|
extcon: Update the prototype of extcon_register_notifier() with enum extcon
Previously, extcon consumer driver used the extcon_register_interest()
to register the notifier chain and then to receive the notifier event
when external connector's state is changed. When registering the notifier chain
for specific external connector with extcon_register_interest(), it used the
the string name of external connector directly. There are potential problem
because of unclear, non-standard and inconsequent cable name. Namely,
it is not appropriate method to identify each external connector.
So, this patch modify the prototype of extcon_register_notifier() by using
the 'enum extcon' which are the unique id for each external connector
instead of unclear string method.
- Previously, the extcon consumer driver used the extcon_register_interest()
with 'cable_name' to point out the specific external connector. Also. it used
the un-needed structure (struct extcon_specific_cable_nb).
: int extcon_register_interest(struct extcon_specific_cable_nb *obj,
const char *extcon_name, const char *cable_name,
struct notifier_block *nb)
- Newly, the updated extcon_register_notifier() would definitely support
the same feature to detech the changed state of external connector without
any specific structure (struct extcon_specific_cable_nb).
: int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
struct notifier_block *nb)
This patch support the both extcon_register_interest() and new extcon_register_
notifier(). But the extcon_{register|unregister}_interest() will be deprecated
because extcon core would support the notifier event for extcon consumer driver
with only updated extcon_register_notifier() and 'extcon_specific_cable_nb'
will be removed if there are no extcon consumer driver with legacy
extcon_{register|unregister}_interest().
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2015-05-19 18:01:12 +07:00
|
|
|
struct raw_notifier_head *nh;
|
2012-04-20 12:16:24 +07:00
|
|
|
struct list_head entry;
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
int max_supported;
|
2013-08-31 11:16:49 +07:00
|
|
|
spinlock_t lock; /* could be called by irq handler */
|
|
|
|
u32 state;
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
|
|
|
|
/* /sys/class/extcon/.../cable.n/... */
|
|
|
|
struct device_type extcon_dev_type;
|
|
|
|
struct extcon_cable *cables;
|
2013-08-31 11:16:49 +07:00
|
|
|
|
Extcon: support mutually exclusive relation between cables.
There could be cables that t recannot be attaches simulatenously. Extcon
device drivers may express such information via mutually_exclusive in
struct extcon_dev.
For example, for an extcon device with 16 cables (bits 0 to 15 are
available), if mutually_exclusive = { 0x7, 0xC0, 0x81, 0 }, then, the
following attachments are prohibitted.
{0, 1}
{0, 2}
{1, 2}
{6, 7}
{0, 7}
and every attachment set that are superset of one of the above.
For the detail, please refer to linux/include/linux/extcon.h.
The concept is suggested by NeilBrown <neilb@suse.de>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V5:
- Updated sysfs format
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:26 +07:00
|
|
|
/* /sys/class/extcon/.../mutually_exclusive/... */
|
|
|
|
struct attribute_group attr_g_muex;
|
|
|
|
struct attribute **attrs_muex;
|
|
|
|
struct device_attribute *d_attrs_muex;
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
};
|
|
|
|
|
2012-04-20 12:16:22 +07:00
|
|
|
#if IS_ENABLED(CONFIG_EXTCON)
|
2012-04-20 12:16:24 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Following APIs are for notifiers or configurations.
|
|
|
|
* Notifiers are the external port and connection devices.
|
|
|
|
*/
|
2013-09-27 07:20:26 +07:00
|
|
|
extern int extcon_dev_register(struct extcon_dev *edev);
|
2012-04-20 12:16:22 +07:00
|
|
|
extern void extcon_dev_unregister(struct extcon_dev *edev);
|
2014-04-21 17:10:08 +07:00
|
|
|
extern int devm_extcon_dev_register(struct device *dev,
|
|
|
|
struct extcon_dev *edev);
|
|
|
|
extern void devm_extcon_dev_unregister(struct device *dev,
|
|
|
|
struct extcon_dev *edev);
|
2012-04-20 12:16:24 +07:00
|
|
|
extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
|
2012-04-20 12:16:22 +07:00
|
|
|
|
2014-04-24 17:46:49 +07:00
|
|
|
/*
|
|
|
|
* Following APIs control the memory of extcon device.
|
|
|
|
*/
|
2015-06-12 09:10:06 +07:00
|
|
|
extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable);
|
2014-04-24 17:46:49 +07:00
|
|
|
extern void extcon_dev_free(struct extcon_dev *edev);
|
2014-04-24 18:12:15 +07:00
|
|
|
extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
|
2015-06-12 09:10:06 +07:00
|
|
|
const unsigned int *cable);
|
2014-04-24 18:12:15 +07:00
|
|
|
extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev);
|
2014-04-24 17:46:49 +07:00
|
|
|
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
/*
|
2016-07-22 11:03:17 +07:00
|
|
|
* get/set_state access each bit of the 32b encoded state value.
|
2016-06-27 19:09:04 +07:00
|
|
|
* They are used to access the status of each cable based on the cable id.
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
*/
|
2016-07-22 11:03:17 +07:00
|
|
|
extern int extcon_get_state(struct extcon_dev *edev, unsigned int id);
|
|
|
|
extern int extcon_set_state(struct extcon_dev *edev, unsigned int id,
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
bool cable_state);
|
extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
synchronize the information between extcon provider driver
and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data.
extcon_set_state(edev, EXTCON_USB, 1);
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-07-22 11:16:34 +07:00
|
|
|
extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
|
|
|
|
bool cable_state);
|
|
|
|
/*
|
|
|
|
* Synchronize the state and property data for a specific external connector.
|
|
|
|
*/
|
|
|
|
extern int extcon_sync(struct extcon_dev *edev, unsigned int id);
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
|
2016-07-11 17:30:43 +07:00
|
|
|
/*
|
|
|
|
* get/set_property access the property value of each external connector.
|
|
|
|
* They are used to access the property of each cable based on the property id.
|
|
|
|
*/
|
|
|
|
extern int extcon_get_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value *prop_val);
|
|
|
|
extern int extcon_set_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value prop_val);
|
extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
synchronize the information between extcon provider driver
and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data.
extcon_set_state(edev, EXTCON_USB, 1);
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-07-22 11:16:34 +07:00
|
|
|
extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value prop_val);
|
2016-07-11 17:30:43 +07:00
|
|
|
|
2016-07-25 19:15:19 +07:00
|
|
|
/*
|
|
|
|
* get/set_property_capability set the capability of the property for each
|
|
|
|
* external connector. They are used to set the capability of the property
|
|
|
|
* of each external connector based on the id and property.
|
|
|
|
*/
|
|
|
|
extern int extcon_get_property_capability(struct extcon_dev *edev,
|
|
|
|
unsigned int id, unsigned int prop);
|
|
|
|
extern int extcon_set_property_capability(struct extcon_dev *edev,
|
|
|
|
unsigned int id, unsigned int prop);
|
|
|
|
|
2012-04-20 12:16:24 +07:00
|
|
|
/*
|
|
|
|
* Following APIs are to monitor every action of a notifier.
|
2012-08-23 07:11:54 +07:00
|
|
|
* Registrar gets notified for every external port of a connection device.
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
* Probably this could be used to debug an action of notifier; however,
|
2012-08-23 07:11:54 +07:00
|
|
|
* we do not recommend to use this for normal 'notifiee' device drivers who
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
* want to be notified by a specific external port of the notifier.
|
2012-04-20 12:16:24 +07:00
|
|
|
*/
|
2015-06-12 09:10:06 +07:00
|
|
|
extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
|
extcon: Update the prototype of extcon_register_notifier() with enum extcon
Previously, extcon consumer driver used the extcon_register_interest()
to register the notifier chain and then to receive the notifier event
when external connector's state is changed. When registering the notifier chain
for specific external connector with extcon_register_interest(), it used the
the string name of external connector directly. There are potential problem
because of unclear, non-standard and inconsequent cable name. Namely,
it is not appropriate method to identify each external connector.
So, this patch modify the prototype of extcon_register_notifier() by using
the 'enum extcon' which are the unique id for each external connector
instead of unclear string method.
- Previously, the extcon consumer driver used the extcon_register_interest()
with 'cable_name' to point out the specific external connector. Also. it used
the un-needed structure (struct extcon_specific_cable_nb).
: int extcon_register_interest(struct extcon_specific_cable_nb *obj,
const char *extcon_name, const char *cable_name,
struct notifier_block *nb)
- Newly, the updated extcon_register_notifier() would definitely support
the same feature to detech the changed state of external connector without
any specific structure (struct extcon_specific_cable_nb).
: int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
struct notifier_block *nb)
This patch support the both extcon_register_interest() and new extcon_register_
notifier(). But the extcon_{register|unregister}_interest() will be deprecated
because extcon core would support the notifier event for extcon consumer driver
with only updated extcon_register_notifier() and 'extcon_specific_cable_nb'
will be removed if there are no extcon consumer driver with legacy
extcon_{register|unregister}_interest().
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2015-05-19 18:01:12 +07:00
|
|
|
struct notifier_block *nb);
|
2015-06-12 09:10:06 +07:00
|
|
|
extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
|
2012-04-20 12:16:24 +07:00
|
|
|
struct notifier_block *nb);
|
2016-06-27 18:03:39 +07:00
|
|
|
extern int devm_extcon_register_notifier(struct device *dev,
|
|
|
|
struct extcon_dev *edev, unsigned int id,
|
|
|
|
struct notifier_block *nb);
|
|
|
|
extern void devm_extcon_unregister_notifier(struct device *dev,
|
|
|
|
struct extcon_dev *edev, unsigned int id,
|
|
|
|
struct notifier_block *nb);
|
2014-03-18 17:55:46 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Following API get the extcon device from devicetree.
|
|
|
|
* This function use phandle of devicetree to get extcon device directly.
|
|
|
|
*/
|
2015-04-24 12:48:52 +07:00
|
|
|
extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
|
|
|
|
int index);
|
2015-04-15 11:57:51 +07:00
|
|
|
|
|
|
|
/* Following API to get information of extcon device */
|
|
|
|
extern const char *extcon_get_edev_name(struct extcon_dev *edev);
|
|
|
|
|
2016-05-31 15:32:30 +07:00
|
|
|
|
2012-04-20 12:16:22 +07:00
|
|
|
#else /* CONFIG_EXTCON */
|
2013-09-27 07:20:26 +07:00
|
|
|
static inline int extcon_dev_register(struct extcon_dev *edev)
|
2012-04-20 12:16:22 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
|
|
|
|
|
2014-04-21 17:10:08 +07:00
|
|
|
static inline int devm_extcon_dev_register(struct device *dev,
|
|
|
|
struct extcon_dev *edev)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void devm_extcon_dev_unregister(struct device *dev,
|
|
|
|
struct extcon_dev *edev) { }
|
|
|
|
|
2015-06-12 09:10:06 +07:00
|
|
|
static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable)
|
2014-04-24 17:46:49 +07:00
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void extcon_dev_free(struct extcon_dev *edev) { }
|
|
|
|
|
2014-04-24 18:12:15 +07:00
|
|
|
static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
|
2015-06-12 09:10:06 +07:00
|
|
|
const unsigned int *cable)
|
2014-04-24 18:12:15 +07:00
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void devm_extcon_dev_free(struct extcon_dev *edev) { }
|
|
|
|
|
2016-07-22 11:03:17 +07:00
|
|
|
|
|
|
|
static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id)
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-22 11:03:17 +07:00
|
|
|
static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id,
|
|
|
|
bool cable_state)
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
synchronize the information between extcon provider driver
and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data.
extcon_set_state(edev, EXTCON_USB, 1);
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-07-22 11:16:34 +07:00
|
|
|
static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
|
|
|
|
bool cable_state)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_sync(struct extcon_dev *edev, unsigned int id)
|
2016-09-15 17:16:11 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_get_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value *prop_val)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value prop_val)
|
extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
synchronize the information between extcon provider driver
and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data.
extcon_set_state(edev, EXTCON_USB, 1);
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-07-22 11:16:34 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-09-15 17:16:11 +07:00
|
|
|
static inline int extcon_set_property_sync(struct extcon_dev *edev,
|
|
|
|
unsigned int id, unsigned int prop,
|
2016-07-11 17:30:43 +07:00
|
|
|
union extcon_property_value prop_val)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-25 19:15:19 +07:00
|
|
|
static inline int extcon_get_property_capability(struct extcon_dev *edev,
|
|
|
|
unsigned int id, unsigned int prop)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_set_property_capability(struct extcon_dev *edev,
|
|
|
|
unsigned int id, unsigned int prop)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-20 12:16:24 +07:00
|
|
|
static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_register_notifier(struct extcon_dev *edev,
|
2015-06-12 09:10:06 +07:00
|
|
|
unsigned int id,
|
extcon: Update the prototype of extcon_register_notifier() with enum extcon
Previously, extcon consumer driver used the extcon_register_interest()
to register the notifier chain and then to receive the notifier event
when external connector's state is changed. When registering the notifier chain
for specific external connector with extcon_register_interest(), it used the
the string name of external connector directly. There are potential problem
because of unclear, non-standard and inconsequent cable name. Namely,
it is not appropriate method to identify each external connector.
So, this patch modify the prototype of extcon_register_notifier() by using
the 'enum extcon' which are the unique id for each external connector
instead of unclear string method.
- Previously, the extcon consumer driver used the extcon_register_interest()
with 'cable_name' to point out the specific external connector. Also. it used
the un-needed structure (struct extcon_specific_cable_nb).
: int extcon_register_interest(struct extcon_specific_cable_nb *obj,
const char *extcon_name, const char *cable_name,
struct notifier_block *nb)
- Newly, the updated extcon_register_notifier() would definitely support
the same feature to detech the changed state of external connector without
any specific structure (struct extcon_specific_cable_nb).
: int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
struct notifier_block *nb)
This patch support the both extcon_register_interest() and new extcon_register_
notifier(). But the extcon_{register|unregister}_interest() will be deprecated
because extcon core would support the notifier event for extcon consumer driver
with only updated extcon_register_notifier() and 'extcon_specific_cable_nb'
will be removed if there are no extcon consumer driver with legacy
extcon_{register|unregister}_interest().
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2015-05-19 18:01:12 +07:00
|
|
|
struct notifier_block *nb)
|
2012-04-20 12:16:24 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_unregister_notifier(struct extcon_dev *edev,
|
2015-06-12 09:10:06 +07:00
|
|
|
unsigned int id,
|
extcon: Update the prototype of extcon_register_notifier() with enum extcon
Previously, extcon consumer driver used the extcon_register_interest()
to register the notifier chain and then to receive the notifier event
when external connector's state is changed. When registering the notifier chain
for specific external connector with extcon_register_interest(), it used the
the string name of external connector directly. There are potential problem
because of unclear, non-standard and inconsequent cable name. Namely,
it is not appropriate method to identify each external connector.
So, this patch modify the prototype of extcon_register_notifier() by using
the 'enum extcon' which are the unique id for each external connector
instead of unclear string method.
- Previously, the extcon consumer driver used the extcon_register_interest()
with 'cable_name' to point out the specific external connector. Also. it used
the un-needed structure (struct extcon_specific_cable_nb).
: int extcon_register_interest(struct extcon_specific_cable_nb *obj,
const char *extcon_name, const char *cable_name,
struct notifier_block *nb)
- Newly, the updated extcon_register_notifier() would definitely support
the same feature to detech the changed state of external connector without
any specific structure (struct extcon_specific_cable_nb).
: int extcon_register_notifier(struct extcon_dev *edev, enum extcon id,
struct notifier_block *nb)
This patch support the both extcon_register_interest() and new extcon_register_
notifier(). But the extcon_{register|unregister}_interest() will be deprecated
because extcon core would support the notifier event for extcon consumer driver
with only updated extcon_register_notifier() and 'extcon_specific_cable_nb'
will be removed if there are no extcon consumer driver with legacy
extcon_{register|unregister}_interest().
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
2015-05-19 18:01:12 +07:00
|
|
|
struct notifier_block *nb)
|
2012-04-20 12:16:24 +07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-27 18:03:39 +07:00
|
|
|
static inline int devm_extcon_register_notifier(struct device *dev,
|
|
|
|
struct extcon_dev *edev, unsigned int id,
|
|
|
|
struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void devm_extcon_unregister_notifier(struct device *dev,
|
|
|
|
struct extcon_dev *edev, unsigned int id,
|
|
|
|
struct notifier_block *nb) { }
|
|
|
|
|
2016-05-31 15:32:30 +07:00
|
|
|
static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
|
|
|
|
int index)
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
{
|
2016-05-31 15:32:30 +07:00
|
|
|
return ERR_PTR(-ENODEV);
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
}
|
2016-05-31 15:32:30 +07:00
|
|
|
#endif /* CONFIG_EXTCON */
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
|
2016-05-31 15:32:30 +07:00
|
|
|
/*
|
|
|
|
* Following structure and API are deprecated. EXTCON remains the function
|
|
|
|
* definition to prevent the build break.
|
|
|
|
*/
|
|
|
|
struct extcon_specific_cable_nb {
|
|
|
|
struct notifier_block *user_nb;
|
|
|
|
int cable_index;
|
|
|
|
struct extcon_dev *edev;
|
|
|
|
unsigned long previous_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline int extcon_register_interest(struct extcon_specific_cable_nb *obj,
|
|
|
|
const char *extcon_name, const char *cable_name,
|
|
|
|
struct notifier_block *nb)
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
{
|
2016-05-31 15:32:30 +07:00
|
|
|
return -EINVAL;
|
Extcon: support multiple states at a device.
One switch device (e.g., MUIC(MAX8997, MAX77686, ...), and some 30-pin
devices) may have multiple cables attached. For example, one
30-pin port may inhabit a USB cable, an HDMI cable, and a mic.
Thus, one switch device requires multiple state bits each representing
a type of cable.
For such purpose, we use the 32bit state variable; thus, up to 32
different type of cables may be defined for a switch device. The list of
possible cables is defined by the array of cable names in the switch_dev
struct given to the class.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V7
- Bugfixed in _call_per_cable() (incorrect nb) (Chanwoo Choi)
- Compiler error in header for !CONFIG_EXTCON (Chanwoo Choi)
Changes from V5
- Sysfs style reformed: subdirectory per cable.
- Updated standard cable names
- Removed unnecessary printf
- Bugfixes after testing
Changes from V4
- Bugfixes after more testing at Exynos4412 boards with userspace
processses.
Changes from V3
- Bugfixes after more testing at Exynos4412 boards.
Changes from V2
- State can be stored by user
- Documentation updated
Changes from RFC
- Switch is renamed to extcon
- Added kerneldoc comments
- Added APIs to support "standard" cable names
- Added helper APIs to support notifier block registration with cable
name.
- Regrouped function list in the header file.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-20 12:16:25 +07:00
|
|
|
}
|
2014-03-18 17:55:46 +07:00
|
|
|
|
2016-05-31 15:32:30 +07:00
|
|
|
static inline int extcon_unregister_interest(struct extcon_specific_cable_nb
|
|
|
|
*obj)
|
2014-03-18 17:55:46 +07:00
|
|
|
{
|
2016-05-31 15:32:30 +07:00
|
|
|
return -EINVAL;
|
2014-03-18 17:55:46 +07:00
|
|
|
}
|
2016-07-22 11:03:17 +07:00
|
|
|
|
|
|
|
static inline int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id)
|
|
|
|
{
|
|
|
|
return extcon_get_state(edev, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
|
|
|
|
bool cable_state)
|
|
|
|
{
|
extcon: Add the synchronization extcon APIs to support the notification
This patch adds the synchronization extcon APIs to support the notifications
for both state and property. When extcon_*_sync() functions is called,
the extcon informs the information from extcon provider to extcon client.
The extcon driver may need to change the both state and multiple properties
at the same time. After setting the data of a external connector,
the extcon send the notification to client driver with the extcon_*_sync().
The list of new extcon APIs as following:
- extcon_sync() : Send the notification for each external connector to
synchronize the information between extcon provider driver
and extcon client driver.
- extcon_set_state_sync() : Set the state of external connector with noti.
- extcon_set_property_sync() : Set the property of external connector with noti.
For example,
case 1, change the state of external connector and synchronized the data.
extcon_set_state_sync(edev, EXTCON_USB, 1);
case 2, change both the state and property of external connector
and synchronized the data.
extcon_set_state(edev, EXTCON_USB, 1);
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS 1);
extcon_sync(edev, EXTCON_USB);
case 3, change the property of external connector and synchronized the data.
extcon_set_property(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
extcon_sync(edev, EXTCON_USB);
case 4, change the property of external connector and synchronized the data.
extcon_set_property_sync(edev, EXTCON_USB, EXTCON_PROP_USB_VBUS, 0);
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
2016-07-22 11:16:34 +07:00
|
|
|
return extcon_set_state_sync(edev, id, cable_state);
|
2016-07-22 11:03:17 +07:00
|
|
|
}
|
2012-04-20 12:16:22 +07:00
|
|
|
#endif /* __LINUX_EXTCON_H__ */
|