2012-04-20 13:16:22 +08:00
|
|
|
/*
|
2015-04-24 13:48:52 +08:00
|
|
|
* drivers/extcon/extcon.c - External Connector (extcon) framework.
|
2012-04-20 13:16:22 +08: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 18:16:05 +08:00
|
|
|
* Copyright (C) 2015 Samsung Electronics
|
|
|
|
* Author: Chanwoo Choi <cw00.choi@samsung.com>
|
|
|
|
*
|
2012-04-20 13:16:22 +08:00
|
|
|
* Copyright (C) 2012 Samsung Electronics
|
|
|
|
* Author: Donggeun Kim <dg77.kim@samsung.com>
|
|
|
|
* Author: MyungJoo Ham <myungjoo.ham@samsung.com>
|
|
|
|
*
|
|
|
|
* based on android/drivers/switch/switch_class.c
|
|
|
|
* 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.
|
2015-04-24 13:48:52 +08:00
|
|
|
*/
|
2012-04-20 13:16:22 +08:00
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/err.h>
|
2014-10-16 21:11:44 +08:00
|
|
|
#include <linux/of.h>
|
2012-04-20 13:16:22 +08:00
|
|
|
#include <linux/slab.h>
|
2012-08-17 03:03:21 +08:00
|
|
|
#include <linux/sysfs.h>
|
2012-04-20 13:16:22 +08:00
|
|
|
|
2016-12-26 19:37:38 +08:00
|
|
|
#include "extcon.h"
|
|
|
|
|
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
|
|
|
#define SUPPORTED_CABLE_MAX 32
|
|
|
|
#define CABLE_NAME_MAX 30
|
|
|
|
|
2016-07-11 15:34:52 +08:00
|
|
|
struct __extcon_info {
|
|
|
|
unsigned int type;
|
|
|
|
unsigned int id;
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
} extcon_info[] = {
|
|
|
|
[EXTCON_NONE] = {
|
|
|
|
.type = EXTCON_TYPE_MISC,
|
|
|
|
.id = EXTCON_NONE,
|
|
|
|
.name = "NONE",
|
|
|
|
},
|
2015-06-12 10:10:06 +08:00
|
|
|
|
2015-05-19 18:58:49 +08:00
|
|
|
/* USB external connector */
|
2016-07-11 15:34:52 +08:00
|
|
|
[EXTCON_USB] = {
|
|
|
|
.type = EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_USB,
|
|
|
|
.name = "USB",
|
|
|
|
},
|
|
|
|
[EXTCON_USB_HOST] = {
|
|
|
|
.type = EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_USB_HOST,
|
2017-01-07 04:17:36 +08:00
|
|
|
.name = "USB-HOST",
|
2016-07-11 15:34:52 +08:00
|
|
|
},
|
2015-05-19 18:58:49 +08:00
|
|
|
|
2015-10-03 13:15:13 +08:00
|
|
|
/* Charging external connector */
|
2016-07-11 15:34:52 +08:00
|
|
|
[EXTCON_CHG_USB_SDP] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_SDP,
|
|
|
|
.name = "SDP",
|
|
|
|
},
|
|
|
|
[EXTCON_CHG_USB_DCP] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_DCP,
|
|
|
|
.name = "DCP",
|
|
|
|
},
|
|
|
|
[EXTCON_CHG_USB_CDP] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_CDP,
|
|
|
|
.name = "CDP",
|
|
|
|
},
|
|
|
|
[EXTCON_CHG_USB_ACA] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_ACA,
|
|
|
|
.name = "ACA",
|
|
|
|
},
|
|
|
|
[EXTCON_CHG_USB_FAST] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_FAST,
|
|
|
|
.name = "FAST-CHARGER",
|
|
|
|
},
|
|
|
|
[EXTCON_CHG_USB_SLOW] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_SLOW,
|
|
|
|
.name = "SLOW-CHARGER",
|
|
|
|
},
|
2016-08-05 17:15:46 +08:00
|
|
|
[EXTCON_CHG_WPT] = {
|
|
|
|
.type = EXTCON_TYPE_CHG,
|
|
|
|
.id = EXTCON_CHG_WPT,
|
|
|
|
.name = "WPT",
|
|
|
|
},
|
2017-01-02 12:03:03 +08:00
|
|
|
[EXTCON_CHG_USB_PD] = {
|
|
|
|
.type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_CHG_USB_PD,
|
|
|
|
.name = "PD",
|
|
|
|
},
|
2015-05-19 18:58:49 +08:00
|
|
|
|
2015-10-03 13:15:13 +08:00
|
|
|
/* Jack external connector */
|
2016-07-11 15:34:52 +08:00
|
|
|
[EXTCON_JACK_MICROPHONE] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_MICROPHONE,
|
|
|
|
.name = "MICROPHONE",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_HEADPHONE] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_HEADPHONE,
|
|
|
|
.name = "HEADPHONE",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_LINE_IN] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_LINE_IN,
|
|
|
|
.name = "LINE-IN",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_LINE_OUT] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_LINE_OUT,
|
|
|
|
.name = "LINE-OUT",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_VIDEO_IN] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_VIDEO_IN,
|
|
|
|
.name = "VIDEO-IN",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_VIDEO_OUT] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_VIDEO_OUT,
|
|
|
|
.name = "VIDEO-OUT",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_SPDIF_IN] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_SPDIF_IN,
|
|
|
|
.name = "SPDIF-IN",
|
|
|
|
},
|
|
|
|
[EXTCON_JACK_SPDIF_OUT] = {
|
|
|
|
.type = EXTCON_TYPE_JACK,
|
|
|
|
.id = EXTCON_JACK_SPDIF_OUT,
|
|
|
|
.name = "SPDIF-OUT",
|
|
|
|
},
|
2015-05-19 18:58:49 +08:00
|
|
|
|
2015-10-03 13:15:13 +08:00
|
|
|
/* Display external connector */
|
2016-07-11 15:34:52 +08:00
|
|
|
[EXTCON_DISP_HDMI] = {
|
|
|
|
.type = EXTCON_TYPE_DISP,
|
|
|
|
.id = EXTCON_DISP_HDMI,
|
|
|
|
.name = "HDMI",
|
|
|
|
},
|
|
|
|
[EXTCON_DISP_MHL] = {
|
|
|
|
.type = EXTCON_TYPE_DISP,
|
|
|
|
.id = EXTCON_DISP_MHL,
|
|
|
|
.name = "MHL",
|
|
|
|
},
|
|
|
|
[EXTCON_DISP_DVI] = {
|
|
|
|
.type = EXTCON_TYPE_DISP,
|
|
|
|
.id = EXTCON_DISP_DVI,
|
|
|
|
.name = "DVI",
|
|
|
|
},
|
|
|
|
[EXTCON_DISP_VGA] = {
|
|
|
|
.type = EXTCON_TYPE_DISP,
|
|
|
|
.id = EXTCON_DISP_VGA,
|
|
|
|
.name = "VGA",
|
|
|
|
},
|
2016-07-22 00:13:02 +08:00
|
|
|
[EXTCON_DISP_DP] = {
|
|
|
|
.type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_DISP_DP,
|
|
|
|
.name = "DP",
|
|
|
|
},
|
2016-08-05 16:49:23 +08:00
|
|
|
[EXTCON_DISP_HMD] = {
|
|
|
|
.type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
|
|
|
|
.id = EXTCON_DISP_HMD,
|
|
|
|
.name = "HMD",
|
|
|
|
},
|
2015-05-19 18:58:49 +08:00
|
|
|
|
2015-10-03 13:15:13 +08:00
|
|
|
/* Miscellaneous external connector */
|
2016-07-11 15:34:52 +08:00
|
|
|
[EXTCON_DOCK] = {
|
|
|
|
.type = EXTCON_TYPE_MISC,
|
|
|
|
.id = EXTCON_DOCK,
|
|
|
|
.name = "DOCK",
|
|
|
|
},
|
|
|
|
[EXTCON_JIG] = {
|
|
|
|
.type = EXTCON_TYPE_MISC,
|
|
|
|
.id = EXTCON_JIG,
|
|
|
|
.name = "JIG",
|
|
|
|
},
|
|
|
|
[EXTCON_MECHANICAL] = {
|
|
|
|
.type = EXTCON_TYPE_MISC,
|
|
|
|
.id = EXTCON_MECHANICAL,
|
|
|
|
.name = "MECHANICAL",
|
|
|
|
},
|
|
|
|
|
|
|
|
{ /* sentinel */ }
|
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 13:16:25 +08:00
|
|
|
};
|
|
|
|
|
2016-06-27 18:17:06 +08:00
|
|
|
/**
|
|
|
|
* struct extcon_cable - An internal data for each cable of extcon device.
|
|
|
|
* @edev: The extcon device
|
|
|
|
* @cable_index: Index of this cable in the edev
|
|
|
|
* @attr_g: Attribute group for the cable
|
|
|
|
* @attr_name: "name" sysfs entry
|
|
|
|
* @attr_state: "state" sysfs entry
|
|
|
|
* @attrs: Array pointing to attr_name and attr_state for attr_g
|
|
|
|
*/
|
|
|
|
struct extcon_cable {
|
|
|
|
struct extcon_dev *edev;
|
|
|
|
int cable_index;
|
|
|
|
|
|
|
|
struct attribute_group attr_g;
|
|
|
|
struct device_attribute attr_name;
|
|
|
|
struct device_attribute attr_state;
|
|
|
|
|
|
|
|
struct attribute *attrs[3]; /* to be fed to attr_g.attrs */
|
2016-07-11 18:30:43 +08:00
|
|
|
|
|
|
|
union extcon_property_value usb_propval[EXTCON_PROP_USB_CNT];
|
|
|
|
union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT];
|
|
|
|
union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT];
|
|
|
|
union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT];
|
2016-07-25 20:15:19 +08:00
|
|
|
|
|
|
|
unsigned long usb_bits[BITS_TO_LONGS(EXTCON_PROP_USB_CNT)];
|
|
|
|
unsigned long chg_bits[BITS_TO_LONGS(EXTCON_PROP_CHG_CNT)];
|
|
|
|
unsigned long jack_bits[BITS_TO_LONGS(EXTCON_PROP_JACK_CNT)];
|
|
|
|
unsigned long disp_bits[BITS_TO_LONGS(EXTCON_PROP_DISP_CNT)];
|
2016-06-27 18:17:06 +08:00
|
|
|
};
|
|
|
|
|
2012-06-05 23:14:38 +08:00
|
|
|
static struct class *extcon_class;
|
2012-04-20 13:16:22 +08:00
|
|
|
|
2012-04-20 13:16:24 +08:00
|
|
|
static LIST_HEAD(extcon_dev_list);
|
|
|
|
static DEFINE_MUTEX(extcon_dev_list_lock);
|
|
|
|
|
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 13:16:26 +08:00
|
|
|
/**
|
|
|
|
* check_mutually_exclusive - Check if new_state violates mutually_exclusive
|
2013-08-31 12:16:49 +08:00
|
|
|
* condition.
|
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 13:16:26 +08:00
|
|
|
* @edev: the extcon device
|
|
|
|
* @new_state: new cable attach status for @edev
|
|
|
|
*
|
|
|
|
* Returns 0 if nothing violates. Returns the index + 1 for the first
|
|
|
|
* violated condition.
|
|
|
|
*/
|
|
|
|
static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (!edev->mutually_exclusive)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; edev->mutually_exclusive[i]; i++) {
|
2012-08-30 03:05:10 +08:00
|
|
|
int weight;
|
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 13:16:26 +08:00
|
|
|
u32 correspondants = new_state & edev->mutually_exclusive[i];
|
|
|
|
|
2012-08-30 03:05:10 +08:00
|
|
|
/* calculate the total number of bits set */
|
|
|
|
weight = hweight32(correspondants);
|
|
|
|
if (weight > 1)
|
|
|
|
return i + 1;
|
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 13:16:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-06-12 10:10:06 +08:00
|
|
|
static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id)
|
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
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Find the the index of extcon cable in edev->supported_cable */
|
|
|
|
for (i = 0; i < edev->max_supported; i++) {
|
|
|
|
if (edev->supported_cable[i] == id)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
static int get_extcon_type(unsigned int prop)
|
|
|
|
{
|
|
|
|
switch (prop) {
|
|
|
|
case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
|
|
|
|
return EXTCON_TYPE_USB;
|
|
|
|
case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
|
|
|
|
return EXTCON_TYPE_CHG;
|
|
|
|
case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
|
|
|
|
return EXTCON_TYPE_JACK;
|
|
|
|
case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
|
|
|
|
return EXTCON_TYPE_DISP;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_extcon_attached(struct extcon_dev *edev, unsigned int index)
|
|
|
|
{
|
|
|
|
return !!(edev->state & BIT(index));
|
|
|
|
}
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
static bool is_extcon_changed(struct extcon_dev *edev, int index,
|
|
|
|
bool new_state)
|
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 19:01:12 +08:00
|
|
|
{
|
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 12:16:34 +08:00
|
|
|
int state = !!(edev->state & BIT(index));
|
|
|
|
return (state != new_state);
|
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 19:01:12 +08:00
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
static bool is_extcon_property_supported(unsigned int id, unsigned int prop)
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not. */
|
|
|
|
type = get_extcon_type(prop);
|
|
|
|
if (type < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Check whether a specific extcon id supports the property or not. */
|
|
|
|
return !!(extcon_info[id].type & type);
|
|
|
|
}
|
|
|
|
|
2016-07-25 20:15:19 +08:00
|
|
|
static int is_extcon_property_capability(struct extcon_dev *edev,
|
|
|
|
unsigned int id, int index,unsigned int prop)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable;
|
|
|
|
int type, ret;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not. */
|
|
|
|
type = get_extcon_type(prop);
|
|
|
|
if (type < 0)
|
|
|
|
return type;
|
|
|
|
|
|
|
|
cable = &edev->cables[index];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case EXTCON_TYPE_USB:
|
|
|
|
ret = test_bit(prop - EXTCON_PROP_USB_MIN, cable->usb_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_CHG:
|
|
|
|
ret = test_bit(prop - EXTCON_PROP_CHG_MIN, cable->chg_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_JACK:
|
|
|
|
ret = test_bit(prop - EXTCON_PROP_JACK_MIN, cable->jack_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_DISP:
|
|
|
|
ret = test_bit(prop - EXTCON_PROP_DISP_MIN, cable->disp_bits);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
static void init_property(struct extcon_dev *edev, unsigned int id, int index)
|
|
|
|
{
|
|
|
|
unsigned int type = extcon_info[id].type;
|
|
|
|
struct extcon_cable *cable = &edev->cables[index];
|
|
|
|
|
|
|
|
if (EXTCON_TYPE_USB & type)
|
|
|
|
memset(cable->usb_propval, 0, sizeof(cable->usb_propval));
|
|
|
|
if (EXTCON_TYPE_CHG & type)
|
|
|
|
memset(cable->chg_propval, 0, sizeof(cable->chg_propval));
|
|
|
|
if (EXTCON_TYPE_JACK & type)
|
|
|
|
memset(cable->jack_propval, 0, sizeof(cable->jack_propval));
|
|
|
|
if (EXTCON_TYPE_DISP & type)
|
|
|
|
memset(cable->disp_propval, 0, sizeof(cable->disp_propval));
|
|
|
|
}
|
|
|
|
|
2012-04-20 13:16:22 +08:00
|
|
|
static ssize_t state_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
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 13:16:25 +08:00
|
|
|
int i, count = 0;
|
2013-09-09 13:33:32 +08:00
|
|
|
struct extcon_dev *edev = dev_get_drvdata(dev);
|
2012-04-20 13:16:22 +08: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 13:16:25 +08:00
|
|
|
if (edev->max_supported == 0)
|
|
|
|
return sprintf(buf, "%u\n", edev->state);
|
|
|
|
|
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
|
|
|
for (i = 0; i < edev->max_supported; i++) {
|
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 13:16:25 +08:00
|
|
|
count += sprintf(buf + count, "%s=%d\n",
|
2016-07-11 15:34:52 +08:00
|
|
|
extcon_info[edev->supported_cable[i]].name,
|
2017-03-29 18:18:36 +08:00
|
|
|
!!(edev->state & BIT(i)));
|
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 13:16:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2016-07-18 14:39:28 +08:00
|
|
|
static DEVICE_ATTR_RO(state);
|
2012-04-20 13:16:22 +08:00
|
|
|
|
|
|
|
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2013-09-09 13:33:32 +08:00
|
|
|
struct extcon_dev *edev = dev_get_drvdata(dev);
|
2012-04-20 13:16:22 +08:00
|
|
|
|
2015-04-15 14:02:01 +08:00
|
|
|
return sprintf(buf, "%s\n", edev->name);
|
2012-04-20 13:16:22 +08:00
|
|
|
}
|
2013-07-25 06:05:10 +08:00
|
|
|
static DEVICE_ATTR_RO(name);
|
2012-04-20 13:16:22 +08: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 13:16:25 +08:00
|
|
|
static ssize_t cable_name_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable = container_of(attr, struct extcon_cable,
|
|
|
|
attr_name);
|
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
|
|
|
int i = cable->cable_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 13:16:25 +08:00
|
|
|
|
|
|
|
return sprintf(buf, "%s\n",
|
2016-07-11 15:34:52 +08:00
|
|
|
extcon_info[cable->edev->supported_cable[i]].name);
|
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 13:16:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t cable_state_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable = container_of(attr, struct extcon_cable,
|
|
|
|
attr_state);
|
|
|
|
|
2015-07-07 21:06:15 +08:00
|
|
|
int i = cable->cable_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 13:16:25 +08:00
|
|
|
return sprintf(buf, "%d\n",
|
2016-07-22 12:03:17 +08:00
|
|
|
extcon_get_state(cable->edev, cable->edev->supported_cable[i]));
|
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 13:16:25 +08:00
|
|
|
}
|
|
|
|
|
2012-04-20 13:16:22 +08:00
|
|
|
/**
|
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 12:16:34 +08:00
|
|
|
* extcon_sync() - Synchronize the states for both the attached/detached
|
|
|
|
* @edev: the extcon device that has the cable.
|
2012-04-20 13:16:24 +08:00
|
|
|
*
|
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 12:16:34 +08:00
|
|
|
* This function send a notification to synchronize the all states of a
|
|
|
|
* specific external connector
|
2012-04-20 13:16:22 +08:00
|
|
|
*/
|
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 12:16:34 +08:00
|
|
|
int extcon_sync(struct extcon_dev *edev, unsigned int id)
|
2012-04-20 13:16:22 +08:00
|
|
|
{
|
|
|
|
char name_buf[120];
|
|
|
|
char state_buf[120];
|
|
|
|
char *prop_buf;
|
|
|
|
char *envp[3];
|
|
|
|
int env_offset = 0;
|
|
|
|
int length;
|
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 19:01:12 +08:00
|
|
|
int index;
|
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 12:16:34 +08:00
|
|
|
int 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 13:16:25 +08:00
|
|
|
unsigned long flags;
|
2012-04-20 13:16:22 +08:00
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return 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 13:16:25 +08:00
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
2012-04-20 13:16:22 +08:00
|
|
|
|
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 12:16:34 +08:00
|
|
|
state = !!(edev->state & BIT(index));
|
2017-03-29 18:30:17 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call functions in a raw notifier chain for the specific one
|
|
|
|
* external connector.
|
|
|
|
*/
|
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 12:16:34 +08:00
|
|
|
raw_notifier_call_chain(&edev->nh[index], state, edev);
|
|
|
|
|
2017-03-29 18:30:17 +08:00
|
|
|
/*
|
|
|
|
* Call functions in a raw notifier chain for the all supported
|
|
|
|
* external connectors.
|
|
|
|
*/
|
|
|
|
raw_notifier_call_chain(&edev->nh_all, state, edev);
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
/* This could be in interrupt handler */
|
|
|
|
prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
|
|
|
|
if (!prop_buf) {
|
|
|
|
/* Unlock early before uevent */
|
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 13:16:25 +08:00
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
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 12:16:34 +08:00
|
|
|
|
|
|
|
dev_err(&edev->dev, "out of memory in extcon_set_state\n");
|
|
|
|
kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE);
|
|
|
|
|
2016-12-03 16:56:49 +08:00
|
|
|
return -ENOMEM;
|
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 12:16:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
length = name_show(&edev->dev, NULL, prop_buf);
|
|
|
|
if (length > 0) {
|
|
|
|
if (prop_buf[length - 1] == '\n')
|
|
|
|
prop_buf[length - 1] = 0;
|
|
|
|
snprintf(name_buf, sizeof(name_buf), "NAME=%s", prop_buf);
|
|
|
|
envp[env_offset++] = name_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = state_show(&edev->dev, NULL, prop_buf);
|
|
|
|
if (length > 0) {
|
|
|
|
if (prop_buf[length - 1] == '\n')
|
|
|
|
prop_buf[length - 1] = 0;
|
|
|
|
snprintf(state_buf, sizeof(state_buf), "STATE=%s", prop_buf);
|
|
|
|
envp[env_offset++] = state_buf;
|
2012-04-20 13:16:22 +08:00
|
|
|
}
|
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 12:16:34 +08:00
|
|
|
envp[env_offset] = NULL;
|
|
|
|
|
|
|
|
/* Unlock early before uevent */
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
kobject_uevent_env(&edev->dev.kobj, KOBJ_CHANGE, envp);
|
|
|
|
free_page((unsigned long)prop_buf);
|
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 13:16:26 +08:00
|
|
|
|
|
|
|
return 0;
|
2012-04-20 13:16:22 +08:00
|
|
|
}
|
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 12:16:34 +08:00
|
|
|
EXPORT_SYMBOL_GPL(extcon_sync);
|
2012-04-20 13:16:22 +08: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 13:16:25 +08:00
|
|
|
/**
|
2016-07-22 12:03:17 +08:00
|
|
|
* extcon_get_state() - Get the state of a external connector.
|
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 13:16:25 +08:00
|
|
|
* @edev: the extcon device that has the cable.
|
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
|
|
|
* @id: the unique id of each external connector in extcon enumeration.
|
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 13:16:25 +08:00
|
|
|
*/
|
2016-07-22 12:03:17 +08:00
|
|
|
int extcon_get_state(struct extcon_dev *edev, const 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 13:16:25 +08:00
|
|
|
{
|
2016-07-22 12:03:17 +08:00
|
|
|
int index, state;
|
|
|
|
unsigned long flags;
|
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 13:16:25 +08:00
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
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
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return 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 13:16:25 +08:00
|
|
|
|
2016-07-22 12:03:17 +08:00
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
state = is_extcon_attached(edev, index);
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
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 13:16:25 +08:00
|
|
|
|
2016-07-22 12:03:17 +08:00
|
|
|
return 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 13:16:25 +08:00
|
|
|
}
|
2016-07-22 12:03:17 +08:00
|
|
|
EXPORT_SYMBOL_GPL(extcon_get_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 13:16:25 +08:00
|
|
|
|
|
|
|
/**
|
2016-07-22 12:03:17 +08:00
|
|
|
* extcon_set_state() - Set the state of a external connector.
|
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 12:16:34 +08:00
|
|
|
* without a notification.
|
2013-08-31 12:16:49 +08:00
|
|
|
* @edev: the extcon device that has the cable.
|
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
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @state: the new cable status. The default semantics is
|
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 13:16:25 +08:00
|
|
|
* true: attached / false: detached.
|
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 12:16:34 +08:00
|
|
|
*
|
|
|
|
* This function only set the state of a external connector without
|
|
|
|
* a notification. To synchronize the data of a external connector,
|
|
|
|
* use extcon_set_state_sync() and extcon_sync().
|
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 13:16:25 +08:00
|
|
|
*/
|
2016-07-22 12:03:17 +08:00
|
|
|
int extcon_set_state(struct extcon_dev *edev, unsigned int id,
|
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
|
|
|
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 13:16:25 +08:00
|
|
|
{
|
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 12:16:34 +08:00
|
|
|
unsigned long flags;
|
|
|
|
int index, ret = 0;
|
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 13:16:25 +08:00
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
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
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
|
|
|
|
/* Check whether the external connector's state is changed. */
|
|
|
|
if (!is_extcon_changed(edev, index, cable_state))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (check_mutually_exclusive(edev,
|
|
|
|
(edev->state & ~BIT(index)) | (cable_state & BIT(index)))) {
|
|
|
|
ret = -EPERM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
/*
|
|
|
|
* Initialize the value of extcon property before setting
|
|
|
|
* the detached state for an external connector.
|
|
|
|
*/
|
|
|
|
if (!cable_state)
|
|
|
|
init_property(edev, id, index);
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
/* Update the state for a external connector. */
|
|
|
|
if (cable_state)
|
|
|
|
edev->state |= BIT(index);
|
|
|
|
else
|
|
|
|
edev->state &= ~(BIT(index));
|
|
|
|
out:
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
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 13:16:25 +08:00
|
|
|
}
|
2016-07-22 12:03:17 +08:00
|
|
|
EXPORT_SYMBOL_GPL(extcon_set_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 13:16:25 +08:00
|
|
|
|
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 12:16:34 +08:00
|
|
|
/**
|
|
|
|
* extcon_set_state_sync() - Set the state of a external connector
|
|
|
|
* with a notification.
|
|
|
|
* @edev: the extcon device that has the cable.
|
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @state: the new cable status. The default semantics is
|
|
|
|
* true: attached / false: detached.
|
|
|
|
*
|
|
|
|
* This function set the state of external connector and synchronize the data
|
|
|
|
* by usning a notification.
|
|
|
|
*/
|
|
|
|
int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
|
|
|
|
bool cable_state)
|
|
|
|
{
|
|
|
|
int ret, index;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
/* Check whether the external connector's state is changed. */
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
ret = is_extcon_changed(edev, index, cable_state);
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
if (!ret)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = extcon_set_state(edev, id, cable_state);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return extcon_sync(edev, id);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_set_state_sync);
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
/**
|
|
|
|
* extcon_get_property() - Get the property value of a specific cable.
|
|
|
|
* @edev: the extcon device that has the cable.
|
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @prop: the property id among enum extcon_property.
|
|
|
|
* @prop_val: the pointer which store the value of property.
|
|
|
|
*
|
|
|
|
* When getting the property value of external connector, the external connector
|
|
|
|
* should be attached. If detached state, function just return 0 without
|
|
|
|
* property value. Also, the each property should be included in the list of
|
|
|
|
* supported properties according to the type of external connectors.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_get_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value *prop_val)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable;
|
|
|
|
unsigned long flags;
|
|
|
|
int index, ret = 0;
|
|
|
|
|
|
|
|
*prop_val = (union extcon_property_value)(0);
|
|
|
|
|
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not */
|
|
|
|
if (!is_extcon_property_supported(id, prop))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Find the cable index of external connector by using id */
|
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
|
2016-07-25 20:15:19 +08:00
|
|
|
/* Check whether the property is available or not. */
|
|
|
|
if (!is_extcon_property_capability(edev, id, index, prop)) {
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
/*
|
|
|
|
* Check whether the external connector is attached.
|
|
|
|
* If external connector is detached, the user can not
|
|
|
|
* get the property value.
|
|
|
|
*/
|
|
|
|
if (!is_extcon_attached(edev, index)) {
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cable = &edev->cables[index];
|
|
|
|
|
|
|
|
/* Get the property value according to extcon type */
|
|
|
|
switch (prop) {
|
|
|
|
case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
|
|
|
|
*prop_val = cable->usb_propval[prop - EXTCON_PROP_USB_MIN];
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
|
|
|
|
*prop_val = cable->chg_propval[prop - EXTCON_PROP_CHG_MIN];
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
|
|
|
|
*prop_val = cable->jack_propval[prop - EXTCON_PROP_JACK_MIN];
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
|
|
|
|
*prop_val = cable->disp_propval[prop - EXTCON_PROP_DISP_MIN];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_get_property);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extcon_set_property() - Set the property value of a specific cable.
|
|
|
|
* @edev: the extcon device that has the cable.
|
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @prop: the property id among enum extcon_property.
|
|
|
|
* @prop_val: the pointer including the new value of property.
|
|
|
|
*
|
|
|
|
* The each property should be included in the list of supported properties
|
|
|
|
* according to the type of external connectors.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_set_property(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value prop_val)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable;
|
|
|
|
unsigned long flags;
|
|
|
|
int index, ret = 0;
|
|
|
|
|
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not */
|
|
|
|
if (!is_extcon_property_supported(id, prop))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Find the cable index of external connector by using id */
|
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
|
2016-07-25 20:15:19 +08:00
|
|
|
/* Check whether the property is available or not. */
|
|
|
|
if (!is_extcon_property_capability(edev, id, index, prop)) {
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:30:43 +08:00
|
|
|
cable = &edev->cables[index];
|
|
|
|
|
|
|
|
/* Set the property value according to extcon type */
|
|
|
|
switch (prop) {
|
|
|
|
case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
|
|
|
|
cable->usb_propval[prop - EXTCON_PROP_USB_MIN] = prop_val;
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
|
|
|
|
cable->chg_propval[prop - EXTCON_PROP_CHG_MIN] = prop_val;
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
|
|
|
|
cable->jack_propval[prop - EXTCON_PROP_JACK_MIN] = prop_val;
|
|
|
|
break;
|
|
|
|
case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
|
|
|
|
cable->disp_propval[prop - EXTCON_PROP_DISP_MIN] = prop_val;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_set_property);
|
|
|
|
|
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 12:16:34 +08:00
|
|
|
/**
|
|
|
|
* extcon_set_property_sync() - Set the property value of a specific cable
|
|
|
|
with a notification.
|
|
|
|
* @prop_val: the pointer including the new value of property.
|
|
|
|
*
|
|
|
|
* When setting the property value of external connector, the external connector
|
|
|
|
* should be attached. The each property should be included in the list of
|
|
|
|
* supported properties according to the type of external connectors.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop,
|
|
|
|
union extcon_property_value prop_val)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = extcon_set_property(edev, id, prop, prop_val);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return extcon_sync(edev, id);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_set_property_sync);
|
|
|
|
|
2016-07-25 20:15:19 +08:00
|
|
|
/**
|
|
|
|
* extcon_get_property_capability() - Get the capability of property
|
|
|
|
* of an external connector.
|
|
|
|
* @edev: the extcon device that has the cable.
|
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @prop: the property id among enum extcon_property.
|
|
|
|
*
|
|
|
|
* Returns 1 if the property is available or 0 if not available.
|
|
|
|
*/
|
|
|
|
int extcon_get_property_capability(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop)
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
|
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not */
|
|
|
|
if (!is_extcon_property_supported(id, prop))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Find the cable index of external connector by using id */
|
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
return is_extcon_property_capability(edev, id, index, prop);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_get_property_capability);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extcon_set_property_capability() - Set the capability of a property
|
|
|
|
* of an external connector.
|
|
|
|
* @edev: the extcon device that has the cable.
|
|
|
|
* @id: the unique id of each external connector
|
|
|
|
* in extcon enumeration.
|
|
|
|
* @prop: the property id among enum extcon_property.
|
|
|
|
*
|
|
|
|
* This function set the capability of a property for an external connector
|
|
|
|
* to mark the bit in capability bitmap which mean the available state of
|
|
|
|
* a property.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_set_property_capability(struct extcon_dev *edev, unsigned int id,
|
|
|
|
unsigned int prop)
|
|
|
|
{
|
|
|
|
struct extcon_cable *cable;
|
|
|
|
int index, type, ret = 0;
|
|
|
|
|
|
|
|
if (!edev)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Check whether the property is supported or not. */
|
|
|
|
if (!is_extcon_property_supported(id, prop))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Find the cable index of external connector by using id. */
|
|
|
|
index = find_cable_index_by_id(edev, id);
|
|
|
|
if (index < 0)
|
|
|
|
return index;
|
|
|
|
|
|
|
|
type = get_extcon_type(prop);
|
|
|
|
if (type < 0)
|
|
|
|
return type;
|
|
|
|
|
|
|
|
cable = &edev->cables[index];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case EXTCON_TYPE_USB:
|
|
|
|
__set_bit(prop - EXTCON_PROP_USB_MIN, cable->usb_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_CHG:
|
|
|
|
__set_bit(prop - EXTCON_PROP_CHG_MIN, cable->chg_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_JACK:
|
|
|
|
__set_bit(prop - EXTCON_PROP_JACK_MIN, cable->jack_bits);
|
|
|
|
break;
|
|
|
|
case EXTCON_TYPE_DISP:
|
|
|
|
__set_bit(prop - EXTCON_PROP_DISP_MIN, cable->disp_bits);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_set_property_capability);
|
|
|
|
|
2012-04-20 13:16:24 +08:00
|
|
|
/**
|
|
|
|
* extcon_get_extcon_dev() - Get the extcon device instance from the name
|
|
|
|
* @extcon_name: The extcon name provided with extcon_dev_register()
|
|
|
|
*/
|
|
|
|
struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
|
|
|
|
{
|
|
|
|
struct extcon_dev *sd;
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!extcon_name)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
2012-04-20 13:16:24 +08:00
|
|
|
mutex_lock(&extcon_dev_list_lock);
|
|
|
|
list_for_each_entry(sd, &extcon_dev_list, entry) {
|
|
|
|
if (!strcmp(sd->name, extcon_name))
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
sd = NULL;
|
|
|
|
out:
|
|
|
|
mutex_unlock(&extcon_dev_list_lock);
|
|
|
|
return sd;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_get_extcon_dev);
|
|
|
|
|
|
|
|
/**
|
2012-08-23 08:11:54 +08:00
|
|
|
* extcon_register_notifier() - Register a notifiee to get notified by
|
2013-08-31 12:16:49 +08:00
|
|
|
* any attach status changes from the extcon.
|
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 19:01:12 +08:00
|
|
|
* @edev: the extcon device that has the external connecotr.
|
|
|
|
* @id: the unique id of each external connector in extcon enumeration.
|
2012-04-20 13:16:24 +08:00
|
|
|
* @nb: a notifier block to be registered.
|
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 13:16:25 +08:00
|
|
|
*
|
|
|
|
* Note that the second parameter given to the callback of nb (val) is
|
|
|
|
* "old_state", not the current state. The current state can be retrieved
|
|
|
|
* by looking at the third pameter (edev pointer)'s state value.
|
2012-04-20 13:16:24 +08:00
|
|
|
*/
|
2015-06-12 10:10:06 +08:00
|
|
|
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 19:01:12 +08:00
|
|
|
struct notifier_block *nb)
|
2012-04-20 13:16:24 +08:00
|
|
|
{
|
2015-03-22 00:26:24 +08:00
|
|
|
unsigned long flags;
|
2016-08-01 17:21:30 +08:00
|
|
|
int ret, idx = -EINVAL;
|
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 19:01:12 +08:00
|
|
|
|
2016-12-19 20:02:33 +08:00
|
|
|
if (!edev || !nb)
|
2015-06-21 22:48:36 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2016-12-19 20:02:33 +08:00
|
|
|
idx = find_cable_index_by_id(edev, id);
|
|
|
|
if (idx < 0)
|
|
|
|
return idx;
|
2015-03-22 00:26:24 +08:00
|
|
|
|
2016-12-19 20:02:33 +08:00
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
ret = raw_notifier_chain_register(&edev->nh[idx], nb);
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
2015-03-22 00:26:24 +08:00
|
|
|
|
|
|
|
return ret;
|
2012-04-20 13:16:24 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_register_notifier);
|
|
|
|
|
|
|
|
/**
|
2012-08-23 08:11:54 +08:00
|
|
|
* extcon_unregister_notifier() - Unregister a notifiee from the extcon device.
|
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 19:01:12 +08:00
|
|
|
* @edev: the extcon device that has the external connecotr.
|
|
|
|
* @id: the unique id of each external connector in extcon enumeration.
|
|
|
|
* @nb: a notifier block to be registered.
|
2012-04-20 13:16:24 +08:00
|
|
|
*/
|
2015-06-12 10:10:06 +08:00
|
|
|
int extcon_unregister_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 19:01:12 +08:00
|
|
|
struct notifier_block *nb)
|
2012-04-20 13:16:24 +08:00
|
|
|
{
|
2015-03-22 00:26:24 +08:00
|
|
|
unsigned long flags;
|
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 19:01:12 +08:00
|
|
|
int ret, idx;
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev || !nb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
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 19:01:12 +08:00
|
|
|
idx = find_cable_index_by_id(edev, id);
|
2016-06-23 18:34:30 +08:00
|
|
|
if (idx < 0)
|
|
|
|
return idx;
|
2015-03-22 00:26:24 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
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 19:01:12 +08:00
|
|
|
ret = raw_notifier_chain_unregister(&edev->nh[idx], nb);
|
2015-03-22 00:26:24 +08:00
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
2012-04-20 13:16:24 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
|
|
|
|
|
2017-03-29 18:30:17 +08:00
|
|
|
/**
|
|
|
|
* extcon_register_notifier_all() - Register a notifier block for all connectors
|
2017-04-24 04:15:20 +08:00
|
|
|
* @edev: the extcon device that has the external connector.
|
2017-03-29 18:30:17 +08:00
|
|
|
* @nb: a notifier block to be registered.
|
|
|
|
*
|
2017-04-24 04:15:20 +08:00
|
|
|
* This function registers a notifier block in order to receive the state
|
2017-03-29 18:30:17 +08:00
|
|
|
* change of all supported external connectors from extcon device.
|
2017-04-24 04:15:20 +08:00
|
|
|
* And the second parameter given to the callback of nb (val) is
|
2017-03-29 18:30:17 +08:00
|
|
|
* the current state and third parameter is the edev pointer.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_register_notifier_all(struct extcon_dev *edev,
|
|
|
|
struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!edev || !nb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
ret = raw_notifier_chain_register(&edev->nh_all, nb);
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_register_notifier_all);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extcon_unregister_notifier_all() - Unregister a notifier block from extcon.
|
|
|
|
* @edev: the extcon device that has the external connecotr.
|
|
|
|
* @nb: a notifier block to be registered.
|
|
|
|
*
|
|
|
|
* Returns 0 if success or error number if fail
|
|
|
|
*/
|
|
|
|
int extcon_unregister_notifier_all(struct extcon_dev *edev,
|
|
|
|
struct notifier_block *nb)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!edev || !nb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&edev->lock, flags);
|
|
|
|
ret = raw_notifier_chain_unregister(&edev->nh_all, nb);
|
|
|
|
spin_unlock_irqrestore(&edev->lock, flags);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_unregister_notifier_all);
|
|
|
|
|
2013-07-25 06:05:10 +08:00
|
|
|
static struct attribute *extcon_attrs[] = {
|
|
|
|
&dev_attr_state.attr,
|
|
|
|
&dev_attr_name.attr,
|
|
|
|
NULL,
|
2012-04-20 13:16:22 +08:00
|
|
|
};
|
2013-07-25 06:05:10 +08:00
|
|
|
ATTRIBUTE_GROUPS(extcon);
|
2012-04-20 13:16:22 +08:00
|
|
|
|
|
|
|
static int create_extcon_class(void)
|
|
|
|
{
|
|
|
|
if (!extcon_class) {
|
|
|
|
extcon_class = class_create(THIS_MODULE, "extcon");
|
|
|
|
if (IS_ERR(extcon_class))
|
|
|
|
return PTR_ERR(extcon_class);
|
2013-07-25 06:05:10 +08:00
|
|
|
extcon_class->dev_groups = extcon_groups;
|
2012-04-20 13:16:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extcon_dev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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 13:16:26 +08:00
|
|
|
static const char *muex_name = "mutually_exclusive";
|
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 13:16:25 +08:00
|
|
|
static void dummy_sysfs_dev_release(struct device *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-24 18:46:49 +08:00
|
|
|
/*
|
|
|
|
* extcon_dev_allocate() - Allocate the memory of extcon device.
|
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
|
|
|
* @supported_cable: Array of supported extcon ending with EXTCON_NONE.
|
2014-04-24 18:46:49 +08:00
|
|
|
* If supported_cable is NULL, cable name related APIs
|
|
|
|
* are disabled.
|
|
|
|
*
|
|
|
|
* This function allocates the memory for extcon device without allocating
|
|
|
|
* memory in each extcon provider driver and initialize default setting for
|
|
|
|
* extcon device.
|
|
|
|
*
|
|
|
|
* Return the pointer of extcon device if success or ERR_PTR(err) if fail
|
|
|
|
*/
|
2015-06-12 10:10:06 +08:00
|
|
|
struct extcon_dev *extcon_dev_allocate(const unsigned int *supported_cable)
|
2014-04-24 18:46:49 +08:00
|
|
|
{
|
|
|
|
struct extcon_dev *edev;
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!supported_cable)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
2014-04-24 18:46:49 +08:00
|
|
|
edev = kzalloc(sizeof(*edev), GFP_KERNEL);
|
|
|
|
if (!edev)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
edev->max_supported = 0;
|
|
|
|
edev->supported_cable = supported_cable;
|
|
|
|
|
|
|
|
return edev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* extcon_dev_free() - Free the memory of extcon device.
|
|
|
|
* @edev: the extcon device to free
|
|
|
|
*/
|
|
|
|
void extcon_dev_free(struct extcon_dev *edev)
|
|
|
|
{
|
|
|
|
kfree(edev);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_dev_free);
|
|
|
|
|
2012-04-20 13:16:22 +08:00
|
|
|
/**
|
|
|
|
* extcon_dev_register() - Register a new extcon device
|
|
|
|
* @edev : the new extcon device (should be allocated before calling)
|
|
|
|
*
|
|
|
|
* Among the members of edev struct, please set the "user initializing data"
|
|
|
|
* in any case and set the "optional callbacks" if required. However, please
|
|
|
|
* do not set the values of "internal data", which are initialized by
|
|
|
|
* this function.
|
|
|
|
*/
|
2013-09-27 08:20:26 +08:00
|
|
|
int extcon_dev_register(struct extcon_dev *edev)
|
2012-04-20 13:16:22 +08: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 13:16:25 +08:00
|
|
|
int ret, index = 0;
|
2015-04-15 14:02:01 +08:00
|
|
|
static atomic_t edev_no = ATOMIC_INIT(-1);
|
2012-04-20 13:16:22 +08:00
|
|
|
|
|
|
|
if (!extcon_class) {
|
|
|
|
ret = create_extcon_class();
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev || !edev->supported_cable)
|
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
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
for (; edev->supported_cable[index] != EXTCON_NONE; 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 13:16:25 +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
|
|
|
edev->max_supported = 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 13:16:25 +08:00
|
|
|
if (index > SUPPORTED_CABLE_MAX) {
|
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
|
|
|
dev_err(&edev->dev,
|
|
|
|
"exceed the maximum number of supported cables\n");
|
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 13:16:25 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
edev->dev.class = extcon_class;
|
|
|
|
edev->dev.release = extcon_dev_release;
|
2012-04-20 13:16:22 +08:00
|
|
|
|
2015-04-15 14:02:01 +08:00
|
|
|
edev->name = dev_name(edev->dev.parent);
|
2013-09-27 08:20:26 +08:00
|
|
|
if (IS_ERR_OR_NULL(edev->name)) {
|
|
|
|
dev_err(&edev->dev,
|
|
|
|
"extcon device name is null\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-04-15 14:02:01 +08:00
|
|
|
dev_set_name(&edev->dev, "extcon%lu",
|
|
|
|
(unsigned long)atomic_inc_return(&edev_no));
|
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 13:16:25 +08:00
|
|
|
|
|
|
|
if (edev->max_supported) {
|
|
|
|
char buf[10];
|
|
|
|
char *str;
|
|
|
|
struct extcon_cable *cable;
|
|
|
|
|
|
|
|
edev->cables = kzalloc(sizeof(struct extcon_cable) *
|
|
|
|
edev->max_supported, GFP_KERNEL);
|
|
|
|
if (!edev->cables) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_sysfs_alloc;
|
|
|
|
}
|
|
|
|
for (index = 0; index < edev->max_supported; index++) {
|
|
|
|
cable = &edev->cables[index];
|
|
|
|
|
|
|
|
snprintf(buf, 10, "cable.%d", index);
|
|
|
|
str = kzalloc(sizeof(char) * (strlen(buf) + 1),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!str) {
|
|
|
|
for (index--; index >= 0; index--) {
|
|
|
|
cable = &edev->cables[index];
|
|
|
|
kfree(cable->attr_g.name);
|
|
|
|
}
|
|
|
|
ret = -ENOMEM;
|
|
|
|
|
|
|
|
goto err_alloc_cables;
|
|
|
|
}
|
|
|
|
strcpy(str, buf);
|
|
|
|
|
|
|
|
cable->edev = edev;
|
|
|
|
cable->cable_index = index;
|
|
|
|
cable->attrs[0] = &cable->attr_name.attr;
|
|
|
|
cable->attrs[1] = &cable->attr_state.attr;
|
|
|
|
cable->attrs[2] = NULL;
|
|
|
|
cable->attr_g.name = str;
|
|
|
|
cable->attr_g.attrs = cable->attrs;
|
|
|
|
|
2012-08-17 03:03:21 +08:00
|
|
|
sysfs_attr_init(&cable->attr_name.attr);
|
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 13:16:25 +08:00
|
|
|
cable->attr_name.attr.name = "name";
|
|
|
|
cable->attr_name.attr.mode = 0444;
|
|
|
|
cable->attr_name.show = cable_name_show;
|
|
|
|
|
2012-08-17 03:03:21 +08:00
|
|
|
sysfs_attr_init(&cable->attr_state.attr);
|
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 13:16:25 +08:00
|
|
|
cable->attr_state.attr.name = "state";
|
2013-05-22 18:31:59 +08:00
|
|
|
cable->attr_state.attr.mode = 0444;
|
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 13:16:25 +08:00
|
|
|
cable->attr_state.show = cable_state_show;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 13:16:26 +08:00
|
|
|
if (edev->max_supported && edev->mutually_exclusive) {
|
|
|
|
char buf[80];
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
/* Count the size of mutually_exclusive array */
|
|
|
|
for (index = 0; edev->mutually_exclusive[index]; index++)
|
|
|
|
;
|
|
|
|
|
|
|
|
edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
|
|
|
|
(index + 1), GFP_KERNEL);
|
|
|
|
if (!edev->attrs_muex) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_muex;
|
|
|
|
}
|
|
|
|
|
|
|
|
edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
|
|
|
|
index, GFP_KERNEL);
|
|
|
|
if (!edev->d_attrs_muex) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
kfree(edev->attrs_muex);
|
|
|
|
goto err_muex;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (index = 0; edev->mutually_exclusive[index]; index++) {
|
|
|
|
sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
|
|
|
|
name = kzalloc(sizeof(char) * (strlen(buf) + 1),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!name) {
|
|
|
|
for (index--; index >= 0; index--) {
|
|
|
|
kfree(edev->d_attrs_muex[index].attr.
|
|
|
|
name);
|
|
|
|
}
|
|
|
|
kfree(edev->d_attrs_muex);
|
|
|
|
kfree(edev->attrs_muex);
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_muex;
|
|
|
|
}
|
|
|
|
strcpy(name, buf);
|
2012-08-17 03:03:21 +08:00
|
|
|
sysfs_attr_init(&edev->d_attrs_muex[index].attr);
|
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 13:16:26 +08:00
|
|
|
edev->d_attrs_muex[index].attr.name = name;
|
|
|
|
edev->d_attrs_muex[index].attr.mode = 0000;
|
|
|
|
edev->attrs_muex[index] = &edev->d_attrs_muex[index]
|
|
|
|
.attr;
|
|
|
|
}
|
|
|
|
edev->attr_g_muex.name = muex_name;
|
|
|
|
edev->attr_g_muex.attrs = edev->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 13:16:25 +08:00
|
|
|
if (edev->max_supported) {
|
|
|
|
edev->extcon_dev_type.groups =
|
|
|
|
kzalloc(sizeof(struct attribute_group *) *
|
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 13:16:26 +08:00
|
|
|
(edev->max_supported + 2), GFP_KERNEL);
|
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 13:16:25 +08:00
|
|
|
if (!edev->extcon_dev_type.groups) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_alloc_groups;
|
|
|
|
}
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
edev->extcon_dev_type.name = dev_name(&edev->dev);
|
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 13:16:25 +08:00
|
|
|
edev->extcon_dev_type.release = dummy_sysfs_dev_release;
|
|
|
|
|
|
|
|
for (index = 0; index < edev->max_supported; index++)
|
|
|
|
edev->extcon_dev_type.groups[index] =
|
|
|
|
&edev->cables[index].attr_g;
|
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 13:16:26 +08:00
|
|
|
if (edev->mutually_exclusive)
|
|
|
|
edev->extcon_dev_type.groups[index] =
|
|
|
|
&edev->attr_g_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 13:16:25 +08:00
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
edev->dev.type = &edev->extcon_dev_type;
|
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 13:16:25 +08:00
|
|
|
}
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
ret = device_register(&edev->dev);
|
2012-04-20 13:16:22 +08:00
|
|
|
if (ret) {
|
2013-09-27 08:19:40 +08:00
|
|
|
put_device(&edev->dev);
|
2012-04-20 13:16:22 +08:00
|
|
|
goto err_dev;
|
|
|
|
}
|
|
|
|
|
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 13:16:25 +08:00
|
|
|
spin_lock_init(&edev->lock);
|
2017-04-24 02:54:11 +08:00
|
|
|
edev->nh = devm_kcalloc(&edev->dev, edev->max_supported,
|
|
|
|
sizeof(*edev->nh), GFP_KERNEL);
|
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 19:01:12 +08:00
|
|
|
if (!edev->nh) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (index = 0; index < edev->max_supported; index++)
|
|
|
|
RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]);
|
2012-04-20 13:16:24 +08:00
|
|
|
|
2017-03-29 18:30:17 +08:00
|
|
|
RAW_INIT_NOTIFIER_HEAD(&edev->nh_all);
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
dev_set_drvdata(&edev->dev, edev);
|
2012-04-20 13:16:22 +08:00
|
|
|
edev->state = 0;
|
2012-04-20 13:16:24 +08:00
|
|
|
|
|
|
|
mutex_lock(&extcon_dev_list_lock);
|
|
|
|
list_add(&edev->entry, &extcon_dev_list);
|
|
|
|
mutex_unlock(&extcon_dev_list_lock);
|
|
|
|
|
2012-04-20 13:16:22 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_dev:
|
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 13:16:25 +08:00
|
|
|
if (edev->max_supported)
|
|
|
|
kfree(edev->extcon_dev_type.groups);
|
|
|
|
err_alloc_groups:
|
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 13:16:26 +08:00
|
|
|
if (edev->max_supported && edev->mutually_exclusive) {
|
|
|
|
for (index = 0; edev->mutually_exclusive[index]; index++)
|
|
|
|
kfree(edev->d_attrs_muex[index].attr.name);
|
|
|
|
kfree(edev->d_attrs_muex);
|
|
|
|
kfree(edev->attrs_muex);
|
|
|
|
}
|
|
|
|
err_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 13:16:25 +08:00
|
|
|
for (index = 0; index < edev->max_supported; index++)
|
|
|
|
kfree(edev->cables[index].attr_g.name);
|
|
|
|
err_alloc_cables:
|
|
|
|
if (edev->max_supported)
|
|
|
|
kfree(edev->cables);
|
|
|
|
err_sysfs_alloc:
|
2012-04-20 13:16:22 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_dev_register);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* extcon_dev_unregister() - Unregister the extcon device.
|
2012-08-23 08:11:54 +08:00
|
|
|
* @edev: the extcon device instance to be unregistered.
|
2012-04-20 13:16:22 +08:00
|
|
|
*
|
|
|
|
* Note that this does not call kfree(edev) because edev was not allocated
|
|
|
|
* by this class.
|
|
|
|
*/
|
|
|
|
void extcon_dev_unregister(struct extcon_dev *edev)
|
|
|
|
{
|
2012-10-22 08:43:33 +08:00
|
|
|
int index;
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!edev)
|
|
|
|
return;
|
|
|
|
|
2012-10-22 08:43:33 +08:00
|
|
|
mutex_lock(&extcon_dev_list_lock);
|
|
|
|
list_del(&edev->entry);
|
|
|
|
mutex_unlock(&extcon_dev_list_lock);
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
if (IS_ERR_OR_NULL(get_device(&edev->dev))) {
|
|
|
|
dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n",
|
|
|
|
dev_name(&edev->dev));
|
2012-10-22 08:43:33 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-02 06:48:14 +08:00
|
|
|
device_unregister(&edev->dev);
|
|
|
|
|
2012-10-22 08:43:33 +08:00
|
|
|
if (edev->mutually_exclusive && edev->max_supported) {
|
|
|
|
for (index = 0; edev->mutually_exclusive[index];
|
|
|
|
index++)
|
|
|
|
kfree(edev->d_attrs_muex[index].attr.name);
|
|
|
|
kfree(edev->d_attrs_muex);
|
|
|
|
kfree(edev->attrs_muex);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (index = 0; index < edev->max_supported; index++)
|
|
|
|
kfree(edev->cables[index].attr_g.name);
|
|
|
|
|
|
|
|
if (edev->max_supported) {
|
|
|
|
kfree(edev->extcon_dev_type.groups);
|
|
|
|
kfree(edev->cables);
|
|
|
|
}
|
|
|
|
|
2013-09-27 08:19:40 +08:00
|
|
|
put_device(&edev->dev);
|
2012-04-20 13:16:22 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_dev_unregister);
|
|
|
|
|
2014-03-18 18:55:46 +08:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
/*
|
|
|
|
* extcon_get_edev_by_phandle - Get the extcon device from devicetree
|
|
|
|
* @dev - instance to the given device
|
|
|
|
* @index - index into list of extcon_dev
|
|
|
|
*
|
|
|
|
* return the instance of extcon device
|
|
|
|
*/
|
|
|
|
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
|
|
|
{
|
|
|
|
struct device_node *node;
|
|
|
|
struct extcon_dev *edev;
|
|
|
|
|
2015-06-21 22:48:36 +08:00
|
|
|
if (!dev)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
2014-03-18 18:55:46 +08:00
|
|
|
if (!dev->of_node) {
|
2016-07-06 02:57:05 +08:00
|
|
|
dev_dbg(dev, "device does not have a device node entry\n");
|
2014-03-18 18:55:46 +08:00
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
node = of_parse_phandle(dev->of_node, "extcon", index);
|
|
|
|
if (!node) {
|
2016-07-06 02:57:05 +08:00
|
|
|
dev_dbg(dev, "failed to get phandle in %s node\n",
|
2014-03-18 18:55:46 +08:00
|
|
|
dev->of_node->full_name);
|
|
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:11:44 +08:00
|
|
|
mutex_lock(&extcon_dev_list_lock);
|
|
|
|
list_for_each_entry(edev, &extcon_dev_list, entry) {
|
|
|
|
if (edev->dev.parent && edev->dev.parent->of_node == node) {
|
|
|
|
mutex_unlock(&extcon_dev_list_lock);
|
2016-07-01 17:41:55 +08:00
|
|
|
of_node_put(node);
|
2014-10-16 21:11:44 +08:00
|
|
|
return edev;
|
|
|
|
}
|
2014-03-18 18:55:46 +08:00
|
|
|
}
|
2014-10-16 21:11:44 +08:00
|
|
|
mutex_unlock(&extcon_dev_list_lock);
|
2016-07-01 17:41:55 +08:00
|
|
|
of_node_put(node);
|
2014-03-18 18:55:46 +08:00
|
|
|
|
2014-10-16 21:11:44 +08:00
|
|
|
return ERR_PTR(-EPROBE_DEFER);
|
2014-03-18 18:55:46 +08:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-ENOSYS);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_OF */
|
|
|
|
EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
|
|
|
|
|
2015-04-15 12:57:51 +08:00
|
|
|
/**
|
|
|
|
* extcon_get_edev_name() - Get the name of the extcon device.
|
|
|
|
* @edev: the extcon device
|
|
|
|
*/
|
|
|
|
const char *extcon_get_edev_name(struct extcon_dev *edev)
|
|
|
|
{
|
|
|
|
return !edev ? NULL : edev->name;
|
|
|
|
}
|
|
|
|
|
2012-04-20 13:16:22 +08:00
|
|
|
static int __init extcon_class_init(void)
|
|
|
|
{
|
|
|
|
return create_extcon_class();
|
|
|
|
}
|
|
|
|
module_init(extcon_class_init);
|
|
|
|
|
|
|
|
static void __exit extcon_class_exit(void)
|
|
|
|
{
|
|
|
|
class_destroy(extcon_class);
|
|
|
|
}
|
|
|
|
module_exit(extcon_class_exit);
|
|
|
|
|
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
|
|
|
MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
|
2012-04-20 13:16:22 +08:00
|
|
|
MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
|
|
|
|
MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>");
|
|
|
|
MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
|
|
|
|
MODULE_DESCRIPTION("External connector (extcon) class driver");
|
|
|
|
MODULE_LICENSE("GPL");
|