Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05de9fa9 authored by Nicholas Troast's avatar Nicholas Troast Committed by Kyle Yan
Browse files

qcom-charger: introduce SMB138X charger driver



This driver supports the SMB138X charger device.

This charger peripheral is common among other chips, therefore the
driver uses the smb library to support all common functionality.

Register access is provided by the parent device via regmap. Interrupts
are controlled by the parent device, and handlers are registered by the
SMB138X charger driver.

The power supply framework is used to communicate battery and usb
properties to userspace and other driver consumers such as fuel gauge
and USB.

VBUS and VCONN regulators are registered for supporting OTG, and powered
Type-C cables respectively.

CRs-Fixed: 1023141
Change-Id: I119d33cdfdfc874b5d7f6137618ee3e590c72064
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 76fd66f1
Loading
Loading
Loading
Loading
+199 −0
Original line number Diff line number Diff line
Qualcomm Technologies, Inc. SMB138X Charger Specific Bindings

SMB138X Charger is an efficient programmable battery charger capable of charging
a high-capacity lithium-ion battery over micro-USB or USB Type-C ultrafast with
Quick Charge 2.0, Quick Charge 3.0 support. Wireless charging features full
A4WP Rezence 1.2, WPC 1.2, and PMA support.

=======================
Required Node Structure
=======================

SMB138X Charger must be described in two levels of devices nodes.

==================================
First Level Node - SMB138X Charger
==================================

Charger specific properties:
- compatible
  Usage:      required
  Value type: <string>
  Definition: String which indicates the charging mode. Can be one of the
	      following:
              Standalone/Parallel Master	- "qcom,smb138x-charger"
	      Parallel Slave			- "qcom,smb138x-parallel-slave"

- qcom,suspend-input
  Usage:      optional
  Value type: <empty>
  Definition: Boolean flag which indicates that the charger should not draw
	      current from any of its input sources (USB, DC).

- qcom,fcc-max-ua
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the maximum fast charge current in micro-amps.

- qcom,usb-icl-ua
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the USB input current limit in micro-amps.

- qcom,dc-icl-ua
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the DC input current limit in micro-amps.

================================================
Second Level Nodes - SMB138X Charger Peripherals
================================================

Peripheral specific properties:
- reg
  Usage:      required
  Value type: <prop-encoded-array>
  Definition: Address and size of the peripheral's register block.

- interrupts
  Usage:      required
  Value type: <prop-encoded-array>
  Definition: Peripheral interrupt specifier.

- interrupt-names
  Usage:      required
  Value type: <stringlist>
  Definition: Interrupt names.  This list must match up 1-to-1 with the
	      interrupts specified in the 'interrupts' property.

=======================================
Second Level Nodes - SMB138X Regulators
=======================================

The following regulator nodes are supported:
"qcom,smb138x-vbus"	- Regulator for enabling VBUS
"qcom,smb138x-vconn"	- Regulator for enabling VCONN

- regulator-name
  Usage:      required
  Value type: <string>
  Definition: Specifies the name for this regulator.

=======
Example
=======

smb138x_charger: qcom,smb138x-charger {
	compatible = "qcom,qpnp-smb138x-charger";
	#address-cells = <1>;
	#size-cells = <1>;

	qcom,suspend-input;
	dpdm-supply = <&qusb_phy0>;

	qcom,chgr@1000 {
		reg = <0x1000 0x100>;
		interrupts =    <0x10 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x10 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x10 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x10 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x10 0x4 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "chg-error",
					"chg-state-change",
					"step-chg-state-change",
					"step-chg-soc-update-fail",
					"step-chg-soc-update-request";
	};

	qcom,otg@1100 {
		reg = <0x1100 0x100>;
		interrupts =    <0x11 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x11 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x11 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x11 0x3 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "otg-fail",
					"otg-overcurrent",
					"otg-oc-dis-sw-sts",
					"testmode-change-detect";
	};

	qcom,bat-if@1200 {
		reg = <0x1200 0x100>;
		interrupts =    <0x12 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x12 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x12 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x12 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x12 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x12 0x5 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "bat-temp",
					"bat-ocp",
					"bat-ov",
					"bat-low",
					"bat-therm-or-id-missing",
					"bat-terminal-missing";
	};

	qcom,usb-chgpth@1300 {
		reg = <0x1300 0x100>;
		interrupts =    <0x13 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x5 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x6 IRQ_TYPE_EDGE_BOTH>,
				<0x13 0x7 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "usbin-collapse",
					"usbin-lt-3p6v",
					"usbin-uv",
					"usbin-ov",
					"usbin-plugin",
					"usbin-src-change",
					"usbin-icl-change",
					"type-c-change";
	};

	qcom,dc-chgpth@1400 {
		reg = <0x1400 0x100>;
		interrupts =    <0x14 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x5 IRQ_TYPE_EDGE_BOTH>,
				<0x14 0x6 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "dcin-collapse",
					"dcin-lt-3p6v",
					"dcin-uv",
					"dcin-ov",
					"dcin-plugin",
					"div2-en-dg",
					"dcin-icl-change";
	};

	qcom,chgr-misc@1600 {
		reg = <0x1600 0x100>;
		interrupts =    <0x16 0x0 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x1 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x2 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x3 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x4 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x5 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x6 IRQ_TYPE_EDGE_BOTH>,
				<0x16 0x7 IRQ_TYPE_EDGE_BOTH>;

		interrupt-names =       "wdog-snarl",
					"wdog-bark",
					"aicl-fail",
					"aicl-done",
					"high-duty-cycle",
					"input-current-limiting",
					"temperature-change",
					"switcher-power-ok";
	};
};
+12 −0
Original line number Diff line number Diff line
@@ -77,6 +77,18 @@ config QPNP_SMB2
	help
	  Enables support for the SMB2 charging peripheral

config SMB138X_CHARGER
	tristate "SMB138X Battery Charger"
	depends on MFD_I2C_PMIC
	select POWER_SUPPLY
	help
	  Say Y to include support for SMB138X Battery Charger.
	  SMB1380 is a dual phase 6A battery charger, and SMB1381 is a single
	  phase 5A battery charger.
	  The driver supports charger enable/disable.
	  The driver reports the charger status via the power supply framework.
	  A charger status change triggers an IRQ via the device STAT pin.

config QPNP_QNOVO
	bool "QPNP QNOVO driver"
	depends on SPMI
+1 −0
Original line number Diff line number Diff line
@@ -6,4 +6,5 @@ obj-$(CONFIG_MSM_BCL_CTL) += msm_bcl.o
obj-$(CONFIG_MSM_BCL_PERIPHERAL_CTL) += bcl_peripheral.o
obj-$(CONFIG_BATTERY_BCL) += battery_current_limit.o
obj-$(CONFIG_QPNP_SMB2)		+= qpnp-smb2.o smb-lib.o pmic-voter.o
obj-$(CONFIG_SMB138X_CHARGER)	+= smb138x-charger.o smb-lib.o pmic-voter.o
obj-$(CONFIG_QPNP_QNOVO)	+= qpnp-qnovo.o
+963 −0

File added.

Preview size limit exceeded, changes collapsed.