linux/drivers/greybus/gb-beagleplay.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Beagleplay Linux Driver for Greybus
 *
 * Copyright (c) 2023 Ayush Singh <[email protected]>
 * Copyright (c) 2023 BeagleBoard.org Foundation
 */

#include <linux/gfp.h>
#include <linux/greybus.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/printk.h>
#include <linux/serdev.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/greybus/hd.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/crc-ccitt.h>
#include <linux/circ_buf.h>
#include <linux/types.h>
#include <linux/workqueue.h>

#define RX_HDLC_PAYLOAD
#define CRC_LEN
#define MAX_RX_HDLC
#define TX_CIRC_BUF_SIZE

#define ADDRESS_GREYBUS
#define ADDRESS_DBG
#define ADDRESS_CONTROL

#define HDLC_FRAME
#define HDLC_ESC
#define HDLC_XOR

#define CONTROL_SVC_START
#define CONTROL_SVC_STOP

/* The maximum number of CPorts supported by Greybus Host Device */
#define GB_MAX_CPORTS

/**
 * struct gb_beagleplay - BeaglePlay Greybus driver
 *
 * @sd: underlying serdev device
 *
 * @gb_hd: greybus host device
 *
 * @tx_work: hdlc transmit work
 * @tx_producer_lock: hdlc transmit data producer lock. acquired when appending data to buffer.
 * @tx_consumer_lock: hdlc transmit data consumer lock. acquired when sending data over uart.
 * @tx_circ_buf: hdlc transmit circular buffer.
 * @tx_crc: hdlc transmit crc-ccitt fcs
 *
 * @rx_buffer_len: length of receive buffer filled.
 * @rx_buffer: hdlc frame receive buffer
 * @rx_in_esc: hdlc rx flag to indicate ESC frame
 */
struct gb_beagleplay {};

/**
 * struct hdlc_payload - Structure to represent part of HDCL frame payload data.
 *
 * @len: buffer length in bytes
 * @buf: payload buffer
 */
struct hdlc_payload {};

/**
 * struct hdlc_greybus_frame - Structure to represent greybus HDLC frame payload
 *
 * @cport: cport id
 * @hdr: greybus operation header
 * @payload: greybus message payload
 *
 * The HDLC payload sent over UART for greybus address has cport preappended to greybus message
 */
struct hdlc_greybus_frame {} __packed;

static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len)
{}

static void hdlc_rx_dbg_frame(const struct gb_beagleplay *bg, const char *buf, u16 len)
{}

/**
 * hdlc_write() - Consume HDLC Buffer.
 * @bg: beagleplay greybus driver
 *
 * Assumes that consumer lock has been acquired.
 */
static void hdlc_write(struct gb_beagleplay *bg)
{}

/**
 * hdlc_append() - Queue HDLC data for sending.
 * @bg: beagleplay greybus driver
 * @value: hdlc byte to transmit
 *
 * Assumes that producer lock as been acquired.
 */
static void hdlc_append(struct gb_beagleplay *bg, u8 value)
{}

static void hdlc_append_escaped(struct gb_beagleplay *bg, u8 value)
{}

static void hdlc_append_tx_frame(struct gb_beagleplay *bg)
{}

static void hdlc_append_tx_u8(struct gb_beagleplay *bg, u8 value)
{}

static void hdlc_append_tx_buf(struct gb_beagleplay *bg, const u8 *buf, u16 len)
{}

static void hdlc_append_tx_crc(struct gb_beagleplay *bg)
{}

static void hdlc_transmit(struct work_struct *work)
{}

static void hdlc_tx_frames(struct gb_beagleplay *bg, u8 address, u8 control,
			   const struct hdlc_payload payloads[], size_t count)
{}

static void hdlc_tx_s_frame_ack(struct gb_beagleplay *bg)
{}

static void hdlc_rx_frame(struct gb_beagleplay *bg)
{}

static size_t hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count)
{}

static int hdlc_init(struct gb_beagleplay *bg)
{}

static void hdlc_deinit(struct gb_beagleplay *bg)
{}

static size_t gb_tty_receive(struct serdev_device *sd, const u8 *data,
			     size_t count)
{}

static void gb_tty_wakeup(struct serdev_device *serdev)
{}

static struct serdev_device_ops gb_beagleplay_ops =;

/**
 * gb_message_send() - Send greybus message using HDLC over UART
 *
 * @hd: pointer to greybus host device
 * @cport: AP cport where message originates
 * @msg: greybus message to send
 * @mask: gfp mask
 *
 * Greybus HDLC frame has the following payload:
 * 1. le16 cport
 * 2. gb_operation_msg_hdr msg_header
 * 3. u8 *msg_payload
 */
static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_message *msg, gfp_t mask)
{}

static void gb_message_cancel(struct gb_message *message)
{}

static struct gb_hd_driver gb_hdlc_driver =;

static void gb_beagleplay_start_svc(struct gb_beagleplay *bg)
{}

static void gb_beagleplay_stop_svc(struct gb_beagleplay *bg)
{}

static void gb_greybus_deinit(struct gb_beagleplay *bg)
{}

static int gb_greybus_init(struct gb_beagleplay *bg)
{}

static void gb_serdev_deinit(struct gb_beagleplay *bg)
{}

static int gb_serdev_init(struct gb_beagleplay *bg)
{}

static int gb_beagleplay_probe(struct serdev_device *serdev)
{}

static void gb_beagleplay_remove(struct serdev_device *serdev)
{}

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

static struct serdev_device_driver gb_beagleplay_driver =;

module_serdev_device_driver();

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