portexpander board definition

Hello,

I have a MCP23017 portexpander connected to an nrf9160 board with I2C, can somebody please explain me, how to integrate the GPIOs of the portexpander in the devicetree?

This is the subnode in the I2C node:

portexp: portexp@20 {
        compatible = "microchip,mcp230xx";
        reg = <0x20>;
        gpio-controller;
        #gpio-cells = <2>;
		ngpios = <16>;
       	//interrupt-parent = <&gpio0>;
        //interrupts = <12 IRQ_TYPE_EDGE_RISING>; // You may need to adjust this GPIO number (12) based on your board configuration.
        //interrupt-controller;
        //#interrupt-cells = <2>;

		outputs {
			compatible = "gpio-outputs";
			gpio0: gpio0 {
				compatible = "gpio-out";
				gpio-hog;
				gpio-line-name = "PORTEXP_GPIO0";
				gpios = <&portexp 8 GPIO_ACTIVE_HIGH>;
				output-high;
			};

			gpio1: gpio1 {
				compatible = "gpio-out";
				gpio-hog;
				gpio-line-name = "PORTEXP_GPIO1";
				gpios = <&portexp 9 GPIO_ACTIVE_HIGH>;
				output-high;
			};
		};

		aliases {
			out1 = &gpio0;
			out2 = &gpio1;
		};
    };

I am getting the different erros when testing: "C:/Users/thoma/zephyrproject/zephyr/include/zephyr/devicetree.h:230:32: error: 'DT_N_ALIAS_out1_P_gpios_IDX_0_VAL_pin' undeclared here (not in a function); did you mean 'DT_N_S_leds_S_led_1_P_gpios_IDX_0_VAL_pin'?"
or: devicetree error: 'gpio-hog' is marked as required in 'properties:' in C:/Users/thoma/zephyrproject/zephyr/dts/bindings\gpio\microchip,mcp230xx.yaml, but does not appear in <Node /soc/sercom@42000800/portexp@20/aliases in 'C:/Users/thoma/zephyrproject/zephyr/misc/empty_file.c'>

I've also tried it with another board defintion file as a starting base (Arduino mkr zero with an ATSAMD21G18), but with similar results.

Thank you very much!

Related