linux/drivers/hwmon/bt1-pvt.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
 *
 * Baikal-T1 Process, Voltage, Temperature sensor driver
 */
#ifndef __HWMON_BT1_PVT_H__
#define __HWMON_BT1_PVT_H__

#include <linux/completion.h>
#include <linux/hwmon.h>
#include <linux/kernel.h>
#include <linux/ktime.h>
#include <linux/mutex.h>
#include <linux/seqlock.h>

/* Baikal-T1 PVT registers and their bitfields */
#define PVT_CTRL
#define PVT_CTRL_EN
#define PVT_CTRL_MODE_FLD
#define PVT_CTRL_MODE_MASK
#define PVT_CTRL_MODE_TEMP
#define PVT_CTRL_MODE_VOLT
#define PVT_CTRL_MODE_LVT
#define PVT_CTRL_MODE_HVT
#define PVT_CTRL_MODE_SVT
#define PVT_CTRL_TRIM_FLD
#define PVT_CTRL_TRIM_MASK
#define PVT_DATA
#define PVT_DATA_VALID
#define PVT_DATA_DATA_FLD
#define PVT_DATA_DATA_MASK
#define PVT_TTHRES
#define PVT_VTHRES
#define PVT_LTHRES
#define PVT_HTHRES
#define PVT_STHRES
#define PVT_THRES_LO_FLD
#define PVT_THRES_LO_MASK
#define PVT_THRES_HI_FLD
#define PVT_THRES_HI_MASK
#define PVT_TTIMEOUT
#define PVT_INTR_STAT
#define PVT_INTR_MASK
#define PVT_RAW_INTR_STAT
#define PVT_INTR_DVALID
#define PVT_INTR_TTHRES_LO
#define PVT_INTR_TTHRES_HI
#define PVT_INTR_VTHRES_LO
#define PVT_INTR_VTHRES_HI
#define PVT_INTR_LTHRES_LO
#define PVT_INTR_LTHRES_HI
#define PVT_INTR_HTHRES_LO
#define PVT_INTR_HTHRES_HI
#define PVT_INTR_STHRES_LO
#define PVT_INTR_STHRES_HI
#define PVT_INTR_ALL
#define PVT_CLR_INTR

/*
 * PVT sensors-related limits and default values
 * @PVT_TEMP_MIN: Minimal temperature in millidegrees of Celsius.
 * @PVT_TEMP_MAX: Maximal temperature in millidegrees of Celsius.
 * @PVT_TEMP_CHS: Number of temperature hwmon channels.
 * @PVT_VOLT_MIN: Minimal voltage in mV.
 * @PVT_VOLT_MAX: Maximal voltage in mV.
 * @PVT_VOLT_CHS: Number of voltage hwmon channels.
 * @PVT_DATA_MIN: Minimal PVT raw data value.
 * @PVT_DATA_MAX: Maximal PVT raw data value.
 * @PVT_TRIM_MIN: Minimal temperature sensor trim value.
 * @PVT_TRIM_MAX: Maximal temperature sensor trim value.
 * @PVT_TRIM_DEF: Default temperature sensor trim value (set a proper value
 *		  when one is determined for Baikal-T1 SoC).
 * @PVT_TRIM_TEMP: Maximum temperature encoded by the trim factor.
 * @PVT_TRIM_STEP: Temperature stride corresponding to the trim value.
 * @PVT_TOUT_MIN: Minimal timeout between samples in nanoseconds.
 * @PVT_TOUT_DEF: Default data measurements timeout. In case if alarms are
 *		  activated the PVT IRQ is enabled to be raised after each
 *		  conversion in order to have the thresholds checked and the
 *		  converted value cached. Too frequent conversions may cause
 *		  the system CPU overload. Lets set the 50ms delay between
 *		  them by default to prevent this.
 */
#define PVT_TEMP_MIN
#define PVT_TEMP_MAX
#define PVT_TEMP_CHS
#define PVT_VOLT_MIN
#define PVT_VOLT_MAX
#define PVT_VOLT_CHS
#define PVT_DATA_MIN
#define PVT_DATA_MAX
#define PVT_TRIM_MIN
#define PVT_TRIM_MAX
#define PVT_TRIM_TEMP
#define PVT_TRIM_STEP
#define PVT_TRIM_DEF
#define PVT_TOUT_MIN
#if defined(CONFIG_SENSORS_BT1_PVT_ALARMS)
#define PVT_TOUT_DEF
#else
#define PVT_TOUT_DEF
#endif

/*
 * enum pvt_sensor_type - Baikal-T1 PVT sensor types (correspond to each PVT
 *			  sampling mode)
 * @PVT_SENSOR*: helpers to traverse the sensors in loops.
 * @PVT_TEMP: PVT Temperature sensor.
 * @PVT_VOLT: PVT Voltage sensor.
 * @PVT_LVT: PVT Low-Voltage threshold sensor.
 * @PVT_HVT: PVT High-Voltage threshold sensor.
 * @PVT_SVT: PVT Standard-Voltage threshold sensor.
 */
enum pvt_sensor_type {};

/*
 * enum pvt_clock_type - Baikal-T1 PVT clocks.
 * @PVT_CLOCK_APB: APB clock.
 * @PVT_CLOCK_REF: PVT reference clock.
 */
enum pvt_clock_type {};

/*
 * struct pvt_sensor_info - Baikal-T1 PVT sensor informational structure
 * @channel: Sensor channel ID.
 * @label: hwmon sensor label.
 * @mode: PVT mode corresponding to the channel.
 * @thres_base: upper and lower threshold values of the sensor.
 * @thres_sts_lo: low threshold status bitfield.
 * @thres_sts_hi: high threshold status bitfield.
 * @type: Sensor type.
 * @attr_min_alarm: Min alarm attribute ID.
 * @attr_min_alarm: Max alarm attribute ID.
 */
struct pvt_sensor_info {};

#define PVT_SENSOR_INFO(_ch, _label, _type, _mode, _thres)

/*
 * struct pvt_cache - PVT sensors data cache
 * @data: data cache in raw format.
 * @thres_sts_lo: low threshold status saved on the previous data conversion.
 * @thres_sts_hi: high threshold status saved on the previous data conversion.
 * @data_seqlock: cached data seq-lock.
 * @conversion: data conversion completion.
 */
struct pvt_cache {};

/*
 * struct pvt_hwmon - Baikal-T1 PVT private data
 * @dev: device structure of the PVT platform device.
 * @hwmon: hwmon device structure.
 * @regs: pointer to the Baikal-T1 PVT registers region.
 * @irq: PVT events IRQ number.
 * @clks: Array of the PVT clocks descriptor (APB/ref clocks).
 * @ref_clk: Pointer to the reference clocks descriptor.
 * @iface_mtx: Generic interface mutex (used to lock the alarm registers
 *	       when the alarms enabled, or the data conversion interface
 *	       if alarms are disabled).
 * @sensor: current PVT sensor the data conversion is being performed for.
 * @cache: data cache descriptor.
 * @timeout: conversion timeout cache.
 */
struct pvt_hwmon {};

/*
 * struct pvt_poly_term - a term descriptor of the PVT data translation
 *			  polynomial
 * @deg: degree of the term.
 * @coef: multiplication factor of the term.
 * @divider: distributed divider per each degree.
 * @divider_leftover: divider leftover, which couldn't be redistributed.
 */
struct pvt_poly_term {};

/*
 * struct pvt_poly - PVT data translation polynomial descriptor
 * @total_divider: total data divider.
 * @terms: polynomial terms up to a free one.
 */
struct pvt_poly {};

#endif /* __HWMON_BT1_PVT_H__ */