xref: /linux/drivers/i3c/master/mipi-i3c-hci/ibi.h (revision 24168c5e6dfbdd5b414f048f47f75d64533296ca)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright (c) 2020, MIPI Alliance, Inc.
4  *
5  * Author: Nicolas Pitre <npitre@baylibre.com>
6  *
7  * Common IBI related stuff
8  */
9 
10 #ifndef IBI_H
11 #define IBI_H
12 
13 /*
14  * IBI Status Descriptor bits
15  */
16 #define IBI_STS				BIT(31)
17 #define IBI_ERROR			BIT(30)
18 #define IBI_STATUS_TYPE			BIT(29)
19 #define IBI_HW_CONTEXT			GENMASK(28, 26)
20 #define IBI_TS				BIT(25)
21 #define IBI_LAST_STATUS			BIT(24)
22 #define IBI_CHUNKS			GENMASK(23, 16)
23 #define IBI_ID				GENMASK(15, 8)
24 #define IBI_TARGET_ADDR			GENMASK(15, 9)
25 #define IBI_TARGET_RNW			BIT(8)
26 #define IBI_DATA_LENGTH			GENMASK(7, 0)
27 
28 /*  handy helpers */
29 static inline struct i3c_dev_desc *
30 i3c_hci_addr_to_dev(struct i3c_hci *hci, unsigned int addr)
31 {
32 	struct i3c_bus *bus = i3c_master_get_bus(&hci->master);
33 	struct i3c_dev_desc *dev;
34 
35 	i3c_bus_for_each_i3cdev(bus, dev) {
36 		if (dev->info.dyn_addr == addr)
37 			return dev;
38 	}
39 	return NULL;
40 }
41 
42 #endif
43