From dd77752ee73dd030c0db7566d8c659d98cd6839e Mon Sep 17 00:00:00 2001 From: Jie Zhang Date: Mon, 8 Feb 2010 03:56:49 +0000 Subject: [PATCH] Wait some clocks at Run-Test/Idle for Blackfin. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1769 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 16 +++++++++++ urjtag/include/urjtag/bfin.h | 1 + urjtag/include/urjtag/chain.h | 3 +- urjtag/include/urjtag/part.h | 1 + urjtag/src/bfin/bfin-part-bfin.c | 47 ++++++++++++++++++++++++++++++++ urjtag/src/bfin/bfin.c | 3 ++ urjtag/src/tap/chain.c | 14 ++++++++++ urjtag/src/tap/tap.c | 1 + 8 files changed, 85 insertions(+), 1 deletion(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 9956d60f..613150ed 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,19 @@ +2010-02-08 Jie Zhang + + * include/urjtag/part.h (struct URJ_PART_PARAMS): Add wait_ready. + * include/urjtag/bfin.h (bfin_wait_clocks): Declare. + * include/urjtag/chain.h (urj_tap_chain_wait_ready): Declare. + * src/tap/chain.c (urj_tap_chain_wait_ready): New. + * src/tap/tap.c (urj_tap_defer_shift_register): Call + urj_tap_chain_wait_ready if Run-Test/Idle. + * src/bfin/bfin.c (bfin_wait_clocks): Define. + (part_emudat_defer_get): Call chain_wait_ready when Run-Test/Idle. + (part_emudat_get): Likewise. + * src/bfin/bfin-part-bfin.c: Include , , + and . + (bfin_wait_ready): New. + (bfin_part_init): Init wait_ready. + 2010-02-06 Jie Zhang * include/urjtag/cable.h (enum action): Add URJ_TAP_CABLE_CLOCK_COMPACT. diff --git a/urjtag/include/urjtag/bfin.h b/urjtag/include/urjtag/bfin.h index 08fd9099..af339386 100644 --- a/urjtag/include/urjtag/bfin.h +++ b/urjtag/include/urjtag/bfin.h @@ -212,6 +212,7 @@ enum { }; extern int bfin_check_emuready; +extern int bfin_wait_clocks; /* From src/bfin/bfin.c */ diff --git a/urjtag/include/urjtag/chain.h b/urjtag/include/urjtag/chain.h index c29b6bc3..9b8d477c 100644 --- a/urjtag/include/urjtag/chain.h +++ b/urjtag/include/urjtag/chain.h @@ -81,7 +81,8 @@ int urj_tap_chain_get_pod_signal (urj_chain_t *chain, urj_pod_sigsel_t sig); * * @return NULL on error, and sets urj_error. */ -urj_part_t *urj_tap_chain_active_part(urj_chain_t *chain); +urj_part_t *urj_tap_chain_active_part (urj_chain_t *chain); +void urj_tap_chain_wait_ready (urj_chain_t *chain); typedef struct { diff --git a/urjtag/include/urjtag/part.h b/urjtag/include/urjtag/part.h index 8515964f..363376a0 100644 --- a/urjtag/include/urjtag/part.h +++ b/urjtag/include/urjtag/part.h @@ -34,6 +34,7 @@ struct URJ_PART_PARAMS { void (*free) (void *); + void (*wait_ready) (void *); void *data; }; diff --git a/urjtag/src/bfin/bfin-part-bfin.c b/urjtag/src/bfin/bfin-part-bfin.c index ee57c1d0..bf7cc845 100644 --- a/urjtag/src/bfin/bfin-part-bfin.c +++ b/urjtag/src/bfin/bfin-part-bfin.c @@ -17,16 +17,20 @@ */ +#include #include #include #include #include #include +#include +#include #include #include #include #include +#include /* The helper functions for Blackfin DBGCTL and DBGSTAT operations. */ @@ -113,6 +117,48 @@ struct emu_oab bfin_emu_oab = 0x0001, /* DBGSTAT_EMUDOF */ }; +static void +bfin_wait_ready (void *data) +{ + urj_chain_t *chain = (urj_chain_t *) data; + + /* When CCLK is 62MHz and SCLK is 31MHz, which is the lowest frequency I + can set in bf537 stamp linux kernel, set the gnICE+ cable frequency to + 15MHz (current default), --wait-clocks >= 12 is required. + + When CCLK is 62MHz and SCLK is 31MHz, set the gnICE+ cable frequency to + 30MHz, --wait-clocks >= 21 is required. + + When CCLK is 62MHz and SCLK is 31MHz, set the gnICE+ cable frequency to + 6MHz (default), --wait-clocks >= 5 is required. + + When CCLK is 62MHz and SCLK is 31MHz, set the gnICE cable frequency to + 6MHz (default), --wait-clocks >= 2 is required. */ + + if (bfin_wait_clocks == -1) + { + urj_cable_t *cable = chain->cable; + uint32_t frequency = cable->frequency; + const char *name = cable->driver->name; + + if (strcmp (name, "gnICE+") == 0 && frequency == 15000000) + bfin_wait_clocks = 12; + else if (strcmp (name, "gnICE+") == 0 && frequency == 30000000) + bfin_wait_clocks = 21; + else if (strcmp (name, "gnICE+") == 0 && frequency == 6000000) + bfin_wait_clocks = 5; + else if (strcmp (name, "gnICE") == 0 && frequency == 6000000) + bfin_wait_clocks = 2; + else + { + bfin_wait_clocks = 21; + urj_warning (_("untested cable or frequency, set wait_clocks to %d\n"), bfin_wait_clocks); + } + } + + urj_tap_chain_defer_clock (chain, 0, 0, bfin_wait_clocks); +} + static void bfin_part_init (urj_part_t *part) { @@ -121,6 +167,7 @@ bfin_part_init (urj_part_t *part) assert (part && part->params); part->params->free = free; + part->params->wait_ready = bfin_wait_ready; part->params->data = malloc (sizeof (struct bfin_part_data)); EMU_OAB (part) = &bfin_emu_oab; diff --git a/urjtag/src/bfin/bfin.c b/urjtag/src/bfin/bfin.c index df0cba9f..47d365bc 100644 --- a/urjtag/src/bfin/bfin.c +++ b/urjtag/src/bfin/bfin.c @@ -47,6 +47,7 @@ const char *scans[] = { int bfin_check_emuready = 1; +int bfin_wait_clocks = -1; static struct timespec bfin_emu_wait_ts = {0, 5000000}; @@ -1062,6 +1063,7 @@ part_emudat_defer_get (urj_chain_t *chain, int n, int exit) { assert (urj_tap_state (chain) & URJ_TAP_STATE_IDLE); urj_tap_chain_defer_clock (chain, 0, 0, 1); + urj_tap_chain_wait_ready (chain); } if (part_scan_select (chain, n, EMUDAT_SCAN) < 0) @@ -1146,6 +1148,7 @@ part_emudat_get (urj_chain_t *chain, int n, int exit) { assert (urj_tap_state (chain) & URJ_TAP_STATE_IDLE); urj_tap_chain_defer_clock (chain, 0, 0, 1); + urj_tap_chain_wait_ready (chain); } if (part_scan_select (chain, n, EMUDAT_SCAN) < 0) diff --git a/urjtag/src/tap/chain.c b/urjtag/src/tap/chain.c index 9200bd8d..d677a88f 100644 --- a/urjtag/src/tap/chain.c +++ b/urjtag/src/tap/chain.c @@ -331,3 +331,17 @@ urj_tap_chain_active_part (urj_chain_t *chain) return chain->parts->parts[chain->active_part]; } + +void +urj_tap_chain_wait_ready (urj_chain_t *chain) +{ + urj_part_t *part; + + if (!chain || !chain->parts) + return; + + part = chain->parts->parts[chain->main_part]; + if (part->params && part->params->wait_ready) + part->params->wait_ready (chain); +} + diff --git a/urjtag/src/tap/tap.c b/urjtag/src/tap/tap.c index 8871f9f1..54f142ca 100644 --- a/urjtag/src/tap/tap.c +++ b/urjtag/src/tap/tap.c @@ -105,6 +105,7 @@ urj_tap_defer_shift_register (urj_chain_t *chain, { urj_tap_chain_defer_clock (chain, 1, 0, 1); /* Update-DR or Update-IR */ urj_tap_chain_defer_clock (chain, 0, 0, 1); /* Run-Test/Idle */ + urj_tap_chain_wait_ready (chain); } else if (tap_exit == URJ_CHAIN_EXITMODE_UPDATE) urj_tap_chain_defer_clock (chain, 1, 0, 1); /* Update-DR or Update-IR */