Db845 : gpio 1,2,3 and 4

hi,

cpu gpio 1,2,3 and 4 are not accessible in cat /sys/kernel/debug/gpio. currently it is configured as SPI gpios.
if we want to use these as generanl purpose gpios where do we need to change?

regards,
vinaysimha

They are defined as pinctrl qup_spi0_default in the device tree (arch/arm64/boot/dts/qcom/sdm845.dtsi) and selected by spi0 (spi0: spi@880000). However spi0 is ‘disabled’ so these pins should be available for use as gpio.

Eventhough spi0 is disabled, we are not able to access gpio 1,2,3 and 4 , cat sys/kernel/debug/gpio also does not shows, please suggest.

Well no sure which GPIO you refer here since SoC GPIO_1 is routed to CAN bus… If you look in /sys/class/gpio you’ll find three gpio controller, one of them is the primary pin controller (gpiochip361). That means gpios are indexed starting at 361 for this controller. So to the GPIO_1 you see on schematics is gpio 361 under linux. For example to control GPIO_10 which is routed to Low Speed Connector 1 pin 29, you can do the following:

$ echo 371 > /sys/class/gpio/export
$ echo out > sys/class/gpio/gpio371/direction
$ echo 1 > /sys/class/gpio/gpio371/value

Note that is the old (deprecated) way to control gpio (sysfs). The correct way would be to use gpio chardev (/dev/gpio*) e.g. via libgpiod. You can do the same with gpiod:

$ apt-get install gpiod
$ gpiodetect 
gpiochip0 [3400000.pinctrl] (151 lines)
gpiochip1 [c440000.spmi:pmic@0:gpios@c000] (26 lines)
gpiochip2 [c440000.spmi:pmic@2:gpios@c000] (14 lines)
$ gpioset gpiochip0 10=1

i am not able to access of gpios 81 and 82.

root@linaro-alip:~# gpioset gpiochip0 2=1
gpioset: error setting the GPIO line values: Invalid argument
root@linaro-alip:~# gpioset gpiochip0 81=1
gpioset: error setting the GPIO line values: Invalid argument
root@linaro-alip:~# gpioset gpiochip0 82=1
gpioset: error setting the GPIO line values: Invalid argument
root@linaro-alip:~#

/sys/kernel/debug/gpio does not starts with 0. it starts with 4

gpiochip0: GPIOs 361-511, parent: platform/3400000.pinctrl, 3400000.pinctrl:
gpio4 : out low func1 2mA no pull
gpio5 : out high func1 2mA pull up
gpio6 : in low func0 2mA pull down
gpio7 : in low func0 2mA pull down
gpio8 : in low func0 2mA pull down

gpio80 : in low func0 2mA pull down
gpio85 : in high func1 2mA pull down
gpio86 : in high func1 2mA pull down

gpio81, gpio82 are missing,

any suggestion how can i use the gpios 0-3, 81-82 as normal gpios[gpio_in / gpoi_out]?

Good question, I need to double check that since these pins are also missing in /sys/kernel/debug/pinctrl/3400000.pinctrl/pins.

So it seems to be an issue with console which is somewhat incomplete (too much data?). Use gpioinfo tool instead to get list of gpio (including used ones). I’m able to control these gpios on my side.

How/where to disable this GPIO to CAN bus and use it as normal GPIO?

GPIO 81-84 used for PCM/I2S, how to disable this GPIO and use it as normal GPIO/i2c?

@Loic

able to solve by modifying in devcfg.
thanks.