Raspberry Pi as JTAG programmer?
OpenOCD has a generic sysfsgpio driver and have had a specific Raspberry Pi BCM2835 driver for quite some time, and AFAICT the speed is fine (e.g. STM32F1 flashing is limited by the speed of its flash) - about 4&nbsp;MHz is easily obtainable and for many usecases no external circuity is needed. There's also support for SWD, but it's not yet upstream.

You should clone the current Git HEAD and compile it natively with --enable-bcm2835gpio, and then use config from interface/raspberrypi-native.cfg.

Please refer to the official README and Texinfo manual for the specifics.

Regarding the hardware part of the question: If the target voltage is equal or very close to 3.3&nbsp;V you can connect the Raspberry Pi's pins directly to the target interface, if not, you might (not always needed as many modern microcontrollers have "5 V-tolerant" pins, so they can be connected to sources with voltages higher than their Vcc without any damage, but check the documentation first!) need to add an appropriate voltage-translation buffer.

To provide better impedance-matching, it's recommended to have 47-100 ohms series resistors on every signal line, close to the Raspberry Pi connector. For more details, please see Michael Schwingen's detailed explanation, Re: High output drive capability in Raspberry Pi.