Skip to contentSkip to conversation

extcon: intel-cht-wc: Add Intel Cherry Trail Whiskey Cove PMIC extcon driver

PATCH Applied Hans de Goede 2 participants 3 messages Mar 23, 2017 – Mar 24, 2017 External connector subsystem (extcon)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 extcon: intel-cht-wc: Add Intel Cherry Trail Whiskey Cove PMIC extcon driver

Add a driver for charger detection / control on the Intel Cherrytrail Whiskey Cove PMIC.

---
Changes in v2:
-Improve wait for charger detection loop, use jiffies to get an accurate timeout -Sort registers by address, remove duplicate definition
-Return IRQ_NONE on interrupt handling errors
-Various small style cleanups
-Fix reporting no charger cable being present when detecting the same
charger type 2 times in a row
-Reset to autonomous / hw-mode on probe-error and on remove
Changes in v3:
-Add intel prefix to Kconfig symbol and filename
-Clarified "Unhandled charger type" warning msg
-Dropped usb_id sysfs attribute

---
 drivers/extcon/Kconfig               |   7 +
 drivers/extcon/Makefile              |   1 +
 drivers/extcon/extcon-intel-cht-wc.c | 352 +++++++++++++++++++++++++++++++++++
 3 files changed, 360 insertions(+)
 create mode 100644 drivers/extcon/extcon-intel-cht-wc.c
drivers/extcon/Kconfig +7 -0
index 96bbae5..bcf2cf6 100644
@@ -52,6 +52,13 @@ config EXTCON_INTEL_INT3496
 	  This ACPI device is typically found on Intel Baytrail or Cherrytrail
 	  based tablets, or other Baytrail / Cherrytrail devices.
 
+config EXTCON_INTEL_CHT_WC
+	tristate "Intel Cherrytrail Whiskey Cove PMIC extcon driver"
+	depends on INTEL_SOC_PMIC_CHTWC
+	help
+	  Say Y here to enable extcon support for charger detection / control
+	  on the Intel Cherrytrail Whiskey Cove PMIC.
+
 config EXTCON_MAX14577
 	tristate "Maxim MAX14577/77836 EXTCON Support"
 	depends on MFD_MAX14577
drivers/extcon/Makefile +1 -0
index 237ac3f..ecfa958 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_EXTCON_ARIZONA)	+= extcon-arizona.o
 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_MAX14577)	+= extcon-max14577.o
 obj-$(CONFIG_EXTCON_MAX3355)	+= extcon-max3355.o
 obj-$(CONFIG_EXTCON_MAX77693)	+= extcon-max77693.o
drivers/extcon/extcon-intel-cht-wc.c new file +352 -0

352 lines not on this page · raw message

Signature · 1 line
2.9.3
maintainer Applied
#1 lore raw

Hi,

Quoted 15 lines · Hans de Goede

Add a driver for charger detection / control on the Intel Cherrytrail Whiskey Cove PMIC.

---
Changes in v2:

(quoted diff) +0 -6
-Improve wait for charger detection loop, use jiffies to get an accurate timeout
-Sort registers by address, remove duplicate definition
-Return IRQ_NONE on interrupt handling errors
-Various small style cleanups
-Fix reporting no charger cable being present when detecting the same
 charger type 2 times in a row
-Reset to autonomous / hw-mode on probe-error and on remove

Changes in v3:

Review

Quoted 9 lines
(quoted diff) +0 -4
-Add intel prefix to Kconfig symbol and filename
-Clarified "Unhandled charger type" warning msg
-Dropped usb_id sysfs attribute
---
 drivers/extcon/Kconfig               |   7 +
 drivers/extcon/Makefile              |   1 +
 drivers/extcon/extcon-intel-cht-wc.c | 352 +++++++++++++++++++++++++++++++++++
 3 files changed, 360 insertions(+)
 create mode 100644 drivers/extcon/extcon-intel-cht-wc.c

Applied it on extcon-next branch.

[snip]

drivers/extcon/extcon-intel-cht-wc.c line 145

Quoted 4 lines
drivers/extcon/extcon-intel-cht-wc.c new file +4 -0
+	usbsrc = (usbsrc & CHT_WC_USBSRC_TYPE_MASK) >> CHT_WC_USBSRC_TYPE_SHIFT;
+	switch (usbsrc) {
+	default:
+		dev_warn(ext->dev, "Unhandled charger type %d, defaulting to SDP\n",

Nit:
This line is over length 80. So, I changed it as following

		dev_warn(ext->dev,
			"Unhandled charger type %d, defaulting to SDP\n",
Quoted 16 lines
drivers/extcon/extcon-intel-cht-wc.c new file +16 -0
+			 ret);
+		/* Fall through, treat as SDP */
+	case CHT_WC_USBSRC_TYPE_SDP:
+	case CHT_WC_USBSRC_TYPE_FLOAT_DP_DN:
+	case CHT_WC_USBSRC_TYPE_OTHER:
+		return EXTCON_CHG_USB_SDP;
+	case CHT_WC_USBSRC_TYPE_CDP:
+		return EXTCON_CHG_USB_CDP;
+	case CHT_WC_USBSRC_TYPE_DCP:
+	case CHT_WC_USBSRC_TYPE_DCP_EXTPHY:
+	case CHT_WC_USBSRC_TYPE_MHL: /* MHL2+ delivers upto 2A, treat as DCP */
+		return EXTCON_CHG_USB_DCP;
+	case CHT_WC_USBSRC_TYPE_ACA:
+		return EXTCON_CHG_USB_ACA;
+	}
+}
Signature · 3 lines
Best Regards,
Chanwoo Choi
Samsung Electronics
#2 lore raw

Hi,

Quoted 21 lines · Chanwoo Choi

Hi,

Quoted 18 lines · Hans de Goede

Add a driver for charger detection / control on the Intel Cherrytrail Whiskey Cove PMIC.

---
Changes in v2:

(quoted diff) +0 -6
-Improve wait for charger detection loop, use jiffies to get an accurate timeout
-Sort registers by address, remove duplicate definition
-Return IRQ_NONE on interrupt handling errors
-Various small style cleanups
-Fix reporting no charger cable being present when detecting the same
 charger type 2 times in a row
-Reset to autonomous / hw-mode on probe-error and on remove

Changes in v3:

(quoted diff) +0 -4
-Add intel prefix to Kconfig symbol and filename
-Clarified "Unhandled charger type" warning msg
-Dropped usb_id sysfs attribute
---
Quoted 8 lines
Quoted 6 lines
 drivers/extcon/Kconfig               |   7 +
 drivers/extcon/Makefile              |   1 +
 drivers/extcon/extcon-intel-cht-wc.c | 352 +++++++++++++++++++++++++++++++++++
 3 files changed, 360 insertions(+)
 create mode 100644 drivers/extcon/extcon-intel-cht-wc.c

Applied it on extcon-next branch.

Thank you.

Regards,

Hans

Quoted 31 lines

[snip]

drivers/extcon/extcon-intel-cht-wc.c line 145

Quoted 4 lines
drivers/extcon/extcon-intel-cht-wc.c new file +4 -0
+	usbsrc = (usbsrc & CHT_WC_USBSRC_TYPE_MASK) >> CHT_WC_USBSRC_TYPE_SHIFT;
+	switch (usbsrc) {
+	default:
+		dev_warn(ext->dev, "Unhandled charger type %d, defaulting to SDP\n",

Nit:
This line is over length 80. So, I changed it as following

		dev_warn(ext->dev,
			"Unhandled charger type %d, defaulting to SDP\n",
Quoted 16 lines
drivers/extcon/extcon-intel-cht-wc.c new file +16 -0
+			 ret);
+		/* Fall through, treat as SDP */
+	case CHT_WC_USBSRC_TYPE_SDP:
+	case CHT_WC_USBSRC_TYPE_FLOAT_DP_DN:
+	case CHT_WC_USBSRC_TYPE_OTHER:
+		return EXTCON_CHG_USB_SDP;
+	case CHT_WC_USBSRC_TYPE_CDP:
+		return EXTCON_CHG_USB_CDP;
+	case CHT_WC_USBSRC_TYPE_DCP:
+	case CHT_WC_USBSRC_TYPE_DCP_EXTPHY:
+	case CHT_WC_USBSRC_TYPE_MHL: /* MHL2+ delivers upto 2A, treat as DCP */
+		return EXTCON_CHG_USB_DCP;
+	case CHT_WC_USBSRC_TYPE_ACA:
+		return EXTCON_CHG_USB_ACA;
+	}
+}