Advertisement
Guest User

Untitled

a guest
Mar 12th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "bone/black.h"
  2. #include "gpio.h"
  3.  
  4. // disable conflicting cape-universal nodes
  5. USES_PIN( P9_13 );
  6.  
  7. // Since we're creating a virtual device, there's not really a better place to
  8. // put it than root of the device tree.
  9. / {
  10. // Node name "magnet-gpios" is arbitrary but should not conflict with other
  11. // nodes or properties in the root of the device tree.
  12. // To list all of these on a running system: ls /proc/device-tree/
  13. magnet-gpios {
  14. // configure the driver for this device node, which must be "gpio-of-helper"
  15. compatible = "gpio-of-helper";
  16.  
  17. // Attach pinmux node to this device node. In rare cases devices may have
  18. // multiple pinmux states, but usually you only have a "default" state.
  19. pinctrl-names = "default";
  20. pinctrl-0 = <&magnet_gpio_pins>; //<--- references the "magnet_gpio_pins:" label below
  21.  
  22. // The node name "magnet_dir" becomes the gpio label and may be arbitrary but
  23. // must be unique for each gpio (globally, not merely those exported by this
  24. // gpio-of-helper device).
  25. magnet_dir {
  26. gpio = <
  27. &gpio0
  28. 31
  29. ACTIVE_HIGH
  30. >;
  31. output; // initial direction: input or output (optional for outputs)
  32. init-low; // if output, whether it's initially low or initially high
  33. };
  34. };
  35. };
  36.  
  37. // Pinmux nodes must be created inside the pinmux controller, which is &am33xx_pinmux
  38. &am33xx_pinmux {
  39. // Label "magnet_gpio_pins" is arbitrary but must be _globally_ unique among all labels
  40. // in the device tree (base + overlays), hence it's a good idea to make a bit more
  41. // verbose than the node name needs to be. Also, unlike the node name, the label
  42. // needs to be a valid C identifier (so only alphanumeric and underscores).
  43. //
  44. // Node name "magnet-gpios" only needs to be unique inside &am33xx_pinmux, so usually
  45. // it's fine to just use the same name as the device it's for.
  46. //
  47. magnet_gpio_pins: magnet-gpios {
  48. pinctrl-single,pins = <
  49. PIN_PULLDN( P9_13, 7 )
  50. >;
  51. };
  52. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement