@kanjiviroja, controlling the functionality of the pins and which driver is owning it is clearly something which the operating system should handle. And as @bhuvanchandra.dv says, there is no kernel interface to influence this directly.
However, you can influence it indirectly. The kernel muxes a pin automatically when its driver gets loaded, or when a GPIO get exported. Only one device can actively control a pin, you can see the current controlling device driver in
If you plan to use a pin for two things (e.g. GPIO and UART), just make sure the pinmux for the two options are part of your device tree, and use the bind/unbind option to unbind the serial driver:
echo 40028000.serial > /sys/bus/platform/drivers/fsl-lpuart/unbind
After that, you will be able to use it as GPIO
echo 26 > /sys/class/gpio/export
You can also do the opposite, unexport the GPIO and (re)bind the UART driver.
What functionality are you trying to switch between? What is your exact use case?