1 /* 2 * Remote I3C Device 3 * 4 * Copyright (c) 2023 Google LLC 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the 8 * Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * for more details. 15 */ 16 17 /* 18 * The remote I3C protocol is as follows: 19 * On an I3C private and CCC TX (controller -> target) 20 * - 1-byte opcode 21 * - 4-byte number of bytes in the packet as a LE uint32 22 * - n-byte payload 23 * 24 * On an I3C private and CCC RX (target -> controller) 25 * Controller to target: 26 * - 1-byte opcode 27 * - 4-byte number of bytes to read as a LE uint32 28 * Remote target response: 29 * - 4-byte number of bytes in the packet as a LE uint32 30 * - n-byte payload 31 * 32 * IBI (target -> controller, initiated by target) 33 * - 1-byte opcode 34 * - 1-byte IBI address 35 * - 1-byte RnW boolean 36 * - 4-byte length of IBI payload from target as a LE uint32 (can be 0) 37 * - n-byte IBI payload 38 */ 39 40 #ifndef REMOTE_I3C_H_ 41 #define REMOTE_I3C_H_ 42 43 #define TYPE_REMOTE_I3C "remote-i3c" 44 #define REMOTE_I3C(obj) OBJECT_CHECK(RemoteI3C, (obj), TYPE_REMOTE_I3C) 45 46 /* 1-byte IBI addr, 1-byte is recv, 4-byte data len. */ 47 #define REMOTE_I3C_IBI_HDR_LEN 6 48 49 /* Stored in a uint8_t */ 50 typedef enum { 51 /* Sent from us to remote target. */ 52 REMOTE_I3C_START_RECV = 1, 53 REMOTE_I3C_START_SEND = 2, 54 REMOTE_I3C_STOP = 3, 55 REMOTE_I3C_NACK = 4, 56 REMOTE_I3C_RECV = 5, 57 REMOTE_I3C_SEND = 6, 58 REMOTE_I3C_HANDLE_CCC_WRITE = 7, 59 REMOTE_I3C_HANDLE_CCC_READ = 8, 60 REMOTE_I3C_IBI = 9, 61 /* Sent from remote target to us. */ 62 REMOTE_I3C_IBI_ACK = 0xc0, 63 REMOTE_I3C_IBI_NACK = 0xc1, 64 REMOTE_I3C_IBI_DATA_NACK = 0xc2, 65 } RemoteI3CCommand; 66 67 typedef enum { 68 REMOTE_I3C_RX_ACK = 0, 69 REMOTE_I3C_RX_NACK = 1, 70 } RemoteI3CRXEvent; 71 72 #endif 73