README.gpio 1.1 KB

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