Loading Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt +15 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,21 @@ Optional properties: - io-channels: Should contain IIO channel specifier for the ADC channel, which report chip die temperature. - io-channel-names: Should contain "thermal". - qcom,temperature-threshold-set: Defines the temperature threshold set to configure. Supported values are 0 to 3. Each set defines the over-temperature stage 1, 2, and 3 temperature thresholds. If this property is not specified, then set 0 will be used by default. Threshold set mapping (TEMP_GEN1, TEMP_GEN2 rev 0): 0 = {105 C, 125 C, 145 C} 1 = {110 C, 130 C, 150 C} 2 = {115 C, 135 C, 155 C} 3 = {120 C, 140 C, 160 C} Threshold set mapping (TEMP_GEN2 rev 1 and above): 0 = { 90 C, 110 C, 140 C} 1 = { 95 C, 115 C, 145 C} 2 = {100 C, 120 C, 150 C} 3 = {105 C, 125 C, 155 C} Example: Loading drivers/thermal/qcom-spmi-temp-alarm.c +13 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ static const long temp_map_gen2_v1[THRESH_COUNT][STAGE_COUNT] = { #define TEMP_STAGE_HYSTERESIS 2000 #define THRESH_MIN 0 #define THRESH_MAX 3 /* Temperature in Milli Celsius reported during stage 0 if no ADC is present */ #define DEFAULT_TEMP 37000 Loading @@ -77,6 +78,7 @@ struct qpnp_tm_chip { unsigned int stage; unsigned int prev_stage; unsigned int base; u32 init_thresh; struct iio_channel *adc; const long (*temp_map)[THRESH_COUNT][STAGE_COUNT]; }; Loading Loading @@ -250,7 +252,7 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip) * Set threshold and disable software override of stage 2 and 3 * shutdowns. */ chip->thresh = THRESH_MIN; chip->thresh = chip->init_thresh; reg &= ~(SHUTDOWN_CTRL1_OVERRIDE_MASK | SHUTDOWN_CTRL1_THRESHOLD_MASK); reg |= chip->thresh & SHUTDOWN_CTRL1_THRESHOLD_MASK; ret = qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); Loading Loading @@ -288,6 +290,16 @@ static int qpnp_tm_probe(struct platform_device *pdev) if (ret < 0) return ret; chip->init_thresh = THRESH_MIN; if (of_property_read_u32(node, "qcom,temperature-threshold-set", &chip->init_thresh) == 0) { if (chip->init_thresh > THRESH_MAX) { dev_err(&pdev->dev, "Invalid qcom,temperature-threshold-set=%u\n", chip->init_thresh); return -EINVAL; } } irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; Loading Loading
Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt +15 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,21 @@ Optional properties: - io-channels: Should contain IIO channel specifier for the ADC channel, which report chip die temperature. - io-channel-names: Should contain "thermal". - qcom,temperature-threshold-set: Defines the temperature threshold set to configure. Supported values are 0 to 3. Each set defines the over-temperature stage 1, 2, and 3 temperature thresholds. If this property is not specified, then set 0 will be used by default. Threshold set mapping (TEMP_GEN1, TEMP_GEN2 rev 0): 0 = {105 C, 125 C, 145 C} 1 = {110 C, 130 C, 150 C} 2 = {115 C, 135 C, 155 C} 3 = {120 C, 140 C, 160 C} Threshold set mapping (TEMP_GEN2 rev 1 and above): 0 = { 90 C, 110 C, 140 C} 1 = { 95 C, 115 C, 145 C} 2 = {100 C, 120 C, 150 C} 3 = {105 C, 125 C, 155 C} Example: Loading
drivers/thermal/qcom-spmi-temp-alarm.c +13 −1 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ static const long temp_map_gen2_v1[THRESH_COUNT][STAGE_COUNT] = { #define TEMP_STAGE_HYSTERESIS 2000 #define THRESH_MIN 0 #define THRESH_MAX 3 /* Temperature in Milli Celsius reported during stage 0 if no ADC is present */ #define DEFAULT_TEMP 37000 Loading @@ -77,6 +78,7 @@ struct qpnp_tm_chip { unsigned int stage; unsigned int prev_stage; unsigned int base; u32 init_thresh; struct iio_channel *adc; const long (*temp_map)[THRESH_COUNT][STAGE_COUNT]; }; Loading Loading @@ -250,7 +252,7 @@ static int qpnp_tm_init(struct qpnp_tm_chip *chip) * Set threshold and disable software override of stage 2 and 3 * shutdowns. */ chip->thresh = THRESH_MIN; chip->thresh = chip->init_thresh; reg &= ~(SHUTDOWN_CTRL1_OVERRIDE_MASK | SHUTDOWN_CTRL1_THRESHOLD_MASK); reg |= chip->thresh & SHUTDOWN_CTRL1_THRESHOLD_MASK; ret = qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg); Loading Loading @@ -288,6 +290,16 @@ static int qpnp_tm_probe(struct platform_device *pdev) if (ret < 0) return ret; chip->init_thresh = THRESH_MIN; if (of_property_read_u32(node, "qcom,temperature-threshold-set", &chip->init_thresh) == 0) { if (chip->init_thresh > THRESH_MAX) { dev_err(&pdev->dev, "Invalid qcom,temperature-threshold-set=%u\n", chip->init_thresh); return -EINVAL; } } irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; Loading