Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-06 Thread Jean-Christophe PLAGNIOL-VILLARD
On 06:58 Fri 06 May , Øyvind Harboe wrote:
  +# The chip may run @ 32khz, so set a really low JTAG speed
  +adapter_khz 8
  this is the wrong place it's not board specific but soc specific
 
  tcl/target/at91rm9200.cfg
 
 Perhaps jtag_rclk 8 should be used, i.e. use RCLK if it is supported
 and fall back to 8 khz. Of course post reset init jtag_rclk's fallback
 frequency could be increased.
jtalg_rclk 0

I think is better
then If the board need to overwrite it the do it after the source of the soc
file

Best Regards,
J.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-06 Thread Øyvind Harboe
On Fri, May 6, 2011 at 10:33 AM, Jean-Christophe PLAGNIOL-VILLARD
plagn...@jcrosoft.com wrote:
 On 06:58 Fri 06 May     , Ųyvind Harboe wrote:
  +# The chip may run @ 32khz, so set a really low JTAG speed
  +adapter_khz 8
  this is the wrong place it's not board specific but soc specific
 
  tcl/target/at91rm9200.cfg

 Perhaps jtag_rclk 8 should be used, i.e. use RCLK if it is supported
 and fall back to 8 khz. Of course post reset init jtag_rclk's fallback
 frequency could be increased.
 jtalg_rclk 0

This illegal.

jtag_rclk will use rclk, if rclk is available and fall back to
the frequency specified.

The above would mean use rclk if available, otherwise 0khz = error.

I think using rclk if available and falling back to 8khz is a reasonable
default.



-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-06 Thread Laurent Gauch


/  +# The chip may run @ 32khz, so set a really low JTAG speed
//  +adapter_khz 8
//  this is the wrong place it's not board specific but soc specific
// 
//  tcl/target/at91rm9200.cfg
// 
// Perhaps jtag_rclk 8 should be used, i.e. use RCLK if it is supported

// and fall back to 8 khz. Of course post reset init jtag_rclk's fallback
// frequency could be increased.
/jtalg_rclk 0

I think is better
then If the board need to overwrite it the do it after the source of the soc
file

Best Regards,
  
please respect the 1/6 (Processor frequency / JTAG frequency) in case 
the RTCK is not present, not featured by the device by the board or not 
supported by the JTAG interface.


please use
jtag_rclk 5
in your case.

If the RTCK mechanism is supported by your device / your board / your 
JTAG interface, the JTAG will start generating TCK edges at the maximum 
frequency featured by the JTAG interface ( as 30MHZ for a Amontec 
JTAGkey-2 ).
The frequency will be controlled by the target via the RTCK signal. So 
no need to be worry about the frequency of the processor, regarding post 
init reset procedure ...


Laurent Gauch
 http://www.amontec.com/
 Amontec JTAGkey-2 : High speed USB JTAG interface with RTCK / 24mA 
output driver / auto-sense 1.4V to 5.5V !

 http://www.amontec.com/jtagkey.shtml












___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-05 Thread Jonas Hoerberg
On Wednesday, May 04, 2011 8:08 PM , Øyvind Harboe wrote:
 On Wed, May 4, 2011 at 7:51 PM, Jean-Christophe PLAGNIOL-VILLARD
 plagn...@jcrosoft.com wrote:
  On 04:17 Wed 04 May     , Ųyvind Harboe wrote:
   why do you want to set one the adapter is in auto adaptive mode by 
   default
   no need to set any speed
 
  OpenOCD doesn't have an auto-adaptive mode, so I guess you need
  to explain what you are referring to.
 
  on J-Link
 
  if you set the speed to 0x
  then the adapter will automaticly adaptive clocking
 
 Are you talking about RCLK? Sounds like the RCLK support
 in jlink adapter does not report back properly to OpenOCD.
 
 OpenOCD uses 0 to -speed() to mean RCLK.
 
 If jlink has some other magic value, then the jlink driver needs
 to do the translation.


/* Sets speed in kHz. */
static int jlink_speed(int speed)
{
...
/* check for RTCK setting */
if (speed == 0)
speed = -1;

usb_out_buffer[0] = EMU_CMD_SET_SPEED;
usb_out_buffer[1] = (speed  0)  0xff;
usb_out_buffer[2] = (speed  8)  0xff;
...
}
...
static int jlink_khz(int khz, int *jtag_speed)
{
*jtag_speed = khz;

return ERROR_OK;
}

So the translation is in place.

The previous behaviour for all adapters when no speed was set in the init 
script resulted in that jtag-speed()  was called with 0 as the parameter.
For jlink (jlink_speed(0)) this resulted in setting the adapter to the RTCK 
mode.
This is not a good default mode because not all target boards supports RTCK.

The at91rm9200-ek.cfg script is fixed by taking the lowest speed setting from 
the reset init procedure. See the patch below.
The same must be done for many of the other board scripts.
If the target board support RTCK then I also suggest that the adapter_khz calls 
is replaced by jtag_rclk. This will benefit adapters with RTCK support.

Best regards
Jonas Hörberg

diff --git a/tcl/board/at91rm9200-ek.cfg b/tcl/board/at91rm9200-ek.cfg
index 07a006b..cf0fb7a 100644
--- a/tcl/board/at91rm9200-ek.cfg
+++ b/tcl/board/at91rm9200-ek.cfg
@@ -18,6 +18,8 @@ $_TARGETNAME configure -event reset-init { at91rm9200_ek_init 
}
 set _FLASHNAME $_CHIPNAME.flash
 flash bank $_FLASHNAME cfi 0x1000 0x0080 2 2 $_TARGETNAME
 
+# The chip may run @ 32khz, so set a really low JTAG speed
+adapter_khz 8
 
 proc at91rm9200_ek_init { } {
# Try to run at 1khz... Yea, that slow!
# Chip is really running @ 32khz
adapter_khz 8

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-05 Thread Øyvind Harboe
Merged.

Thanks!


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-05 Thread Jean-Christophe PLAGNIOL-VILLARD
 Best regards
 Jonas Hörberg
 
 diff --git a/tcl/board/at91rm9200-ek.cfg b/tcl/board/at91rm9200-ek.cfg
 index 07a006b..cf0fb7a 100644
 --- a/tcl/board/at91rm9200-ek.cfg
 +++ b/tcl/board/at91rm9200-ek.cfg
 @@ -18,6 +18,8 @@ $_TARGETNAME configure -event reset-init { 
 at91rm9200_ek_init }
  set _FLASHNAME $_CHIPNAME.flash
  flash bank $_FLASHNAME cfi 0x1000 0x0080 2 2 $_TARGETNAME
  
 +# The chip may run @ 32khz, so set a really low JTAG speed
 +adapter_khz 8
this is the wrong place it's not board specific but soc specific

tcl/target/at91rm9200.cfg

Best Regards.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-05 Thread Øyvind Harboe
 +# The chip may run @ 32khz, so set a really low JTAG speed
 +adapter_khz 8
 this is the wrong place it's not board specific but soc specific

 tcl/target/at91rm9200.cfg

Perhaps jtag_rclk 8 should be used, i.e. use RCLK if it is supported
and fall back to 8 khz. Of course post reset init jtag_rclk's fallback
frequency could be increased.

I think in some ways the speed does belong in the board as they
could let be of bringing out rclk on the JTAG connector and
perhaps the board only supports or rather works with a lower
frequency that what the part could do.

Certainly the target script could have a default jtag_rclk 8, I suppose.

Patches gladly accepted!


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-04 Thread Jean-Christophe PLAGNIOL-VILLARD
On 04:17 Wed 04 May , Øyvind Harboe wrote:
  why do you want to set one the adapter is in auto adaptive mode by default
  no need to set any speed
 
 OpenOCD doesn't have an auto-adaptive mode, so I guess you need
 to explain what you are referring to.

on J-Link

if you set the speed to 0x
then the adapter will automaticly adaptive clocking

Best Regards,
J.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-04 Thread Øyvind Harboe
On Wed, May 4, 2011 at 7:51 PM, Jean-Christophe PLAGNIOL-VILLARD
plagn...@jcrosoft.com wrote:
 On 04:17 Wed 04 May     , Ųyvind Harboe wrote:
  why do you want to set one the adapter is in auto adaptive mode by default
  no need to set any speed

 OpenOCD doesn't have an auto-adaptive mode, so I guess you need
 to explain what you are referring to.

 on J-Link

 if you set the speed to 0x
 then the adapter will automaticly adaptive clocking

Are you talking about RCLK? Sounds like the RCLK support
in jlink adapter does not report back properly to OpenOCD.

OpenOCD uses 0 to -speed() to mean RCLK.

If jlink has some other magic value, then the jlink driver needs
to do the translation.

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Jean-Christophe PLAGNIOL-VILLARD
Please revert this break the rm9200-ek with jlink

where we do have a adapter_khz specified in the init script

Best Regards,
J.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Øyvind Harboe
Please be more specific. We intend to move forward on this one and
we are interested in hearing what problems you are seeing.

This is an important and somewhat tricky problem that we intend
to put to bet once and for all, and knew that there were risks of
regressions before we would get it right.


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Jean-Christophe PLAGNIOL-VILLARD
On 14:26 Tue 03 May , Øyvind Harboe wrote:
 Please be more specific. We intend to move forward on this one and
 we are interested in hearing what problems you are seeing.
 
 This is an important and somewhat tricky problem that we intend
 to put to bet once and for all, and knew that there were risks of
 regressions before we would get it right.
 
# ./build/src/openocd -c interface jlink -c jlink pid 0x102 -f 
board/at91rm9200-ek.cfg -s tcl
Open On-Chip Debugger 0.5.0-dev-00871-g2a28ce8-dirty (2011-05-03-20:04)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
Warn : Adapter driver 'jlink' did not declare which transports it allows; 
assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
dcc downloads are enabled
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
at91rm9200_ek_init
Info : J-Link initialization started / target CPU reset initiated
Info : J-Link compiled Jul 30 2008 11:24:37 ARM Rev.5
Info : J-Link caps 0x80d7bbf
Info : J-Link hw version 52000
Info : J-Link hw type J-Link
Info : J-Link max mem block 9992
Info : J-Link configuration
Info : USB-Address: 0x1
Info : Kickstart power on JTAG-pin 19: 0x
Info : Vref = 3.261 TCK = 1 TDI = 0 TDO = 1 TMS = 0 SRST = 0 TRST = 0
Info : J-Link JTAG Interface ready
Error: An adapter speed is not selected in the init script. Insert a call to 
adapter_khz or jtag_rclk to proceed.
in procedure 'init'

Best Regards,
J.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Øyvind Harboe
The error message is working as intended, near as I can tell.

You have to specify the JTAG communication frequency, there
no longer is any concept of a default frequency.

These scripts are missing a statement to set the JTAG communication
frequency.

Patches gladly accepted!


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Jean-Christophe PLAGNIOL-VILLARD
On 15:52 Tue 03 May , Øyvind Harboe wrote:
 The error message is working as intended, near as I can tell.
 
 You have to specify the JTAG communication frequency, there
 no longer is any concept of a default frequency.
 
 These scripts are missing a statement to set the JTAG communication
 frequency.
 
 Patches gladly accepted!
why do you want to set one the adapter is in auto adaptive mode by default
no need to set any speed

Best Regards,
J.
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-03 Thread Øyvind Harboe
 why do you want to set one the adapter is in auto adaptive mode by default
 no need to set any speed

OpenOCD doesn't have an auto-adaptive mode, so I guess you need
to explain what you are referring to.


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-05-01 Thread Øyvind Harboe
Merged.

Thanks!

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Øyvind Harboe
Any objections?

I'd rather like to hear some testing feedback on this one!


-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Øyvind Harboe
Test results using dummy interface.



a) Failure as expected without settings speed:

openocd -c interface dummy
Open On-Chip Debugger 0.5.0-dev-00867-g9ae4ddd (2011-04-29-12:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Error: An adapter speed is not selected in the init script. Insert a
call to adapter_khz or jtag_rclk to proceed.
in procedure 'init'


b) No failure when setting speed:

openocd -c interface dummy;adapter_khz 1
Open On-Chip Debugger 0.5.0-dev-00867-g9ae4ddd (2011-04-29-12:45)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
1 kHz
Info : clock speed 1 kHz
Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!



-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Jonas Hoerberg
Test results:
JTAGkey-Tiny (FT2232D): Works
JTAGkey2 (FT2232H): Works
Parport (Wiggler clone):
Works as long as any calls to parport_toggling_time is done after the speed 
is set.
It cannot be called before because the 
parport_handle_parport_toggling_time_command function calls jtag_get_speed 
that with the patch returns an error until a speed is selected.

Best regards
Jonas Hörberg

___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Øyvind Harboe
So is this something that should be fixed or is this an
inherent limitation of the parport driver?

The parport drivers main purpose, IMHO, is to act as reference
code for the bitbang driver.

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Jonas Hoerberg

On Friday, April 29, 2011 3:03 PM, Øyvind Harboe 
[mailto:oyvind.har...@zylin.com] wrote:
 
 So is this something that should be fixed or is this an
 inherent limitation of the parport driver?
 
 The parport drivers main purpose, IMHO, is to act as reference
 code for the bitbang driver.

I believe that extremely  few use the parport_toggling_time_command command. 
However the bug will be very annoying for those who does.
My opinion is that we should fix this or else we should remove the  parport 
toggling time setting feature.
I see some quick and dirty fixes but none quick and clean fix at the moment.
Alternative A: make parport_handle_parport_toggling_time_command ignore the 
return value of jtag_get_speed.
Alternative B: make parport_handle_parport_toggling_time_command skip the 
jtag_get_speed call when bitbang_interface is clear.

/Jonas Hörberg
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-29 Thread Øyvind Harboe
On Fri, Apr 29, 2011 at 3:32 PM, Jonas Hoerberg
jhorb...@sauer-danfoss.com wrote:

 On Friday, April 29, 2011 3:03 PM, Øyvind Harboe 
 [mailto:oyvind.har...@zylin.com] wrote:

 So is this something that should be fixed or is this an
 inherent limitation of the parport driver?

 The parport drivers main purpose, IMHO, is to act as reference
 code for the bitbang driver.

 I believe that extremely  few use the parport_toggling_time_command 
 command. However the bug will be very annoying for those who does.
 My opinion is that we should fix this or else we should remove the  parport 
 toggling time setting feature.
 I see some quick and dirty fixes but none quick and clean fix at the moment.
 Alternative A: make parport_handle_parport_toggling_time_command ignore the 
 return value of jtag_get_speed.
 Alternative B: make parport_handle_parport_toggling_time_command skip the 
 jtag_get_speed call when bitbang_interface is clear.

I don't mind leaving a hack behind in the parport driver to move
things forward here.

Perhaps add a hack in a seperate patch with some good comments?

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-28 Thread Øyvind Harboe
I haven't been able to test, but this does indeed seem
like what we need.

Testing anyone?

Do we want to do away with adapter_speed as user visible command entirely?

The error message should use adapter_khz instead of adapter_speed.

-- 
Øyvind Harboe

Can Zylin Consulting help on your project?

US toll free 1-866-980-3434 / International +47 51 87 40 27

http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] [PATCH] adapter speed: require init script setting and centralize activation from drivers to core.c

2011-04-28 Thread Jonas Hoerberg

On Thursday, April 28, 2011 12:38 PM, Øyvind Harboe 
[mailto:oyvind.har...@zylin.com] wrote:
 
 I haven't been able to test, but this does indeed seem
 like what we need.
 
 Testing anyone?
 
 Do we want to do away with adapter_speed as user visible command entirely?
 
 The error message should use adapter_khz instead of adapter_speed.
 

I do not think there exist a command named adapter_speed.
A patch with a corrected error message is attached.

/Jonas Hörberg

Signed-off-by: Jonas Hörberg jhorb...@sauer-danfoss.com
---
 src/jtag/core.c  |   15 +++
 src/jtag/drivers/amt_jtagaccel.c |6 --
 src/jtag/drivers/ft2232.c|6 --
 src/jtag/drivers/gw16012.c   |5 -
 src/jtag/drivers/jlink.c |5 -
 src/jtag/drivers/parport.c   |4 
 src/jtag/drivers/presto.c|7 ---
 src/jtag/drivers/rlink.c |5 -
 src/jtag/drivers/usb_blaster.c   |6 --
 src/jtag/zy1000/zy1000.c |5 -
 10 files changed, 11 insertions(+), 53 deletions(-)

diff --git a/src/jtag/core.c b/src/jtag/core.c
index 4c5d37a..55bb2a8 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -124,7 +124,7 @@ static struct jtag_event_callback *jtag_event_callbacks;
 static int speed_khz = 0;
 /* speed to fallback to when RCLK is requested but not supported */
 static int rclk_fallback_speed_khz = 0;
-static enum {CLOCK_MODE_SPEED, CLOCK_MODE_KHZ, CLOCK_MODE_RCLK} clock_mode;
+static enum {CLOCK_MODE_UNSELECTED, CLOCK_MODE_KHZ, CLOCK_MODE_RCLK} 
clock_mode;
 static int jtag_speed = 0;

 static struct jtag_interface *jtag = NULL;
@@ -1389,12 +1389,22 @@ int adapter_init(struct command_context *cmd_ctx)
return retval;
}

+   if (CLOCK_MODE_UNSELECTED == clock_mode)
+   {
+   LOG_ERROR(An adapter speed is not selected in the init script.
+Insert a call to adapter_khz or jtag_rclk to 
proceed.);
+   return ERROR_JTAG_INIT_FAILED;
+   }
+
int requested_khz = jtag_get_speed_khz();
int actual_khz = requested_khz;
int jtag_speed_var;
retval = jtag_get_speed(jtag_speed_var);
if (retval != ERROR_OK)
return retval;
+   retval = jtag-speed(jtag_speed_var);
+   if (retval != ERROR_OK)
+   return retval;
retval = jtag_get_speed_readable(actual_khz);
if (ERROR_OK != retval)
LOG_INFO(adapter-specific clock speed value %d, 
jtag_speed_var);
@@ -1647,9 +1657,6 @@ int jtag_get_speed(int *speed)
 {
switch(clock_mode)
{
-   case CLOCK_MODE_SPEED:
-   *speed = jtag_speed;
-   break;
case CLOCK_MODE_KHZ:
adapter_khz_to_speed(jtag_get_speed_khz(), speed);
break;
diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c
index ee44a2b..a433e81 100644
--- a/src/jtag/drivers/amt_jtagaccel.c
+++ b/src/jtag/drivers/amt_jtagaccel.c
@@ -506,12 +506,6 @@ static int amt_jtagaccel_init(void)
aw_control_fsm |= 0x04;
AMT_AW(aw_control_fsm);

-   int jtag_speed_var;
-   int retval = jtag_get_speed(jtag_speed_var);
-   if (retval != ERROR_OK)
-  return retval;
-   amt_jtagaccel_speed(jtag_speed_var);
-
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config  RESET_TRST_OPEN_DRAIN)
aw_control_rst = ~0x8;
diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c
index fdabb64..8c2382a 100644
--- a/src/jtag/drivers/ft2232.c
+++ b/src/jtag/drivers/ft2232.c
@@ -2485,12 +2485,6 @@ static int ft2232_init(void)
return ERROR_JTAG_INIT_FAILED;
}

-   int jtag_speed_var;
-   retval = jtag_get_speed(jtag_speed_var);
-   if (retval != ERROR_OK)
-   return retval;
-   ft2232_speed(jtag_speed_var);
-
buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
if ((retval = ft2232_write(buf, 1, bytes_written)) != ERROR_OK)
{
diff --git a/src/jtag/drivers/gw16012.c b/src/jtag/drivers/gw16012.c
index 1729299..22a37ac 100644
--- a/src/jtag/drivers/gw16012.c
+++ b/src/jtag/drivers/gw16012.c
@@ -529,11 +529,6 @@ static int gw16012_init(void)
gw16012_input(status_port);
gw16012_msb = (status_port  0x80) ^ 0x80;

-   int jtag_speed_var;
-   int retval = jtag_get_speed(jtag_speed_var);
-   if (retval != ERROR_OK)
-   return retval;
-   gw16012_speed(jtag_speed_var);
gw16012_reset(0, 0);

return ERROR_OK;
diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c
index 6eb707a..adaa640 100644
--- a/src/jtag/drivers/jlink.c
+++ b/src/jtag/drivers/jlink.c
@@ -439,11 +439,6 @@ static int jlink_init(void)
jlink_reset(0, 0);
jtag_sleep(3000);
jlink_tap_init();
-