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