Dallas one wire device tree configuration with ds18b20

Hi,

I’m trying to configure the 1-wire driver on the TX1 so I can use the ds18b20 temp sensor on gpio63. I referenced linux/Documentation//devicetree/bindings/w1/w1-gpio.txt which states that the only two required properties for the device tree are compatible and gpios. I have added the following to my device tree:

onewire@0 {
		compatible = "w1-gpio";
		gpios = <0x78 0x3F 0>;
	};

I have connected the ds18b20 data line to GPIO63 through a 4.7k pullup, power to 3.3V and gnd to gnd. I’ve also rebuilt the kernel with 1-wire support. When I try to load the w1-gpio and w1-therm modules I see the following messages:

[ 1727.628517] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97
[ 1727.636854] in_atomic(): 0, irqs_disabled(): 128, pid: 341, name: w1_bus_master1
[ 1727.644234] CPU: 3 PID: 341 Comm: w1_bus_master1 Not tainted 4.4.38-tegra #1
[ 1727.651178] Hardware name: jetson_tx1 (DT)
[ 1727.655262] Call trace:
[ 1727.657705] [<ffffffc000088ab8>] dump_backtrace+0x0/0xe8
[ 1727.663004] [<ffffffc000088bb4>] show_stack+0x14/0x20
[ 1727.668042] [<ffffffc0003895e0>] dump_stack+0xb4/0xec
[ 1727.673082] [<ffffffc0000c84dc>] ___might_sleep+0x13c/0x148
[ 1727.678641] [<ffffffc0000c8558>] __might_sleep+0x70/0x98
[ 1727.683941] [<ffffffc000b69cec>] mutex_lock+0x24/0x60
[ 1727.688981] [<ffffffc0003bb144>] pinctrl_get_device_gpio_range+0x34/0xf8
[ 1727.695667] [<ffffffc0003bb4b8>] pinctrl_gpio_direction+0x20/0x88
[ 1727.701745] [<ffffffc0003bb548>] pinctrl_gpio_direction_output+0x10/0x18
[ 1727.708432] [<ffffffc0003d9efc>] tegra_gpio_direction_output+0x7c/0xb8
[ 1727.714943] [<ffffffc0003d295c>] _gpiod_direction_output_raw+0xfc/0x2f0
[ 1727.721542] [<ffffffc0003d2b8c>] gpiod_direction_output_raw+0x3c/0x48
[ 1727.727970] [<ffffffbffc019134>] w1_gpio_write_bit_dir+0x2c/0x38 [w1_gpio]
[ 1727.734835] [<ffffffbffc00b7ac>] w1_touch_bit+0x54/0xc8 [wire]
[ 1727.740659] [<ffffffbffc00ba98>] w1_write_8+0xa0/0xd8 [wire]
[ 1727.746309] [<ffffffbffc00a710>] w1_search+0x100/0x288 [wire]
[ 1727.752045] [<ffffffbffc00bd5c>] w1_search_devices+0x44/0x50 [wire]
[ 1727.758303] [<ffffffbffc00a8ec>] w1_search_process_cb+0x54/0x140 [wire]
[ 1727.764907] [<ffffffbffc00aaec>] w1_process+0x8c/0x198 [wire]
[ 1727.770641] [<ffffffc0000c1100>] kthread+0xf8/0x100
[ 1727.775505] [<ffffffc0000847a0>] ret_from_fork+0x10/0x30

Any help would really be appreciated. Thank you!

hello mashah,

there should be NULL pointer accessing in your customize driver,
please narrow down each functions and check the corresponding device tree settings,
thanks

Hi JerryChang,

I don’t completely understand. By custom driver do you mean the 1-wire driver? Because I’m simply using the driver that’s shipped with the linux kernel

hello mashah,

please confirm both of your device tree entries had refer to correct parents.
for example, is there a description for ‘w1-gpio’.
you may also refer to kernel sources as an example,
thanks

sources/hardware/nvidia/platform/t210/common/kernel-dts/t210-common-platforms/tegra210-common.dtsi

Hey Jerry,

I’ve tried looking at the device tree sources but I still don’t understand what I have to accomplish. Does there need to be a description for every compatible value for a node? I thought it was used by the kernel to know which driver to use and I’ve already compiled the kernel with the w1-gpio driver module. How would I describe the w1-gpio driver?

I can’t answer your full question, but the “compatible” line will be a comma delimited list of possible drivers. There may be more than one driver, but only one loads at a time. On the other hand, if you have multiple controllers of the same design, then different controllers might load different drivers. An example is that the serial UART hardware has both an ordinary and typical 16550A style UART driver as a possibility…but there is also a more enhanced version with DMA (the “high speed” or “hsuart” driver). During boot the serial console uses the older style driver, but the other serial UARTs use the “hsuart”. One controller, one driver. Any driver from the list of drivers. If you use only one driver, then only that one needs to be marked “compatible”.

Thanks for the clarification linuxdev. I assume what I’m doing is right then in the device tree by listing w1-gpio as the only compatible driver because that’s the one I want the kernel to use.