Onboard LEDs connected to the RK805-1 out1 and out2 GPIO pins
#1
Are the two LEDs (white and red) that are connected to the RK805-1 out1 and out2 pins (which seem to be general purpose IO pins according to the data sheet) controllable from user space somehow? I have noticed that at least the u-boot-spi flash tool can blink the red LED and also at least one of the available images I tried turned off the red LED after successful boot. The image I am currently running leaves both LEDs turned on all the time.
  Reply
#2
The purpose is to turn off the LEDs?
  Reply
#3
The purpose would be to make them usable for my own application.

I have searched through /sys and found device tree entries, so there was at least the intention to make them known to the kernel and use them somehow:
Code:
find /sys -name *-led
/sys/firmware/devicetree/base/leds/power-led
/sys/firmware/devicetree/base/leds/standby-led

Code:
ls -la /sys/firmware/devicetree/base/leds/standby-led
total 0
drwxr-xr-x 2 root root  0 Feb 24 11:32 .
drwxr-xr-x 4 root root  0 Feb 24 11:31 ..
-r--r--r-- 1 root root  3 Feb 24 12:06 default-state
-r--r--r-- 1 root root 12 Feb 24 12:06 gpios
-r--r--r-- 1 root root 14 Feb 24 12:06 linux,default-trigger
-r--r--r-- 1 root root 12 Feb 24 12:06 name

Code:
cat /sys/firmware/devicetree/base/leds/standby-led/linux,default-trigger
disk-activity

Code:
cat -v /sys/firmware/devicetree/base/leds/standby-led/gpios
^@^@^@z^@^@^@^@^@^@^@^A

Some things like trigger look very similar to what I have read elsewhere about other Linux LED drivers but none of these tutorials does really apply to this one and I cannot find any device node to control them.
  Reply
#4
I have found that I can control them by bypassing the driver and directly writing to the chip registers. The RK805 is connected to i2c-1 with address 0x18 and the two GPIOs can be controlled by the two lowest bits in register 0x52.

They are low-active, so to turn them both off write 3 to the register (binary 0b00000011):


Code:
i2cset -f -y 1 0x18 0x52 3



and to turn them on set the corresponding bit to 0, so by writing any of the numbers 0, 1, 2, 3 to that register both LEDs can be controlled.

But this is not the proper way to do it!

I had to use -f because the rk808 driver is already using that bus address! I'm interfering with its function in a very dangerous way by issuing commands directly to the chip behind the driver's back. And it is the power supply chip, I guess I could wreak havok by accidentally changing one of the output voltages, I would rather not mess around on the i2c of this chip directly.
Is here somebody who knows enough about the rk808 driver to tell me the proper way to control these two bits in the out register of the chip or whether they are already registered in the sysfs as a gpio under some other obscure name that I did not find? Where should I look next?

there is also /sys/bus/platform/devices/rk8xx-gpio which belongs to this driver but I have no idea how it works and how to use it.

writing 0b11 to this register to turn them off will even survive a warm reboot! The LEDs are still off!
So neither the rk808 driver nor anything else will even try to initialize them, they don't seem to be controlled by anything at the moment, despite the entries in the device tree.
  Reply
#5
Code:
-- Override tiriger-source --
$ sudo sh -c "echo 'none' > /sys/devices/platform/leds/leds/power-led/trigger"
$ sudo sh -c "echo 'none' > /sys/devices/platform/leds/leds/standby-led/trigger"

-- LED on/off --
$ sudo sh -c "echo '0' > /sys/devices/platform/leds/leds/power-led/brightness"
$ sudo sh -c "echo '0' > /sys/devices/platform/leds/leds/standby-led/brightness"
$ sudo sh -c "echo '255' > /sys/devices/platform/leds/leds/power-led/brightness"
$ sudo sh -c "echo '255' > /sys/devices/platform/leds/leds/standby-led/brightness"

> So neither the rk808 driver nor anything else will even try to initialize them...
Some version of kernel that fails to initialize rk8xx-gpio also exists.
Therefore, its symptom depends on the version of kernel.
  Reply
#6
Quote:t4_4tCode:
-- Override tiriger-source --
$ sudo sh -c "echo 'none' > /sys/devices/platform/leds/leds/power-led/trigger"
$ sudo sh -c "echo 'none' > /sys/devices/platform/leds/leds/standby-led/trigger"

-- LED on/off --
$ sudo sh -c "echo '0' > /sys/devices/platform/leds/leds/power-led/brightness"
$ sudo sh -c "echo '0' > /sys/devices/platform/leds/leds/standby-led/brightness"
$ sudo sh -c "echo '255' > /sys/devices/platform/leds/leds/power-led/brightness"
$ sudo sh -c "echo '255' > /sys/devices/platform/leds/leds/standby-led/brightness"

> So neither the rk808 driver nor anything else will even try to initialize them...
Some version of kernel that fails to initialize rk8xx-gpio also exists.
Therefore, its symptom depends on the version of kernel.

there are no leds at all in /sys/devices/platform/leds

Code:
--(#)-- ls -la /sys/devices/platform/leds/
total 0
drwxr-xr-x  3 root root    0 Feb 25 12:13 .
drwxr-xr-x 76 root root    0 Feb 25 10:23 ..
-rw-r--r--  1 root root 4096 Feb 25 12:13 driver_override
-r--r--r--  1 root root 4096 Feb 25 12:13 modalias
lrwxrwxrwx  1 root root    0 Feb 25 12:13 of_node -> ../../../firmware/devicetree/base/leds
drwxr-xr-x  2 root root    0 Feb 25 12:13 power
lrwxrwxrwx  1 root root    0 Feb 25 12:13 subsystem -> ../../../bus/platform
-rw-r--r--  1 root root 4096 Feb 25 12:13 uevent


Code:
--(#)-- uname -r
4.4.103-rockchip-ayufan-175

I can't remember which of the downloadable images that was, i suspect it was one of the 0.6.x ones. I have already configured lots of stuff all over the place, so I can't just start over with a different image.

Can I install just the kernel from a different image without having to install and configure all the stuff again from scratch?
  Reply
#7
The kernel you are using is a version problem with "rk8xx-gpio".
As far as I know, I know that there are problems with the following Kernel versions.

x 0.6.2: jenkins-linux-build-rock-64-146 <-> 0.6.16: jenkins-linux-build-rock-64-177
# dmesg | grep "rk8xx-gpio: register"
[ 2.431774] rk8xx-gpio rk8xx-gpio: register rk8xx gpiochip fail: -28
# ls /sys/devices/platform/leds/leds/
ls: cannot access '/sys/devices/platform/leds/leds/': No such file or directory

----
o Other-ver:
# dmesg | grep "rk8xx-gpio: register"
[ 2.381873] rk8xx-gpio rk8xx-gpio: register rk8050 gpio successful
# ls /sys/devices/platform/leds/leds/
power-led standby-led

----
As kernel-upgrading may involve side effects,
Please do after taking a backup etc.

kernel upgrade: https://github.com/ayufan-rock64/linux-build/releases
example: ( @Stretch-minimal image )
download linux-image-4.4.103-rockchip-ayufan-187_0.6.21_arm64.deb
after
dpkg -i ./linux-image-4.4.103-rockchip-ayufan-187_0.6.21_arm64.deb
  Reply
#8
It also depends on how the leds are configured/bound in the devicetree for a certain kernel/image version:

https://github.com/ayufan-rock64/linux-k...64.dts#L54
Come have a chat in the Pine IRC channel >>
  Reply
#9
it works indeed the way t4_4t said when I use a newer kernel than the one I accidentally happened to use when I posted this thread. There are now entries in the sysfs for both LEDs and they work.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 Rev3 doesn't boot and leds blinking fast dishins 6 8,808 06-30-2022, 06:28 PM
Last Post: rookie_267
  need a dts file to set some pins as pulldown interrupts in kernel using a DTO dkebler 0 2,233 02-05-2020, 10:58 PM
Last Post: dkebler
  Gpio error wile using GPIOtest.py Aditya Rastogi 0 2,107 01-31-2019, 02:41 AM
Last Post: Aditya Rastogi
  Migrate Linux from microSD to onboard eMMC elik745i 7 11,189 11-03-2018, 08:23 AM
Last Post: mara
  Memory addresses of GPIO pins AckRite 3 5,513 10-23-2018, 03:18 PM
Last Post: AckRite
  GPIO indicators via DTB Mentaluproar 0 1,655 07-10-2018, 04:58 PM
Last Post: Mentaluproar
  RFLink connected to /dev/ttyUSB0 not working ulysse132 9 10,863 05-17-2018, 01:15 PM
Last Post: Rocklobster
  Onboard IR receiver plambe 3 4,769 03-01-2018, 04:28 AM
Last Post: plambe
  What is name of gpio hardware on a rock64? gene83 6 7,412 10-05-2017, 07:57 AM
Last Post: gene83

Forum Jump:


Users browsing this thread: 1 Guest(s)