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

Commit 6b2e6b0c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: add PMIC revid source property for flash LED"

parents fe358ba2 021246bc
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -86,6 +86,8 @@ operational simplification. For backward compatibility purpose, switch node can
			  "1", etc..
- qcom,max-current	: maximum current allowed on this LED. Valid values should be
			  integer from 0 to 1000 inclusive, indicating 0 to 1000 mA.
- qcom,pmic-revid	: PMIC revision id source. This property is needed for PMI8996
			revision check.

Optional properties inside child node:
- qcom,current		: default current intensity for LED. Accepted values should be
@@ -129,6 +131,7 @@ Example:
		qcom,die-temp-vadc = <&pmi8994_vadc>;
		qcom,die-temp-threshold = <85 80 75 70 65>;
		qcom,die-temp-derate-current = <400 800 1200 1600 2000>;
		qcom,pmic-revid = <&pmi8994_revid>;

		pm8226_flash0: qcom,flash_0 {
			label = "flash";
+1 −0
Original line number Diff line number Diff line
@@ -638,6 +638,7 @@
			qcom,headroom-sense-ch0-enabled;
			qcom,headroom-sense-ch1-enabled;
			qcom,power-detect-enabled;
			qcom,pmic-revid = <&pmi8994_revid>;

			pmi8994_flash0: qcom,flash_0 {
				label = "flash";
+55 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <linux/workqueue.h>
#include <linux/power_supply.h>
#include <linux/qpnp/qpnp-adc.h>
#include <linux/qpnp/qpnp-revid.h>
#include "leds.h"
#include <linux/debugfs.h>
#include <linux/uaccess.h>
@@ -115,6 +116,7 @@
#define	FLASH_LED_MODULE_CTRL_DEFAULT				0x60
#define	FLASH_LED_CURRENT_READING_DELAY_MIN			5000
#define	FLASH_LED_CURRENT_READING_DELAY_MAX			5001
#define PMI8996_SUBTYPE						19

#define FLASH_UNLOCK_SECURE					0xA5
#define FLASH_LED_TORCH_ENABLE					0x00
@@ -230,6 +232,7 @@ struct qpnp_flash_led_buffer {
 * Flash LED data structure containing flash LED attributes
 */
struct qpnp_flash_led {
	struct pmic_revid_data		*revid_data;
	struct spmi_device		*spmi_dev;
	struct flash_led_platform_data	*pdata;
	struct pinctrl			*pinctrl;
@@ -571,6 +574,28 @@ static int64_t qpnp_flash_led_get_die_temp(struct qpnp_flash_led *led)
	return die_temp_result.physical;
}

static int qpnp_get_pmic_revid(struct qpnp_flash_led *led)
{
	struct device_node *revid_dev_node;

	revid_dev_node = of_parse_phandle(led->spmi_dev->dev.of_node,
				"qcom,pmic-revid", 0);
	if (!revid_dev_node) {
		dev_err(&led->spmi_dev->dev,
			"qcom,pmic-revid property missing\n");
		return -EINVAL;
	}

	led->revid_data = get_revid_data(revid_dev_node);
	if (IS_ERR(led->revid_data)) {
		pr_err("Couldn't get revid data rc = %ld\n",
				PTR_ERR(led->revid_data));
		return PTR_ERR(led->revid_data);
	}

	return 0;
}

static int
qpnp_flash_led_get_max_avail_current(struct flash_node_data *flash_node,
					struct qpnp_flash_led *led)
@@ -938,6 +963,20 @@ static int qpnp_flash_led_module_disable(struct qpnp_flash_led *led,
			}
		}

		if (led->battery_psy &&
			led->revid_data->pmic_subtype == PMI8996_SUBTYPE &&
						!led->revid_data->rev3) {
			psy_prop.intval = false;
			rc = led->battery_psy->set_property(led->battery_psy,
					POWER_SUPPLY_PROP_FLASH_TRIGGER,
							&psy_prop);
			if (rc) {
				dev_err(&led->spmi_dev->dev,
				"Failed to enble charger i/p current limit\n");
				return -EINVAL;
			}
		}

		rc = qpnp_led_masked_write(led->spmi_dev,
				FLASH_MODULE_ENABLE_CTRL(led->base),
				FLASH_MODULE_ENABLE_MASK,
@@ -1506,6 +1545,18 @@ static void qpnp_flash_led_work(struct work_struct *work)
						FLASH_RAMP_UP_DELAY_US_MAX);
		}

		if (led->revid_data->pmic_subtype == PMI8996_SUBTYPE &&
						!led->revid_data->rev3) {
			rc = led->battery_psy->set_property(led->battery_psy,
						POWER_SUPPLY_PROP_FLASH_TRIGGER,
							&psy_prop);
			if (rc) {
				dev_err(&led->spmi_dev->dev,
				"Failed to disable charger i/p curr limit\n");
				goto exit_flash_led_work;
			}
		}

		if (led->pdata->hdrm_sns_ch0_en ||
					led->pdata->hdrm_sns_ch1_en) {
			if (flash_node->id == FLASH_LED_SWITCH) {
@@ -2357,6 +2408,10 @@ static int qpnp_flash_led_probe(struct spmi_device *spmi)
		return rc;
	}

	rc = qpnp_get_pmic_revid(led);
	if (rc)
		return rc;

	temp = NULL;
	while ((temp = of_get_next_child(node, temp)))
		num_leds++;