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

Commit 35a52a17 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

thermal: adc_tm: Update channel assignments for PM8150B 1.0



BTM channels CH_0 and CH_1 on PM8150B on 1.0 are reserved.
Therefore assign any BTM channels from CH_2 onwards
for PM8150B 1.0.

Change-Id: I3bb7a3d60f6a8502a7e6561b8258173e0317a4d6
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent c18689d5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -47,6 +47,12 @@ ADC node:
    Value type: <prop-encoded-array>
    Definition: End of conversion interrupt.

- qcom,pmic-revid:
    Usage: optional
    Value type:<u32>
    Definition: phandle pointing to the revision peripheral node. Use it to query the
                PMIC type and revision.

Channel node properties:

- reg:
+10 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ static int adc_tm_get_dt_data(struct platform_device *pdev,

static int adc_tm_probe(struct platform_device *pdev)
{
	struct device_node *child, *node = pdev->dev.of_node;
	struct device_node *child, *revid_dev_node, *node = pdev->dev.of_node;
	struct device *dev = &pdev->dev;
	struct adc_tm_chip *adc_tm;
	struct regmap *regmap;
@@ -280,6 +280,15 @@ static int adc_tm_probe(struct platform_device *pdev)
	adc_tm->base = reg;
	adc_tm->dt_channels = dt_chan_num;

	revid_dev_node = of_parse_phandle(node, "qcom,pmic-revid", 0);
	if (revid_dev_node) {
		adc_tm->pmic_rev_id = get_revid_data(revid_dev_node);
		if (IS_ERR(adc_tm->pmic_rev_id)) {
			pr_debug("Unable to get revid\n");
			return -EPROBE_DEFER;
		}
	}

	ret = adc_tm_get_dt_data(pdev, adc_tm, channels, dt_chan_num);
	if (ret) {
		dev_err(dev, "adc-tm get dt data failed\n");
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/iio/consumer.h>
#include <linux/qpnp/qpnp-revid.h>

struct adc_tm_chip;

@@ -91,6 +92,7 @@ struct adc_tm_chip {
	const struct adc_tm_ops		*ops;
	const struct adc_tm_data	*data;
	unsigned int			dt_channels;
	struct pmic_revid_data		*pmic_rev_id;
	struct adc_tm_sensor		sensor[0];
};

+22 −3
Original line number Diff line number Diff line
@@ -518,7 +518,8 @@ static int adc_tm5_register_interrupts(struct adc_tm_chip *chip)
static int adc_tm5_init(struct adc_tm_chip *chip, uint32_t dt_chans)
{
	u8 buf[4], channels_available, meas_int_timer_2_3 = 0;
	int ret, i;
	int ret;
	unsigned int offset_btm_idx = 0, i;

	ret = adc_tm5_read_reg(chip, ADC_TM_NUM_BTM, &channels_available, 1);
	if (ret < 0) {
@@ -561,8 +562,26 @@ static int adc_tm5_init(struct adc_tm_chip *chip, uint32_t dt_chans)

	spin_lock_init(&chip->adc_tm_lock);

	for (i = 0; i < dt_chans; i++)
		chip->sensor[i].btm_ch = adc_tm_ch_data[i].btm_amux_ch;
	if (chip->pmic_rev_id) {
		switch (chip->pmic_rev_id->pmic_subtype)
		/*
		 * PM8150B 1.0 CH_0 and CH_1 is already used.
		 * Therefore configure to use CH_2 onwards.
		 */
		case PM8150B_SUBTYPE:
			if (chip->pmic_rev_id->rev4 == PM8150B_V1P0_REV4)
				offset_btm_idx = ADC_TM_CHAN2;
	}

	for (i = 0; i < dt_chans; i++) {
		if ((i + offset_btm_idx) > ADC_TM_CHAN7) {
			pr_err("Invalid BTM index\n", (i + offset_btm_idx));
			return -EINVAL;
		}

		chip->sensor[i].btm_ch =
				adc_tm_ch_data[i + offset_btm_idx].btm_amux_ch;
	}

	return ret;
}