linux/drivers/hwmon/sg2042-mcu.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2024 Inochi Amaoto <[email protected]>
 *
 * Sophgo power control mcu for SG2042
 */

#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>

/* fixed MCU registers */
#define REG_BOARD_TYPE
#define REG_MCU_FIRMWARE_VERSION
#define REG_PCB_VERSION
#define REG_PWR_CTRL
#define REG_SOC_TEMP
#define REG_BOARD_TEMP
#define REG_RST_COUNT
#define REG_UPTIME
#define REG_RESET_REASON
#define REG_MCU_TYPE
#define REG_REPOWER_POLICY
#define REG_CRITICAL_TEMP
#define REG_REPOWER_TEMP

#define REPOWER_POLICY_REBOOT
#define REPOWER_POLICY_KEEP_OFF

#define MCU_POWER_MAX

#define DEFINE_MCU_DEBUG_ATTR(_name, _reg, _format)					\

struct sg2042_mcu_data {};

static struct dentry *sgmcu_debugfs;

static ssize_t reset_count_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

static ssize_t uptime_show(struct device *dev,
			   struct device_attribute *attr,
			   char *buf)
{}

static ssize_t reset_reason_show(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{}

static ssize_t repower_policy_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buf)
{}

static ssize_t repower_policy_store(struct device *dev,
				    struct device_attribute *attr,
				    const char *buf, size_t count)
{}

static DEVICE_ATTR_RO(reset_count);
static DEVICE_ATTR_RO(uptime);
static DEVICE_ATTR_RO(reset_reason);
static DEVICE_ATTR_RW(repower_policy);

DEFINE_MCU_DEBUG_ATTR();
DEFINE_MCU_DEBUG_ATTR();
DEFINE_MCU_DEBUG_ATTR();
DEFINE_MCU_DEBUG_ATTR();

static struct attribute *sg2042_mcu_attrs[] =;

static const struct attribute_group sg2042_mcu_attr_group =;

static const struct attribute_group *sg2042_mcu_groups[] =;

static const struct hwmon_channel_info * const sg2042_mcu_info[] =;

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

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

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

static const struct hwmon_ops sg2042_mcu_ops =;

static const struct hwmon_chip_info sg2042_mcu_chip_info =;

static void sg2042_mcu_debugfs_init(struct sg2042_mcu_data *mcu,
				    struct device *dev)
{}

static int sg2042_mcu_i2c_probe(struct i2c_client *client)
{}

static void sg2042_mcu_i2c_remove(struct i2c_client *client)
{}

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

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

static struct i2c_driver sg2042_mcu_driver =;

static int __init sg2042_mcu_init(void)
{}

static void __exit sg2042_mcu_exit(void)
{}

module_init();
module_exit(sg2042_mcu_exit);

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