* are immediatley available.
*/
+
+/* ARM ADI Specification requires at least 10 bits used for TAR autoincrement */
+
+/*
+ u32 tar_block_size(u32 address)
+ Return the largest block starting at address that does not cross a tar block size alignment boundary
+*/
+static u32 max_tar_block_size(u32 tar_autoincr_block, u32 address)
+{
+ return (tar_autoincr_block - ((tar_autoincr_block - 1) & address)) >> 2;
+}
+
/***************************************************************************
* *
* DPACC and APACC scanchain access through JTAG-DP *
while (wcount > 0)
{
- /* Adjust to write blocks within 4K aligned boundaries */
- blocksize = (0x1000 - (0xFFF & address)) >> 2;
+ /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
{
int nbytes;
- /* Adjust to read within 4K block boundaries */
- blocksize = (0x1000 - (0xFFF & address)) >> 1;
+ /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
{
int nbytes;
- /* Adjust to read within 4K block boundaries */
- blocksize = (0x1000 - (0xFFF & address));
+ /* Adjust to write blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
while (wcount > 0)
{
- /* Adjust to read within 4K block boundaries */
- blocksize = (0x1000 - (0xFFF & address)) >> 2;
+ /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
{
int nbytes;
- /* Adjust to read within 4K block boundaries */
- blocksize = (0x1000 - (0xFFF & address)) >> 1;
+ /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
{
int nbytes;
- /* Adjust to read within 4K block boundaries */
- blocksize = (0x1000 - (0xFFF & address));
+ /* Adjust to read blocks within boundaries aligned to the TAR autoincremnent size*/
+ blocksize = max_tar_block_size(swjdp->tar_autoincr_block, address);
if (wcount < blocksize)
blocksize = wcount;
u8 ack;
/* extra tck clocks for memory bus access */
u32 memaccess_tck;
+ /* Size of TAR autoincrement block, ARM ADI Specification requires at least 10 bits */
+ u32 tar_autoincr_block;
+
} swjdp_common_t;
+/* Accessor function for currently selected DAP-AP number */
+static inline u8 dap_ap_get_select(swjdp_common_t *swjdp)
+{
+ return (u8)( swjdp ->apsel >> 24);
+}
+
/* Internal functions used in the module, partial transactions, use with caution */
extern int dap_dp_write_reg(swjdp_common_t *swjdp, u32 value, u8 reg_addr);
/* extern int swjdp_write_apacc(swjdp_common_t *swjdp, u32 value, u8 reg_addr); */