linux/drivers/hwmon/oxp-sensors.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Platform driver for OneXPlayer, AOK ZOE, and Aya Neo Handhelds that expose
 * fan reading and control via hwmon sysfs.
 *
 * Old OXP boards have the same DMI strings and they are told apart by
 * the boot cpu vendor (Intel/AMD). Currently only AMD boards are
 * supported but the code is made to be simple to add other handheld
 * boards in the future.
 * Fan control is provided via pwm interface in the range [0-255].
 * Old AMD boards use [0-100] as range in the EC, the written value is
 * scaled to accommodate for that. Newer boards like the mini PRO and
 * AOK ZOE are not scaled but have the same EC layout.
 *
 * Copyright (C) 2022 Joaquín I. Aramendía <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/dmi.h>
#include <linux/hwmon.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/processor.h>

/* Handle ACPI lock mechanism */
static u32 oxp_mutex;

#define ACPI_LOCK_DELAY_MS

static bool lock_global_acpi_lock(void)
{}

static bool unlock_global_acpi_lock(void)
{}

enum oxp_board {};

static enum oxp_board board;

/* Fan reading and PWM */
#define OXP_SENSOR_FAN_REG
#define OXP_SENSOR_PWM_ENABLE_REG
#define OXP_SENSOR_PWM_REG

/* Turbo button takeover function
 * Older boards have different values and EC registers
 * for the same function
 */
#define OXP_OLD_TURBO_SWITCH_REG
#define OXP_OLD_TURBO_TAKE_VAL
#define OXP_OLD_TURBO_RETURN_VAL

#define OXP_TURBO_SWITCH_REG
#define OXP_TURBO_TAKE_VAL
#define OXP_TURBO_RETURN_VAL

static const struct dmi_system_id dmi_table[] =;

/* Helper functions to handle EC read/write */
static int read_from_ec(u8 reg, int size, long *val)
{}

static int write_to_ec(u8 reg, u8 value)
{}

/* Turbo button toggle functions */
static int tt_toggle_enable(void)
{}

static int tt_toggle_disable(void)
{}

/* Callbacks for turbo toggle attribute */
static umode_t tt_toggle_is_visible(struct kobject *kobj,
				    struct attribute *attr, int n)
{}

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

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

static DEVICE_ATTR_RW(tt_toggle);

/* PWM enable/disable functions */
static int oxp_pwm_enable(void)
{}

static int oxp_pwm_disable(void)
{}

/* Callbacks for hwmon interface */
static umode_t oxp_ec_hwmon_is_visible(const void *drvdata,
				       enum hwmon_sensor_types type, u32 attr, int channel)
{}

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

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

/* Known sensors in the OXP EC controllers */
static const struct hwmon_channel_info * const oxp_platform_sensors[] =;

static struct attribute *oxp_ec_attrs[] =;

static struct attribute_group oxp_ec_attribute_group =;

static const struct attribute_group *oxp_ec_groups[] =;

static const struct hwmon_ops oxp_ec_hwmon_ops =;

static const struct hwmon_chip_info oxp_ec_chip_info =;

/* Initialization logic */
static int oxp_platform_probe(struct platform_device *pdev)
{}

static struct platform_driver oxp_platform_driver =;

static struct platform_device *oxp_platform_device;

static int __init oxp_platform_init(void)
{}

static void __exit oxp_platform_exit(void)
{}

MODULE_DEVICE_TABLE(dmi, dmi_table);

module_init();
module_exit(oxp_platform_exit);

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