linux/drivers/hwmon/lan966x-hwmon.c

// SPDX-License-Identifier: GPL-2.0-only

#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/hwmon.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/polynomial.h>
#include <linux/regmap.h>

/*
 * The original translation formulae of the temperature (in degrees of Celsius)
 * are as follows:
 *
 *   T = -3.4627e-11*(N^4) + 1.1023e-7*(N^3) + -1.9165e-4*(N^2) +
 *       3.0604e-1*(N^1) + -5.6197e1
 *
 * where [-56.197, 136.402]C and N = [0, 1023].
 *
 * They must be accordingly altered to be suitable for the integer arithmetics.
 * The technique is called 'factor redistribution', which just makes sure the
 * multiplications and divisions are made so to have a result of the operations
 * within the integer numbers limit. In addition we need to translate the
 * formulae to accept millidegrees of Celsius. Here what it looks like after
 * the alterations:
 *
 *   T = -34627e-12*(N^4) + 110230e-9*(N^3) + -191650e-6*(N^2) +
 *       306040e-3*(N^1) + -56197
 *
 * where T = [-56197, 136402]mC and N = [0, 1023].
 */

static const struct polynomial poly_N_to_temp =;

#define PVT_SENSOR_CTRL
#define PVT_SENSOR_CFG
#define SENSOR_CFG_CLK_CFG
#define SENSOR_CFG_TRIM_VAL
#define SENSOR_CFG_SAMPLE_ENA
#define SENSOR_CFG_START_CAPTURE
#define SENSOR_CFG_CONTINIOUS_MODE
#define SENSOR_CFG_PSAMPLE_ENA
#define PVT_SENSOR_STAT
#define SENSOR_STAT_DATA_VALID
#define SENSOR_STAT_DATA

#define FAN_CFG
#define FAN_CFG_DUTY_CYCLE
#define INV_POL
#define GATE_ENA
#define PWM_OPEN_COL_ENA
#define FAN_STAT_CFG
#define FAN_PWM_FREQ
#define FAN_PWM_CYC_10US
#define FAN_PWM_FREQ_FREQ
#define FAN_CNT
#define FAN_CNT_DATA

#define LAN966X_PVT_CLK

struct lan966x_hwmon {};

static int lan966x_hwmon_read_temp(struct device *dev, long *val)
{}

static int lan966x_hwmon_read_fan(struct device *dev, long *val)
{}

static int lan966x_hwmon_read_pwm(struct device *dev, long *val)
{}

static int lan966x_hwmon_read_pwm_freq(struct device *dev, long *val)
{}

static int lan966x_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
			      u32 attr, int channel, long *val)
{}

static int lan966x_hwmon_write_pwm(struct device *dev, long val)
{}

static int lan966x_hwmon_write_pwm_freq(struct device *dev, long val)
{}

static int lan966x_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
			       u32 attr, int channel, long val)
{}

static umode_t lan966x_hwmon_is_visible(const void *data,
					enum hwmon_sensor_types type,
					u32 attr, int channel)
{}

static const struct hwmon_channel_info * const lan966x_hwmon_info[] =;

static const struct hwmon_ops lan966x_hwmon_ops =;

static const struct hwmon_chip_info lan966x_hwmon_chip_info =;

static void lan966x_hwmon_disable(void *data)
{}

static int lan966x_hwmon_enable(struct device *dev,
				struct lan966x_hwmon *hwmon)
{}

static struct regmap *lan966x_init_regmap(struct platform_device *pdev,
					  const char *name)
{}

static int lan966x_hwmon_probe(struct platform_device *pdev)
{}

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

static struct platform_driver lan966x_hwmon_driver =;
module_platform_driver();

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