From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <kishon@ti.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 28/51] extcon: Add the extcon_type to gather each connector into five category
Date: Wed, 14 Sep 2016 13:14:09 +0530 [thread overview]
Message-ID: <1473839072-5673-29-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1473839072-5673-1-git-send-email-kishon@ti.com>
From: Chanwoo Choi <cw00.choi@samsung.com>
This patch adds the new extcon type to group the each connecotr
into following five category. This type would be used to handle
the connectors as a group unit instead of a connector unit.
- EXTCON_TYPE_USB : USB connector
- EXTCON_TYPE_CHG : Charger connector
- EXTCON_TYPE_JACK : Jack connector
- EXTCON_TYPE_DISP : Display connector
- EXTCON_TYPE_MISC : Miscellaneous connector
Also, each external connector is possible to belong to one more extcon type.
In caes of EXTCON_CHG_USB_SDP, it have the EXTCON_TYPE_CHG and EXTCON_TYPE_USB.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
Tested-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/extcon/extcon.c | 159 ++++++++++++++++++++++++++++++++++++++---------
include/linux/extcon.h | 9 +++
2 files changed, 139 insertions(+), 29 deletions(-)
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 9a266e5..f209a69 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -38,43 +38,144 @@
#define SUPPORTED_CABLE_MAX 32
#define CABLE_NAME_MAX 30
-static const char *extcon_name[] = {
- [EXTCON_NONE] = "NONE",
+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",
+ },
/* USB external connector */
- [EXTCON_USB] = "USB",
- [EXTCON_USB_HOST] = "USB-HOST",
+ [EXTCON_USB] = {
+ .type = EXTCON_TYPE_USB,
+ .id = EXTCON_USB,
+ .name = "USB",
+ },
+ [EXTCON_USB_HOST] = {
+ .type = EXTCON_TYPE_USB,
+ .id = EXTCON_USB_HOST,
+ .name = "USB_HOST",
+ },
/* Charging external connector */
- [EXTCON_CHG_USB_SDP] = "SDP",
- [EXTCON_CHG_USB_DCP] = "DCP",
- [EXTCON_CHG_USB_CDP] = "CDP",
- [EXTCON_CHG_USB_ACA] = "ACA",
- [EXTCON_CHG_USB_FAST] = "FAST-CHARGER",
- [EXTCON_CHG_USB_SLOW] = "SLOW-CHARGER",
+ [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",
+ },
/* Jack external connector */
- [EXTCON_JACK_MICROPHONE] = "MICROPHONE",
- [EXTCON_JACK_HEADPHONE] = "HEADPHONE",
- [EXTCON_JACK_LINE_IN] = "LINE-IN",
- [EXTCON_JACK_LINE_OUT] = "LINE-OUT",
- [EXTCON_JACK_VIDEO_IN] = "VIDEO-IN",
- [EXTCON_JACK_VIDEO_OUT] = "VIDEO-OUT",
- [EXTCON_JACK_SPDIF_IN] = "SPDIF-IN",
- [EXTCON_JACK_SPDIF_OUT] = "SPDIF-OUT",
+ [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",
+ },
/* Display external connector */
- [EXTCON_DISP_HDMI] = "HDMI",
- [EXTCON_DISP_MHL] = "MHL",
- [EXTCON_DISP_DVI] = "DVI",
- [EXTCON_DISP_VGA] = "VGA",
+ [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",
+ },
/* Miscellaneous external connector */
- [EXTCON_DOCK] = "DOCK",
- [EXTCON_JIG] = "JIG",
- [EXTCON_MECHANICAL] = "MECHANICAL",
-
- NULL,
+ [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 */ }
};
/**
@@ -168,7 +269,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
for (i = 0; i < edev->max_supported; i++) {
count += sprintf(buf + count, "%s=%d\n",
- extcon_name[edev->supported_cable[i]],
+ extcon_info[edev->supported_cable[i]].name,
!!(edev->state & (1 << i)));
}
@@ -193,7 +294,7 @@ static ssize_t cable_name_show(struct device *dev,
int i = cable->cable_index;
return sprintf(buf, "%s\n",
- extcon_name[cable->edev->supported_cable[i]]);
+ extcon_info[cable->edev->supported_cable[i]].name);
}
static ssize_t cable_state_show(struct device *dev,
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 667b1d3..46d8028 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -29,6 +29,15 @@
#include <linux/device.h>
/*
+ * Define the type of supported external connectors
+ */
+#define EXTCON_TYPE_USB BIT(0) /* USB connector */
+#define EXTCON_TYPE_CHG BIT(1) /* Charger connector */
+#define EXTCON_TYPE_JACK BIT(2) /* Jack connector */
+#define EXTCON_TYPE_DISP BIT(3) /* Display connector */
+#define EXTCON_TYPE_MISC BIT(4) /* Miscellaneous connector */
+
+/*
* Define the unique id of supported external connectors
*/
#define EXTCON_NONE 0
--
1.7.9.5
next prev parent reply other threads:[~2016-09-14 7:45 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-14 7:43 [GIT PULL] phy: for 4.9 Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 01/51] phy: exynos5-usbdrd: Remove "static" from local variable Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 02/51] dt: bindings: add bindings for Allwinner A64 usb phy Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 03/51] phy: sun4i: add support for " Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 04/51] phy: bcm-ns-usb3: new driver for USB 3.0 PHY on Northstar Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 05/51] phy: qcom-ufs: use of_property_read_bool Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 06/51] Documentation: bindings: add DT documentation for Rockchip USB2PHY Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 07/51] phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 08/51] Documentation: bindings: add dt documentation for Rockchip PCIe PHY Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 09/51] phy: add a driver for the Rockchip SoC internal " Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 10/51] phy: tegra: add missing header dependencies Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 11/51] phy: tegra: mark tegra_xusb_lane_lookup_function() static Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 12/51] phy: bcm-ns2-pcie: Get rid of struct ns2_pci_phy Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 13/51] phy: bcm-ns2-pcie: Set missing .owner field in ns2_pci_phy_ops Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 14/51] phy: rcar-gen3-usb2: revise the example of device tree doc Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 15/51] phy: rcar-gen3-usb2: Add a compatible string for r8a7796 Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 16/51] phy: omap-usb2: support suspend/resume Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 17/51] dt-bindings: phy: ti: add documentation for ti,dra7x-usb2 Kishon Vijay Abraham I
2016-09-14 7:43 ` [PATCH 18/51] phy: rockchip-inno-usb2: add COMMON_CLK dependency Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 19/51] extcon: adc-jack: update cable state during boot Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 20/51] extcon: Move extcon_get_edev_by_phandle() errors to dbg level Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 21/51] extcon: arizona: Remove unneeded semi-colon Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 22/51] extcon: arizona: Remove the usage of extcon_update_state() Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 23/51] extcon: adc-jack: Remove the usage of extcon_set_state() Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 24/51] extcon: gpio: " Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 25/51] extcon: Remove the state_store() to prevent the wrong access Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 26/51] extcon: Block the bit masking operation for cable state except for extcon core Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 27/51] extcon: Fix compile time warning Kishon Vijay Abraham I
2016-09-14 7:44 ` Kishon Vijay Abraham I [this message]
2016-09-14 7:44 ` [PATCH 29/51] extcon: Add the support for extcon property according to extcon type Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 30/51] extcon: Add the support for the capability of each property Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 31/51] extcon: Rename the extcon_set/get_state() to maintain the function naming pattern Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 32/51] extcon: Add the synchronization extcon APIs to support the notification Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 33/51] extcon: Add EXTCON_DISP_DP and the property for USB Type-C Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 34/51] extcon: Add new EXTCON_DISP_HMD for Head-mounted Display device Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 35/51] extcon: Add new EXTCON_CHG_WPT for Wireless Power Transfer device Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 36/51] extcon: Introduce EXTCON_PROP_USB_SS property for SuperSpeed mode Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 37/51] phy: da8xx-usb: Fix syscon device name Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 38/51] phy: Add USB Type-C PHY driver for rk3399 Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 39/51] Documentation: bindings: add dt doc for Rockchip USB Type-C PHY Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 40/51] usb: phy: add USB_SUPPORT dependency Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 41/51] phy: rockchip-typec: add pm runtime support Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 42/51] phy-sun4i-usb: Use bool where appropriate Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 43/51] phy-sun4i-usb: Refactor forced session ending Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 44/51] phy-sun4i-usb: Simplify missing dr_mode handling Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 45/51] phy-sun4i-usb: Add support for phy_set_mode Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 46/51] phy-sun4i-usb: Warn when external vbus is detected Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 47/51] phy: Add reset callback Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 48/51] phy: rockchip-usb: use rockchip_usb_phy_reset to reset phy during wakeup Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 49/51] phy: sun4i-usb: Use spinlock to guard phyctl register access Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 50/51] phy-twl4030-usb: better handle musb_mailbox() failure Kishon Vijay Abraham I
2016-09-14 7:44 ` [PATCH 51/51] phy-twl4030-usb: initialize charging-related stuff via pm_runtime Kishon Vijay Abraham I
2016-09-15 8:38 ` [GIT PULL] phy: for 4.9 Greg KH
2016-09-15 10:22 ` Kishon Vijay Abraham I
2016-09-15 10:36 ` Greg KH
2016-09-15 10:56 ` Kishon Vijay Abraham I
2016-09-15 11:13 ` Kishon Vijay Abraham I
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473839072-5673-29-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox