[Solved] ath79 support for MikroTik RB750r2 (hEX lite) => cs-gpios value for HC595-based network LEDs


I am adding ath79 support for the MikroTik RB750r2 (hEX lite), which was already supported by ar71xx. So far almost everything is working, only the network activity LEDs are missing and I got stuck there.

The patch is available at https://github.com/rogerpueyo/openwrt/tree/ath79-mikrotik-rb750-r2-hex-lite.

The 5 network activity LEDs are connected to an HC595 SPI serial shift register. In the DTS I declared it as:

&spi {
	status = "okay";

	// cs-gpios = <&gpio 0 0>; //Nope
	// cs-gpios = <0>, <&gpio 11 GPIO_ACTIVE_LOW>; //Nope
	// cs-gpios = <0>, <&gpio 11 GPIO_ACTIVE_HIGH; //Nope
	// cs-gpios = <&gpio 8 GPIO_ACTIVE_LOW>, <&gpio 11 GPIO_ACTIVE_HIGH>; //Nope

	ssr: ssr@1 {
		compatible = "fairchild,74hc595";
		#gpio-cells = <2>;
		registers-number = <1>;
		reg = <1>;
		spi-max-frequency = <50000000>;

and also added the 5 LEDs:

		led1 {
			label = "green:led1";
			gpios = <&ssr 0 GPIO_ACTIVE_LOW>;


		led5 {
			label = "green:led5";
			gpios = <&ssr 4 GPIO_ACTIVE_LOW>;

I configure the LEDs to be triggered by hearbeat:

cd /sys/class/leds
for i in gre*led?; do echo heartbeat > $i/trigger; done

but nothing happens until I do this trick to toggle the CS pin of the HC595 SSR (GPIO11 was already used in ar71xx):

cd /sys/class/gpio
echo 11 > export
cd gpio11
echo out > direction
while true; do echo 0 > value; echo 1 > value; done

Then, the 5 LEDs go ON/OFF with the heartbeat trigger.

I tried several cs-gpios configurations, as shown above, but I didn't find the correct one.

Can anyone please give me a hint on how to configure the cs-gpios parameter?

Thanks! :slight_smile:

Some ideas:
cs-gpios = <0>, <&gpio 11 GPIO_ACTIVE_LOW>; //Nope looks okay, but I don't know if it should be high or low. spi-cs-high (on the SPI child node) also interacts with this.


Some of the Mikrotik SPI devices use SPI_MODE_3: (cpol+cpha), so you may also need in the ssr node: spi-cpha; and spi-cpol;.
May also want to slow the speed.

Hi John,

Thanks for the pointers. Unfortunately, I couldn't make it work.

  1. The cs-gpios = <0>, <&gpio 11 GPIO_ACTIVE_LOW>; setting looks like it should work, based on the ar71xx code, but I must be missing something. I also tried with GPIO_ACTIVE_HIGH but it didn't make any difference.
  2. Same goes for spi-cs-high = <1>, didn't make any difference, either with GPIO_ACTIVE_HIGH or with GPIO_ACTIVE_LOW.
  3. Apparently, this device/SoC doesn't like SPI modes other than 0. Setting spi-cpha, spi-cpol, or both made the kernel complain about the bit being unsupported
  4. I reduced the speed to 5000000.

I was wondering if it actually made sense that I could export GPIO11 as if it was unused (e.g., I can't export GPIO4 which is wired to the usr LED). Shouldn't it be accessible under /sys/class/gpio/gpio11 if it was actually controlling the SRR's CS line?


Update: I found the solution in this pull request for the very similar RB952 device: https://github.com/openwrt/openwrt/pull/3295#issuecomment-677976211

Thanks @johnth for your tips.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.