I tried this method and it didn't work, But /sys/class/pwm is empty.
 
please check and let me know the modification need to do for getting pwm2.
 
My modification is as follows:
imx8qxp.dtsi:
+       pwm2: pwm@5d020000 {
+               compatible = "fsl,imx8qxp-pwm", "fsl,imx27-pwm";
+               reg = <0x0 0x5d020000 0 0x10000>;
+               clock-names = "ipg", "per";
+               clocks = <&pwm2_lpcg 4>,
+               <&pwm2_lpcg 1>;
+               assigned-clocks = <&clk IMX_SC_R_PWM_2 IMX_SC_PM_CLK_PER>;
+               assigned-clock-rates = <24000000>;
+               power-domains = <&pd IMX_SC_R_PWM_2>;          
+               #pwm-cells = <2>;
+               status = "disabled";
+       };      
+Add the following content to the DTS file of our board
inside &iomuxc {
pinctrl_pwm2_d: pwm2d {                fsl,pins = <IMX8QXP_UART1_RTS_B_LSIO_PWM2_OUT               0x60>;
        };
 }
&pwm2 {pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm2_d>;
#pwm-cells = <2>;
status = "okay";
};