linux/drivers/mfd/rave-sp.c

// SPDX-License-Identifier: GPL-2.0+

/*
 * Multifunction core driver for Zodiac Inflight Innovations RAVE
 * Supervisory Processor(SP) MCU that is connected via dedicated UART
 * port
 *
 * Copyright (C) 2017 Zodiac Inflight Innovations
 */

#include <linux/atomic.h>
#include <linux/crc-itu-t.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/mfd/rave-sp.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/sched.h>
#include <linux/serdev.h>
#include <asm/unaligned.h>

/*
 * UART protocol using following entities:
 *  - message to MCU => ACK response
 *  - event from MCU => event ACK
 *
 * Frame structure:
 * <STX> <DATA> <CHECKSUM> <ETX>
 * Where:
 * - STX - is start of transmission character
 * - ETX - end of transmission
 * - DATA - payload
 * - CHECKSUM - checksum calculated on <DATA>
 *
 * If <DATA> or <CHECKSUM> contain one of control characters, then it is
 * escaped using <DLE> control code. Added <DLE> does not participate in
 * checksum calculation.
 */
#define RAVE_SP_STX
#define RAVE_SP_ETX
#define RAVE_SP_DLE

#define RAVE_SP_MAX_DATA_SIZE
#define RAVE_SP_CHECKSUM_8B2C
#define RAVE_SP_CHECKSUM_CCITT
#define RAVE_SP_CHECKSUM_SIZE
/*
 * We don't store STX, ETX and unescaped bytes, so Rx is only
 * DATA + CSUM
 */
#define RAVE_SP_RX_BUFFER_SIZE

#define RAVE_SP_STX_ETX_SIZE
/*
 * For Tx we have to have space for everything, STX, EXT and
 * potentially stuffed DATA + CSUM data + csum
 */
#define RAVE_SP_TX_BUFFER_SIZE

/**
 * enum rave_sp_deframer_state - Possible state for de-framer
 *
 * @RAVE_SP_EXPECT_SOF:		 Scanning input for start-of-frame marker
 * @RAVE_SP_EXPECT_DATA:	 Got start of frame marker, collecting frame
 * @RAVE_SP_EXPECT_ESCAPED_DATA: Got escape character, collecting escaped byte
 */
enum rave_sp_deframer_state {};

/**
 * struct rave_sp_deframer - Device protocol deframer
 *
 * @state:  Current state of the deframer
 * @data:   Buffer used to collect deframed data
 * @length: Number of bytes de-framed so far
 */
struct rave_sp_deframer {};

/**
 * struct rave_sp_reply - Reply as per RAVE device protocol
 *
 * @length:	Expected reply length
 * @data:	Buffer to store reply payload in
 * @code:	Expected reply code
 * @ackid:	Expected reply ACK ID
 * @received:   Successful reply reception completion
 */
struct rave_sp_reply {};

/**
 * struct rave_sp_checksum - Variant specific checksum implementation details
 *
 * @length:	Calculated checksum length
 * @subroutine:	Utilized checksum algorithm implementation
 */
struct rave_sp_checksum {};

struct rave_sp_version {} __packed;

struct rave_sp_status {} __packed;

/**
 * struct rave_sp_variant_cmds - Variant specific command routines
 *
 * @translate:	Generic to variant specific command mapping routine
 * @get_status: Variant specific implementation of CMD_GET_STATUS
 */
struct rave_sp_variant_cmds {};

/**
 * struct rave_sp_variant - RAVE supervisory processor core variant
 *
 * @checksum:	Variant specific checksum implementation
 * @cmd:	Variant specific command pointer table
 *
 */
struct rave_sp_variant {};

/**
 * struct rave_sp - RAVE supervisory processor core
 *
 * @serdev:			Pointer to underlying serdev
 * @deframer:			Stored state of the protocol deframer
 * @ackid:			ACK ID used in last reply sent to the device
 * @bus_lock:			Lock to serialize access to the device
 * @reply_lock:			Lock protecting @reply
 * @reply:			Pointer to memory to store reply payload
 *
 * @variant:			Device variant specific information
 * @event_notifier_list:	Input event notification chain
 *
 * @part_number_firmware:	Firmware version
 * @part_number_bootloader:	Bootloader version
 */
struct rave_sp {};

static bool rave_sp_id_is_event(u8 code)
{}

static void rave_sp_unregister_event_notifier(struct device *dev, void *res)
{}

int devm_rave_sp_register_event_notifier(struct device *dev,
					 struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

static void csum_8b2c(const u8 *buf, size_t size, u8 *crc)
{}

static void csum_ccitt(const u8 *buf, size_t size, u8 *crc)
{}

static void *stuff(unsigned char *dest, const unsigned char *src, size_t n)
{}

static int rave_sp_write(struct rave_sp *sp, const u8 *data, u8 data_size)
{}

static u8 rave_sp_reply_code(u8 command)
{}

int rave_sp_exec(struct rave_sp *sp,
		 void *__data,  size_t data_size,
		 void *reply_data, size_t reply_data_size)
{}
EXPORT_SYMBOL_GPL();

static void rave_sp_receive_event(struct rave_sp *sp,
				  const unsigned char *data, size_t length)
{}

static void rave_sp_receive_reply(struct rave_sp *sp,
				  const unsigned char *data, size_t length)
{}

static void rave_sp_receive_frame(struct rave_sp *sp,
				  const unsigned char *data,
				  size_t length)
{}

static size_t rave_sp_receive_buf(struct serdev_device *serdev,
				  const u8 *buf, size_t size)
{}

static int rave_sp_rdu1_cmd_translate(enum rave_sp_command command)
{}

static int rave_sp_rdu2_cmd_translate(enum rave_sp_command command)
{}

static int rave_sp_default_cmd_translate(enum rave_sp_command command)
{}

static const char *devm_rave_sp_version(struct device *dev,
					struct rave_sp_version *version)
{}

static int rave_sp_rdu1_get_status(struct rave_sp *sp,
				   struct rave_sp_status *status)
{}

static int rave_sp_emulated_get_status(struct rave_sp *sp,
				       struct rave_sp_status *status)
{}

static int rave_sp_get_status(struct rave_sp *sp)
{}

static const struct rave_sp_checksum rave_sp_checksum_8b2c =;

static const struct rave_sp_checksum rave_sp_checksum_ccitt =;

static const struct rave_sp_variant rave_sp_legacy =;

static const struct rave_sp_variant rave_sp_rdu1 =;

static const struct rave_sp_variant rave_sp_rdu2 =;

static const struct of_device_id rave_sp_dt_ids[] =;

static const struct serdev_device_ops rave_sp_serdev_device_ops =;

static int rave_sp_probe(struct serdev_device *serdev)
{}

MODULE_DEVICE_TABLE(of, rave_sp_dt_ids);

static struct serdev_device_driver rave_sp_drv =;
module_serdev_device_driver();

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