diff --git a/drivers/i3c/i3c_npcm4xx.c b/drivers/i3c/i3c_npcm4xx.c index 1d3a64e3aedddb..7cc52cc622d233 100644 --- a/drivers/i3c/i3c_npcm4xx.c +++ b/drivers/i3c/i3c_npcm4xx.c @@ -582,8 +582,8 @@ I3C_ErrCode_Enum hal_I3C_Config_Device(I3C_DEVICE_INFO_t *pDevice) PDMA->SCATBA = (uint32_t) I3C_SCATTER_GATHER_TABLE.SCAT_DSCT; } -// hal_I3C_set_MAXRD(port, pDevice->max_rd_len); -// hal_I3C_set_MAXWR(port, pDevice->max_wr_len); + hal_I3C_set_MAXRD(port, pDevice->max_rd_len); + hal_I3C_set_MAXWR(port, pDevice->max_wr_len); /* Used for the Mixed bus to send the first START frame */ mconfig &= ~I3C_MCONFIG_ODHPP_MASK; @@ -3430,7 +3430,10 @@ if (intmasked == 0) return; * 1. We must terminate previous RX DMA / FIFO before master send "Index" / Data * 2. We must init RX DMA to get "Index" and data */ - I3C_Slave_Handle_DMA((uint32_t)pDevice); + if (intmasked & I3C_INTMASKED_STOP_MASK) { + /* update tx buffer here, only when slave doesn't get STOP */ + I3C_Slave_Handle_DMA((uint32_t)pDevice); + } I3C_SET_REG_STATUS(I3C_IF, I3C_STATUS_START_MASK); } @@ -3441,7 +3444,8 @@ if (intmasked == 0) return; } if (intmasked & I3C_INTMASKED_CCC_MASK) { - I3C_SET_REG_STATUS(I3C_IF, I3C_STATUS_CCC_MASK); + /* Can't reset here, will validate CCC in I3C_Slave_Handle_DMA() */ + /* I3C_SET_REG_STATUS(I3C_IF, I3C_STATUS_CCC_MASK); */ } if (intmasked & I3C_INTMASKED_DDRMATCHED_MASK) { @@ -3645,9 +3649,9 @@ void I3C_Slave_Handle_DMA(__u32 Parm) PDMA->CHCTL &= ~MaskBit(port + I3C_PORT_MAX); if (I3C_GET_REG_STATUS(port) & I3C_STATUS_CCC_MASK) { - /* reserved for vendor CCC */ + /* reserved for vendor CCC, drop rx data directly */ if (slvRxBuf[port][0] == CCC_BROADCAST_SETAASA) { - + LOG_WRN("rcv setaasa..."); } /* we can't support SETAASA because DYNADDR is RO. */ @@ -3938,7 +3942,7 @@ static void sir_allowed_worker(struct k_work *work) { struct i3c_npcm4xx_obj *obj = CONTAINER_OF(work, struct i3c_npcm4xx_obj, work); - k_msleep(1000); + /* k_msleep(1000); */ obj->sir_allowed_by_sw = 1; } @@ -3991,8 +3995,8 @@ static int i3c_npcm4xx_init(const struct device *dev) pDevice->staticAddr = config->assigned_addr; - pDevice->max_rd_len = 1024; // I3C_PAYLOAD_SIZE_MAX; - pDevice->max_wr_len = 1024; // I3C_PAYLOAD_SIZE_MAX; + pDevice->max_rd_len = I3C_PAYLOAD_SIZE_MAX; + pDevice->max_wr_len = I3C_PAYLOAD_SIZE_MAX; if (config->slave) { if (config->secondary) diff --git a/tests/boards/npcm400f_evb/boards/npcm400f_evb.overlay b/tests/boards/npcm400f_evb/boards/npcm400f_evb.overlay index d5860cf5c792d9..9570a5f8a21ccc 100644 --- a/tests/boards/npcm400f_evb/boards/npcm400f_evb.overlay +++ b/tests/boards/npcm400f_evb/boards/npcm400f_evb.overlay @@ -53,7 +53,7 @@ reg = <0x21>; msg-size = <256>; num-of-msgs = <4>; - mandatory-data-byte = <0xB0>; + mandatory-data-byte = <0xAE>; label = "I3C_1_SMQ"; status = "okay"; }; diff --git a/tests/boards/npcm400f_evb/src/i3c.c b/tests/boards/npcm400f_evb/src/i3c.c index eaccf06deda281..08a53e200177e9 100644 --- a/tests/boards/npcm400f_evb/src/i3c.c +++ b/tests/boards/npcm400f_evb/src/i3c.c @@ -89,7 +89,7 @@ static void test_i3c_slave_task(void *arg1, void *arg2, void *arg3) /* Test part 1: read and compare the data */ /* reset rx buffer */ - /* memset(test_data_rx_slv, 0x00, sizeof(test_data_rx_slv)); */ + memset(test_data_rx_slv, 0x00, sizeof(test_data_rx_slv)); while (1) { ret = i3c_slave_mqueue_read(slave_mq, (uint8_t *)test_data_rx_slv, TEST_PRIV_XFER_SIZE); @@ -108,6 +108,8 @@ static void test_i3c_slave_task(void *arg1, void *arg2, void *arg3) /* Test part 2: send IBI to notify the master device to get the pending data */ /* prepare_test_data(test_data_tx_slv, TEST_IBI_PAYLOAD_SIZE); */ + + /* for debug only */ memcpy(test_data_tx_slv, test_data_rx_slv, TEST_IBI_PAYLOAD_SIZE); ret = i3c_slave_mqueue_write(slave_mq, test_data_tx_slv, TEST_IBI_PAYLOAD_SIZE); ast_zassert_equal(ret, 0, "failed to do slave mqueue write"); @@ -157,14 +159,12 @@ static void test_i3c_ci(int count) /* try to enter i3c mode */ /* assign dynamic address with setdasa or entdaa, doesn't support setaasa in slave mode */ i3c_master_send_rstdaa(dev_master); - /* i3c_master_send_aasa(dev_master); */ + i3c_master_send_aasa(dev_master); /* Compatibility test for JESD403 */ i3c_master_send_entdaa(slave); slave->info.i2c_mode = 0; /* must wait for a while, for slave finish sir_allowed_worker ? */ - /* if skip the delay, the following getpid will be nacked */ - /* and dma will capture enec mask data later */ - k_sleep(K_MSEC(2000)); + /* k_sleep(K_USEC(1)); */ /* try to collect more slave info if called setaasa in the former */ i3c_master_send_getpid(dev_master, slave->info.dynamic_addr, &slave->info.pid); @@ -193,7 +193,8 @@ static void test_i3c_ci(int count) for (i = 0; i < count; i++) { /* prepare request message */ prepare_test_data(test_data_tx_mst, TEST_PRIV_XFER_SIZE); - test_data_tx_mst[0] = i; /* for debug only */ + /* test_data_tx_mst[0] = i; */ /* for debug only */ + /* k_usleep(100); */ /* debug only */ /* Requester send request message */ xfer[0].rnw = 0; @@ -227,6 +228,7 @@ static void test_i3c_ci(int count) k_yield(); ret = i3c_master_priv_xfer(slave, &xfer[0], 1); ast_zassert_mem_equal(test_data_tx_slv, test_data_rx_mst, TEST_IBI_PAYLOAD_SIZE, "data mismatch"); + /*k_usleep(100);*/ /* debug only */ } }