gpio: added support for input GPIOs, restored support for 'inverted' flag.