IMX6 - Not all PWM units available in user space with custom dts

Hello,

I’ve been building a custom Linux image using Yocto with a custom device tree source.
I have enabled all the PWMs by setting the status to ‘okay’, but only 2 PWMs are availalble in user space under /sys/class/pwm.

The device tree source looks like this:

/dts-v1/;

#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include "imx6dl.dtsi"
#include "imx6qdl-colibri.dtsi"

/ {
	model = "Toradex Colibri iMX6DL/S on Colibri Evaluation Board V3";
	compatible = "toradex,colibri_imx6dl-eval", "toradex,colibri_imx6dl", "fsl,imx6dl";

	aliases {
		/* the following, together with kernel patches, forces a fixed assignment
		   between device id and usdhc controller */
		/* i.e. the eMMC on usdhc3 will be /dev/mmcblk0 */
		mmc0 = &usdhc3; /* eMMC */
		mmc1 = &usdhc1; /* MMC 4bit slot */
	};

	extcon_usbc_det: usbc_det {
		compatible = "linux,extcon-usb-gpio";
		debounce = <25>;
		id-gpio = <&gpio7 12 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_usbc_det_1>;
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio_keys>;

		wakeup {
			label = "Wake-Up";
			gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_WAKEUP>;
			debounce-interval = <10>;
			gpio-key,wakeup;
		};
	};

	regulators {
		reg_usb_host_vbus: usb_host_vbus {
			status = "okay";
		};
	};
};

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <
		&pinctrl_gpio_unit1
		&pinctrl_pwm_unit1
	>;

	gpio {
		pinctrl_gpio_unit1: gpio-unit1 {
			fsl,pins = <
				/* Pins for the GPIO IN */
				MX6QDL_PAD_EIM_D17__GPIO3_IO17   PAD_CTRL_HYS_PU /* SODIMM 96 */

				/* EN */
				MX6QDL_PAD_SD2_DAT0__GPIO1_IO15	 PAD_CTRL_HYS_PU /* SODIMM 98 */

				/* Pins for the STATUS LEDS */
				MX6QDL_PAD_NANDF_D4__GPIO2_IO04  PAD_CTRL_HYS_PU /* SODIMM 102 */
				MX6QDL_PAD_SD4_DAT0__GPIO2_IO08  PAD_CTRL_HYS_PU /* SODIMM 104 */

				/* Pins for the HW WATCHDOG */
				MX6QDL_PAD_GPIO_9__GPIO1_IO09	 PAD_CTRL_HYS_PU /* SODIMM 28 */
			>;
		};
	};

	pwm {
		pinctrl_pwm_unit1: pwm-unit1 {
			fsl,pins = <
				/* PWM */
				MX6QDL_PAD_SD4_DAT1__PWM3_OUT 	 0x1b0b1		 /* SODIMM 59 */
			>;
		};
	};
};

&pwm1 {
	status = "okay";
};

&pwm2 {
	status = "okay";
};

/* PWM */
&pwm3 {
	status = "okay";
};

&pwm4 {
	status = "okay";
};

/* UART for serial interface with module */
&uart1 {
	status = "okay";
};

/* UART for RS485 communication */
&uart2 {
	status = "okay";
};

/* USB */
&usbh1 {
	status = "okay";
};

/* USB-OTG for debugging purposes */
&usbotg {
	status = "okay";
	extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;
};

/* MMC */
&usdhc1 {
	status = "okay";
};

&weim {
	status = "okay";
	fsl,weim-cs-gpr = <&gpr>;
	/* weim memory map: 32MB on CS0, 32MB on CS1, 32MB on CS2, 32MB on CS3 */
	ranges = <0 0 0x08000000 0x02000000
	          1 0 0x0a000000 0x02000000
	          2 0 0x0c000000 0x02000000
	          3 0 0x0e000000 0x02000000>;
	/* SRAM on CS0 */
	sram@0,0 {
		compatible = "cypress,cy7c1019dv33-10zsxi, mtd-ram";
		reg = <0 0 0x00010000>;
		#address-cells = <1>;
		#size-cells = <1>;
		bank-width = <2>;
		fsl,weim-cs-timing = <0x00010081 0x00000000 0x04000000
				0x00000000 0x04000040 0x00000000>;
	};
	/* SRAM on CS1 */
	sram@1,0 {
		compatible = "cypress,cy7c1019dv33-10zsxi, mtd-ram";
		reg = <1 0 0x00010000>;
		#address-cells = <1>;
		#size-cells = <1>;
		bank-width = <2>;
		fsl,weim-cs-timing = <0x00010081 0x00000000 0x04000000
				0x00000000 0x04000040 0x00000000>;
	};
};

This is the result of an ls command on /sys/class/pwm:

root@colibri-imx6:/sys/class/pwm# ls -l
lrwxrwxrwx    1 root     root             0 Mar  6 14:43 pwmchip0 -> ../../devices/soc0/soc/2000000.aips-bus/2084000.pwm/pwm/pwmchip0
lrwxrwxrwx    1 root     root             0 Mar  6 14:43 pwmchip1 -> ../../devices/soc0/soc/2000000.aips-bus/208c000.pwm/pwm/pwmchip1

Does anyone know why only 2 PWMs are available and visible in user space instead of all 4 and how I can fix this?

Thanks in advance!

I found the cause. The 4th PWM wasn’t enabled because the pin for this PWM was already set as regular GPIO in the dts file above. The 3rd pin wasn’t functioning properly because the PWM pin mux configuration was in both my own dts file and the derived imx6 colibri dts file. Apparently this caused issues and I’ve replaced pinctrl-0 with my own configuration in the end.

Perfect that it works. Thanks for your Input.