Skip to contentSkip to conversation

extcon: Introduce support of Basin Cove PMIC

PATCH Applied Andy Shevchenko 2 participants 4 messages Mar 19, 2019 – Mar 21, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover extcon: Introduce support of Basin Cove PMIC

On Intel Merrifield platforms the Basin Cove PMIC responsible for USB DR detection among other things.

Here is the extcon driver to support USB DR and charger detection.

Since v2:
- rebase on top of extcon-next
- update copyright year
- address most of Chanwoo's comments
(rest is left in similarity with other Intel extcon drivers)

Andy Shevchenko (2):
extcon: intel: Split out some definitions to a common header
extcon: mrfld: Introduce extcon driver for Basin Cove PMIC

 drivers/extcon/Kconfig               |   7 +
 drivers/extcon/Makefile              |   1 +
 drivers/extcon/extcon-intel-cht-wc.c |  21 +-
 drivers/extcon/extcon-intel-mrfld.c  | 284 +++++++++++++++++++++++++++
 drivers/extcon/extcon-intel.h        |  20 ++
 5 files changed, 319 insertions(+), 14 deletions(-)
 create mode 100644 drivers/extcon/extcon-intel-mrfld.c
 create mode 100644 drivers/extcon/extcon-intel.h
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/2 extcon: intel: Split out some definitions to a common header

We are going to use some definitions in the other Intel extcon drivers, thus, split out them to a common header file.

---
 drivers/extcon/extcon-intel-cht-wc.c | 21 +++++++--------------
 drivers/extcon/extcon-intel.h        | 20 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 14 deletions(-)
 create mode 100644 drivers/extcon/extcon-intel.h
drivers/extcon/extcon-intel-cht-wc.c +7 -14
index 53b28ecc4ad1..9d32150e68db 100644
@@ -17,6 +17,8 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
+#include "extcon-intel.h"
+
 #define CHT_WC_PHYCTRL			0x5e07
 
 #define CHT_WC_CHGRCTRL0		0x5e16
@@ -80,15 +82,6 @@
 #define CHT_WC_VBUS_GPIO_CTLO_DRV_OD	BIT(4)
 #define CHT_WC_VBUS_GPIO_CTLO_DIR_OUT	BIT(5)
 
-enum cht_wc_usb_id {
-	USB_ID_OTG,
-	USB_ID_GND,
-	USB_ID_FLOAT,
-	USB_RID_A,
-	USB_RID_B,
-	USB_RID_C,
-};
-
 enum cht_wc_mux_select {
 	MUX_SEL_PMIC = 0,
 	MUX_SEL_SOC,
@@ -116,9 +109,9 @@ static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
 {
 	switch ((pwrsrc_sts & CHT_WC_PWRSRC_USBID_MASK) >> CHT_WC_PWRSRC_USBID_SHIFT) {
 	case CHT_WC_PWRSRC_RID_GND:
-		return USB_ID_GND;
+		return INTEL_USB_ID_GND;
 	case CHT_WC_PWRSRC_RID_FLOAT:
-		return USB_ID_FLOAT;
+		return INTEL_USB_ID_FLOAT;
 	case CHT_WC_PWRSRC_RID_ACA:
 	default:
 		/*
@@ -126,7 +119,7 @@ static int cht_wc_extcon_get_id(struct cht_wc_extcon_data *ext, int pwrsrc_sts)
 		 * the USBID GPADC channel here and determine ACA role
 		 * based on that.
 		 */
-		return USB_ID_FLOAT;
+		return INTEL_USB_ID_FLOAT;
 	}
 }
 
@@ -260,7 +253,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
 	}
 
 	id = cht_wc_extcon_get_id(ext, pwrsrc_sts);
-	if (id == USB_ID_GND) {
+	if (id == INTEL_USB_ID_GND) {
 		cht_wc_extcon_enable_charging(ext, false);
 		cht_wc_extcon_set_otgmode(ext, true);
 
@@ -293,7 +286,7 @@ static void cht_wc_extcon_pwrsrc_event(struct cht_wc_extcon_data *ext)
 		ext->previous_cable = cable;
 	}
 
-	ext->usb_host = ((id == USB_ID_GND) || (id == USB_RID_A));
+	ext->usb_host = ((id == INTEL_USB_ID_GND) || (id == INTEL_USB_RID_A));
 	extcon_set_state_sync(ext->edev, EXTCON_USB_HOST, ext->usb_host);
 }
 
drivers/extcon/extcon-intel.h new file +20 -0
new file mode 100644
index 000000000000..0ad645ec7b33
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Header file for Intel extcon hardware
+ *
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ */
+
+#ifndef __EXTCON_INTEL_H__
+#define __EXTCON_INTEL_H__
+
+enum extcon_intel_usb_id {
+	INTEL_USB_ID_OTG,
+	INTEL_USB_ID_GND,
+	INTEL_USB_ID_FLOAT,
+	INTEL_USB_RID_A,
+	INTEL_USB_RID_B,
+	INTEL_USB_RID_C,
+};
+
+#endif	/* __EXTCON_INTEL_H__ */
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 2/2 extcon: mrfld: Introduce extcon driver for Basin Cove PMIC

In reply to Andy Shevchenko

On Intel Merrifield the Basin Cove PMIC provides a feature to detect the USB connection type. This driver utilizes the feature in order to support the USB dual role detection.

---
 drivers/extcon/Kconfig              |   7 +
 drivers/extcon/Makefile             |   1 +
 drivers/extcon/extcon-intel-mrfld.c | 284 ++++++++++++++++++++++++++++
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/extcon/extcon-intel-mrfld.c
drivers/extcon/Kconfig +7 -0
index 8e17149655f0..46ad2bbeb44c 100644
@@ -60,6 +60,13 @@ config EXTCON_INTEL_CHT_WC
 	  Say Y here to enable extcon support for charger detection / control
 	  on the Intel Cherrytrail Whiskey Cove PMIC.
 
+config EXTCON_INTEL_MRFLD
+	tristate "Intel Merrifield Basin Cove PMIC extcon driver"
+	depends on INTEL_SOC_PMIC_MRFLD
+	help
+	  Say Y here to enable extcon support for charger detection / control
+	  on the Intel Merrifield Basin Cove PMIC.
+
 config EXTCON_MAX14577
 	tristate "Maxim MAX14577/77836 EXTCON Support"
 	depends on MFD_MAX14577
drivers/extcon/Makefile +1 -0
index 261ce4cfe209..d3941a735df3 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_EXTCON_AXP288)	+= extcon-axp288.o
 obj-$(CONFIG_EXTCON_GPIO)	+= extcon-gpio.o
 obj-$(CONFIG_EXTCON_INTEL_INT3496) += extcon-intel-int3496.o
 obj-$(CONFIG_EXTCON_INTEL_CHT_WC) += extcon-intel-cht-wc.o
+obj-$(CONFIG_EXTCON_INTEL_MRFLD) += extcon-intel-mrfld.o
 obj-$(CONFIG_EXTCON_MAX14577)	+= extcon-max14577.o
 obj-$(CONFIG_EXTCON_MAX3355)	+= extcon-max3355.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
drivers/extcon/extcon-intel-mrfld.c new file +284 -0

284 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer Applied
#3 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 15 lines · Andy Shevchenko

On Intel Merrifield platforms the Basin Cove PMIC responsible for USB DR detection among other things.

Here is the extcon driver to support USB DR and charger detection.

Since v2:
- rebase on top of extcon-next
- update copyright year
- address most of Chanwoo's comments
(rest is left in similarity with other Intel extcon drivers)

Andy Shevchenko (2):
extcon: intel: Split out some definitions to a common header
extcon: mrfld: Introduce extcon driver for Basin Cove PMIC

Quoted 9 lines
 drivers/extcon/Kconfig               |   7 +
 drivers/extcon/Makefile              |   1 +
 drivers/extcon/extcon-intel-cht-wc.c |  21 +-
 drivers/extcon/extcon-intel-mrfld.c  | 284 +++++++++++++++++++++++++++
 drivers/extcon/extcon-intel.h        |  20 ++
 5 files changed, 319 insertions(+), 14 deletions(-)
 create mode 100644 drivers/extcon/extcon-intel-mrfld.c
 create mode 100644 drivers/extcon/extcon-intel.h

Applied them to extcon-next branch. Thanks.

Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics