From: Øyvind H. <go...@us...> - 2010-08-02 22:23:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via c49d4c9f7f43979e3abf04067dc38535f7ebc45a (commit) via 4e27305ed5dac23e8b9a43e43b4b908dc53a0a20 (commit) from d1638abd6a67ea028a3896c356af3fe135c719c7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c49d4c9f7f43979e3abf04067dc38535f7ebc45a Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Aug 2 22:12:33 2010 +0200 zy1000: use correct base clock when calculating speed divisor revc uses 60MHz and revb 64MHz, use this in calculations. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 23f2fdd..3ecd0f9 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -1,4 +1,4 @@ -'n/*************************************************************************** +/*************************************************************************** * Copyright (C) 2007-2010 by Ãyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * @@ -62,6 +62,9 @@ #ifdef CYGPKG_HAL_NIOS2 #include <cyg/hal/io.h> #include <cyg/firmwareutil/firmwareutil.h> +#define ZYLIN_KHZ 60000 +#else +#define ZYLIN_KHZ 64000 #endif #define ZYLIN_VERSION GIT_ZY1000_VERSION @@ -70,6 +73,9 @@ #define ZYLIN_OPENOCD GIT_OPENOCD_VERSION #define ZYLIN_OPENOCD_VERSION "ZY1000 " ZYLIN_VERSION " " ZYLIN_DATE +#else +/* Assume we're connecting to a revc w/60MHz clock. */ +#define ZYLIN_KHZ 60000 #endif @@ -102,7 +108,7 @@ static int zy1000_khz(int khz, int *jtag_speed) * 64000 / 6 = 10666 * */ - speed = (64000 + (khz -1)) / khz; + speed = (ZYLIN_KHZ + (khz -1)) / khz; speed = (speed + 1 ) / 2; speed *= 2; if (speed > 8190) @@ -123,7 +129,7 @@ static int zy1000_speed_div(int speed, int *khz) } else { - *khz = 64000/speed; + *khz = ZYLIN_KHZ / speed; } return ERROR_OK; @@ -265,7 +271,8 @@ int zy1000_speed(int speed) { if (speed > 8190 || speed < 2) { - LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz"); + LOG_USER("valid ZY1000 jtag_speed=[8190,2]. With divisor is %dkHz / even values between 8190-2, i.e. min %dHz, max %dMHz", + ZYLIN_KHZ, (ZYLIN_KHZ * 1000) / 8190, ZYLIN_KHZ / (2 * 1000)); return ERROR_INVALID_ARGUMENTS; } commit 4e27305ed5dac23e8b9a43e43b4b908dc53a0a20 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Aug 2 17:09:57 2010 +0200 zy1000: print out khz correctly in response to setting JTAG speed Calculate printout based on same core routines. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 28c65b6..23f2fdd 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -1,4 +1,4 @@ -/*************************************************************************** +'n/*************************************************************************** * Copyright (C) 2007-2010 by Ãyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * @@ -84,7 +84,33 @@ static int zy1000_khz(int khz, int *jtag_speed) } else { - *jtag_speed = 64000/khz; + int speed; + /* Round speed up to nearest divisor. + * + * E.g. 16000kHz + * (64000 + 15999) / 16000 = 4 + * (4 + 1) / 2 = 2 + * 2 * 2 = 4 + * + * 64000 / 4 = 16000 + * + * E.g. 15999 + * (64000 + 15998) / 15999 = 5 + * (5 + 1) / 2 = 3 + * 3 * 2 = 6 + * + * 64000 / 6 = 10666 + * + */ + speed = (64000 + (khz -1)) / khz; + speed = (speed + 1 ) / 2; + speed *= 2; + if (speed > 8190) + { + /* maximum dividend */ + speed = 8190; + } + *jtag_speed = speed; } return ERROR_OK; } @@ -243,9 +269,12 @@ int zy1000_speed(int speed) return ERROR_INVALID_ARGUMENTS; } - LOG_USER("jtag_speed %d => JTAG clk=%f", speed, 64.0/(float)speed); + int khz; + speed &= ~1; + zy1000_speed_div(speed, &khz); + LOG_USER("jtag_speed %d => JTAG clk=%d kHz", speed, khz); ZY1000_POKE(ZY1000_JTAG_BASE + 0x14, 0x100); - ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed&~1); + ZY1000_POKE(ZY1000_JTAG_BASE + 0x1c, speed); } return ERROR_OK; } ----------------------------------------------------------------------- Summary of changes: src/jtag/zy1000/zy1000.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 41 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |