Implement gpio_get_direction() callback for Tegra GPIO.
The direction is only valid if the pin is configured as
GPIO. If pin is not configured in GPIO mode then this
function return error.
This makes debugfs and initial reading of the state of
the lines more accurate.
+static int tegra_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+ struct tegra_gpio_info *tgi = gpiochip_get_data(chip);
+ u32 pin_mask = BIT(GPIO_BIT(offset));
+ u32 cnf, oe;
+
+ cnf = tegra_gpio_readl(tgi, GPIO_CNF(tgi, offset));
+ oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset));
+ if (cnf & pin_mask) {
+ if (oe & pin_mask)
+ return GPIOF_DIR_OUT;
+
+ return GPIOF_DIR_IN;
+ }
+
+ return -EINVAL;
+}