* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
static int dev_mem_fd;
static volatile uint32_t *pio_base;
-static int bcm2835gpio_read(void);
-static void bcm2835gpio_write(int tck, int tms, int tdi);
-static void bcm2835gpio_reset(int trst, int srst);
+static bb_value_t bcm2835gpio_read(void);
+static int bcm2835gpio_write(int tck, int tms, int tdi);
+static int bcm2835gpio_reset(int trst, int srst);
static int bcm2835_swdio_read(void);
static void bcm2835_swdio_drive(bool is_output);
static int speed_offset = 28;
static unsigned int jtag_delay;
-static int bcm2835gpio_read(void)
+static bb_value_t bcm2835gpio_read(void)
{
- return !!(GPIO_LEV & 1<<tdo_gpio);
+ return (GPIO_LEV & 1<<tdo_gpio) ? BB_HIGH : BB_LOW;
}
-static void bcm2835gpio_write(int tck, int tms, int tdi)
+static int bcm2835gpio_write(int tck, int tms, int tdi)
{
uint32_t set = tck<<tck_gpio | tms<<tms_gpio | tdi<<tdi_gpio;
uint32_t clear = !tck<<tck_gpio | !tms<<tms_gpio | !tdi<<tdi_gpio;
for (unsigned int i = 0; i < jtag_delay; i++)
asm volatile ("");
+
+ return ERROR_OK;
}
-static void bcm2835gpio_swd_write(int tck, int tms, int tdi)
+static int bcm2835gpio_swd_write(int tck, int tms, int tdi)
{
uint32_t set = tck<<swclk_gpio | tdi<<swdio_gpio;
uint32_t clear = !tck<<swclk_gpio | !tdi<<swdio_gpio;
for (unsigned int i = 0; i < jtag_delay; i++)
asm volatile ("");
+
+ return ERROR_OK;
}
/* (1) assert or (0) deassert reset lines */
-static void bcm2835gpio_reset(int trst, int srst)
+static int bcm2835gpio_reset(int trst, int srst)
{
uint32_t set = 0;
uint32_t clear = 0;
GPIO_SET = set;
GPIO_CLR = clear;
+
+ return ERROR_OK;
}
static void bcm2835_swdio_drive(bool is_output)
}
command_print(CMD_CTX,
- "BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdi = %d",
+ "BCM2835 GPIO config: tck = %d, tms = %d, tdi = %d, tdo = %d",
tck_gpio, tms_gpio, tdi_gpio, tdo_gpio);
return ERROR_OK;
LOG_INFO("JTAG and SWD modes enabled");
else
LOG_INFO("JTAG only mode enabled (specify swclk and swdio gpio to add SWD mode)");
- if (!is_gpio_valid(trst_gpio) && !is_gpio_valid(srst_gpio)) {
- LOG_ERROR("Require at least one of trst or srst gpios to be specified");
- return ERROR_JTAG_INIT_FAILED;
- }
} else if (bcm2835gpio_swd_mode_possible()) {
LOG_INFO("SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)");
} else {
return ERROR_JTAG_INIT_FAILED;
}
- /* set 16mA drive strength */
- pads_base[BCM2835_PADS_GPIO_0_27_OFFSET] = 0x5a000018 + 7;
+ /* set 4mA drive strength, slew rate limited, hysteresis on */
+ pads_base[BCM2835_PADS_GPIO_0_27_OFFSET] = 0x5a000008 + 1;
tdo_gpio_mode = MODE_GPIO(tdo_gpio);
tdi_gpio_mode = MODE_GPIO(tdi_gpio);