linux/drivers/thermal/qcom/qcom-spmi-temp-alarm.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2011-2015, 2017, 2020, The Linux Foundation. All rights reserved.
 */

#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/iio/consumer.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/thermal.h>

#include "../thermal_hwmon.h"

#define QPNP_TM_REG_DIG_MAJOR
#define QPNP_TM_REG_TYPE
#define QPNP_TM_REG_SUBTYPE
#define QPNP_TM_REG_STATUS
#define QPNP_TM_REG_SHUTDOWN_CTRL1
#define QPNP_TM_REG_ALARM_CTRL

#define QPNP_TM_TYPE
#define QPNP_TM_SUBTYPE_GEN1
#define QPNP_TM_SUBTYPE_GEN2

#define STATUS_GEN1_STAGE_MASK
#define STATUS_GEN2_STATE_MASK
#define STATUS_GEN2_STATE_SHIFT

#define SHUTDOWN_CTRL1_OVERRIDE_S2
#define SHUTDOWN_CTRL1_THRESHOLD_MASK

#define SHUTDOWN_CTRL1_RATE_25HZ

#define ALARM_CTRL_FORCE_ENABLE

#define THRESH_COUNT
#define STAGE_COUNT

/* Over-temperature trip point values in mC */
static const long temp_map_gen1[THRESH_COUNT][STAGE_COUNT] =;

static const long temp_map_gen2_v1[THRESH_COUNT][STAGE_COUNT] =;

#define TEMP_THRESH_STEP

#define THRESH_MIN
#define THRESH_MAX

#define TEMP_STAGE_HYSTERESIS

/* Temperature in Milli Celsius reported during stage 0 if no ADC is present */
#define DEFAULT_TEMP

struct qpnp_tm_chip {};

/* This array maps from GEN2 alarm state to GEN1 alarm stage */
static const unsigned int alarm_state_map[8] =;

static int qpnp_tm_read(struct qpnp_tm_chip *chip, u16 addr, u8 *data)
{}

static int qpnp_tm_write(struct qpnp_tm_chip *chip, u16 addr, u8 data)
{}

/**
 * qpnp_tm_decode_temp() - return temperature in mC corresponding to the
 *		specified over-temperature stage
 * @chip:		Pointer to the qpnp_tm chip
 * @stage:		Over-temperature stage
 *
 * Return: temperature in mC
 */
static long qpnp_tm_decode_temp(struct qpnp_tm_chip *chip, unsigned int stage)
{}

/**
 * qpnp_tm_get_temp_stage() - return over-temperature stage
 * @chip:		Pointer to the qpnp_tm chip
 *
 * Return: stage (GEN1) or state (GEN2) on success, or errno on failure.
 */
static int qpnp_tm_get_temp_stage(struct qpnp_tm_chip *chip)
{}

/*
 * This function updates the internal temp value based on the
 * current thermal stage and threshold as well as the previous stage
 */
static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)
{}

static int qpnp_tm_get_temp(struct thermal_zone_device *tz, int *temp)
{}

static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip,
					     int temp)
{}

static int qpnp_tm_set_trip_temp(struct thermal_zone_device *tz,
				 const struct thermal_trip *trip, int temp)
{}

static const struct thermal_zone_device_ops qpnp_tm_sensor_ops =;

static irqreturn_t qpnp_tm_isr(int irq, void *data)
{}

static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip)
{}

/*
 * This function initializes the internal temp value based on only the
 * current thermal stage and threshold. Setup threshold control and
 * disable shutdown override.
 */
static int qpnp_tm_init(struct qpnp_tm_chip *chip)
{}

static int qpnp_tm_probe(struct platform_device *pdev)
{}

static const struct of_device_id qpnp_tm_match_table[] =;
MODULE_DEVICE_TABLE(of, qpnp_tm_match_table);

static struct platform_driver qpnp_tm_driver =;
module_platform_driver();

MODULE_ALIAS();
MODULE_DESCRIPTION();
MODULE_LICENSE();