# Enable I2C bus in TrustZone Source: [https://docs.qualcomm.com/doc/80-88500-1/topic/50_Enable_I2C_bus_in_TrustZone.html](https://docs.qualcomm.com/doc/80-88500-1/topic/50_Enable_I2C_bus_in_TrustZone.html) ## About this task ## Procedure 1. Grant the I^2^C access to the trusted application by adding the I^2^C access permission in the metadata section within the SCON script files. md = { 'appName': 'upostui', #both 32 bit and 64 bit use the same name in metadata.c 'privileges': ['default', 'I2C', 'SecureDisplay', ], 'stackSize': stacksize, 'heapSize': 0x106000, } Copy to clipboard Note: If this step is not completed, the I^2^C access initialized by the trusted application gets rejected before this access requirement is passed into the I^2^C driver layer, and the following error message is displayed: `qsee_i2c_open FAILED with retval = 0xffffffff` 2. Choose the I^2^C bus instance from the following options available in the qsee\_i2c.h file: typedef enum { QSEE_I2CPD_DEVICE_1, QSEE_I2CPD_DEVICE_2, QSEE_I2CPD_DEVICE_3, QSEE_I2CPD_DEVICE_4, ............... QSEE_I2CPD_DEVICE_14, QSEE_I2CPD_DEVICE_15, QSEE_I2CPD_DEVICE_16, QSEE_I2CPD_DEVICE_17, QSEE_I2CPD_DEVICE_18, QSEE_I2CPD_DEVICE_19, QSEE_I2CPD_DEVICE_20, QSEE_I2CPD_DEVICE_LIMIT /**< Used to check the bounds of this enumeration. */ } qsee_i2cpd_device_id_t;Copy to clipboard Note: Do not choose the I^2^C bus instance from the tzbsp\_i2c.h file. Though the indexes in qsee\_i2c.h and tzbsp\_i2c.h files are similar, these indexes are used for different purposes. Hence, incorrect references can lead to the wrong bus index. 3. In the trustzone\_images/ssg/securemsm/sse/qsee/SecureTouch/drTs/controller/chipset/kona/inc/synaptics\_ts\_defs.h file, define the chosen I^2^C bus instance (`QSEE_I2CPD_DEVICE_15`). #define I2C_DEVICE QSEE_I2CPD_DEVICE_15Copy to clipboard 4. Enable the corresponding I^2^C instance by adding the `#define ENABLE_I2C_15` micro definition at the beginning of the i2c\_devcfg.c file to enable and get the I^2^C instance compiled into the TrustZone binary. Due to TrustZone memory space, resources, and security limitations most of the QUP v3 serial engine instances are not activated by default. Therefore, most I^2^C instances do not get compiled into the TrustZone binary. To access a specific serial engine from the TrustZone, modify the i2c\_devcfg.c file. 5. Assign the access control in the \trustzone\_images\core\settings\buses\qup\_accesscontrol\qupv3\ config\kona\QUPAC\_Access.c file. As an example, the fifteenth QUP is being configured as the I^2^C in the TrustZone and only the GSI mode is allowed within the TrustZone due to security reasons, configure the `QUPV3_0_SE5` definition as: : const QUPv3_se_security_permissions_type qupv3_perms_default[] = { { QUPV3_1_SE6, QUPV3_PROTOCOL_I2C, QUPV3_MODE_GSI, AC_HLOS, FLASE, TRUE , TRUE }, // Forcetouch };Copy to clipboard 6. Modify the gpi\_tz\_845.c file to assign the GPII resource to the serial engine. const tgt_gpi_config_type tgt_gpi_config[] ={ { /* .qup_type */ 1, /*QUP indiex, 1 represent the 2nd QUP group*/ /* .gpii_id */ 8, /* .protocol */ 3, /* Protocol running on this GPII, 3 means I2C*/ /* .options */ 0, /* .ee */ 8, /* .se */ 6, /* set Serial Engine index to 6, represents the 7th instance of QUP1*/ /* .irq */ 327 },Copy to clipboard **Parent Topic:** [I2C in QUP](https://docs.qualcomm.com/doc/80-88500-1/topic/41_I2C_in_QUP_v3.html) Last Published: Aug 18, 2023 [Previous Topic Configure GPI as I2C](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/49_Configure_GPI_as_I2C.md) [Next Topic Enable I2C bus in aDSP](https://docs.qualcomm.com/bundle/publicresource/80-88500-1/topics/51_Enable_I2C_bus_in_aDSP.md)