Device Tree for MCP4912

Hello,

Could someone help me to define device tree for MCP4912 ADC? Unfortunately I can’t seem to find device tree bindings for this chip.
The chip uses SPI and CS0. I tried to define it under dspi but it doesn’t seem to work correctly.
Below is output of dmesg and device tree entry.

[    0.869695] spi_master spi1: spi_device register error /soc/aips-bus@40000000/dspi1@4002d000/mcp4912@0
[    0.879120] spi_master spi1: Failed to create SPI device for /soc/aips-bus@40000000/dspi1@4002d000/mcp4912@0


/* Spi for anlog outputs dig inp output*/
&dspi1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_dspi1>;

	mcp2515can {
		status = "disabled";
	};

	spidev0 {
		status = "disabled";
	};

	/* Digital input outpu */
	/*spidev1: spidev@1 {
		compatible = "toradex,evalspi";
		reg = <1>;
		spi-max-frequency = <50000000>;
		status = "disabled";
	};*/

	adcx: mcp4912@0 {
		compatible = "microchip,mcp4912";
		reg = <0>;
		/*vref-supply = <&reg_module_3v3_avdd>;*/
		vdd-supply = <&reg_module_3v3_avdd>;
		spi-max-frequency = <1000000>;
	};

	gpiom1: gpio@1 {
		compatible = "microchip,mcp23s17";
		gpio-controller;
		#gpio-cells = <2>;
		/*spi-present-mask = <0x01>;*/
                microchip,spi-present-mask = <0x01>;
		reg = <1>;
		spi-max-frequency = <1000000>;
                #interrupt-cells = <2>;
                interrupt-controller;
                microchip,irq-mirror;
	};

};

Thank you.

Greetings @navmatix!

It looks like there is a driver for this device on the Linux kernel: linux/mcp4922.c at master · torvalds/linux · GitHub

However, I wasn’t able to find any documentation on its device tree bindings. I suggest you to analyze that code and perhaps base your device tree nodes on another device such as the mcp4725: https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/iio/dac/mcp4725.txt

Hello @gustavo.tx,

Actually I followed the same links as you suggested and tried to define DT according to mcp4725 however it did not work in my case. I’ll try to dig in the driver source code a bit more

Thank you.

Finally it works. I had to disable spidev1.0. Disabling whole spidev1 did not work. Here’s part of working DT:

        spidev1: spidev@0 {
                status = "disabled";
        };

        adcx: mcp4912@0 {
                compatible = "microchip,mcp4912";
                reg = <0>;
                vref-supply = <&reg_module_3v3_avdd>;
                spi-max-frequency = <1000000>;
        };

@navmatix,

I’m glad that this works! Thank you for your feedback.