@@ -157,6 +157,7 @@ struct i3c_stm32_data {
157
157
uint8_t num_addr ; /* Number of valid addresses */
158
158
} ibi ;
159
159
struct k_sem ibi_lock_sem ; /* Semaphore used for ibi requests */
160
+ bool hj_pm_lock ; /* Used as flag for setting pm */
160
161
#endif
161
162
};
162
163
/**
@@ -1562,6 +1563,9 @@ static int i3c_stm32_init(const struct device *dev)
1562
1563
1563
1564
#ifdef CONFIG_I3C_USE_IBI
1564
1565
LL_I3C_EnableHJAck (i3c );
1566
+ hj_pm_lock = true;
1567
+ (void )pm_device_runtime_get (dev );
1568
+ pm_policy_state_lock_get (PM_STATE_SUSPEND_TO_IDLE , PM_ALL_SUBSTATES );
1565
1569
#endif
1566
1570
1567
1571
return 0 ;
@@ -1895,6 +1899,34 @@ static void i3c_stm32_error_isr(void *arg)
1895
1899
1896
1900
#ifdef CONFIG_I3C_USE_IBI
1897
1901
1902
+ int i3c_stm32_ibi_hj_response (const struct device * dev , bool ack )
1903
+ {
1904
+ const struct i3c_stm32_config * config = dev -> config ;
1905
+ I3C_TypeDef * i3c = config -> i3c ;
1906
+
1907
+ if (ack ) {
1908
+ /*
1909
+ * This prevents pm_device_runtime from being called multiple times
1910
+ * with redunant calls
1911
+ */
1912
+ if (!hj_pm_lock ) {
1913
+ hj_pm_lock = true;
1914
+ (void )pm_device_runtime_get (dev );
1915
+ pm_policy_state_lock_get (PM_STATE_SUSPEND_TO_IDLE , PM_ALL_SUBSTATES );
1916
+ }
1917
+ LL_I3C_EnableHJAck (i3c );
1918
+ } else {
1919
+ LL_I3C_DisableHJAck (i3c );
1920
+ if (hj_pm_lock ) {
1921
+ hj_pm_lock = false;
1922
+ (void )pm_device_runtime_put (dev );
1923
+ pm_policy_state_lock_put (PM_STATE_SUSPEND_TO_IDLE , PM_ALL_SUBSTATES );
1924
+ }
1925
+ }
1926
+
1927
+ return 0 ;
1928
+ }
1929
+
1898
1930
int i3c_stm32_ibi_enable (const struct device * dev , struct i3c_device_desc * target )
1899
1931
{
1900
1932
int ret = 0 ;
@@ -2068,6 +2100,7 @@ static DEVICE_API(i3c, i3c_stm32_driver_api) = {
2068
2100
.do_daa = i3c_stm32_do_daa ,
2069
2101
.do_ccc = i3c_stm32_do_ccc ,
2070
2102
#ifdef CONFIG_I3C_USE_IBI
2103
+ .ibi_hj_response = i3c_stm32_ibi_hj_response ,
2071
2104
.ibi_enable = i3c_stm32_ibi_enable ,
2072
2105
.ibi_disable = i3c_stm32_ibi_disable ,
2073
2106
#endif
0 commit comments