linux/drivers/hwmon/pmbus/stpddc60.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Hardware monitoring driver for the STPDDC60 controller
 *
 * Copyright (c) 2021 Flextronics International Sweden AB.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/pmbus.h>
#include "pmbus.h"

#define STPDDC60_MFR_READ_VOUT
#define STPDDC60_MFR_OV_LIMIT_OFFSET
#define STPDDC60_MFR_UV_LIMIT_OFFSET

static const struct i2c_device_id stpddc60_id[] =;
MODULE_DEVICE_TABLE(i2c, stpddc60_id);

static struct pmbus_driver_info stpddc60_info =;

/*
 * Calculate the closest absolute offset between commanded vout value
 * and limit value in steps of 50mv in the range 0 (50mv) to 7 (400mv).
 * Return 0 if the upper limit is lower than vout or if the lower limit
 * is higher than vout.
 */
static u8 stpddc60_get_offset(int vout, u16 limit, bool over)
{}

/*
 * Adjust the linear format word to use the given fixed exponent.
 */
static u16 stpddc60_adjust_linear(u16 word, s16 fixed)
{}

/*
 * The VOUT_COMMAND register uses the VID format but the vout alarm limit
 * registers use the LINEAR format so we override VOUT_MODE here to force
 * LINEAR format for all registers.
 */
static int stpddc60_read_byte_data(struct i2c_client *client, int page, int reg)
{}

/*
 * The vout related registers return values in LINEAR11 format when LINEAR16
 * is expected. Clear the top 5 bits to set the exponent part to zero to
 * convert the value to LINEAR16 format.
 */
static int stpddc60_read_word_data(struct i2c_client *client, int page,
				   int phase, int reg)
{}

/*
 * The vout under- and over-voltage limits are set as an offset relative to
 * the commanded vout voltage. The vin, iout, pout and temp limits must use
 * the same fixed exponent the chip uses to encode the data when read.
 */
static int stpddc60_write_word_data(struct i2c_client *client, int page,
				    int reg, u16 word)
{}

static int stpddc60_probe(struct i2c_client *client)
{}

static struct i2c_driver stpddc60_driver =;

module_i2c_driver();

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