Other Parts Discussed in Thread: AM6442
Tool/software:
Hi,
In our custom hardware we want to use gpio falling edge interrupt and manage it in user space. For that purpose I used gpiolib and wrote some test application:
#include <cstdio> #include <cstring> #include <gpiod.h> using namespace std; #define GPIO_CHIP_DEFAULT "gpiochip1" #define GPIO_LABEL_DEFAULT "STORE" int main(int argc, char *argv[]) { if(argc < 3) { printf("Provide gpiochip and pinLabel\n"); return 1; } const char * pinLabel = argv[1]; if(pinLabel == nullptr) { printf("Setting default pin label to: %s\n",GPIO_LABEL_DEFAULT); pinLabel = GPIO_LABEL_DEFAULT; } const char * gpioChipName = argv[2]; if(gpioChipName == nullptr) { printf("Setting default gpiochip to: %s\n",GPIO_CHIP_DEFAULT); gpioChipName = GPIO_CHIP_DEFAULT; } gpiod_line * gpioLine; gpiod_chip * gpioChip; gpiod_line_event event; memset(&event,0,sizeof(event)); gpioChip = gpiod_chip_open_by_name(gpioChipName); if(!gpioChip) { printf("Failed open gpiochip: %s!\n",gpioChipName); return 1; } gpioLine = gpiod_line_find(pinLabel); if(!gpioLine) { printf("Cannot find gpio line: %s!\n",pinLabel); goto release_chip; } if(gpiod_line_is_requested(gpioLine)) { printf("Gpio line STORE reserved by other process!\n"); goto release_chip; } if(gpiod_line_request_falling_edge_events(gpioLine,"PowerHoldUp")) { printf("Failed subscribe Gpio line %s on interrupt event!\n",pinLabel); goto release_line; } if (gpiod_line_event_wait(gpioLine,nullptr) > 0) { if (!gpiod_line_event_read(gpioLine, &event)) { if(event.event_type == GPIOD_LINE_EVENT_FALLING_EDGE) { printf("falling edge interrupt triggered!\n"); } } } printf("end of program!\n"); release_line: gpiod_line_release(gpioLine); gpioLine = nullptr; release_chip: gpiod_chip_close(gpioChip); gpioChip = nullptr; }
I also made some adjustment in device tree:
&main_gpio0 { status = "okay"; ti,ngpio = <32>; gpio-line-names = "GPIO0_0", "BIO_INT1", "TF11", "TF12", "GPIO0_4","STORE","FACTORY_DEFAULT", "U1_BTN_INT","TF1","GPIO0_9","GPIO0_10", "ANALOG_RFU0","ANALOG_RFU1", "BIO_INT2","BIO_INT3","GPIO0_31", "GPIO0_32","ADC_MCLK","ACT_RELAY","ADC_CONVST_SAR", "ADC_SAMPLE_CLK","TF2","ANALOG_INT","GPIO0_39", "GPIO0_40","ADC_DRDY","VPP_EN","RTC_1PPS"; }; &main_pmx0 { pinctrl-names = "default"; pinctrl-0 = <&store_pin>; store_pin: store-pin { pinctrl-single,pins = < AM64X_IOPAD(0x0014, PIN_INPUT, 7) /* (M20) GPIO0_5 */ >; }; };
But seems that it is not enough because interrupt is not tirggered after shorting STORE pin into GND. I tested this code also on Raspberry PI 4 and it works fine. So I guess application is written correct. So what is missed in configuration on AM6442 side? We are using custom image build via Yocto and meta-ti layer SDK 9.0
BR,
Jakub