Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Greybus manifest definition
0004  *
0005  * See "Greybus Application Protocol" document (version 0.1) for
0006  * details on these values and structures.
0007  *
0008  * Copyright 2014-2015 Google Inc.
0009  * Copyright 2014-2015 Linaro Ltd.
0010  *
0011  * Released under the GPLv2 and BSD licenses.
0012  */
0013 
0014 #ifndef __GREYBUS_MANIFEST_H
0015 #define __GREYBUS_MANIFEST_H
0016 
0017 #include <linux/bits.h>
0018 #include <linux/types.h>
0019 
0020 enum greybus_descriptor_type {
0021     GREYBUS_TYPE_INVALID        = 0x00,
0022     GREYBUS_TYPE_INTERFACE      = 0x01,
0023     GREYBUS_TYPE_STRING     = 0x02,
0024     GREYBUS_TYPE_BUNDLE     = 0x03,
0025     GREYBUS_TYPE_CPORT      = 0x04,
0026 };
0027 
0028 enum greybus_protocol {
0029     GREYBUS_PROTOCOL_CONTROL    = 0x00,
0030     /* 0x01 is unused */
0031     GREYBUS_PROTOCOL_GPIO       = 0x02,
0032     GREYBUS_PROTOCOL_I2C        = 0x03,
0033     GREYBUS_PROTOCOL_UART       = 0x04,
0034     GREYBUS_PROTOCOL_HID        = 0x05,
0035     GREYBUS_PROTOCOL_USB        = 0x06,
0036     GREYBUS_PROTOCOL_SDIO       = 0x07,
0037     GREYBUS_PROTOCOL_POWER_SUPPLY   = 0x08,
0038     GREYBUS_PROTOCOL_PWM        = 0x09,
0039     /* 0x0a is unused */
0040     GREYBUS_PROTOCOL_SPI        = 0x0b,
0041     GREYBUS_PROTOCOL_DISPLAY    = 0x0c,
0042     GREYBUS_PROTOCOL_CAMERA_MGMT    = 0x0d,
0043     GREYBUS_PROTOCOL_SENSOR     = 0x0e,
0044     GREYBUS_PROTOCOL_LIGHTS     = 0x0f,
0045     GREYBUS_PROTOCOL_VIBRATOR   = 0x10,
0046     GREYBUS_PROTOCOL_LOOPBACK   = 0x11,
0047     GREYBUS_PROTOCOL_AUDIO_MGMT = 0x12,
0048     GREYBUS_PROTOCOL_AUDIO_DATA = 0x13,
0049     GREYBUS_PROTOCOL_SVC            = 0x14,
0050     GREYBUS_PROTOCOL_BOOTROM    = 0x15,
0051     GREYBUS_PROTOCOL_CAMERA_DATA    = 0x16,
0052     GREYBUS_PROTOCOL_FW_DOWNLOAD    = 0x17,
0053     GREYBUS_PROTOCOL_FW_MANAGEMENT  = 0x18,
0054     GREYBUS_PROTOCOL_AUTHENTICATION = 0x19,
0055     GREYBUS_PROTOCOL_LOG        = 0x1a,
0056         /* ... */
0057     GREYBUS_PROTOCOL_RAW        = 0xfe,
0058     GREYBUS_PROTOCOL_VENDOR     = 0xff,
0059 };
0060 
0061 enum greybus_class_type {
0062     GREYBUS_CLASS_CONTROL       = 0x00,
0063     /* 0x01 is unused */
0064     /* 0x02 is unused */
0065     /* 0x03 is unused */
0066     /* 0x04 is unused */
0067     GREYBUS_CLASS_HID       = 0x05,
0068     /* 0x06 is unused */
0069     /* 0x07 is unused */
0070     GREYBUS_CLASS_POWER_SUPPLY  = 0x08,
0071     /* 0x09 is unused */
0072     GREYBUS_CLASS_BRIDGED_PHY   = 0x0a,
0073     /* 0x0b is unused */
0074     GREYBUS_CLASS_DISPLAY       = 0x0c,
0075     GREYBUS_CLASS_CAMERA        = 0x0d,
0076     GREYBUS_CLASS_SENSOR        = 0x0e,
0077     GREYBUS_CLASS_LIGHTS        = 0x0f,
0078     GREYBUS_CLASS_VIBRATOR      = 0x10,
0079     GREYBUS_CLASS_LOOPBACK      = 0x11,
0080     GREYBUS_CLASS_AUDIO     = 0x12,
0081     /* 0x13 is unused */
0082     /* 0x14 is unused */
0083     GREYBUS_CLASS_BOOTROM       = 0x15,
0084     GREYBUS_CLASS_FW_MANAGEMENT = 0x16,
0085     GREYBUS_CLASS_LOG       = 0x17,
0086         /* ... */
0087     GREYBUS_CLASS_RAW       = 0xfe,
0088     GREYBUS_CLASS_VENDOR        = 0xff,
0089 };
0090 
0091 enum {
0092     GREYBUS_INTERFACE_FEATURE_TIMESYNC = BIT(0),
0093 };
0094 
0095 /*
0096  * The string in a string descriptor is not NUL-terminated.  The
0097  * size of the descriptor will be rounded up to a multiple of 4
0098  * bytes, by padding the string with 0x00 bytes if necessary.
0099  */
0100 struct greybus_descriptor_string {
0101     __u8    length;
0102     __u8    id;
0103     __u8    string[];
0104 } __packed;
0105 
0106 /*
0107  * An interface descriptor describes information about an interface as a whole,
0108  * *not* the functions within it.
0109  */
0110 struct greybus_descriptor_interface {
0111     __u8    vendor_stringid;
0112     __u8    product_stringid;
0113     __u8    features;
0114     __u8    pad;
0115 } __packed;
0116 
0117 /*
0118  * An bundle descriptor defines an identification number and a class for
0119  * each bundle.
0120  *
0121  * @id: Uniquely identifies a bundle within a interface, its sole purpose is to
0122  * allow CPort descriptors to specify which bundle they are associated with.
0123  * The first bundle will have id 0, second will have 1 and so on.
0124  *
0125  * The largest CPort id associated with an bundle (defined by a
0126  * CPort descriptor in the manifest) is used to determine how to
0127  * encode the device id and module number in UniPro packets
0128  * that use the bundle.
0129  *
0130  * @class: It is used by kernel to know the functionality provided by the
0131  * bundle and will be matched against drivers functinality while probing greybus
0132  * driver. It should contain one of the values defined in
0133  * 'enum greybus_class_type'.
0134  *
0135  */
0136 struct greybus_descriptor_bundle {
0137     __u8    id; /* interface-relative id (0..) */
0138     __u8    class;
0139     __u8    pad[2];
0140 } __packed;
0141 
0142 /*
0143  * A CPort descriptor indicates the id of the bundle within the
0144  * module it's associated with, along with the CPort id used to
0145  * address the CPort.  The protocol id defines the format of messages
0146  * exchanged using the CPort.
0147  */
0148 struct greybus_descriptor_cport {
0149     __le16  id;
0150     __u8    bundle;
0151     __u8    protocol_id;    /* enum greybus_protocol */
0152 } __packed;
0153 
0154 struct greybus_descriptor_header {
0155     __le16  size;
0156     __u8    type;       /* enum greybus_descriptor_type */
0157     __u8    pad;
0158 } __packed;
0159 
0160 struct greybus_descriptor {
0161     struct greybus_descriptor_header        header;
0162     union {
0163         struct greybus_descriptor_string    string;
0164         struct greybus_descriptor_interface interface;
0165         struct greybus_descriptor_bundle    bundle;
0166         struct greybus_descriptor_cport     cport;
0167     };
0168 } __packed;
0169 
0170 struct greybus_manifest_header {
0171     __le16  size;
0172     __u8    version_major;
0173     __u8    version_minor;
0174 } __packed;
0175 
0176 struct greybus_manifest {
0177     struct greybus_manifest_header      header;
0178     struct greybus_descriptor       descriptors[];
0179 } __packed;
0180 
0181 #endif /* __GREYBUS_MANIFEST_H */