Currently there is no API function that specifically reads the direction from a GPIO pin;
The GDIR register functions as direction control when the IOMUXC is in GPIO mode. Each bit specifies the direction of a one-bit signal.


The GDIR register is a read/write register which you can read during run-time to store or obtain the direction (input/output) of a GPIO pin. The example you provided (gpio_pin_direction_t F(GPIO_Type *base, uint32_t port)) is a good way of implementing this function.
I hope you find this helpful! If you have any doubts about the register do not hesitate to ask.
Best regards, Julian