Hi,
Based on your information the problem could be that you are not setting the device tree properly. Please have a look at the following link. Here you will find how to correctly set the device tree to use a GPIO.
Link: Toggle pin on i.MX 8M Mini Applications Processor ... - NXP Community
I hope this information will be helpful.
Have a great day!