#include "bone/black.h" #include "gpio.h" // Since we're creating a virtual device, there's not really a better place to // put it than root of the device tree. / { // Node name "gpios" is arbitrary but should not conflict with other // nodes or properties in the root of the device tree. // To list all of these on a running system: ls /proc/device-tree/ motor-gpios { // configure the driver for this device node, which must be "gpio-of-helper" compatible = "gpio-of-helper"; // Attach pinmux node to this device node. In rare cases devices may have // multiple pinmux states, but usually you only have a "default" state. pinctrl-names = "default"; pinctrl-0 = <&gpio_pins>; //<--- references the "gpio_pins:" label below // For each gpio to be setup { // The node name "gpio-label" becomes the gpio label and may be arbitrary but // must be unique for each gpio (globally, not merely those exported by this // gpio-of-helper device). MS1 { gpio = < &gpio2 4 ACTIVE_HIGH >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; MS2 { gpio = < &gpio1 13 ACTIVE_HIGH >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; enable { gpio = < &gpio1 12 ACTIVE_LOW >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; motor_dir { gpio = < &gpio0 31 ACTIVE_HIGH >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; stepper_dir { gpio = < &gpio0 23 ACTIVE_HIGH >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; step { gpio = < &gpio0 26 ACTIVE_HIGH >; output; // initial direction: input or output (optional for outputs) init-low; // if output, whether it's initially low or initially high }; // } }; }; // Pinmux nodes must be created inside the pinmux controller, which is &am33xx_pinmux &am33xx_pinmux { // Label "gpio_pins" is arbitrary but must be _globally_ unique among all labels // in the device tree (base + overlays), hence it's a good idea to make a bit more // verbose than the node name needs to be. Also, unlike the node name, the label // needs to be a valid C identifier (so only alphanumeric and underscores). // // Node name "gpios" only needs to be unique inside &am33xx_pinmux, so usually // it's fine to just use the same name as the device it's for. // gpio_pins: motor-gpios { pinctrl-single,pins = < // { PIN_PULLDN( P8_10, 7 ) PIN_PULLDN( P8_11, 7 ) PIN_PULLDN( P8_12, 7 ) PIN_PULLDN( P8_13, 7 ) PIN_PULLDN( P8_14, 7 ) PIN_PULLDN( P9_13, 7 ) // } >; }; };