Hi,
I have been struggling with how the gpios are structured in the device tree. I have 4 spi devices that I wish to attach to my AGX Orin dev kit. I have used the pinmux spreadsheet to enable SPI1 and two software chip select gpios (and CAN0 and CAN1 but this isn’t super important to this post) and as I build and deploy the kernel myself I wish to modify the existing device tree sources and not use the generated dts files and the system image generation scripts.
The pinmux configuration I am interested in transplanting into my device tree sources is specifically
spi1_sck_pz3 {
nvidia,pins = "spi1_sck_pz3";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_miso_pz4 {
nvidia,pins = "spi1_miso_pz4";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_mosi_pz5 {
nvidia,pins = "spi1_mosi_pz5";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_cs0_pz6 {
nvidia,pins = "spi1_cs0_pz6";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_cs1_pz7 {
nvidia,pins = "spi1_cs1_pz7";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
soc_gpio19_pg6 {
nvidia,pins = "soc_gpio19_pg6";
nvidia,function = "gp";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
soc_gpio07_pi6 {
nvidia,pins = "soc_gpio07_pi6";
nvidia,function = "gp";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
This I have transplanted into tegra234-soc-base.dtsi under the tegra_pinctrl
tegra_pinctrl: pinmux: pinmux@2430000 {
compatible = "nvidia,tegra234-pinmux";
reg = <0x0 0x2430000 0x0 0x19100
0x0 0xc300000 0x0 0x4000>;
#gpio-range-cells = <3>;
status = "okay";
pinctl-0 = <&exp_header_pinmux>;
pinctrl-name = "default";
exp_header_pinmux: exp-header-pinmux {
spi1_sck_pz3 {
nvidia,pins = "spi1_sck_pz3";
nvidia,function = "spi1";
......
Then finally adding my spi devices to tegra234-soc-spi.dtsi
spi1: spi@c260000 {
compatible = "nvidia,tegra186-spi";
reg = <0x0 0x0c260000 0x0 0x10000>;
interrupts = <0 37 0x04>;
#address-cells = <1>;
#size-cells = <0>;
iommus = <&smmu_niso0 TEGRA_SID_NISO0_GPCDMA_0>;
dma-coherent;
dmas = <&gpcdma 16>, <&gpcdma 16>;
dma-names = "rx", "tx";
spi-max-frequency = <65000000>;
nvidia,clk-parents = "pll_p", "osc";
clocks = <&bpmp_clks TEGRA234_CLK_SPI2>,
<&bpmp_clks TEGRA234_CLK_PLLAON>,
<&bpmp_clks TEGRA234_CLK_OSC>;
clock-names = "spi", "pll_p", "osc";
resets = <&bpmp_resets TEGRA234_RESET_SPI2>;
reset-names = "spi";
status = "okay";
num-cs = <4>;
cs-gpios = <&soc_gpio07_pi6 0>,
<&soc_gpio19_pg6 0>,
<&spi1_cs0_pz6 0>,
<&spi1_cs1_pz7 0>;
tcan1: tcan4x5x@0 {
reg = <0>;
spi-max-frequency = <10000000>;
compatible = "ti,tcan4x5x";
};
tcan2: tcan4x5x@1 {
reg = <1>;
spi-max-frequency = <10000000>;
compatible = "ti,tcan4x5x";
};
tcan3: tcan4x5x@2 {
reg = <2>;
spi-max-frequency = <10000000>;
compatible = "ti,tcan4x5x";
};
tcan4: tcan4x5x@3 {
reg = <3>;
spi-max-frequency = <10000000>;
compatible = "ti,tcan4x5x";
};
};
with the cs-gpios declared external in this file to resolve the handles.
But for the life of me I cannot get the device tree to compile. I am always presented with
FATAL ERROR: Unable to parse input tree
I am after some advice as to how one goes about configuring Nvidia’s GPIOs to interface them with an spi device in an spi driver. I have attached a patch of the modifications in case the above lines are confusing.
spi_device_tree.txt (6.7 KB)
Cheers,
Alex