linux/drivers/thermal/armada_thermal.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Marvell EBU Armada SoCs thermal sensor driver
 *
 * Copyright (C) 2013 Marvell
 */
#include <linux/device.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/of_device.h>
#include <linux/thermal.h>
#include <linux/iopoll.h>
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/interrupt.h>

/* Thermal Manager Control and Status Register */
#define PMU_TDC0_SW_RST_MASK
#define PMU_TM_DISABLE_OFFS
#define PMU_TM_DISABLE_MASK
#define PMU_TDC0_REF_CAL_CNT_OFFS
#define PMU_TDC0_REF_CAL_CNT_MASK
#define PMU_TDC0_OTF_CAL_MASK
#define PMU_TDC0_START_CAL_MASK

#define A375_UNIT_CONTROL_SHIFT
#define A375_UNIT_CONTROL_MASK
#define A375_READOUT_INVERT
#define A375_HW_RESETn

/* Errata fields */
#define CONTROL0_TSEN_TC_TRIM_MASK
#define CONTROL0_TSEN_TC_TRIM_VAL

#define CONTROL0_TSEN_START
#define CONTROL0_TSEN_RESET
#define CONTROL0_TSEN_ENABLE
#define CONTROL0_TSEN_AVG_BYPASS
#define CONTROL0_TSEN_CHAN_SHIFT
#define CONTROL0_TSEN_CHAN_MASK
#define CONTROL0_TSEN_OSR_SHIFT
#define CONTROL0_TSEN_OSR_MAX
#define CONTROL0_TSEN_MODE_SHIFT
#define CONTROL0_TSEN_MODE_EXTERNAL
#define CONTROL0_TSEN_MODE_MASK

#define CONTROL1_TSEN_AVG_MASK
#define CONTROL1_EXT_TSEN_SW_RESET
#define CONTROL1_EXT_TSEN_HW_RESETn
#define CONTROL1_TSEN_INT_EN
#define CONTROL1_TSEN_SELECT_OFF
#define CONTROL1_TSEN_SELECT_MASK

#define STATUS_POLL_PERIOD_US
#define STATUS_POLL_TIMEOUT_US
#define OVERHEAT_INT_POLL_DELAY_MS

struct armada_thermal_data;

/* Marvell EBU Thermal Sensor Dev Structure */
struct armada_thermal_priv {};

struct armada_thermal_data {};

struct armada_drvdata {};

/*
 * struct armada_thermal_sensor - hold the information of one thermal sensor
 * @thermal: pointer to the local private structure
 * @tzd: pointer to the thermal zone device
 * @id: identifier of the thermal sensor
 */
struct armada_thermal_sensor {};

static void armadaxp_init(struct platform_device *pdev,
			  struct armada_thermal_priv *priv)
{}

static void armada370_init(struct platform_device *pdev,
			   struct armada_thermal_priv *priv)
{}

static void armada375_init(struct platform_device *pdev,
			   struct armada_thermal_priv *priv)
{}

static int armada_wait_sensor_validity(struct armada_thermal_priv *priv)
{}

static void armada380_init(struct platform_device *pdev,
			   struct armada_thermal_priv *priv)
{}

static void armada_ap80x_init(struct platform_device *pdev,
			      struct armada_thermal_priv *priv)
{}

static void armada_cp110_init(struct platform_device *pdev,
			      struct armada_thermal_priv *priv)
{}

static bool armada_is_valid(struct armada_thermal_priv *priv)
{}

static void armada_enable_overheat_interrupt(struct armada_thermal_priv *priv)
{}

static void __maybe_unused
armada_disable_overheat_interrupt(struct armada_thermal_priv *priv)
{}

/* There is currently no board with more than one sensor per channel */
static int armada_select_channel(struct armada_thermal_priv *priv, int channel)
{}

static int armada_read_sensor(struct armada_thermal_priv *priv, int *temp)
{}

static int armada_get_temp_legacy(struct thermal_zone_device *thermal,
				  int *temp)
{}

static struct thermal_zone_device_ops legacy_ops =;

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

static const struct thermal_zone_device_ops of_ops =;

static unsigned int armada_mc_to_reg_temp(struct armada_thermal_data *data,
					  unsigned int temp_mc)
{}

/*
 * The documentation states:
 * high/low watermark = threshold +/- 0.4761 * 2^(hysteresis + 2)
 * which is the mathematical derivation for:
 * 0x0 <=> 1.9°C, 0x1 <=> 3.8°C, 0x2 <=> 7.6°C, 0x3 <=> 15.2°C
 */
static unsigned int hyst_levels_mc[] =;

static unsigned int armada_mc_to_reg_hyst(struct armada_thermal_data *data,
					  unsigned int hyst_mc)
{}

static void armada_set_overheat_thresholds(struct armada_thermal_priv *priv,
					   int thresh_mc, int hyst_mc)
{}

static irqreturn_t armada_overheat_isr(int irq, void *blob)
{}

static irqreturn_t armada_overheat_isr_thread(int irq, void *blob)
{}

static const struct armada_thermal_data armadaxp_data =;

static const struct armada_thermal_data armada370_data =;

static const struct armada_thermal_data armada375_data =;

static const struct armada_thermal_data armada380_data =;

static const struct armada_thermal_data armada_ap806_data =;

static const struct armada_thermal_data armada_ap807_data =;

static const struct armada_thermal_data armada_cp110_data =;

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

static const struct regmap_config armada_thermal_regmap_config =;

static int armada_thermal_probe_legacy(struct platform_device *pdev,
				       struct armada_thermal_priv *priv)
{}

static int armada_thermal_probe_syscon(struct platform_device *pdev,
				       struct armada_thermal_priv *priv)
{}

static void armada_set_sane_name(struct platform_device *pdev,
				 struct armada_thermal_priv *priv)
{}

/*
 * The IP can manage to trigger interrupts on overheat situation from all the
 * sensors. However, the interrupt source changes along with the last selected
 * source (ie. the last read sensor), which is an inconsistent behavior. Avoid
 * possible glitches by always selecting back only one channel (arbitrarily: the
 * first in the DT which has a critical trip point). We also disable sensor
 * switch during overheat situations.
 */
static int armada_configure_overheat_int(struct armada_thermal_priv *priv,
					 struct thermal_zone_device *tz,
					 int sensor_id)
{}

static int armada_thermal_probe(struct platform_device *pdev)
{}

static void armada_thermal_exit(struct platform_device *pdev)
{}

static struct platform_driver armada_thermal_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();