This is an automated email from Gerrit.

Alamy Liu ([email protected]) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/3245

-- gerrit

commit c8e05a70e0f83ca1be19ea322365f6e72a0ac2c1
Author: Alamy Liu <[email protected]>
Date:   Wed Aug 12 09:54:28 2015 -0700

    adi_v5: Add dap_dp_* helper functions
    
    Adding the following dap_dp_* helper functions so it's more complete
      dap_dp_write_atomic(...)
      dap_dp_reg_set_bits(...)
      dap_dp_reg_clear_bits(...)
    
    Change-Id: Ibb4687b950403ef64c59c4cbfbec988723fb0d52
    Signed-off-by: Alamy Liu <[email protected]>

diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 03d038c..8af9193 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -421,6 +421,63 @@ static inline int dap_dp_read_atomic(struct adiv5_dap 
*dap, unsigned reg,
        return dap_run(dap);
 }
 
+static inline int dap_dp_write_atomic(struct adiv5_dap *dap, unsigned reg,
+                                     uint32_t value)
+{
+       int retval;
+
+       retval = dap_queue_dp_write(dap, reg, value);
+       if (retval != ERROR_OK)
+               return retval;
+
+       return dap_run(dap);
+}
+
+static inline int dap_dp_reg_set_bits(
+       struct adiv5_dap *dap, unsigned reg, uint32_t bit_mask)
+{
+       int rc;
+       uint32_t regval = 0;    /* CAUTION: Must clear it, or garbage data
+                                  in stack will pollute read data.
+                                  Didn't dig the reason, but verified */
+
+       /*   In the case that this function is invoked by dap_power_on() to
+        * clear error bits, dap_queue_dp_read() should be used,
+        * not dap_dp_read_atomic().  Thus, dap_power_on() is designed in he way
+        * to clear error bits directly.
+        *
+        * Reason:
+        *   This is a two steps function: READ-(set)-WRITE.
+        * Error bits (SSTICKYERR | SSTICKYCMP | SSTICKYORUN) might have been
+        * there when we READ it (that's why we want to clear it).
+        * With dap_dp_read_aotmic() function call, 
jtagdp_transaction_endcheck()
+        * will throw ERROR_JTAG_DEVICE_ERROR before we have a chance to clear
+        * it (Write 1 to clear).
+        */
+       rc = dap_queue_dp_read(dap, reg, &regval);
+       if (rc != ERROR_OK)
+               return rc;
+
+       regval |= bit_mask;
+
+       return dap_dp_write_atomic(dap, reg, regval);
+}
+
+static inline int dap_dp_reg_clear_bits(
+       struct adiv5_dap *dap, unsigned reg, uint32_t bit_mask)
+{
+       int rc;
+       uint32_t regval = 0;    /* CAUTION: Must clear to zero */
+
+       rc = dap_queue_dp_read(dap, reg, &regval);
+       if (rc != ERROR_OK)
+               return rc;
+
+       regval &= ~bit_mask;
+
+       return dap_dp_write_atomic(dap, reg, regval);
+}
+
 static inline int dap_dp_poll_register(struct adiv5_dap *dap, unsigned reg,
                                       uint32_t mask, uint32_t value, int 
timeout)
 {

-- 

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to