linux/drivers/hwmon/pmbus/pmbus.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * pmbus.h - Common defines and structures for PMBus devices
 *
 * Copyright (c) 2010, 2011 Ericsson AB.
 * Copyright (c) 2012 Guenter Roeck
 */

#ifndef PMBUS_H
#define PMBUS_H

#include <linux/bitops.h>
#include <linux/regulator/driver.h>

/*
 * Registers
 */
enum pmbus_regs {};

/*
 * OPERATION
 */
#define PB_OPERATION_CONTROL_ON

/*
 * ON_OFF_CONFIG
 */
#define PB_ON_OFF_CONFIG_POWERUP_CONTROL
#define PB_ON_OFF_CONFIG_OPERATION_REQ
#define PB_ON_OFF_CONFIG_EN_PIN_REQ
#define PB_ON_OFF_CONFIG_POLARITY_HIGH
#define PB_ON_OFF_CONFIG_TURN_OFF_FAST

/*
 * WRITE_PROTECT
 */
#define PB_WP_ALL
#define PB_WP_OP
#define PB_WP_VOUT

#define PB_WP_ANY

/*
 * CAPABILITY
 */
#define PB_CAPABILITY_SMBALERT
#define PB_CAPABILITY_ERROR_CHECK

/*
 * VOUT_MODE
 */
#define PB_VOUT_MODE_MODE_MASK
#define PB_VOUT_MODE_PARAM_MASK

#define PB_VOUT_MODE_LINEAR
#define PB_VOUT_MODE_VID
#define PB_VOUT_MODE_DIRECT

/*
 * Fan configuration
 */
#define PB_FAN_2_PULSE_MASK
#define PB_FAN_2_RPM
#define PB_FAN_2_INSTALLED
#define PB_FAN_1_PULSE_MASK
#define PB_FAN_1_RPM
#define PB_FAN_1_INSTALLED

enum pmbus_fan_mode {};

/*
 * STATUS_BYTE, STATUS_WORD (lower)
 */
#define PB_STATUS_NONE_ABOVE
#define PB_STATUS_CML
#define PB_STATUS_TEMPERATURE
#define PB_STATUS_VIN_UV
#define PB_STATUS_IOUT_OC
#define PB_STATUS_VOUT_OV
#define PB_STATUS_OFF
#define PB_STATUS_BUSY

/*
 * STATUS_WORD (upper)
 */
#define PB_STATUS_UNKNOWN
#define PB_STATUS_OTHER
#define PB_STATUS_FANS
#define PB_STATUS_POWER_GOOD_N
#define PB_STATUS_WORD_MFR
#define PB_STATUS_INPUT
#define PB_STATUS_IOUT_POUT
#define PB_STATUS_VOUT

/*
 * STATUS_IOUT
 */
#define PB_POUT_OP_WARNING
#define PB_POUT_OP_FAULT
#define PB_POWER_LIMITING
#define PB_CURRENT_SHARE_FAULT
#define PB_IOUT_UC_FAULT
#define PB_IOUT_OC_WARNING
#define PB_IOUT_OC_LV_FAULT
#define PB_IOUT_OC_FAULT

/*
 * STATUS_VOUT, STATUS_INPUT
 */
#define PB_VOLTAGE_VIN_OFF
#define PB_VOLTAGE_UV_FAULT
#define PB_VOLTAGE_UV_WARNING
#define PB_VOLTAGE_OV_WARNING
#define PB_VOLTAGE_OV_FAULT

/*
 * STATUS_INPUT
 */
#define PB_PIN_OP_WARNING
#define PB_IIN_OC_WARNING
#define PB_IIN_OC_FAULT

/*
 * STATUS_TEMPERATURE
 */
#define PB_TEMP_UT_FAULT
#define PB_TEMP_UT_WARNING
#define PB_TEMP_OT_WARNING
#define PB_TEMP_OT_FAULT

/*
 * STATUS_FAN
 */
#define PB_FAN_AIRFLOW_WARNING
#define PB_FAN_AIRFLOW_FAULT
#define PB_FAN_FAN2_SPEED_OVERRIDE
#define PB_FAN_FAN1_SPEED_OVERRIDE
#define PB_FAN_FAN2_WARNING
#define PB_FAN_FAN1_WARNING
#define PB_FAN_FAN2_FAULT
#define PB_FAN_FAN1_FAULT

/*
 * CML_FAULT_STATUS
 */
#define PB_CML_FAULT_OTHER_MEM_LOGIC
#define PB_CML_FAULT_OTHER_COMM
#define PB_CML_FAULT_PROCESSOR
#define PB_CML_FAULT_MEMORY
#define PB_CML_FAULT_PACKET_ERROR
#define PB_CML_FAULT_INVALID_DATA
#define PB_CML_FAULT_INVALID_COMMAND

enum pmbus_sensor_classes {};

#define PMBUS_PAGES
#define PMBUS_PHASES

/* Functionality bit mask */
#define PMBUS_HAVE_VIN
#define PMBUS_HAVE_VCAP
#define PMBUS_HAVE_VOUT
#define PMBUS_HAVE_IIN
#define PMBUS_HAVE_IOUT
#define PMBUS_HAVE_PIN
#define PMBUS_HAVE_POUT
#define PMBUS_HAVE_FAN12
#define PMBUS_HAVE_FAN34
#define PMBUS_HAVE_TEMP
#define PMBUS_HAVE_TEMP2
#define PMBUS_HAVE_TEMP3
#define PMBUS_HAVE_STATUS_VOUT
#define PMBUS_HAVE_STATUS_IOUT
#define PMBUS_HAVE_STATUS_INPUT
#define PMBUS_HAVE_STATUS_TEMP
#define PMBUS_HAVE_STATUS_FAN12
#define PMBUS_HAVE_STATUS_FAN34
#define PMBUS_HAVE_VMON
#define PMBUS_HAVE_STATUS_VMON
#define PMBUS_HAVE_PWM12
#define PMBUS_HAVE_PWM34
#define PMBUS_HAVE_SAMPLES

#define PMBUS_PHASE_VIRTUAL
#define PMBUS_PAGE_VIRTUAL

enum pmbus_data_format {};
enum vrm_version {};

struct pmbus_driver_info {};

/* Regulator ops */

extern const struct regulator_ops pmbus_regulator_ops;

/* Macros for filling in array of struct regulator_desc */
#define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step, _min_uV)

#define PMBUS_REGULATOR(_name, _id)

#define PMBUS_REGULATOR_STEP_ONE(_name, _voltages, _step, _min_uV)

#define PMBUS_REGULATOR_ONE(_name)

/* Function declarations */

void pmbus_clear_cache(struct i2c_client *client);
void pmbus_set_update(struct i2c_client *client, u8 reg, bool update);
int pmbus_set_page(struct i2c_client *client, int page, int phase);
int pmbus_read_word_data(struct i2c_client *client, int page, int phase,
			 u8 reg);
int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
			  u16 word);
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
			  u8 value);
int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
			   u8 mask, u8 value);
void pmbus_clear_faults(struct i2c_client *client);
bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
						      *client);
int pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id,
			      enum pmbus_fan_mode mode);
int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id,
			      enum pmbus_fan_mode mode);
int pmbus_lock_interruptible(struct i2c_client *client);
void pmbus_unlock(struct i2c_client *client);
int pmbus_update_fan(struct i2c_client *client, int page, int id,
		     u8 config, u8 mask, u16 command);
struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client);

#endif /* PMBUS_H */