214
edits
Line 275: | Line 275: | ||
}; /* End fragment@1 */ | }; /* End fragment@1 */ | ||
</source> | </source> | ||
==Pre-process the DT overlay file with the C preprocessor (cpp)== | |||
If you want to include kernel definition since the device tree compiler doesn't support C definition syntax you have to use C Pre-process (cpp) to create a file that can be compiled by the Device Tree compiler. | |||
Example: This is the same previous device tree but using pinctrl tegra definitions to set GPIO configuration: | |||
<source lang="c"> | |||
/dts-v1/; | |||
/plugin/; | |||
#include <dt-bindings/pinctrl/pinctrl-tegra.h> | |||
#define OVERLAY_VERSION "0.1" | |||
/ { | |||
overlay-name = "tx2_uart_overlay"; | |||
compatible = "nvidia,p2597-0000+p3310-1000"; | |||
fragment@0 { | |||
target-path = "/"; | |||
__overlay__ { | |||
d3,dts-overlay = __FILE__; | |||
d3,dts-overlay-version = OVERLAY_VERSION; | |||
}; | |||
}; | |||
fragment@1 { | |||
target = <&pinmux>; | |||
__overlay__ { | |||
pinctrl-names = "default"; | |||
pinctrl-0 = <&hdr40_pinmux>; | |||
hdr40_pinmux: header-40pin-pinmux { | |||
pin8 { | |||
nvidia,function = "uarta"; | |||
nvidia,pins = "uart1_tx_pt0"; | |||
nvidia,pull = <TEGRA_PIN_PULL_NONE>; | |||
nvidia,tristate = <TEGRA_PIN_DISABLE>; | |||
nvidia,enable-input = <TEGRA_PIN_DISABLE>; | |||
nvidia,lpdr = <TEGRA_PIN_DISABLE>; | |||
}; | |||
pin10 { | |||
nvidia,function = "uarta"; | |||
nvidia,pins = "uart1_rx_pt1"; | |||
nvidia,pull = <TEGRA_PIN_PULL_UP>; | |||
nvidia,tristate = <TEGRA_PIN_ENABLE>; | |||
nvidia,enable-input = <TEGRA_PIN_ENABLE>; | |||
nvidia,lpdr = <TEGRA_PIN_DISABLE>; | |||
}; | |||
}; | |||
}; | |||
}; | |||
}; | |||
</source> | |||
Use the C Pre-process (cpp) to replace Constants in the device tree overlay | |||
<source lang="bash"> | |||
cpp -nostdinc -I kernel/kernel-4.9/include/ -undef -x assembler-with-cpp tx2-uart-overlay.dts tx2-uart-overlay.dts.preprocessed | |||
</source> | |||
Parameter description: | |||
* -nostdinc: Do not search the standard system directories for header files. | |||
* -undef: Do not predefine any system-specific or GCC-specific macros. | |||
* -x assembler-with-cpp: Allow #tags in the code (example: #address-cells) | |||
==See Also== | ==See Also== |
edits