/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2018 Cadence Design Systems Inc. * * Author: Boris Brezillon <[email protected]> */ #ifndef I3C_CCC_H #define I3C_CCC_H #include <linux/bitops.h> #include <linux/i3c/device.h> /* I3C CCC (Common Command Codes) related definitions */ #define I3C_CCC_DIRECT … #define I3C_CCC_ID(id, broadcast) … /* Commands valid in both broadcast and unicast modes */ #define I3C_CCC_ENEC(broadcast) … #define I3C_CCC_DISEC(broadcast) … #define I3C_CCC_ENTAS(as, broadcast) … #define I3C_CCC_RSTDAA(broadcast) … #define I3C_CCC_SETMWL(broadcast) … #define I3C_CCC_SETMRL(broadcast) … #define I3C_CCC_SETXTIME(broadcast) … #define I3C_CCC_VENDOR(id, broadcast) … /* Broadcast-only commands */ #define I3C_CCC_ENTDAA … #define I3C_CCC_DEFSLVS … #define I3C_CCC_ENTTM … #define I3C_CCC_ENTHDR(x) … /* Unicast-only commands */ #define I3C_CCC_SETDASA … #define I3C_CCC_SETNEWDA … #define I3C_CCC_GETMWL … #define I3C_CCC_GETMRL … #define I3C_CCC_GETPID … #define I3C_CCC_GETBCR … #define I3C_CCC_GETDCR … #define I3C_CCC_GETSTATUS … #define I3C_CCC_GETACCMST … #define I3C_CCC_SETBRGTGT … #define I3C_CCC_GETMXDS … #define I3C_CCC_GETHDRCAP … #define I3C_CCC_GETXTIME … #define I3C_CCC_EVENT_SIR … #define I3C_CCC_EVENT_MR … #define I3C_CCC_EVENT_HJ … /** * struct i3c_ccc_events - payload passed to ENEC/DISEC CCC * * @events: bitmask of I3C_CCC_EVENT_xxx events. * * Depending on the CCC command, the specific events coming from all devices * (broadcast version) or a specific device (unicast version) will be * enabled (ENEC) or disabled (DISEC). */ struct i3c_ccc_events { … }; /** * struct i3c_ccc_mwl - payload passed to SETMWL/GETMWL CCC * * @len: maximum write length in bytes * * The maximum write length is only applicable to SDR private messages or * extended Write CCCs (like SETXTIME). */ struct i3c_ccc_mwl { … }; /** * struct i3c_ccc_mrl - payload passed to SETMRL/GETMRL CCC * * @len: maximum read length in bytes * @ibi_len: maximum IBI payload length * * The maximum read length is only applicable to SDR private messages or * extended Read CCCs (like GETXTIME). * The IBI length is only valid if the I3C slave is IBI capable * (%I3C_BCR_IBI_REQ_CAP is set). */ struct i3c_ccc_mrl { … } __packed; /** * struct i3c_ccc_dev_desc - I3C/I2C device descriptor used for DEFSLVS * * @dyn_addr: dynamic address assigned to the I3C slave or 0 if the entry is * describing an I2C slave. * @dcr: DCR value (not applicable to entries describing I2C devices) * @lvr: LVR value (not applicable to entries describing I3C devices) * @bcr: BCR value or 0 if this entry is describing an I2C slave * @static_addr: static address or 0 if the device does not have a static * address * * The DEFSLVS command should be passed an array of i3c_ccc_dev_desc * descriptors (one entry per I3C/I2C dev controlled by the master). */ struct i3c_ccc_dev_desc { … }; /** * struct i3c_ccc_defslvs - payload passed to DEFSLVS CCC * * @count: number of dev descriptors * @master: descriptor describing the current master * @slaves: array of descriptors describing slaves controlled by the * current master * * Information passed to the broadcast DEFSLVS to propagate device * information to all masters currently acting as slaves on the bus. * This is only meaningful if you have more than one master. */ struct i3c_ccc_defslvs { … } __packed; /** * enum i3c_ccc_test_mode - enum listing all available test modes * * @I3C_CCC_EXIT_TEST_MODE: exit test mode * @I3C_CCC_VENDOR_TEST_MODE: enter vendor test mode */ enum i3c_ccc_test_mode { … }; /** * struct i3c_ccc_enttm - payload passed to ENTTM CCC * * @mode: one of the &enum i3c_ccc_test_mode modes * * Information passed to the ENTTM CCC to instruct an I3C device to enter a * specific test mode. */ struct i3c_ccc_enttm { … }; /** * struct i3c_ccc_setda - payload passed to SETNEWDA and SETDASA CCCs * * @addr: dynamic address to assign to an I3C device * * Information passed to the SETNEWDA and SETDASA CCCs to assign/change the * dynamic address of an I3C device. */ struct i3c_ccc_setda { … }; /** * struct i3c_ccc_getpid - payload passed to GETPID CCC * * @pid: 48 bits PID in big endian */ struct i3c_ccc_getpid { … }; /** * struct i3c_ccc_getbcr - payload passed to GETBCR CCC * * @bcr: BCR (Bus Characteristic Register) value */ struct i3c_ccc_getbcr { … }; /** * struct i3c_ccc_getdcr - payload passed to GETDCR CCC * * @dcr: DCR (Device Characteristic Register) value */ struct i3c_ccc_getdcr { … }; #define I3C_CCC_STATUS_PENDING_INT(status) … #define I3C_CCC_STATUS_PROTOCOL_ERROR … #define I3C_CCC_STATUS_ACTIVITY_MODE(status) … /** * struct i3c_ccc_getstatus - payload passed to GETSTATUS CCC * * @status: status of the I3C slave (see I3C_CCC_STATUS_xxx macros for more * information). */ struct i3c_ccc_getstatus { … }; /** * struct i3c_ccc_getaccmst - payload passed to GETACCMST CCC * * @newmaster: address of the master taking bus ownership */ struct i3c_ccc_getaccmst { … }; /** * struct i3c_ccc_bridged_slave_desc - bridged slave descriptor * * @addr: dynamic address of the bridged device * @id: ID of the slave device behind the bridge */ struct i3c_ccc_bridged_slave_desc { … } __packed; /** * struct i3c_ccc_setbrgtgt - payload passed to SETBRGTGT CCC * * @count: number of bridged slaves * @bslaves: bridged slave descriptors */ struct i3c_ccc_setbrgtgt { … } __packed; /** * enum i3c_sdr_max_data_rate - max data rate values for private SDR transfers */ enum i3c_sdr_max_data_rate { … }; /** * enum i3c_tsco - clock to data turn-around */ enum i3c_tsco { … }; #define I3C_CCC_MAX_SDR_FSCL_MASK … #define I3C_CCC_MAX_SDR_FSCL(x) … /** * struct i3c_ccc_getmxds - payload passed to GETMXDS CCC * * @maxwr: write limitations * @maxrd: read limitations * @maxrdturn: maximum read turn-around expressed micro-seconds and * little-endian formatted */ struct i3c_ccc_getmxds { … } __packed; #define I3C_CCC_HDR_MODE(mode) … /** * struct i3c_ccc_gethdrcap - payload passed to GETHDRCAP CCC * * @modes: bitmap of supported HDR modes */ struct i3c_ccc_gethdrcap { … } __packed; /** * enum i3c_ccc_setxtime_subcmd - SETXTIME sub-commands */ enum i3c_ccc_setxtime_subcmd { … }; /** * struct i3c_ccc_setxtime - payload passed to SETXTIME CCC * * @subcmd: one of the sub-commands ddefined in &enum i3c_ccc_setxtime_subcmd * @data: sub-command payload. Amount of data is determined by * &i3c_ccc_setxtime->subcmd */ struct i3c_ccc_setxtime { … } __packed; #define I3C_CCC_GETXTIME_SYNC_MODE … #define I3C_CCC_GETXTIME_ASYNC_MODE(x) … #define I3C_CCC_GETXTIME_OVERFLOW … /** * struct i3c_ccc_getxtime - payload retrieved from GETXTIME CCC * * @supported_modes: bitmap describing supported XTIME modes * @state: current status (enabled mode and overflow status) * @frequency: slave's internal oscillator frequency in 500KHz steps * @inaccuracy: slave's internal oscillator inaccuracy in 0.1% steps */ struct i3c_ccc_getxtime { … } __packed; /** * struct i3c_ccc_cmd_payload - CCC payload * * @len: payload length * @data: payload data. This buffer must be DMA-able */ struct i3c_ccc_cmd_payload { … }; /** * struct i3c_ccc_cmd_dest - CCC command destination * * @addr: can be an I3C device address or the broadcast address if this is a * broadcast CCC * @payload: payload to be sent to this device or broadcasted */ struct i3c_ccc_cmd_dest { … }; /** * struct i3c_ccc_cmd - CCC command * * @rnw: true if the CCC should retrieve data from the device. Only valid for * unicast commands * @id: CCC command id * @ndests: number of destinations. Should always be one for broadcast commands * @dests: array of destinations and associated payload for this CCC. Most of * the time, only one destination is provided * @err: I3C error code */ struct i3c_ccc_cmd { … }; #endif /* I3C_CCC_H */