Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4990

Device Tree • Re: MCP23017 overlay error -EIO: can't write IOCON 32

$
0
0
I extend it now to all GPIOs

Code:

//Test overlay on bit-bashed I2C//devices connected are an EEPROM ans a GPIO expander////swi2c-dummy-rev1-overlay.dts//for devicetree bindings of MCP23017 refer to///home/pi/linux/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt//MCP23017 data sheet: https://www.microchip.com/en-us/product/mcp23017//AT24AA32A data sheet: https://www.microchip.com/en-us/product/24AA32A//aBUGSworstnightmare, 20241218#include <dt-bindings/gpio/gpio.h>#include <dt-bindings/pinctrl/bcm2835.h>/dts-v1/;/plugin/;/ {compatible = "brcm,bcm2711";fragment@0 {target-path = "/";__overlay__ {i2c_gpio: i2c@0 {reg = <0xffffffff>;compatible = "i2c-gpio";gpios = <&gpio 10 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* sda */ &gpio 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* scl */>;i2c-gpio,delay-us = <2>;        /* ~100 kHz */#address-cells = <1>;#size-cells = <0>;};};};fragment@1 {target-path = "/aliases";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@2 {target-path = "/__symbols__";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@10 {target = <&gpio>;__overlay__ {mcp23017_20_pins: mcp23017_pins@20 {brcm,pins = <18>;brcm,function = <0>;brcm,pull = <2>;};};};fragment@20 {target = <&mcp23017_20>;mcp23017_20_irq: __overlay__ {interrupt-controller;interrupt-parent = <&gpio>;interrupts = <18 2>;interrupt-names = "mcp23017@20 irq";#interrupt-cells=<2>;microchip,irq-mirror;pinctrl-names = "default";pinctrl-0 = <&mcp23017_20_pins>, <&gpio20pullups>;gpio20pullups: pinmux {pins = "gpio0", "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7", "gpio8", "gpio9", "gpio10", "gpio11", "gpio12", "gpio13", "gpio14", "gpio15";bias-pull-up;};};};fragment@30 {target = <&i2c_gpio>;__overlay__ {#address-cells = <1>;#size-cells = <0>;status = "okay";  mcp23017_20: mcp@20 {compatible = "microchip,mcp23017";reg = <0x20>;gpio-controller;#gpio-cells = <2>;status = "okay";};mcp23017_21: mcp@21 {compatible = "microchip,mcp23017";reg = <0x21>;gpio-controller;#gpio-cells = <2>;status = "okay";};  };};__overrides__ {i2c_gpio_sda = <&i2c_gpio>,"gpios:4";i2c_gpio_scl = <&i2c_gpio>,"gpios:16";i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";bus = <&i2c_gpio>, "reg:0";};};

I tried this for the events

Code:

// Test overlay on bit-bashed I2C// Devices connected are an EEPROM and a GPIO expander//// swi2c-dummy-rev1-overlay.dts// For devicetree bindings of MCP23017 refer to// /home/pi/linux/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt// MCP23017 data sheet: https://www.microchip.com/en-us/product/mcp23017// AT24AA32A data sheet: https://www.microchip.com/en-us/product/24AA32A// aBUGSworstnightmare, 20241218#include <dt-bindings/gpio/gpio.h>#include <dt-bindings/pinctrl/bcm2835.h>#include <dt-bindings/input/input.h>/dts-v1/;/plugin/;/ {compatible = "brcm,bcm2711";fragment@0 {target-path = "/";__overlay__ {i2c_gpio: i2c@0 {reg = <0xffffffff>;compatible = "i2c-gpio";gpios = <&gpio 10 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* sda */ &gpio 11 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN|GPIO_PULL_UP) /* scl */>;i2c-gpio,delay-us = <2>;        /* ~100 kHz */#address-cells = <1>;#size-cells = <0>;};};};fragment@1 {target-path = "/aliases";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@2 {target-path = "/__symbols__";__overlay__ {i2c_gpio = "/i2c@0";};};fragment@10 {target = <&gpio>;__overlay__ {mcp23017_20_pins: mcp23017_pins@20 {brcm,pins = <18>;brcm,function = <0>;brcm,pull = <2>;};};};fragment@20 {target = <&mcp23017_20>;mcp23017_20_irq: __overlay__ {interrupt-controller;interrupt-parent = <&gpio>;interrupts = <18 2>;interrupt-names = "mcp23017@20 irq";#interrupt-cells=<2>;microchip,irq-mirror;pinctrl-names = "default";pinctrl-0 = <&mcp23017_20_pins>, <&gpio20pullups>;gpio20pullups: pinmux {pins = "gpio1", "gpio12", "gpio13", "gpio14", "gpio15";bias-pull-up;};};};fragment@30 {target = <&i2c_gpio>;__overlay__ {#address-cells = <1>;#size-cells = <0>;status = "okay";  mcp23017_20: mcp@20 {compatible = "microchip,mcp23017";reg = <0x20>;gpio-controller;#gpio-cells = <2>;status = "okay";};mcp23017_21: mcp@21 {compatible = "microchip,mcp23017";reg = <0x21>;gpio-controller;#gpio-cells = <2>;status = "okay";};  };};fragment@40 {    target-path = "/";    __overlay__ {        buttons {            compatible = "gpio-keys";            pinctrl-names = "default";            status = "okay";            button@0 {                label = "MCP_BUTTON_1";                linux,code = <KEY_ENTER>;                gpios = <&mcp23017_20 1 GPIO_ACTIVE_LOW>;                };};    };};__overrides__ {i2c_gpio_sda = <&i2c_gpio>,"gpios:4";i2c_gpio_scl = <&i2c_gpio>,"gpios:16";i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";bus = <&i2c_gpio>, "reg:0";};};
Seems to be running...

Code:

pi@remote:~ $ evtestNo device specified, trying to scan all of /dev/input/event*Not running as root, no devices may be available.Available devices:/dev/input/event0:buttons/dev/input/event1:vc4-hdmi/dev/input/event2:vc4-hdmi HDMI JackSelect the device event number [0-2]: 0Input driver version is 1.0.1Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100Input device name: "buttons"Supported events:  Event type 0 (EV_SYN)  Event type 1 (EV_KEY)    Event code 28 (KEY_ENTER)Properties:Testing ... (interrupt to exit)Event: time 1735163570.672773, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1Event: time 1735163570.672773, -------------- SYN_REPORT ------------Event: time 1735163570.862761, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0Event: time 1735163570.862761, -------------- SYN_REPORT ------------Event: time 1735163571.792773, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1Event: time 1735163571.792773, -------------- SYN_REPORT ------------Event: time 1735163571.982761, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0Event: time 1735163571.982761, -------------- SYN_REPORT ------------


is my code correct? or any better solution??

Statistics: Posted by koerli — Wed Dec 25, 2024 9:05 pm



Viewing all articles
Browse latest Browse all 4990

Trending Articles