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

Commit c20b98f8 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb1390: add support to configure temp alarm threshold"

parents 0e522d44 24add521
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -38,6 +38,16 @@ Charger specific properties:
  Definition: Minimum ILIM supported, if requested ILIM goes below this value
	      disable SMB1390. If this values is not specified default minimum
	      ILIM is 1A.

- qcom,max-temp-alarm-degc
  Usage:      optional
  Value type: <u32>
  Definition: Maximum die temperature to trigger temp alarm. The value
	      must be one of the following:
	      85, 95, 110, 125.
	      If this value is not specified or is not one of the above
	      then default value is 110.

================================================
Second Level Nodes - SMB1390 Charger Peripherals
================================================
+28 −2
Original line number Diff line number Diff line
@@ -69,6 +69,10 @@
#define CORE_FTRIM_ILIM_REG		0x1030
#define CFG_ILIM_MASK			GENMASK(4, 0)

#define CORE_FTRIM_CTRL_REG		0x1031
#define TEMP_ALERT_LVL_MASK		GENMASK(6, 5)
#define TEMP_ALERT_LVL_SHIFT		5

#define CORE_FTRIM_LVL_REG		0x1033
#define CFG_WIN_HI_MASK			GENMASK(3, 2)
#define WIN_OV_LVL_1000MV		0x08
@@ -171,6 +175,7 @@ struct smb1390 {
	bool			suspended;
	u32			debug_mask;
	u32			min_ilim_ua;
	u32			max_temp_alarm_degc;
};

struct smb_irq {
@@ -877,6 +882,10 @@ static int smb1390_parse_dt(struct smb1390 *chip)
	of_property_read_u32(chip->dev->of_node, "qcom,min-ilim-ua",
			&chip->min_ilim_ua);

	chip->max_temp_alarm_degc = 110;
	of_property_read_u32(chip->dev->of_node, "qcom,max-temp-alarm-degc",
			&chip->max_temp_alarm_degc);

	return 0;
}

@@ -923,7 +932,7 @@ static void smb1390_destroy_votables(struct smb1390 *chip)

static int smb1390_init_hw(struct smb1390 *chip)
{
	int rc;
	int rc = 0, val;

	/*
	 * Improve ILIM accuracy:
@@ -940,8 +949,25 @@ static int smb1390_init_hw(struct smb1390 *chip)
	if (rc < 0)
		return rc;

	switch (chip->max_temp_alarm_degc) {
	case 125:
		val = 0x00;
		break;
	case 95:
		val = 0x02;
		break;
	case 85:
		val = 0x03;
		break;
	case 110:
	default:
		val = 0x01;
		break;
	}
	rc = smb1390_masked_write(chip, CORE_FTRIM_CTRL_REG,
			TEMP_ALERT_LVL_MASK, val << TEMP_ALERT_LVL_SHIFT);

	return 0;
	return rc;
}

static int smb1390_get_irq_index_byname(const char *irq_name)