aboutsummaryrefslogtreecommitdiff
path: root/tcl/interface/raspberrypi5-gpiod.cfg
blob: f3fdde0f204d31ad8511716c95d0e920f288c83a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# SPDX-License-Identifier: GPL-2.0-or-later

# Config for Raspberry Pi 5 used as a bitbang adapter.
# https://www.raspberrypi.com/documentation/computers/raspberry-pi.html

# Raspberry Pi 5 is not compatible with bcm2835gpio native GPIO driver.
# The linuxgpiod driver without configurable adapter speed runs at approximately
# 800 kHz (SWD writes) and 360 kHz (SWD reads)

adapter driver linuxgpiod

proc read_file { name } {
	if {[catch {open $name r} fd]} {
		return ""
	}
	set result [read $fd]
	close $fd
	return $result
}

set pcie_aspm [read_file /sys/module/pcie_aspm/parameters/policy]
# escaping [ ] characters in string match pattern does not work in Jim-Tcl
if {![string match "*<performance>*" [string map { "\[" < "\]" > } $pcie_aspm]]} {
	echo "Warn : Switch PCIe power saving off or the first couple of pulses gets clocked as fast as 20 MHz"
	echo "Warn : Issue 'echo performance | sudo tee /sys/module/pcie_aspm/parameters/policy'"
}

set GPIO_CHIP 4
source [find interface/raspberrypi-gpio-connector.cfg]