AnsweredAssumed Answered

can setting gpio input high/low on imx6q?

Question asked by Lin Hsun on Mar 15, 2017
Latest reply on Mar 15, 2017 by Lin Hsun

Dear all , My board is sabresd_6dq (kernel 3.14.52),  can I setting gpio to input (Hi or Low) ? please get a little suggest. thank.

   P.S I set input after, but the gpio always low, I hope set input (high).

 

// code

func(..){

   int rc, gpio;
   struct device *dev = &pdev->dev;
   struct device_node *np = pdev->dev.of_node;

 

   gpio = of_get_named_gpio(np, "test-gpio", 0);
   if (gpio_is_valid(gpio)) {
      rc = devm_gpio_request_one(&pdev->dev, gpio, GPIOF_OUT_INIT_HIGH, "test gpio");
      if (rc) {
         dev_err(&pdev->dev, "unable to get test-gpio\n");
         goto error_request_gpio;
      }

 

#define INPUT

#ifdef INPUT
      mdelay(500);
      //set input
      gpio_direction_input(gpio);
      // setting gpio input
      int fault;

      fault = gpio_get_value(gpio);

#endif

   }

}

Outcomes