auto
  "   'ˆl–Ým_J*j"Tâ€rà_¸Ø”Å£Ïƒh¹¿Ì      'auto
     )ˆÐÏ„p<Î¿Ì ?÷     )/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * Copyright(c) 2014 - 2015 Google Inc. All rights reserved.
 * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved.
 */

#ifndef __GREYBUS_PROTOCOLS_H
#define __GREYBUS_PROTOCOLS_H

#include <linux/types.h>

/* Fixed IDs for control/svc protocols */

/* SVC switch-port device ids */
#define GB_SVC_DEVICE_ID_SVC			0
#define GB_SVC_DEVICE_ID_AP			1
#define GB_SVC_DEVICE_ID_MIN			2
#define GB_SVC_DEVICE_ID_MAX			31

#define GB_SVC_CPORT_ID				0
#define GB_CONTROL_BUNDLE_ID			0
#define GB_CONTROL_CPORT_ID			0


/*
 * All operation messages (both requests and responses) begin with
 * a header that encodes the size of the message (header included).
 * This header also contains a unique identifier, that associates a
 * response message with its operation.  The header contains an
 * operation type field, whose interpretation is dependent on what
 * type of protocol is used over the connection.  The high bit
 * (0x80) of the operation type field is used to indicate whether
 * the message is a request (clear) or a response (set).
 *
 * Response messages include an additional result byte, which
 * communicates the result of the corresponding request.  A zero
 * result value means the operation completed successfully.  Any
 * other value indicates an error; in this case, the payload of the
 * response message (if any) is ignored.  The result byte must be
 * zero in the header for a request message.
 *
 * The wire format for all numeric fields in the header is little
 * endian.  Any operation-specific data begins immediately after the
 * header.
 */
struct gb_operation_msg_hdr {
	__le16	size;		/* Size in bytes of header + payload */
	__le16	operation_id;	/* Operation unique id */
	__u8	type;		/* E.g GB_I2C_TYPE_* or GB_GPIO_TYPE_* */
	__u8	result;		/* Result of request (in responses only) */
	__u8	pad[2];		/* must be zero (ignore when read) */
} __packed;


/* Generic request types */
#define GB_REQUEST_TYPE_CPORT_SHUTDOWN		0x00
#define GB_REQUEST_TYPE_INVALID			0x7f

struct gb_cport_shutdown_request {
	__u8 phase;
} __packed;


/* Control Protocol */

/* Greybus control request types */
#define GB_CONTROL_TYPE_VERSION			0x01
#define GB_CONTROL_TYPE_PROBE_AP		0x02
#define GB_CONTROL_TYPE_GET_MANIFEST_SIZE	0x03
#define GB_CONTROL_TYPE_GET_MANIFEST		0x04
#define GB_CONTROL_TYPE_CONNECTED		0x05
#define GB_CONTROL_TYPE_DISCONNECTED		0x06
#define GB_CONTROL_TYPE_TIMESYNC_ENABLE		0x07
#define GB_CONTROL_TYPE_TIMESYNC_DISABLE	0x08
#define GB_CONTROL_TYPE_TIMESYNC_AUTHORITATIVE	0x09
/*	Unused					0x0a */
#define GB_CONTROL_TYPE_BUNDLE_VERSION		0x0b
#define GB_CONTROL_TYPE_DISCONNECTING		0x0c
#define GB_CONTROL_TYPE_TIMESYNC_GET_LAST_EVENT	0x0d
#define GB_CONTROL_TYPE_MODE_SWITCH		0x0e
#define GB_CONTROL_TYPE_BUNDLE_SUSPEND		0x0f
#define GB_CONTROL_TYPE_BUNDLE_RESUME		0x10
#define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE	0x11
#define GB_CONTROL_TYPE_BUNDLE_ACTIVATE		0x12
#define GB_CONTROL_TYPE_INTF_SUSPEND_PREPARE		0x13
#define GB_CONTROL_TYPE_INTF_DEACTIVATE_PREPARE	0x14
#define GB_CONTROL_TYPE_INTF_HIBERNATE_ABORT	0x15

struct gb_control_version_request {
	__u8	major;
	__u8	minor;
} __packed;

struct gb_control_version_response {
	__u8	major;
	__u8	minor;
} __packed;

struct gb_control_bundle_version_request {
	__u8	bundle_id;
} __packed;

struct gb_control_bundle_version_response {
	__u8	major;
	__u8	minor;
} __packed;

/* Control protocol manifest get size request has no payload*/
struct gb_control_get_manifest_size_response {
	__le16			size;
} __packed;

/* Control protocol manifest get request has no payload */
struct gb_control_get_manifest_response {
	__u8			data[0];
} __packed;

/* Control protocol [dis]connected request */
struct gb_control_connected_request {
	__le16			cport_id;
} __packed;

struct gb_control_disconnecting_request {
	__le16			cport_id;
} __packed;
/* disconnecting response has no payload */

struct gb_control_disconnected_request {
	__le16			cport_id;
} __packed;
/