README.gpio 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. GPIO hog (CONFIG_GPIO_HOG)
  2. --------
  3. All the GPIO hog are initialized using DM_FLAG_PROBE_AFTER_BIND DM flag
  4. after bind().
  5. Example, for the device tree:
  6. tca6416@20 {
  7. compatible = "ti,tca6416";
  8. reg = <0x20>;
  9. #gpio-cells = <2>;
  10. gpio-controller;
  11. env_reset {
  12. gpio-hog;
  13. input;
  14. gpios = <6 GPIO_ACTIVE_LOW>;
  15. };
  16. boot_rescue {
  17. gpio-hog;
  18. input;
  19. line-name = "foo-bar-gpio";
  20. gpios = <7 GPIO_ACTIVE_LOW>;
  21. };
  22. };
  23. You can than access the gpio in your board code with:
  24. struct gpio_desc *desc;
  25. int ret;
  26. ret = gpio_hog_lookup_name("boot_rescue", &desc);
  27. if (ret)
  28. return;
  29. if (dm_gpio_get_value(desc) == 1)
  30. printf("\nBooting into Rescue System\n");
  31. else if (dm_gpio_get_value(desc) == 0)
  32. printf("\nBoot normal\n");