MCP23008 Device Tree Overlay and Driver for Raspbian

I’ve enabled the i2c-a0 bus and now I’m trying to add support for my MCP23008 GPIO expander on the bus at address 0x23:

$ ls -al /sys/class/i2c-dev/
total 0
drwxr-xr-x  2 root root 0 Dec 31  1969 .
drwxr-xr-x 88 root root 0 Dec 31  1969 ..
lrwxrwxrwx  1 root root 0 Dec 31  1969 i2c-0 -> ../../devices/platform/soc/c8100000.bus/c8100500.i2c/i2c-0/i2c-dev/i2c-0
lrwxrwxrwx  1 root root 0 Oct 24 11:05 i2c-1 -> ../../devices/platform/soc/c883a000.hdmi-tx/i2c-1/i2c-dev/i2c-1

$ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                        

Here is the overlay:

/dts-v1/;
/plugin/;

/ {
        compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl";

        fragment@0 {
                target = <&i2c_AO>;
                __overlay__ {
                        status = "okay";
                };
        };

        fragment@1 {
                target = <&gpio>;
                __overlay__ {
                        mcp23008_pins: mcp23008_pins {
                                brcm,pins = <4>;
                                brcm,function = <0>;
                        };
                };
        };

        fragment@2 {
                target = <&i2c_AO>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;

                        mcp23008: mcp@23 {
                                compatible = "microchip,mcp23008";
                                reg = <0x23>;
                                gpio-controller;
                                #gpio-cells = <2>;
                                #interrupt-cells=<2>;
                                interrupt-parent = <&gpio>;
                                interrupts = <4 2>;
                                interrupt-controller;
                                microchip,irq-mirror;
                        };
                };
        };

        __overrides__ {
                gpiopin = <&mcp23008_pins>,"brcm,pins:0",
                                <&mcp23008>,"interrupts:0";
                addr = <&mcp23008>,"reg:0";
        };
};

It compiles and merges just fine, but it turns out there is also no driver for that IC:

$ ls -al /lib/modules/6.1.26-05272-g26c406245a2c/kernel/drivers/gpio
total 212
drwxr-xr-x 1 root root   502 Jul 13 18:16 .
drwxr-xr-x 1 root root   580 Jul 13 18:16 ..
-rw-r--r-- 1 root root 11136 Apr 27 03:43 gpio-74x164.ko
-rw-r--r-- 1 root root 15464 Apr 27 03:43 gpio-adnp.ko
-rw-r--r-- 1 root root 13184 Apr 27 03:43 gpio-altera.ko
-rw-r--r-- 1 root root  8480 Apr 27 03:43 gpio-bd9571mwv.ko
-rw-r--r-- 1 root root  8168 Apr 27 03:43 gpio-gw-pld.ko
-rw-r--r-- 1 root root 18352 Apr 27 03:43 gpio-max3191x.ko
-rw-r--r-- 1 root root  6816 Apr 27 03:43 gpio-max7300.ko
-rw-r--r-- 1 root root  7176 Apr 27 03:43 gpio-max7301.ko
-rw-r--r-- 1 root root  6736 Apr 27 03:43 gpio-max730x.ko
-rw-r--r-- 1 root root 14544 Apr 27 03:43 gpio-max732x.ko
-rw-r--r-- 1 root root  7728 Apr 27 03:43 gpio-mc33880.ko
-rw-r--r-- 1 root root  8744 Apr 27 03:43 gpio-pca9570.ko
-rw-r--r-- 1 root root 18552 Apr 27 03:43 gpio-pcf857x.ko
-rw-r--r-- 1 root root 10648 Apr 27 03:43 gpio-pisosr.ko
-rw-r--r-- 1 root root 10808 Apr 27 03:43 gpio-syscon.ko
-rw-r--r-- 1 root root  8896 Apr 27 03:43 gpio-tpic2810.ko
-rw-r--r-- 1 root root 11440 Apr 27 03:43 gpio-xra1403.ko

A couple of questions,
Does the devicetree overlay look correct?
The mcp23008 driver is normally part of the Raspbian build but it’s not in the Libre port…
Is this intentional?
Is there a way for me to customize the Raspbian kernel to include this driver in the Libre port?
Do I need to move away from Raspbian and go to Ubuntu or a custom build of Armbian?

You are using an kernel from older images. Please run the following:

sudo apt update
sudo apt install linux-image-lc-lts-arm64 linux-headers-lc-lts-arm64
sudo reboot

I’ve updated the kernel but it does not include drivers for this GPIO expander either and so the overlay cannot work to enable the expander through gpiod or any other normal gpio interface. I do not want to interact directly through a C++ class, what can I do about the driver missing?

For the device tree, read through https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt

The module isn’t enabled in our kernel. It’s been added and should go through CI and pushed to our servers in about 2 hours.

It has been pushed, please update the kernel and try again.