Lines Matching +full:portable +full:- +full:device

5  * SPDX-License-Identifier: Apache-2.0
24 #include <zephyr/device.h>
42 * - BCR[7:6]: Device Role
43 * - 0: I3C Target
44 * - 1: I3C Controller capable
45 * - 2: Reserved
46 * - 3: Reserved
48 * - BCR[5]: Advanced Capabilities
49 * - 0: Does not support optional advanced capabilities.
50 * - 1: Supports optional advanced capabilities which
53 * - BCR[4]: Virtual Target Support
54 * - 0: Is not a virtual target.
55 * - 1: Is a virtual target.
57 * - BCR[3]: Offline Capable
58 * - 0: Will always response to I3C commands.
59 * - 1: Will not always response to I3C commands.
61 * - BCR[2]: IBI Payload
62 * - 0: No data bytes following the accepted IBI.
63 * - 1: One data byte (MDB, Mandatory Data Byte) follows
67 * - BCR[1]: IBI Request Capable
68 * - 0: Not capable
69 * - 1: Capable
71 * - BCR[0]: Max Data Speed Limitation
72 * - 0: No Limitation
73 * - 1: Limitation obtained via GETMXDS CCC.
82 * 0 - No Limitation.
83 * 1 - Limitation obtained via GETMXDS CCC.
93 * 0 - No data bytes following the accepted IBI.
94 * 1 - One data byte (MDB, Mandatory Data Byte) follows the accepted IBI.
102 * 0 - Will always respond to I3C commands.
103 * 1 - Will not always respond to I3C commands.
110 * 0 - Is not a virtual target.
111 * 1 - Is a virtual target.
118 * 0 - Does not support optional advanced capabilities.
119 * 1 - Supports optional advanced capabilities which can be viewed via
124 /** Device Role - I3C Target. */
127 /** Device Role - I3C Controller Capable. */
130 /** Device Role bit shift mask. */
134 * @brief Device Role
136 * Obtain Device Role value from the BCR value obtained via GETBCR.
150 * - LVR[7:5]: I2C device index:
151 * - 0: I2C device has a 50 ns spike filter where
153 * - 1: I2C device does not have a 50 ns spike filter
155 * - 2: I2C device does not have a 50 ns spike filter
157 * - LVR[4]: I2C mode indicator:
158 * - 0: FM+ mode
159 * - 1: FM mode
160 * - LVR[3:0]: Reserved.
185 * @brief I2C Device Index 0.
187 * I2C device has a 50 ns spike filter where it is not affected by high
193 * @brief I2C Device Index 1.
195 * I2C device does not have a 50 ns spike filter but can work with high
201 * @brief I2C Device Index 2.
203 * I2C device does not have a 50 ns spike filter and cannot work with high
208 /** I2C Device Index bitmask. */
212 * @brief I2C Device Index
214 * Obtain I2C Device Index value from the LVR value.
279 /** High Data Rate - Double Data Rate messaging */
282 /** High Data Rate - Ternary Symbol Legacy-inclusive-Bus */
285 /** High Data Rate - Ternary Symbol for Pure Bus */
288 /** High Data Rate - Bulk Transport */
404 * that follows a write, or vice-versa. Some drivers will merge
440 /** I3C HDR-DDR (Double Data Rate) */
443 /** I3C HDR-TSP (Ternary Symbol Pure-bus) */
446 /** I3C HDR-TSL (Ternary Symbol Legacy-inclusive-bus) */
449 /** I3C HDR-BT (Bulk Transport) */
500 /** HDR command code field (7-bit) for HDR-DDR, HDR-TSP and HDR-TSL */
534 * Bit mask of supported HDR modes (0 - 7).
562 * the device driver understands.
596 * @param dev Pointer to controller device driver instance.
603 int (*configure)(const struct device *dev,
611 * @param[in] dev Pointer to controller device driver instance.
618 int (*config_get)(const struct device *dev,
628 * @param dev Pointer to controller device driver instance.
632 int (*recover_bus)(const struct device *dev);
635 * I3C Device Attach
641 * @param dev Pointer to controller device driver instance.
642 * @param target Pointer to target device descriptor.
646 int (*attach_i3c_device)(const struct device *dev,
656 * @param dev Pointer to controller device driver instance.
657 * @param target Pointer to target device descriptor.
662 int (*reattach_i3c_device)(const struct device *dev,
667 * I3C Device Detach
673 * @param dev Pointer to controller device driver instance.
674 * @param target Pointer to target device descriptor.
678 int (*detach_i3c_device)(const struct device *dev,
682 * I2C Device Attach
688 * @param dev Pointer to controller device driver instance.
689 * @param target Pointer to target device descriptor.
693 int (*attach_i2c_device)(const struct device *dev,
697 * I2C Device Detach
703 * @param dev Pointer to controller device driver instance.
704 * @param target Pointer to target device descriptor.
708 int (*detach_i2c_device)(const struct device *dev,
718 * @param dev Pointer to controller device driver instance.
722 int (*do_daa)(const struct device *dev);
731 * @param dev Pointer to controller device driver instance.
736 int (*do_ccc)(const struct device *dev,
744 * @param dev Pointer to controller device driver instance.
745 * @param target Pointer to target device descriptor.
751 int (*i3c_xfers)(const struct device *dev,
757 * Find a registered I3C target device.
761 * This returns the I3C device descriptor of the I3C device
764 * @param dev Pointer to controller device driver instance.
765 * @param id Pointer to I3C device ID.
769 struct i3c_device_desc *(*i3c_device_find)(const struct device *dev,
773 * Raise In-Band Interrupt (IBI).
775 * Target device only API.
779 * @param dev Pointer to controller device driver instance.
784 int (*ibi_raise)(const struct device *dev,
794 * @param dev Pointer to controller device driver instance.
795 * @param target Pointer to target device descriptor.
799 int (*ibi_enable)(const struct device *dev,
809 * @param dev Pointer to controller device driver instance.
810 * @param target Pointer to target device descriptor.
814 int (*ibi_disable)(const struct device *dev,
818 * Register config as target device of a controller.
820 * This tells the controller to act as a target device
823 * Target device only API.
827 * @param dev Pointer to the controller device driver instance.
828 * @param cfg I3C target device configuration
832 int (*target_register)(const struct device *dev,
836 * Unregister config as target device of a controller.
838 * This tells the controller to stop acting as a target device
841 * Target device only API.
845 * @param dev Pointer to the controller device driver instance.
846 * @param cfg I3C target device configuration
850 int (*target_unregister)(const struct device *dev,
858 * Target device only API.
862 * @param dev Pointer to the controller device driver instance.
869 int (*target_tx_write)(const struct device *dev,
878 * @param dev Pointer to the controller device driver instance.
883 void (*iodev_submit)(const struct device *dev,
896 /** Device Provisioned ID */
914 * @brief Structure describing a I3C target device.
916 * Instances of this are passed to the I3C controller device APIs,
918 * - i3c_device_register() to tell the controller of a target device.
919 * - i3c_transfers() to initiate data transfers between controller and
920 * target device.
923 * implements the target device behavior prior to passing the object reference
924 * to I3C controller device APIs. #static_addr can be zero if target device does
932 /** I3C bus to which this target device is attached */
933 const struct device * const bus;
935 /** Device driver instance of the I3C device */
936 const struct device * const dev;
938 /** Device Provisioned ID */
942 * Static address for this target device.
945 * address is used. This means that the target device must
950 * device (as both are to tell target device to use static
958 * This is specified in the device tree property "assigned-address"
967 * Device support for SETAASA
970 * device supports SETAASA.
975 * Dynamic Address for this target device used for communication.
979 * - During Dynamic Address Assignment (during ENTDAA)
980 * - Reset Dynamic Address Assignment (RSTDAA)
981 * - Set All Addresses to Static Addresses (SETAASA)
982 * - Set New Dynamic Address (SETNEWDA)
983 * - Set Dynamic Address from Static Address (SETDASA)
991 * Group address for this target device. Set during:
992 * - Reset Group Address(es) (RSTGRPA)
993 * - Set Group Address (SETGRPA)
1008 * Device Characteristic Register (DCR)
1010 * Describes the type of device. Refer to official documentation
1042 * - Bit[0]: HDR-DDR
1043 * - Bit[1]: HDR-TSP
1044 * - Bit[2]: HDR-TSL
1045 * - Bit[7:3]: Reserved
1051 * - Bit[0]: HDR-DDR
1052 * - Bit[1]: HDR-TSP
1053 * - Bit[2]: HDR-TSL
1054 * - Bit[3]: HDR-BT
1055 * - Bit[7:4]: Reserved
1062 * - Bit[3:0]: I3C 1.x Specification Version
1063 * - Bit[5:4]: Group Address Capabilities
1064 * - Bit[6]: HDR-DDR Write Abort
1065 * - Bit[7]: HDR-DDR Abort CRC
1071 * - Bit[0]: Multi-Lane (ML) Data Transfer Support
1072 * - Bit[1]: Device to Device Transfer (D2DXFER) Support
1073 * - Bit[2]: Device to Device Transfer (D2DXFER) IBI Capable
1074 * - Bit[3]: Defining Byte Support in GETCAPS
1075 * - Bit[4]: Defining Byte Support in GETSTATUS
1076 * - Bit[5]: HDR-BT CRC-32 Support
1077 * - Bit[6]: IBI MDB Support for Pending Read Notification
1078 * - Bit[7]: Reserved
1084 * - Bit[7:0]: Reserved
1098 * In-Band Interrupt (IBI) callback.
1106 * @brief Structure describing a I2C device on I3C bus.
1108 * Instances of this are passed to the I3C controller device APIs,
1110 * () i3c_i2c_device_register() to tell the controller of an I2C device.
1112 * and I2C device.
1115 * implements the device behavior prior to passing the object
1116 * reference to I3C controller device APIs.
1121 /** I3C bus to which this I2C device is attached */
1122 const struct device *bus;
1124 /** Static address for this I2C device. */
1146 * This is a helper struct that can be used by controller device
1147 * driver to aid in device management.
1152 * - Aid in dynamic address assignment.
1153 * - Quick way to find out if a target address is
1154 * a I3C or I2C device.
1176 * This is a helper struct that can be used by controller device
1177 * driver to aid in device management.
1204 * in the device structure.
1207 /** I3C/I2C device list struct. */
1226 * @param bus: the I3C bus device pointer
1227 * @param desc: an I3C device descriptor pointer updated to point to the current slot
1232 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i3c, desc, node)
1237 * @param bus: the I3C bus device pointer
1238 * @param desc: an I2C device descriptor pointer updated to point to the current slot
1243 &((struct i3c_driver_data *)(bus->data))->attached_dev.devices.i2c, desc, node)
1246 * @brief Find a I3C target device descriptor by ID.
1248 * This finds the I3C target device descriptor in the device list
1251 * @param dev_list Pointer to the device list struct.
1252 * @param id Pointer to I3C device ID struct.
1254 * @return Pointer to the I3C target device descriptor, or
1261 * @brief Find a I3C target device descriptor by dynamic address.
1263 * This finds the I3C target device descriptor in the attached
1264 * device list matching the dynamic address (@p addr)
1266 * @param dev Pointer to controller device driver instance.
1269 * @return Pointer to the I3C target device descriptor, or
1272 struct i3c_device_desc *i3c_dev_list_i3c_addr_find(const struct device *dev,
1276 * @brief Find a I2C target device descriptor by address.
1278 * This finds the I2C target device descriptor in the attached
1279 * device list matching the address (@p addr)
1281 * @param dev Pointer to controller device driver instance.
1284 * @return Pointer to the I2C target device descriptor, or
1287 struct i3c_i2c_device_desc *i3c_dev_list_i2c_addr_find(const struct device *dev,
1295 * search through the device list for the matching device
1296 * descriptor. If the device descriptor indicates that there is
1297 * a preferred address (i.e. assigned-address in device tree,
1303 * one of the device in the device list.
1307 * device tree. Or else, the DAA process cannot proceed since
1311 * already assigned to the device
1315 * device (for example, hot-join after device coming back from
1318 * If @p assigned_okay is false, the device cannot have an address
1323 * @param[in] dev_list Pointer to the device list struct.
1324 * @param[in] pid Provisioned ID of device to be assigned address.
1326 * the device list. False otherwise.
1330 * @param[out] target Store the pointer of the device descriptor
1332 * @param[out] addr Address to be assigned to target device.
1335 * @retval -ENODEV if no device matches the PID (@p pid) in
1336 * the device list and @p must_match is true.
1337 * @retval -EINVAL if the device matching PID (@p pid) already
1351 * @param dev Pointer to controller device driver instance.
1357 * @retval -EINVAL If invalid configure parameters.
1358 * @retval -EIO General Input/Output errors.
1359 * @retval -ENOSYS If not implemented.
1361 static inline int i3c_configure(const struct device *dev, in i3c_configure()
1365 (const struct i3c_driver_api *)dev->api; in i3c_configure()
1367 if (api->configure == NULL) { in i3c_configure()
1368 return -ENOSYS; in i3c_configure()
1371 return api->configure(dev, type, config); in i3c_configure()
1382 * @param[in] dev Pointer to controller device driver instance.
1391 * @retval -EIO General Input/Output errors.
1392 * @retval -ENOSYS If not implemented.
1394 static inline int i3c_config_get(const struct device *dev, in i3c_config_get()
1398 (const struct i3c_driver_api *)dev->api; in i3c_config_get()
1400 if (api->config_get == NULL) { in i3c_config_get()
1401 return -ENOSYS; in i3c_config_get()
1404 return api->config_get(dev, type, config); in i3c_config_get()
1413 * @retval -EBUSY If bus recovery fails.
1414 * @retval -EIO General input / output error.
1415 * @retval -ENOSYS Bus recovery is not supported by the controller driver.
1417 static inline int i3c_recover_bus(const struct device *dev) in i3c_recover_bus()
1420 (const struct i3c_driver_api *)dev->api; in i3c_recover_bus()
1422 if (api->recover_bus == NULL) { in i3c_recover_bus()
1423 return -ENOSYS; in i3c_recover_bus()
1426 return api->recover_bus(dev); in i3c_recover_bus()
1430 * @brief Attach an I3C device
1432 * Called to attach a I3C device to the addresses. This is
1442 * @param target Pointer to the target device descriptor
1445 * @retval -EINVAL If address is not available or if the device
1451 * @brief Reattach I3C device
1453 * called after every time an I3C device has its address
1454 * changed. It can be because the device has been powered
1456 * device had a static address and has been assigned a
1467 * @param target Pointer to the target device descriptor
1468 * @param old_dyn_addr The old dynamic address of target device, 0 if
1472 * @retval -EINVAL If address is not available
1477 * @brief Detach I3C Device
1479 * called to remove an I3C device and to free up the address
1490 * @param target Pointer to the target device descriptor
1493 * @retval -EINVAL If device is already detached
1498 * @brief Attach an I2C device
1500 * Called to attach a I2C device to the addresses. This will
1509 * @param target Pointer to the target device descriptor
1512 * @retval -EINVAL If address is not available or if the device
1518 * @brief Detach I2C Device
1520 * called to remove an I2C device and to free up the address
1529 * @param target Pointer to the target device descriptor
1532 * @retval -EINVAL If device is already detached
1547 * @param dev Pointer to the device structure for the controller driver
1551 * @retval -EBUSY Bus is busy.
1552 * @retval -EIO General input / output error.
1553 * @retval -ENODEV If a provisioned ID does not match to any target devices
1554 * in the registered device list.
1555 * @retval -ENOSPC No more free addresses can be assigned to target.
1556 * @retval -ENOSYS Dynamic address assignment is not supported by
1559 static inline int i3c_do_daa(const struct device *dev) in i3c_do_daa()
1562 (const struct i3c_driver_api *)dev->api; in i3c_do_daa()
1564 if (api->do_daa == NULL) { in i3c_do_daa()
1565 return -ENOSYS; in i3c_do_daa()
1568 return api->do_daa(dev); in i3c_do_daa()
1574 * @param dev Pointer to the device structure for the controller driver
1579 * @retval -EBUSY Bus is busy.
1580 * @retval -EIO General Input / output error.
1581 * @retval -EINVAL Invalid valid set in the payload structure.
1582 * @retval -ENOSYS Not implemented.
1584 __syscall int i3c_do_ccc(const struct device *dev,
1587 static inline int z_impl_i3c_do_ccc(const struct device *dev, in z_impl_i3c_do_ccc()
1591 (const struct i3c_driver_api *)dev->api; in z_impl_i3c_do_ccc()
1593 if (api->do_ccc == NULL) { in z_impl_i3c_do_ccc()
1594 return -ENOSYS; in z_impl_i3c_do_ccc()
1597 return api->do_ccc(dev, payload); in z_impl_i3c_do_ccc()
1606 * @brief Perform data transfer from the controller to a I3C target device.
1609 * to a target device synchronously. Use i3c_read()/i3c_write()
1621 * limitations on support for multi-message bus transactions.
1623 * @param target I3C target device descriptor.
1628 * @retval -EBUSY Bus is busy.
1629 * @retval -EIO General input / output error.
1638 (const struct i3c_driver_api *)target->bus->api; in z_impl_i3c_transfer()
1640 return api->i3c_xfers(target->bus, target, msgs, num_msgs); in z_impl_i3c_transfer()
1646 * Find a registered I3C target device.
1650 * This returns the I3C device descriptor of the I3C device
1653 * @param dev Pointer to controller device driver instance.
1654 * @param id Pointer to I3C device ID.
1656 * @return Pointer to I3C device descriptor, or `NULL` if
1657 * no I3C device found matching incoming @p id.
1660 struct i3c_device_desc *i3c_device_find(const struct device *dev, in i3c_device_find()
1664 (const struct i3c_driver_api *)dev->api; in i3c_device_find()
1666 if (api->i3c_device_find == NULL) { in i3c_device_find()
1670 return api->i3c_device_find(dev, id); in i3c_device_find()
1679 * @brief Raise an In-Band Interrupt (IBI).
1681 * This raises an In-Band Interrupt (IBI) to the active controller.
1683 * @param dev Pointer to controller device driver instance.
1687 * @retval -EIO General input / output error.
1689 static inline int i3c_ibi_raise(const struct device *dev, in i3c_ibi_raise()
1693 (const struct i3c_driver_api *)dev->api; in i3c_ibi_raise()
1695 if (api->ibi_raise == NULL) { in i3c_ibi_raise()
1696 return -ENOSYS; in i3c_ibi_raise()
1699 return api->ibi_raise(dev, request); in i3c_ibi_raise()
1703 * @brief Enable IBI of a target device.
1705 * This enables IBI of a target device where the IBI has already been
1708 * @param target I3C target device descriptor.
1711 * @retval -EIO General Input / output error.
1712 * @retval -ENOMEM If these is no more empty entries in
1719 (const struct i3c_driver_api *)target->bus->api; in i3c_ibi_enable()
1721 if (api->ibi_enable == NULL) { in i3c_ibi_enable()
1722 return -ENOSYS; in i3c_ibi_enable()
1725 return api->ibi_enable(target->bus, target); in i3c_ibi_enable()
1729 * @brief Disable IBI of a target device.
1731 * This enables IBI of a target device where the IBI has already been
1734 * @param target I3C target device descriptor.
1737 * @retval -EIO General Input / output error.
1738 * @retval -ENODEV If IBI is not previously enabled for @p target.
1743 (const struct i3c_driver_api *)target->bus->api; in i3c_ibi_disable()
1745 if (api->ibi_disable == NULL) { in i3c_ibi_disable()
1746 return -ENOSYS; in i3c_ibi_disable()
1749 return api->ibi_disable(target->bus, target); in i3c_ibi_disable()
1755 * This reads the BCR from the device descriptor struct to determine
1756 * whether IBI from device has payload.
1758 * Note that BCR must have been obtained from device and
1765 return (target->bcr & I3C_BCR_IBI_PAYLOAD_HAS_DATA_BYTE) in i3c_ibi_has_payload()
1770 * @brief Check if device is IBI capable.
1772 * This reads the BCR from the device descriptor struct to determine
1773 * whether device is capable of IBI.
1775 * Note that BCR must have been obtained from device and
1782 return (target->bcr & I3C_BCR_IBI_REQUEST_CAPABLE) in i3c_device_is_ibi_capable()
1789 * This reads the BCR from the device descriptor struct to determine
1792 * Note that BCR must have been obtained from device and
1799 return I3C_BCR_DEVICE_ROLE(target->bcr) in i3c_device_is_controller_capable()
1811 * @brief Write a set amount of data to an I3C target device.
1815 * @param target I3C target device descriptor.
1820 * @retval -EBUSY Bus is busy.
1821 * @retval -EIO General input / output error.
1838 * @brief Read a set amount of data from an I3C target device.
1842 * @param target I3C target device descriptor.
1847 * @retval -EBUSY Bus is busy.
1848 * @retval -EIO General input / output error.
1865 * @brief Write then read data from an I3C target device.
1868 * it to me" transaction pair through a combined write-then-read bus
1871 * @param target I3C target device descriptor.
1878 * @retval -EBUSY Bus is busy.
1879 * @retval -EIO General input / output error.
1903 * @brief Read multiple bytes from an internal address of an I3C target device.
1906 * I3C target device synchronously.
1910 * @param target I3C target device descriptor,
1916 * @retval -EBUSY Bus is busy.
1917 * @retval -EIO General input / output error.
1930 * @brief Write multiple bytes to an internal address of an I3C target device.
1933 * I3C target device synchronously.
1937 * portable by replacing them with calls to i3c_write() passing a
1940 * @param target I3C target device descriptor.
1946 * @retval -EBUSY Bus is busy.
1947 * @retval -EIO General input / output error.
1972 * @brief Read internal register of an I3C target device.
1974 * This routine reads the value of an 8-bit internal register of an I3C target
1975 * device synchronously.
1977 * @param target I3C target device descriptor.
1982 * @retval -EBUSY Bus is busy.
1983 * @retval -EIO General input / output error.
1994 * @brief Write internal register of an I3C target device.
1996 * This routine writes a value to an 8-bit internal register of an I3C target
1997 * device synchronously.
2002 * @param target I3C target device descriptor.
2007 * @retval -EBUSY Bus is busy.
2008 * @retval -EIO General input / output error.
2019 * @brief Update internal register of an I3C target device.
2021 * This routine updates the value of a set of bits from an 8-bit internal
2022 * register of an I3C target device synchronously.
2027 * @param target I3C target device descriptor.
2033 * @retval -EBUSY Bus is busy.
2034 * @retval -EIO General input / output error.
2078 * @param target I3C target device descriptor.
2088 * @param dev Pointer to controller device driver instance.
2089 * @param i3c_dev_list Pointer to I3C device list.
2092 * @retval -EBUSY Bus is busy.
2093 * @retval -EIO General input / output error.
2094 * @retval -ENODEV If a provisioned ID does not match to any target devices
2095 * in the registered device list.
2096 * @retval -ENOSPC No more free addresses can be assigned to target.
2097 * @retval -ENOSYS Dynamic address assignment is not supported by
2100 int i3c_bus_init(const struct device *dev,
2104 * @brief Get basic information from device and update device descriptor.
2108 * * Device Characteristics Register (GETDCR)
2111 * from the device and update the corresponding fields of the device
2114 * This only updates the field(s) in device descriptor
2117 * @param[in,out] target I3C target device descriptor.
2120 * @retval -EIO General Input/Output error.
2127 * This reads the BCR from the device descriptor struct of all targets
2128 * to determine whether a device is a secondary controller.
2130 * @param dev Pointer to controller device driver instance.
2134 bool i3c_bus_has_sec_controller(const struct device *dev);
2141 * @param dev Pointer to controller device driver instance.
2144 * @retval -ENOMEM No memory to build the payload.
2145 * @retval -EIO General Input/Output error.
2147 int i3c_bus_deftgts(const struct device *dev);
2152 const struct device *bus;
2162 * @param dev Pointer to the device structure for an I3C controller driver.
2166 void i3c_iodev_submit_fallback(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
2169 * @brief Submit request(s) to an I3C device with RTIO
2177 (const struct i3c_iodev_data *)iodev_sqe->sqe.iodev->data; in i3c_iodev_submit()
2178 const struct i3c_driver_api *api = (const struct i3c_driver_api *)data->bus->api; in i3c_iodev_submit()
2180 if (api->iodev_submit == NULL) { in i3c_iodev_submit()
2181 rtio_iodev_sqe_err(iodev_sqe, -ENOSYS); in i3c_iodev_submit()
2184 api->iodev_submit(data->bus, iodev_sqe); in i3c_iodev_submit()
2231 * Include High-Data-Rate (HDR) inline helper functions