Insmod failed in "probe" function

Hi,

I cross compiled my out-of-kernel module. And changed the device tree. But when run on the target machine using insmod, it always shows

root@hd:/media/zh/ssd/ko# insmod ./tst_gpio.ko
root@hd:/media/zh/ssd/ko# dmesg | grep tst-gpio
[  430.968983] tst-gpio init...
[  430.969368] tst-gpio GPIO probe
[  430.969407] tst-gpio match compatible: test,tst-gpio
[  430.969476] OF: /tst-gpio: could not get #gpio-cells for /i2c@3190000
[  430.969637] tst-gpio: -22 is invalid

The added device tree item is as below:

/ {
    tst-gpio {
            #address-cells = <1>;
            #size-cells = <1>;
			compatible = "test,tst-gpio";
			//gpio-hog;
			gpio-pe = <TEGRA194_MAIN_GPIO(N, 1) GPIO_ACTIVE_HIGH>;
            status = "okay";
    };
};

Apparently, it matched my device-tree, by ‘compatible’ property. But why ‘of_get_named_gpio_flags’ complains something about i2c@31900? It seems this function try to iterate all nodes in the whole tree but not the node I pass to it?

And the main driver code is attached.

Thanks.

driver.c (1.9 KB)

hello diverger,

could you please examine your device tree hierarchy, what’s under i2c@3190000?
you may disassembler the dtb file into text file to review the content.
for example, $ dtc -I dtb -O dts -o output.txt tegra.dtb

The device tree is the official one under ‘tegra194-soc’ folder, tegra194-soc-i2c.dsti. Indeed, there is no ‘gpio-cells’ property.

	dp_aux_ch1_i2c: i2c@3190000 {
		#address-cells = <1>;
		#size-cells = <0>;
		iommus = <&smmu TEGRA_SID_GPCDMA_0>;
		dma-coherent;
		compatible = "nvidia,tegra194-i2c";
		reg = <0x0 0x3190000 0x0 0x100>;
		nvidia,hw-instance-id = <0x3>;
		interrupts = <0 TEGRA194_IRQ_I2C4 0x04>;
		status = "disabled";
		clock-frequency = <100000>;
		clocks = <&bpmp_clks TEGRA194_CLK_I2C4
			&bpmp_clks TEGRA194_CLK_PLLP_OUT0>;
		clock-names = "div-clk", "parent";
		resets = <&bpmp_resets TEGRA194_RESET_I2C4>;
		reset-names = "i2c";
		dmas = <&gpcdma 26>, <&gpcdma 26>;
		dma-names = "rx", "tx";
	};

The reverse-compiled version is:

	i2c@3190000 {
		#address-cells = <0x1>;
		#size-cells = <0x0>;
		iommus = <0x2 0x20>;
		dma-coherent;
		compatible = "nvidia,tegra194-i2c";
		reg = <0x0 0x3190000 0x0 0x100>;
		nvidia,hw-instance-id = <0x3>;
		interrupts = <0x0 0x1c 0x4>;
		status = "okay";
		clock-frequency = <0x186a0>;
		clocks = <0x4 0x33 0x4 0x66>;
		clock-names = "div-clk", "parent";
		resets = <0x5 0x1f>;
		reset-names = "i2c";
		dmas = <0x1e 0x1a 0x1e 0x1a>;
		dma-names = "rx", "tx";
		linux,phandle = <0x69>;
		phandle = <0x69>;

		prod-settings {
			#prod-cells = <0x4>;

			prod {
				prod = <0x0 0x9c 0xffff 0x308 0x0 0xd4 0xff 0x0 0x0 0xd8 0xff 0x0 0x0 0xdc 0xffff 0x1 0x0 0xe0 0xffff 0x2>;
			};

			prod_c_fm {
				prod = <0x0 0x6c 0xffff0000 0x3c0000 0x0 0x94 0xffff 0x202 0x0 0x98 0xffffffff 0x2020202>;
			};

			prod_c_fmplus {
				prod = <0x0 0x6c 0xffff0000 0x160000 0x0 0x94 0xffff 0x202 0x0 0x98 0xffffffff 0x2020202>;
			};

			prod_c_hs {
				prod = <0x0 0x6c 0xffffffff 0x580002 0x0 0x94 0xffff 0x101 0x0 0x98 0xffffffff 0x2020202 0x0 0xa0 0xffffff 0x90909>;
			};

			prod_c_sm {
				prod = <0x0 0x6c 0xffff0000 0x4f0000 0x0 0x94 0xffff 0x708 0x0 0x98 0xffffffff 0x8080808>;
			};
		};
	};

The reverse-compiled ‘tst-gpio’ is:

	tst-gpio {
		#address-cells = <0x1>;
		#size-cells = <0x1>;
		compatible = "test,tst-gpio";
		gpio-pe = <0x69 0x0>;
		status = "okay";
	};

this doesn’t look right, the gpio number for this pin, TEGRA194_MAIN_GPIO(N, 1) should be gpio393.

Hmmmm, are there anything wrong in my device tree for tst-gpio?

Thanks.

Hi, Chang

It seems the problem is the phandle value.

Thanks.

hello diverger,

you should have gpio under the same field then it’ll be able to access by driver side.
for example, please check reset-gpios in the sensor device trees for reference, thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.