linux/drivers/platform/x86/msi-ec.c

// SPDX-License-Identifier: GPL-2.0-or-later

/*
 * msi-ec: MSI laptops' embedded controller driver.
 *
 * This driver allows various MSI laptops' functionalities to be
 * controlled from userspace.
 *
 * It contains EC memory configurations for different firmware versions
 * and exports battery charge thresholds to userspace.
 *
 * Copyright (C) 2023 Jose Angel Pastrana <[email protected]>
 * Copyright (C) 2023 Aakash Singh <[email protected]>
 * Copyright (C) 2023 Nikita Kravets <[email protected]>
 */

#define pr_fmt(fmt)

#include "msi-ec.h"

#include <acpi/battery.h>
#include <linux/acpi.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
#include <linux/string.h>

#define SM_ECO_NAME
#define SM_COMFORT_NAME
#define SM_SPORT_NAME
#define SM_TURBO_NAME

#define FM_AUTO_NAME
#define FM_SILENT_NAME
#define FM_BASIC_NAME
#define FM_ADVANCED_NAME

static const char * const ALLOWED_FW_0[] __initconst =;

static struct msi_ec_conf CONF0 __initdata =;

static const char * const ALLOWED_FW_1[] __initconst =;

static struct msi_ec_conf CONF1 __initdata =;

static const char * const ALLOWED_FW_2[] __initconst =;

static struct msi_ec_conf CONF2 __initdata =;

static const char * const ALLOWED_FW_3[] __initconst =;

static struct msi_ec_conf CONF3 __initdata =;

static const char * const ALLOWED_FW_4[] __initconst =;

static struct msi_ec_conf CONF4 __initdata =;

static const char * const ALLOWED_FW_5[] __initconst =;

static struct msi_ec_conf CONF5 __initdata =;

static const char * const ALLOWED_FW_6[] __initconst =;

static struct msi_ec_conf CONF6 __initdata =;

static const char * const ALLOWED_FW_7[] __initconst =;

static struct msi_ec_conf CONF7 __initdata =;

static const char * const ALLOWED_FW_8[] __initconst =;

static struct msi_ec_conf CONF8 __initdata =;

static const char * const ALLOWED_FW_9[] __initconst =;

static struct msi_ec_conf CONF9 __initdata =;

static const char * const ALLOWED_FW_10[] __initconst =;

static struct msi_ec_conf CONF10 __initdata =;

static const char * const ALLOWED_FW_11[] __initconst =;

static struct msi_ec_conf CONF11 __initdata =;

static const char * const ALLOWED_FW_12[] __initconst =;

static struct msi_ec_conf CONF12 __initdata =;

static const char * const ALLOWED_FW_13[] __initconst =;

static struct msi_ec_conf CONF13 __initdata =;

static struct msi_ec_conf *CONFIGS[] __initdata =;

static struct msi_ec_conf conf; // current configuration

/*
 * Helper functions
 */

static int ec_read_seq(u8 addr, u8 *buf, u8 len)
{}

static int ec_get_firmware_version(u8 buf[MSI_EC_FW_VERSION_LENGTH + 1])
{}

/*
 * Sysfs power_supply subsystem
 */

static ssize_t charge_control_threshold_show(u8 offset,
					     struct device *device,
					     struct device_attribute *attr,
					     char *buf)
{}

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

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

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

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

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

static DEVICE_ATTR_RW(charge_control_start_threshold);
static DEVICE_ATTR_RW(charge_control_end_threshold);

static struct attribute *msi_battery_attrs[] =;

ATTRIBUTE_GROUPS();

static int msi_battery_add(struct power_supply *battery,
			   struct acpi_battery_hook *hook)
{}

static int msi_battery_remove(struct power_supply *battery,
			      struct acpi_battery_hook *hook)
{}

static struct acpi_battery_hook battery_hook =;

/*
 * Module load/unload
 */

static const struct dmi_system_id msi_dmi_table[] __initconst __maybe_unused =;
MODULE_DEVICE_TABLE(dmi, msi_dmi_table);

static int __init load_configuration(void)
{}

static int __init msi_ec_init(void)
{}

static void __exit msi_ec_exit(void)
{}

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

module_init();
module_exit(msi_ec_exit);