linux/drivers/char/ipmi/ssif_bmc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * The driver for BMC side of SSIF interface
 *
 * Copyright (c) 2022, Ampere Computing LLC
 *
 */

#include <linux/i2c.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/poll.h>
#include <linux/sched.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
#include <linux/ipmi_ssif_bmc.h>

#define DEVICE_NAME

#define GET_8BIT_ADDR(addr_7bit)

/* A standard SMBus Transaction is limited to 32 data bytes */
#define MAX_PAYLOAD_PER_TRANSACTION
/* Transaction includes the address, the command, the length and the PEC byte */
#define MAX_TRANSACTION

#define MAX_IPMI_DATA_PER_START_TRANSACTION
#define MAX_IPMI_DATA_PER_MIDDLE_TRANSACTION

#define SSIF_IPMI_SINGLEPART_WRITE
#define SSIF_IPMI_SINGLEPART_READ
#define SSIF_IPMI_MULTIPART_WRITE_START
#define SSIF_IPMI_MULTIPART_WRITE_MIDDLE
#define SSIF_IPMI_MULTIPART_WRITE_END
#define SSIF_IPMI_MULTIPART_READ_START
#define SSIF_IPMI_MULTIPART_READ_MIDDLE

/*
 * IPMI 2.0 Spec, section 12.7 SSIF Timing,
 * Request-to-Response Time is T6max(250ms) - T1max(20ms) - 3ms = 227ms
 * Recover ssif_bmc from busy state if it takes up to 500ms
 */
#define RESPONSE_TIMEOUT

struct ssif_part_buffer {};

/*
 * SSIF internal states:
 *   SSIF_READY         0x00 : Ready state
 *   SSIF_START         0x01 : Start smbus transaction
 *   SSIF_SMBUS_CMD     0x02 : Received SMBus command
 *   SSIF_REQ_RECVING   0x03 : Receiving request
 *   SSIF_RES_SENDING   0x04 : Sending response
 *   SSIF_ABORTING      0x05 : Aborting state
 */
enum ssif_state {};

struct ssif_bmc_ctx {};

static inline struct ssif_bmc_ctx *to_ssif_bmc(struct file *file)
{}

static const char *state_to_string(enum ssif_state state)
{}

/* Handle SSIF message that will be sent to user */
static ssize_t ssif_bmc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{}

/* Handle SSIF message that is written by user */
static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t count,
			      loff_t *ppos)
{}

static int ssif_bmc_open(struct inode *inode, struct file *file)
{}

static __poll_t ssif_bmc_poll(struct file *file, poll_table *wait)
{}

static int ssif_bmc_release(struct inode *inode, struct file *file)
{}

/*
 * System calls to device interface for user apps
 */
static const struct file_operations ssif_bmc_fops =;

/* Called with ssif_bmc->lock held. */
static void complete_response(struct ssif_bmc_ctx *ssif_bmc)
{}

static void response_timeout(struct timer_list *t)
{}

/* Called with ssif_bmc->lock held. */
static void handle_request(struct ssif_bmc_ctx *ssif_bmc)
{}

static void calculate_response_part_pec(struct ssif_part_buffer *part)
{}

static void set_singlepart_response_buffer(struct ssif_bmc_ctx *ssif_bmc)
{}

static void set_multipart_response_buffer(struct ssif_bmc_ctx *ssif_bmc)
{}

static bool supported_read_cmd(u8 cmd)
{}

static bool supported_write_cmd(u8 cmd)
{}

/* Process the IPMI response that will be read by master */
static void handle_read_processed(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void handle_write_received(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static bool validate_request_part(struct ssif_bmc_ctx *ssif_bmc)
{}

static void process_request_part(struct ssif_bmc_ctx *ssif_bmc)
{}

static void process_smbus_cmd(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void on_read_requested_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void on_read_processed_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void on_write_requested_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void on_write_received_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

static void on_stop_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
{}

/*
 * Callback function to handle I2C slave events
 */
static int ssif_bmc_cb(struct i2c_client *client, enum i2c_slave_event event, u8 *val)
{}

static int ssif_bmc_probe(struct i2c_client *client)
{}

static void ssif_bmc_remove(struct i2c_client *client)
{}

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

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

static struct i2c_driver ssif_bmc_driver =;

module_i2c_driver();

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