Controlling LEDs through a 74x164 shift register

Dear All,

Next on my list of things to sort out on my Netgear WAC510 is the LEDs.

From the Netgear firmware bootlog, I see these lines:

[    0.154086] gpiochip_add: registered GPIOs 0 to 69 on device: 1000000.pinctrl
[    0.154106] GPIO chip 1000000.pinctrl: created GPIO range 0->69 ==> 1000000.pinctrl PIN 0->69
[    0.156359] sps:sps is ready.
[    0.161704] bio: create slab <bio-0> at 0
[    0.162620] of_get_named_gpiod_flags exited with status 0
[    0.162640] of_get_named_gpiod_flags exited with status 0
[    0.162675] gpiochip_find_base: found new base at 248
[    0.162823] gpiochip_add: registered GPIOs 248 to 255 on device: shift_register_74hc164.7

The Netgear firmware addresses the LEDs using GPIO's 248-254, so I think it's safe to assume they're connected to the 74x164 shift register.

I've compiled my initramfs OpenWrt image with 74x164 and spi support, but the 74x164 chip isn't being detected.

Does anyone have any pointers on how to make the 74x164 kernel module 'see' the chip on the board and control the LEDs?

All I've got so far is a gpiochip0 (base 0) which gives me gpio0->gpio99. If I set all the pins to outputs and toggle them on/off I get weird results which makes me think perhaps the gpiochip0 is taking over the 74x164 address space.

For example:
If I set gpio0-4 as '1', all 7 LEDs light up in one go. If I then toggle gpio5 high/low, after each toggle one more LED goes out, in order starting from one side of the board until all the LEDs are off again. All from toggling gpio5.

If I go all the way through and get up to gpio63, I can toggle the eth1 port.

Am I right in thinking the 74x164 chip is being controlled by the wrong module? How do you fix that if it is, and what else is going on if it isn't?

Many thanks,

Tim

So, the gpio's are currently connected to:
/sys/devices/platform/soc/1000000.pinctrl/gpiochip0/

I wonder if that's wrong, and if some of those gpio's should instead be connected to another SPI bus? My soc is currently showing these:
root@OpenWrt:/# ls -l /sys/devices/platform/soc/
1000000.pinctrl/ a6000.hsphy/
1800000.clock-controller/ a8000.hsphy/
1949000.tcsr/ a800000.wifi/
194b000.tcsr/ b012000.regulator/
1953000.ess_tcsr/ b017000.watchdog/
1957000.tcsr/ b088000.clock-controller/
2089000.regulator/ b098000.clock-controller/
22000.rng/ b099000.regulator/
4ab000.restart/ b0a8000.clock-controller/
60f8800.usb2/ b0a9000.regulator/
7884000.dma/ b0b8000.clock-controller/
78af000.serial/ b0b9000.regulator/
78b5000.spi/ c000000.ess-switch/
8af8800.usb3/ c080000.edma/
8e04000.dma/ driver_override
8e3a000.crypto/ modalias
90000.mdio/ of_node/
98000.ess-psgmii/ subsystem/
9a000.ssphy/ uevent
a000000.wifi/

Thoughts, anyone?

Tim

I think I need the stock Device Tree (dts) file for my device. Booting into the stock Netgear firmware I can see the device tree under /proc and the entries I'm trying to create are all in there.

So, anyone know how to extract a DTS file?

Tim

Have you configured chip select for shift register in your DTS?
Do you maybe have source code on github?

Hi robimarko,

I've not made my DTS yet, so no :slight_smile:

I'm just starting to make my DTS, based on the extracted one from the stock kernel and another similar device (Netgear EX6100v2).

Can't find any reference to the shift register in the stock DTS though, so I must be missing something..

Tim

Which SoC is inside?

You can see what Linux documentation requires for DTS based 74x164
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/Documentation/devicetree/bindings/gpio/gpio-74x164.txt?h=v4.9.85
Can you post stock DTS you are referring to?

The stock kernel reports it as
IPQ40xx/AP-DK01.1-C2

I can't seem to paste in the stock DTS - it's too big apparently.

I'll find a 3rd party to host it..

Thank you for the link,

Tim

Here's the stock dts:

Tim

Ok, so that is basically based on reference board.
That should really ease development as OpenWRT has support for that board with this and couple of later patches fixing some issues
https://github.com/openwrt/openwrt/blob/master/target/linux/ipq806x/patches-4.9/0026-dts-ipq4019-Add-support-for-IPQ4019-DK04-board.patch

Have you added support for any device to OpenWRT before?

regarding your initial question about 74x164: You are aware of this commit?
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=34e9937f2afdf512506836e27cbc4a720049453f

Just to make sure your sources are up to date and not from 2017...

No, I've not made a DTS before.. I'd never even heard of a DTS until last week! I've used Linux for years, but I've only been aware of OpenWrt for a few years and have always wanted to figure out how people seem to get their devices working with it. Adding support for my device seems like a good way to contribute back :slight_smile:

I'm managing to boot into an initramfs version of the ipq4019-ap.dk01.c1 via a console cable and uboot. I can get 2.4Ghz wifi working using the calibration data and the BDF file for the ath10k module. Not tried the 5Ghz yet. The eth1 port is working too, all using the DTS from ipq4019-ap.dk01.c1.

But the LEDs are on this shift register which I think needs to be defined in the DTS.. The stock firmware lists the shift register under /proc/device-tree/soc as 'shift_register_74hc164', but it doesn't give an address for it or any other way to communicate with it. Where is the magic in the stock DTS that links the 74hc164 to the gpio's? I couldn't see it listed in there....?

Thank you for your time,

Tim

Thank you @tmomas - my sources are about a month old.. I'll update them.

Tim

I may have found their patch for SSR.
DTS is Device tree source, pretty much defines everything about the device.

Can you provide full boot log on stock firmware and one when you initramfs image?

I can whip up quick DTS with SSR so you can test it.

Wow - thank you @robimarko!

Here's the stock bootlog up until it gets to trying to load init:


And here's it booting my initramfs:


Tim

Great,I am just looking at it.
I should have a image tommorow ready.
Like always SSR will take a couple of tries.

Here is the tree,I got syntax error somewhere.
Most likely shift register is the culprit.

I was trying to compile Netgear GPL but I always get stuck on OpenSSL with some weird ggdb missing.
That way full DTS would be visible

Wow - thank you again!

I'll try it first thing in the morning as my device is at work..

Am I correct in thinking that the important parts in the DTS file are the numbers 4 and 5 in the spi-gpio block, which denote the GPIO pins that the SPI bus is located on?

I can physically see the 74hc164 chip on the PCB, so I may be able to buzz it out, but I do think at least one of the SPI pins is 5 as that's the one that gives me the weird LED signals when I toggle it. I look forward to trying it out tomorrow..

I get the same openssl errors when I try to compile the Netgear GPL'd firmware. I got further through the compiling of it by replacing the openssl package with the latest one, but then different errors came up as openssl had removed a function which was referred to and I went to the OpenWrt build system instead.

Tim

It still needs to be compiled, there is a syntax error in the DTS which prevents it from compiling properly.
I think that in the end, I will not just include DTS for the reference board, but instead move all relevant parts into WAC510 DTS like I did with Jalapeno.
Most likely, shift register block is not indented correctly, or something like that.
GPIO4 is data GPIO and GPIO5 is serial clock one.

I don't know if I will have time today or will have to do it tomorrow.

Thank you, there's no rush. Tomorrow I'll do some more DTS reading and find some more examples to see if I can make it compile too.

Tim

Actually, got some free time now.
I am gonna extract everything to a single DTS instead of including reference board one.

Also, can you send me BDF files you extracted since those are required for ipq-wifi so the ath10k driver will be able to load calibration?