linux/drivers/platform/olpc/olpc-xo175-ec.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Driver for the OLPC XO-1.75 Embedded Controller.
 *
 * The EC protocol is documented at:
 * http://wiki.laptop.org/go/XO_1.75_HOST_to_EC_Protocol
 *
 * Copyright (C) 2010 One Laptop per Child Foundation.
 * Copyright (C) 2018 Lubomir Rintel <[email protected]>
 */

#include <linux/completion.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/input.h>
#include <linux/kfifo.h>
#include <linux/module.h>
#include <linux/olpc-ec.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/reboot.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/spi/spi.h>

struct ec_cmd_t {};

enum ec_chan_t {};

/*
 * EC events
 */
#define EVENT_AC_CHANGE
#define EVENT_BATTERY_STATUS
#define EVENT_BATTERY_CRITICAL
#define EVENT_BATTERY_SOC_CHANGE
#define EVENT_BATTERY_ERROR
#define EVENT_POWER_PRESSED
#define EVENT_POWER_PRESS_WAKE
#define EVENT_TIMED_HOST_WAKE
#define EVENT_OLS_HIGH_LIMIT
#define EVENT_OLS_LOW_LIMIT

/*
 * EC commands
 * (from http://dev.laptop.org/git/users/rsmith/ec-1.75/tree/ec_cmd.h)
 */
#define CMD_GET_API_VERSION
#define CMD_READ_VOLTAGE
#define CMD_READ_CURRENT
#define CMD_READ_ACR
#define CMD_READ_BATT_TEMPERATURE
#define CMD_READ_AMBIENT_TEMPERATURE
#define CMD_READ_BATTERY_STATUS
#define CMD_READ_SOC
#define CMD_READ_GAUGE_ID
#define CMD_READ_GAUGE_DATA
#define CMD_READ_BOARD_ID
#define CMD_READ_BATT_ERR_CODE
#define CMD_SET_DCON_POWER
#define CMD_RESET_EC
#define CMD_READ_BATTERY_TYPE
#define CMD_SET_AUTOWAK
#define CMD_SET_EC_WAKEUP_TIMER
#define CMD_READ_EXT_SCI_MASK
#define CMD_WRITE_EXT_SCI_MASK
#define CMD_CLEAR_EC_WAKEUP_TIMER
#define CMD_ENABLE_RUNIN_DISCHARGE
#define CMD_DISABLE_RUNIN_DISCHARGE
#define CMD_READ_MPPT_ACTIVE
#define CMD_READ_MPPT_LIMIT
#define CMD_SET_MPPT_LIMIT
#define CMD_DISABLE_MPPT
#define CMD_ENABLE_MPPT
#define CMD_READ_VIN
#define CMD_EXT_SCI_QUERY
#define RSP_KEYBOARD_DATA
#define RSP_TOUCHPAD_DATA
#define CMD_GET_FW_VERSION
#define CMD_POWER_CYCLE
#define CMD_POWER_OFF
#define CMD_RESET_EC_SOFT
#define CMD_READ_GAUGE_U16
#define CMD_ENABLE_MOUSE
#define CMD_ECHO
#define CMD_GET_FW_DATE
#define CMD_GET_FW_USER
#define CMD_TURN_OFF_POWER
#define CMD_READ_OLS
#define CMD_OLS_SMT_LEDON
#define CMD_OLS_SMT_LEDOFF
#define CMD_START_OLS_ASSY
#define CMD_STOP_OLS_ASSY
#define CMD_OLS_SMTTEST_STOP
#define CMD_READ_VIN_SCALED
#define CMD_READ_BAT_MIN_W
#define CMD_READ_BAR_MAX_W
#define CMD_RESET_BAT_MINMAX_W
#define CMD_READ_LOCATION
#define CMD_WRITE_LOCATION
#define CMD_KEYBOARD_CMD
#define CMD_TOUCHPAD_CMD
#define CMD_GET_FW_HASH
#define CMD_SUSPEND_HINT
#define CMD_ENABLE_WAKE_TIMER
#define CMD_SET_WAKE_TIMER
#define CMD_ENABLE_WAKE_AUTORESET
#define CMD_OLS_SET_LIMITS
#define CMD_OLS_GET_LIMITS
#define CMD_OLS_SET_CEILING
#define CMD_OLS_GET_CEILING

/*
 * Accepted EC commands, and how many bytes they return. There are plenty
 * of EC commands that are no longer implemented, or are implemented only on
 * certain older boards.
 */
static const struct ec_cmd_t olpc_xo175_ec_cmds[] =;

#define EC_MAX_CMD_DATA_LEN
#define EC_MAX_RESP_LEN

#define LOG_BUF_SIZE

#define PM_WAKEUP_TIME

#define EC_ALL_EVENTS

enum ec_state_t {};

struct olpc_xo175_ec_cmd {};

struct olpc_xo175_ec_resp {};

struct olpc_xo175_ec {};

static struct platform_device *olpc_ec;

static int olpc_xo175_ec_resp_len(u8 cmd)
{}

static void olpc_xo175_ec_flush_logbuf(struct olpc_xo175_ec *priv)
{}

static void olpc_xo175_ec_complete(void *arg);

static void olpc_xo175_ec_send_command(struct olpc_xo175_ec *priv, void *cmd,
								size_t cmdlen)
{}

static void olpc_xo175_ec_read_packet(struct olpc_xo175_ec *priv)
{}

static void olpc_xo175_ec_complete(void *arg)
{}

/*
 * This function is protected with a mutex. We can safely assume that
 * there will be only one instance of this function running at a time.
 * One of the ways in which we enforce this is by waiting until we get
 * all response bytes back from the EC, rather than just the number that
 * the caller requests (otherwise, we might start a new command while an
 * old command's response bytes are still incoming).
 */
static int olpc_xo175_ec_cmd(u8 cmd, u8 *inbuf, size_t inlen, u8 *resp,
					size_t resp_len, void *ec_cb_arg)
{}

static int olpc_xo175_ec_set_event_mask(unsigned int mask)
{}

static void olpc_xo175_ec_power_off(void)
{}

static int __maybe_unused olpc_xo175_ec_suspend(struct device *dev)
{}

static int __maybe_unused olpc_xo175_ec_resume_noirq(struct device *dev)
{}

static int __maybe_unused olpc_xo175_ec_resume(struct device *dev)
{}

static struct olpc_ec_driver olpc_xo175_ec_driver =;

static void olpc_xo175_ec_remove(struct spi_device *spi)
{}

static int olpc_xo175_ec_probe(struct spi_device *spi)
{}

static const struct dev_pm_ops olpc_xo175_ec_pm_ops =;

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

static const struct spi_device_id olpc_xo175_ec_id_table[] =;
MODULE_DEVICE_TABLE(spi, olpc_xo175_ec_id_table);

static struct spi_driver olpc_xo175_ec_spi_driver =;
module_spi_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR(); /* Functionality */
MODULE_AUTHOR(); /* Bugs */
MODULE_LICENSE();