Enable one wire (w1) drivers on TorizonCore to comunicate with DS2401 IC

We are evaluating TorizonCore running on a Colibri-iMX6DL with our custom carrier board. Our custom board has a DS2401 one wire Serial Number IC connected to pin 127 of the Colibri SoM and we need to be able to read it from our application.

The iMX6DL doesn’t have a dedicated one wire hardware peripheral so we were considering using the w1-gpio kernel driver which implements a one wire bus master using the GPIO API. We also found that there is a kernel driver compatible with the DS2401 IC: w1_smem.c.

As far as we can tell these drivers are not enabled on current releases of TorizonCore, so we were wondering if it would be possible to enable them for future releases. We believe enabling the following kernel configs would suffice:

CONFIG_W1
CONFIG_W1_GPIO
CONFIG_W1_SLAVE_SMEM

Regarding the device tree, we have the following working draft:

	onewire {
		compatible = "w1-gpio";
		gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;

		sn_ic {
			compatible = "w1-smem";
		};
	};

We are not sure what to assign the compatible property of the slave node, we guessed “w1-smem”.

Also we are not sure if the gpios property for the master node is correct and if we need to modify the iomuxc node somehow.

Regards,
Martin.

Greetings @mmarcos.sensor,

I can go ahead and put in the request to have these kernel options enabled by default. Have you already confirmed that these are the right options you need for your hardware peripheral?

We are not sure what to assign the compatible property of the slave node, we guessed “w1-smem”.

I’m not personally familiar with this driver or IC, but I didn’t find any compatible string “w1-smem” anywhere in the kernel. Therefore I don’t believe this is a valid compatible string.

Also we are not sure if the gpios property for the master node is correct and if we need to modify the iomuxc node somehow.

You need to add a pinctrl group to iomuxc to then assign this pin to the onewire node you have here. As a reference see this NXP customer who did a similar one-wire customization in the device tree: Solved: Enable 1-wire in DeviceTree for iMX6 DualLite - NXP Community

Best Regards,
Jeremias

@jeremias.tx

I can go ahead and put in the request to have these kernel options enabled by default. Have you already confirmed that these are the right options you need for your hardware peripheral?

How could we confirm if these are the options we need? We researched the linux 1-wire (w1) subsystem, we browsed the driver sources and reviewed all available options in the Kconfig files. As far as we can tell we only need these 3 options to get our peripheral working with the linux drivers. Is there some way we could test it beforehand? We are currently trying to build a custom linux image to test config options, drivers and device tree. Do you think this is viable?

I’m not personally familiar with this driver or IC, but I didn’t find any compatible string “w1-smem” anywhere in the kernel. Therefore I don’t believe this is a valid compatible string.

We did some more research on the w1_smem driver and we now believe that a slave node for this type of device is not necessary, with the master node is enough. We are not going to be sure until we test it.

Following suggestions in the thread you linked, our current device tree draft is as follows:

/ {
	&iomuxc {
		pinctrl_onewire: onewiregrp {
			fsl,pins = <
				MX6QDL_PAD_NANDF_D6__GPIO2_IO06	0x4001b8b1
			>;
		};
	};

	onewire {
			compatible = "w1-gpio";
			gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
			linux,open-drain;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_onewire>;
			status = "okay";
	};
};

We tried compiling and applying the device tree with torizoncore-builder and it compiled and applied successfully.