Merge "Run software tests from raw otp"
diff --git a/hw/top_matcha/dv/chip_sim_cfg.hjson b/hw/top_matcha/dv/chip_sim_cfg.hjson
index 0e75e2a..0a049d6 100644
--- a/hw/top_matcha/dv/chip_sim_cfg.hjson
+++ b/hw/top_matcha/dv/chip_sim_cfg.hjson
@@ -702,6 +702,13 @@
       reseed: 5
     }
     {
+      name: chip_sw_uart_tx_rx_lc_test
+      uvm_test_seq: chip_sw_uart_tx_rx_vseq
+      sw_images: ["//sw/device/tests/sim_dv:uart_tx_rx_test:1:matcha"]
+      en_run_modes: ["sw_test_mode_test_rom"]
+      run_opts: ["+uart_idx=0", "+calibrate_usb_clk=1", "+raw_otp_jtag=1", "+use_otp_image=OtpTypeLcStRaw"]
+    }
+    {
       name: chip_sw_uart_tx_rx_idx1
       uvm_test_seq: chip_sw_uart_tx_rx_vseq
       sw_images: ["//sw/device/tests/sim_dv:uart_tx_rx_test:1"]
@@ -2213,6 +2220,7 @@
         "chip_sw_sysrst_ctrl_ulp_z3_wakeup",
         "chip_sw_uart_smoketest",
         "chip_sw_uart_tx_rx",
+        "chip_sw_uart_tx_rx_lc_test",
         "chip_tap_straps_dev",
         "chip_tap_straps_rma",
       ]
@@ -2343,6 +2351,7 @@
         "chip_sw_sysrst_ctrl_reset",
         "chip_sw_sysrst_ctrl_ulp_z3_wakeup",
         "chip_sw_uart_tx_rx",
+        "chip_sw_uart_tx_rx_lc_test",
         "chip_tap_straps_dev",
         "chip_tap_straps_prod",
         "chip_tap_straps_rma",
diff --git a/hw/top_matcha/dv/env/seq_lib/chip_sw_base_vseq.sv b/hw/top_matcha/dv/env/seq_lib/chip_sw_base_vseq.sv
index 1f6851d..ee22eb2 100644
--- a/hw/top_matcha/dv/env/seq_lib/chip_sw_base_vseq.sv
+++ b/hw/top_matcha/dv/env/seq_lib/chip_sw_base_vseq.sv
@@ -12,12 +12,20 @@
 
   `uvm_object_new
 
+  bit raw_otp_jtag;
+
   virtual task pre_start();
     super.pre_start();
     set_and_release_sw_strap_nonblocking();
     // Disable mem checks in scoreboard - it does not factor in memory scrambling.
     cfg.en_scb_mem_chk = 1'b0;
 
+    raw_otp_jtag = 1'b0;
+    void'($value$plusargs("raw_otp_jtag=%0d", raw_otp_jtag));
+    if (raw_otp_jtag) begin
+      cfg.chip_vif.tap_straps_if.drive(JtagTapLc);
+    end
+
     // Undriven gpio pins will cause x values in u_gpio.data_in when connected
     // with MIO pads in pinmux
     // TODO(b/287479608): Add more X checkers and report error immediately
@@ -234,10 +242,24 @@
     cfg.mem_bkdr_util_h[mem].write39integ(addr_scr & addr_mask, data_scr ^ flip_bits);
   endfunction
 
+  virtual task apply_reset(string kind = "HARD");
+    super.apply_reset();
+
+    if (raw_otp_jtag) begin
+      set_otp_creator_sw_cfg_rom_exec_en(1);
+    end
+  endtask
+
   virtual task body();
     cfg.sw_test_status_vif.set_num_iterations(num_trans);
     // Initialize the CPU to kick off the sw test. TODO: Should be called in pre_start() instead.
     cpu_init();
+
+    if (raw_otp_jtag) begin
+      wait_lc_ready(1);
+      jtag_lc_state_transition(DecLcStRaw, DecLcStTestUnlocked0);
+      apply_reset();
+    end
   endtask
 
   virtual task post_start();