Commit 8868485d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull more thermal control updates from Rafael Wysocki:
 "These are mostly assorted updates of thermal drivers used on ARM
  platforms:

   - Use dev_err_probe() helpers to simplify the init code in the Qoriq
     thermal driver (Frank Li)

   - Power down the Qoriq's TMU at suspend time (Alice Guo)

   - Add ipq5332, ipq5424 compatible to the QCom's tsens thermal driver
     and TSENS enable / calibration support for V2 (Praveenkumar I)

   - Add missing rk3328 mapping entry (Trevor Woerner)

   - Remove duplicate struct declaration from the thermal core header
     file (Xueqin Luo)

   - Disable the monitoring mode during suspend in the LVTS Mediatek
     driver to prevent temperature acquisition glitches (Nícolas F. R.
     A. Prado)

   - Disable Stage 3 thermal threshold in the LVTS Mediatek driver
     because it disables the suspend ability and does not have an
     interrupt handler (Nícolas F. R. A. Prado)

   - Fix low temperature offset interrupt in the LVTS Mediatek driver to
     prevent multiple interrupts from triggering when the system is at
     its normal functionning temperature (Nícolas F. R. A. Prado)

   - Enable interrupts in the LVTS Mediatek driver only on sensors that
     are in use (Nícolas F. R. A. Prado)

   - Add the BCM74110 compatible DT binding and the corresponding code
     to support a chip based on a different process node than previous
     chips (Florian Fainelli)

   - Correct indentation and style in DTS example (Krzysztof Kozlowski)

   - Unify hexadecimal annotatation in the rcar_gen3 driver (Niklas
     Söderlund)

   - Factor out the code logic to read fuses on Gen3 and Gen4 in the
     rcar_gen3 thermal driver (Niklas Söderlund)

   - Drop unused driver data from the QCom's spmi temperature alarm
     driver (Johan Hovold)"

* tag 'thermal-6.15-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal/drivers/qcom-spmi-temp-alarm: Drop unused driver data
  thermal: rcar_gen3: Reuse logic to read fuses on Gen3 and Gen4
  thermal: rcar_gen3: Use lowercase hex constants
  dt-bindings: thermal: Correct indentation and style in DTS example
  thermal/drivers/brcmstb_thermal: Add support for BCM74110
  dt-bindings: thermal: Update for BCM74110
  thermal/drivers/mediatek/lvts: Only update IRQ enable for valid sensors
  thermal/drivers/mediatek/lvts: Start sensor interrupts disabled
  thermal/drivers/mediatek/lvts: Disable low offset IRQ for minimum threshold
  thermal/drivers/mediatek/lvts: Disable Stage 3 thermal threshold
  thermal/drivers/mediatek/lvts: Disable monitor mode during suspend
  thermal: core: Remove duplicate struct declaration
  thermal/drivers/rockchip: Add missing rk3328 mapping entry
  thermal/drivers/tsens: Add TSENS enable and calibration support for V2
  dt-bindings: thermal: tsens: Add ipq5332, ipq5424 compatible
  thermal/drivers/qoriq: Power down TMU on system suspend
  thermal/drivers/qoriq: Use dev_err_probe() simplify the code
parents 1df77528 12da0fee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ properties:
  compatible:
    items:
      - enum:
          - brcm,avs-tmon-bcm74110
          - brcm,avs-tmon-bcm7216
          - brcm,avs-tmon-bcm7445
      - const: brcm,avs-tmon
+18 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ properties:

      - description: v2 of TSENS with combined interrupt
        enum:
          - qcom,ipq5332-tsens
          - qcom,ipq5424-tsens
          - qcom,ipq8074-tsens

      - description: v2 of TSENS with combined interrupt
@@ -212,6 +214,18 @@ properties:
          - const: s9_p2_backup
          - const: s10_p1_backup
          - const: s10_p2_backup
      - minItems: 8
        items:
          - const: mode
          - const: base0
          - const: base1
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'
          - pattern: '^tsens_sens[0-9]+_off$'

  "#qcom,sensors":
    description:
@@ -271,6 +285,8 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,ipq5332-tsens
              - qcom,ipq5424-tsens
              - qcom,ipq8074-tsens
    then:
      properties:
@@ -286,6 +302,8 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,ipq5332-tsens
              - qcom,ipq5424-tsens
              - qcom,ipq8074-tsens
              - qcom,tsens-v0_1
              - qcom,tsens-v1
+9 −2
Original line number Diff line number Diff line
@@ -286,14 +286,20 @@ static int brcmstb_set_trips(struct thermal_zone_device *tz, int low, int high)
	return 0;
}

static const struct thermal_zone_device_ops brcmstb_16nm_of_ops = {
static const struct thermal_zone_device_ops brcmstb_of_ops = {
	.get_temp	= brcmstb_get_temp,
};

static const struct brcmstb_thermal_params brcmstb_8nm_params = {
	.offset	= 418670,
	.mult	= 509,
	.of_ops	= &brcmstb_of_ops,
};

static const struct brcmstb_thermal_params brcmstb_16nm_params = {
	.offset	= 457829,
	.mult	= 557,
	.of_ops	= &brcmstb_16nm_of_ops,
	.of_ops	= &brcmstb_of_ops,
};

static const struct thermal_zone_device_ops brcmstb_28nm_of_ops = {
@@ -308,6 +314,7 @@ static const struct brcmstb_thermal_params brcmstb_28nm_params = {
};

static const struct of_device_id brcmstb_thermal_id_table[] = {
	{ .compatible = "brcm,avs-tmon-bcm74110", .data = &brcmstb_8nm_params },
	{ .compatible = "brcm,avs-tmon-bcm7216", .data = &brcmstb_16nm_params },
	{ .compatible = "brcm,avs-tmon", .data = &brcmstb_28nm_params },
	{},
+72 −31
Original line number Diff line number Diff line
@@ -65,12 +65,15 @@
#define LVTS_HW_FILTER				0x0
#define LVTS_TSSEL_CONF				0x13121110
#define LVTS_CALSCALE_CONF			0x300
#define LVTS_MONINT_CONF			0x8300318C

#define LVTS_MONINT_OFFSET_SENSOR0		0xC
#define LVTS_MONINT_OFFSET_SENSOR1		0x180
#define LVTS_MONINT_OFFSET_SENSOR2		0x3000
#define LVTS_MONINT_OFFSET_SENSOR3		0x3000000
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR0		BIT(3)
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR1		BIT(8)
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR2		BIT(13)
#define LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR3		BIT(25)
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR0		BIT(2)
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR1		BIT(7)
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR2		BIT(12)
#define LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR3		BIT(24)

#define LVTS_INT_SENSOR0			0x0009001F
#define LVTS_INT_SENSOR1			0x001203E0
@@ -91,8 +94,6 @@
#define LVTS_MSR_READ_TIMEOUT_US	400
#define LVTS_MSR_READ_WAIT_US		(LVTS_MSR_READ_TIMEOUT_US / 2)

#define LVTS_HW_TSHUT_TEMP		105000

#define LVTS_MINIMUM_THRESHOLD		20000

static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
@@ -145,7 +146,6 @@ struct lvts_ctrl {
	struct lvts_sensor sensors[LVTS_SENSOR_MAX];
	const struct lvts_data *lvts_data;
	u32 calibration[LVTS_SENSOR_MAX];
	u32 hw_tshut_raw_temp;
	u8 valid_sensor_mask;
	int mode;
	void __iomem *base;
@@ -329,23 +329,41 @@ static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)

static void lvts_update_irq_mask(struct lvts_ctrl *lvts_ctrl)
{
	static const u32 masks[] = {
		LVTS_MONINT_OFFSET_SENSOR0,
		LVTS_MONINT_OFFSET_SENSOR1,
		LVTS_MONINT_OFFSET_SENSOR2,
		LVTS_MONINT_OFFSET_SENSOR3,
	static const u32 high_offset_inten_masks[] = {
		LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR0,
		LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR1,
		LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR2,
		LVTS_MONINT_OFFSET_HIGH_INTEN_SENSOR3,
	};
	static const u32 low_offset_inten_masks[] = {
		LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR0,
		LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR1,
		LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR2,
		LVTS_MONINT_OFFSET_LOW_INTEN_SENSOR3,
	};
	u32 value = 0;
	int i;

	value = readl(LVTS_MONINT(lvts_ctrl->base));

	for (i = 0; i < ARRAY_SIZE(masks); i++) {
	lvts_for_each_valid_sensor(i, lvts_ctrl) {
		if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
		    && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
			value |= masks[i];
		else
			value &= ~masks[i];
		    && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh) {
			/*
			 * The minimum threshold needs to be configured in the
			 * OFFSETL register to get working interrupts, but we
			 * don't actually want to generate interrupts when
			 * crossing it.
			 */
			if (lvts_ctrl->low_thresh == -INT_MAX) {
				value &= ~low_offset_inten_masks[i];
				value |= high_offset_inten_masks[i];
			} else {
				value |= low_offset_inten_masks[i] | high_offset_inten_masks[i];
			}
		} else {
			value &= ~(low_offset_inten_masks[i] | high_offset_inten_masks[i]);
		}
	}

	writel(value, LVTS_MONINT(lvts_ctrl->base));
@@ -837,14 +855,6 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
		 */
		lvts_ctrl[i].mode = lvts_data->lvts_ctrl[i].mode;

		/*
		 * The temperature to raw temperature must be done
		 * after initializing the calibration.
		 */
		lvts_ctrl[i].hw_tshut_raw_temp =
			lvts_temp_to_raw(LVTS_HW_TSHUT_TEMP,
					 lvts_data->temp_factor);

		lvts_ctrl[i].low_thresh = INT_MIN;
		lvts_ctrl[i].high_thresh = INT_MIN;
	}
@@ -860,6 +870,32 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
	return 0;
}

static void lvts_ctrl_monitor_enable(struct device *dev, struct lvts_ctrl *lvts_ctrl, bool enable)
{
	/*
	 * Bitmaps to enable each sensor on filtered mode in the MONCTL0
	 * register.
	 */
	static const u8 sensor_filt_bitmap[] = { BIT(0), BIT(1), BIT(2), BIT(3) };
	u32 sensor_map = 0;
	int i;

	if (lvts_ctrl->mode != LVTS_MSR_FILTERED_MODE)
		return;

	if (enable) {
		lvts_for_each_valid_sensor(i, lvts_ctrl)
			sensor_map |= sensor_filt_bitmap[i];
	}

	/*
	 * Bits:
	 *      9: Single point access flow
	 *    0-3: Enable sensing point 0-3
	 */
	writel(sensor_map | BIT(9), LVTS_MONCTL0(lvts_ctrl->base));
}

/*
 * At this point the configuration register is the only place in the
 * driver where we write multiple values. Per hardware constraint,
@@ -893,7 +929,6 @@ static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)
	 *         10 : Selected sensor with bits 19-18
	 *         11 : Reserved
	 */
	writel(BIT(16), LVTS_PROTCTL(lvts_ctrl->base));

	/*
	 * LVTS_PROTTA : Stage 1 temperature threshold
@@ -906,8 +941,8 @@ static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)
	 *
	 * writel(0x0, LVTS_PROTTA(lvts_ctrl->base));
	 * writel(0x0, LVTS_PROTTB(lvts_ctrl->base));
	 * writel(0x0, LVTS_PROTTC(lvts_ctrl->base));
	 */
	writel(lvts_ctrl->hw_tshut_raw_temp, LVTS_PROTTC(lvts_ctrl->base));

	/*
	 * LVTS_MONINT : Interrupt configuration register
@@ -915,7 +950,7 @@ static int lvts_irq_init(struct lvts_ctrl *lvts_ctrl)
	 * The LVTS_MONINT register layout is the same as the LVTS_MONINTSTS
	 * register, except we set the bits to enable the interrupt.
	 */
	writel(LVTS_MONINT_CONF, LVTS_MONINT(lvts_ctrl->base));
	writel(0, LVTS_MONINT(lvts_ctrl->base));

	return 0;
}
@@ -1381,8 +1416,11 @@ static int lvts_suspend(struct device *dev)

	lvts_td = dev_get_drvdata(dev);

	for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
	for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
		lvts_ctrl_monitor_enable(dev, &lvts_td->lvts_ctrl[i], false);
		usleep_range(100, 200);
		lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
	}

	clk_disable_unprepare(lvts_td->clk);

@@ -1400,8 +1438,11 @@ static int lvts_resume(struct device *dev)
	if (ret)
		return ret;

	for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
	for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
		lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], true);
		usleep_range(100, 200);
		lvts_ctrl_monitor_enable(dev, &lvts_td->lvts_ctrl[i], true);
	}

	return 0;
}
+0 −1
Original line number Diff line number Diff line
@@ -360,7 +360,6 @@ static int qpnp_tm_probe(struct platform_device *pdev)
	if (!chip)
		return -ENOMEM;

	dev_set_drvdata(&pdev->dev, chip);
	chip->dev = &pdev->dev;

	mutex_init(&chip->lock);
Loading