Skip to content

Commit 086b443

Browse files
committed
i3c_target: Update I3C functional test case for prot evb
Originally, the I3C functional test cases were designed for the DCSCM card. This update adjust them to work with the ast1060_prot EVB. Signed-off-by: Steven Lee <[email protected]>
1 parent 1683d05 commit 086b443

File tree

5 files changed

+45
-160
lines changed

5 files changed

+45
-160
lines changed

[email protected]

Lines changed: 0 additions & 149 deletions
This file was deleted.

src/i3c/ast1060_i3c.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ pub trait HardwareInterface {
439439
fn handle_ibis(&mut self, config: &mut I3cConfig);
440440
fn i3c_aspeed_isr(&mut self, config: &mut I3cConfig);
441441
// target apis
442+
fn target_ibi_raise_hj(&self, config: &mut I3cConfig) -> Result<(), I3cDrvError>;
442443
fn target_handle_response_ready(&mut self, config: &mut I3cConfig);
443444
fn target_pending_read_notify(
444445
&mut self,
@@ -1964,7 +1965,6 @@ impl<I3C: Instance, L: Logger> HardwareInterface for Ast1060I3c<I3C, L> {
19641965
}
19651966

19661967
if (status & INTR_RESP_READY_STAT) != 0 {
1967-
i3c_debug!(self.logger, "Response ready");
19681968
self.target_handle_response_ready(config);
19691969
}
19701970

@@ -1987,6 +1987,25 @@ impl<I3C: Instance, L: Logger> HardwareInterface for Ast1060I3c<I3C, L> {
19871987
self.enable_irq();
19881988
}
19891989

1990+
fn target_ibi_raise_hj(&self, config: &mut I3cConfig) -> Result<(), I3cDrvError> {
1991+
if !config.is_secondary {
1992+
return Err(I3cDrvError::Invalid);
1993+
}
1994+
let hj_support = self.i3c.i3cd008().read().slvhjcap().bit();
1995+
if !hj_support {
1996+
return Err(I3cDrvError::Invalid);
1997+
}
1998+
1999+
let addr_valid = self.i3c.i3cd004().read().dynamic_addr_valid().bit();
2000+
if addr_valid {
2001+
return Err(I3cDrvError::Access);
2002+
}
2003+
2004+
self.i3c.i3cd038().write(|w| unsafe { w.bits(8) }); // set HJ request
2005+
2006+
Ok(())
2007+
}
2008+
19902009
fn target_handle_response_ready(&mut self, config: &mut I3cConfig) {
19912010
let nresp = self.i3c.i3cd04c().read().respbufblr().bits();
19922011

@@ -2022,7 +2041,11 @@ impl<I3C: Instance, L: Logger> HardwareInterface for Ast1060I3c<I3C, L> {
20222041
if rx_len != 0 {
20232042
let mut buf: [u8; 256] = [0u8; 256];
20242043
self.rd_rx_fifo(&mut buf[..rx_len]);
2025-
i3c_debug!(self.logger, "Response data: {:02x?}", &buf[..rx_len]);
2044+
i3c_debug!(
2045+
self.logger,
2046+
"[MASTER ==> TARGET] TARGET READ: {:02x?}",
2047+
&buf[..rx_len]
2048+
);
20262049
}
20272050

20282051
if tid == Tid::TargetIbi as usize {
@@ -2042,7 +2065,6 @@ impl<I3C: Instance, L: Logger> HardwareInterface for Ast1060I3c<I3C, L> {
20422065
notifier: &mut I3cIbi,
20432066
) -> Result<(), I3cDrvError> {
20442067
let reg = self.i3c.i3cd038().read().bits();
2045-
i3c_debug!(self.logger, "target_pending_read_notify: reg=0x{:08x}", reg);
20462068
if !(config.sir_allowed_by_sw && (reg & SLV_EVENT_CTRL_SIR_EN != 0)) {
20472069
return Err(I3cDrvError::Access);
20482070
}

src/i3c/i3c_target.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ impl<HW: HardwareInterface, L: crate::common::Logger> DynamicAddressable for I3c
5454

5555
impl<HW: HardwareInterface, L: crate::common::Logger> IBICapable for I3cController<HW, L> {
5656
fn wants_ibi(&self) -> bool {
57-
// In ast1060, we don't need to tell the controller that we want IBI
5857
true
5958
}
6059

src/pinctrl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,10 +1731,10 @@ paste! {
17311731
pub const PINCTRL_I3C2: &[PinctrlPin] = &[PIN_SCU418_20, PIN_SCU418_21, CLR_PIN_SCU4B8_12, CLR_PIN_SCU4B8_13];
17321732
pub const PINCTRL_I3C3: &[PinctrlPin] = &[PIN_SCU418_22, PIN_SCU418_23, CLR_PIN_SCU4B8_14, CLR_PIN_SCU4B8_15];
17331733

1734-
pub const PINCTRL_HVI3C0: &[PinctrlPin] = &[CLR_PIN_SCU418_8, CLR_PIN_SCU418_9, CLR_PIN_SCU418_16, PIN_SCU418_17, PIN_SCU4B8_8, PIN_SCU4B8_9];
1735-
pub const PINCTRL_HVI3C1: &[PinctrlPin] = &[CLR_PIN_SCU418_10, CLR_PIN_SCU418_11, CLR_PIN_SCU418_18, PIN_SCU418_19, PIN_SCU4B8_10, PIN_SCU4B8_11];
1736-
pub const PINCTRL_HVI3C2: &[PinctrlPin] = &[CLR_PIN_SCU418_12, CLR_PIN_SCU418_13, CLR_PIN_SCU418_20, PIN_SCU418_21, PIN_SCU4B8_12, PIN_SCU4B8_13];
1737-
pub const PINCTRL_HVI3C3: &[PinctrlPin] = &[CLR_PIN_SCU418_14, CLR_PIN_SCU418_15, CLR_PIN_SCU418_22, PIN_SCU418_23, PIN_SCU4B8_14, PIN_SCU4B8_15];
1734+
pub const PINCTRL_HVI3C0: &[PinctrlPin] = &[CLR_PIN_SCU418_8, CLR_PIN_SCU418_9, CLR_PIN_SCU418_16, CLR_PIN_SCU418_17, PIN_SCU4B8_8, PIN_SCU4B8_9];
1735+
pub const PINCTRL_HVI3C1: &[PinctrlPin] = &[CLR_PIN_SCU418_10, CLR_PIN_SCU418_11, CLR_PIN_SCU418_18, CLR_PIN_SCU418_19, PIN_SCU4B8_10, PIN_SCU4B8_11];
1736+
pub const PINCTRL_HVI3C2: &[PinctrlPin] = &[CLR_PIN_SCU418_12, CLR_PIN_SCU418_13, CLR_PIN_SCU418_20, CLR_PIN_SCU418_21, PIN_SCU4B8_12, PIN_SCU4B8_13];
1737+
pub const PINCTRL_HVI3C3: &[PinctrlPin] = &[CLR_PIN_SCU418_14, CLR_PIN_SCU418_15, CLR_PIN_SCU418_22, CLR_PIN_SCU418_23, PIN_SCU4B8_14, PIN_SCU4B8_15];
17381738

17391739
pub const PINCTRL_GPIOA0: &[PinctrlPin] = &[CLR_PIN_SCU410_0, CLR_PIN_SCU4B0_0, CLR_PIN_SCU690_0];
17401740
pub const PINCTRL_GPIOA1: &[PinctrlPin] = &[CLR_PIN_SCU410_1, CLR_PIN_SCU4B0_1, CLR_PIN_SCU690_1];

src/tests/functional/i3c_test.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,28 @@ pub fn test_i3c_target(uart: &mut UartController<'_>) {
206206
c.i3c_pp_scl_lo_period_ns = 36;
207207
c.i3c_od_scl_hi_period_ns = 0;
208208
c.i3c_od_scl_lo_period_ns = 0;
209-
c.sda_tx_hold_ns = 20;
209+
c.sda_tx_hold_ns = 0;
210+
// c.sda_tx_hold_ns = 20;
210211
c.dcr = 0xcc;
211212
c.target_config = Some(I3cTargetConfig::new(0, Some(0), 0xae));
212213
}
213214
let mut ibi_cons = i3c_ibi_workq_consumer(ctrl.hw.bus_num() as usize);
214215
ctrl.init();
215-
let dyn_addr = 9;
216+
let dyn_addr = 8;
216217
let dev_idx = 0;
217218
let _ = ctrl.hw.attach_i3c_dev(dev_idx, dyn_addr);
219+
writeln!(
220+
uart,
221+
"I3C target dev at slot {dev_idx}, dyn addr {dyn_addr}\r"
222+
)
223+
.unwrap();
218224
// Dump I3C2 registers
219225
// dump_i3c_controller_registers(uart, 0x7e7a_4000);
226+
let mut delay = DummyDelay {};
227+
delay.delay_ns(4_000_000_000);
228+
writeln!(uart, "waiting for dynamic address assignment...\r").unwrap();
229+
let _ = ctrl.hw.target_ibi_raise_hj(&mut ctrl.config);
230+
// dump_i3c_controller_registers(uart, 0x7e7a_4000);
220231
loop {
221232
if let Some(work) = ibi_cons.dequeue() {
222233
match work {
@@ -254,9 +265,11 @@ pub fn test_i3c_target(uart: &mut UartController<'_>) {
254265
*b = u8::try_from(i).unwrap();
255266
}
256267
writeln!(uart, "send ibi #{ibi_count}\r").unwrap();
268+
writeln!(uart, "[MASTER <== TARGET] TARGET WRITE: {data:02x?}").unwrap();
269+
writeln!(uart, "\r").unwrap();
257270
ctrl.get_ibi_payload(&mut data).unwrap();
258271
ibi_count += 1;
259-
if ibi_count > 100 {
272+
if ibi_count > 10 {
260273
break;
261274
}
262275
}

0 commit comments

Comments
 (0)