#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/spmi/spmi.h>

&spmi_bus {
	#address-cells = <2>;
	#size-cells = <0>;
	interrupt-controller;
	#interrupt-cells = <4>;

	qcom,pmxr2230@1 {
		compatible = "qcom,spmi-pmic";
		reg = <1 SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		pmxr2230_tz: pmxr2230-temp-alarm@a00 {
			compatible = "qcom,spmi-temp-alarm";
			reg = <0xa00>;
			interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>;
			#thermal-sensor-cells = <0>;
		};

		pmxr2230_gpios: pinctrl@8800 {
			compatible = "qcom,pmxr2230-gpio";
			reg = <0x8800>;
			gpio-controller;
			#gpio-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;
		};

		pmxr2230_pwm_1: pwms@e800 {
			compatible = "qcom,pwm-lpg";
			reg = <0xe800>;
			reg-names = "lpg-base";
			#pwm-cells = <2>;
			qcom,num-lpg-channels = <3>;
			nvmem = <&pmk8550_sdam_21 &pmk8550_sdam_22>;
			nvmem-names = "lpg_chan_sdam", "lut_sdam";
			qcom,lut-sdam-base = <0x45>;
			qcom,lut-patterns = <0 10 20 30 40 50 60 70 80 90 100
					     90 80 70 60 50 40 30 20 10 0>;
			qcom,tick-duration-us = <7800>;

			lpg@1 {
				qcom,lpg-chan-id = <1>;
				qcom,ramp-step-ms = <100>;
				qcom,ramp-low-index = <0>;
				qcom,ramp-high-index = <19>;
				qcom,ramp-pattern-repeat;
				qcom,lpg-sdam-base = <0x48>;
			};

			lpg@2 {
				qcom,lpg-chan-id = <2>;
				qcom,ramp-step-ms = <100>;
				qcom,ramp-low-index = <0>;
				qcom,ramp-high-index = <19>;
				qcom,ramp-pattern-repeat;
				qcom,lpg-sdam-base = <0x56>;
			};

			lpg@3 {
				qcom,lpg-chan-id = <3>;
				qcom,ramp-step-ms = <100>;
				qcom,ramp-low-index = <0>;
				qcom,ramp-high-index = <19>;
				qcom,ramp-pattern-repeat;
				qcom,lpg-sdam-base = <0x64>;
			};
		};

		pmxr2230_pwm_2: pwms@eb00 {
			compatible = "qcom,pwm-lpg";
			reg = <0xeb00>;
			reg-names = "lpg-base";
			#pwm-cells = <2>;
			qcom,num-lpg-channels = <1>;
		};

		pmxr2230_rgb: qcom,leds@ef00 {
			compatible = "qcom,tri-led";
			reg = <0xef00>;

			red {
				label = "red";
				pwms = <&pmxr2230_pwm_1 0 1000000>;
				led-sources = <0>;
				linux,default-trigger = "timer";
			};

			green {
				label = "green";
				pwms = <&pmxr2230_pwm_1 1 1000000>;
				led-sources = <1>;
				linux,default-trigger = "timer";
			};

			blue {
				label = "blue";
				pwms = <&pmxr2230_pwm_1 2 1000000>;
				led-sources = <2>;
				linux,default-trigger = "timer";
			};
		};

		pmxr2230_flash: qcom,flash_led@ee00 {
			compatible = "qcom,pm8350c-flash-led";
			reg = <0xee00>;
			interrupts = <0x1 0xee 0x0 IRQ_TYPE_EDGE_RISING>,
				     <0x1 0xee 0x3 IRQ_TYPE_EDGE_RISING>,
				     <0x1 0xee 0x4 IRQ_TYPE_EDGE_RISING>;
			interrupt-names = "led-fault-irq",
					  "all-ramp-down-done-irq",
					  "all-ramp-up-done-irq";
			qcom,thermal-derate-current = <200 500>;
			status = "disabled";

			pmxr2230_flash0: qcom,flash_0 {
				label = "flash";
				qcom,led-name = "led:flash_0";
				qcom,max-current-ma = <1500>;
				qcom,default-led-trigger = "flash0_trigger";
				qcom,id = <0>;
				qcom,duration-ms = <1280>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_flash1: qcom,flash_1 {
				label = "flash";
				qcom,led-name = "led:flash_1";
				qcom,max-current-ma = <1500>;
				qcom,default-led-trigger = "flash1_trigger";
				qcom,id = <1>;
				qcom,duration-ms = <1280>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_flash2: qcom,flash_2 {
				label = "flash";
				qcom,led-name = "led:flash_2";
				qcom,max-current-ma = <1500>;
				qcom,default-led-trigger = "flash2_trigger";
				qcom,id = <2>;
				qcom,duration-ms = <1280>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_flash3: qcom,flash_3 {
				label = "flash";
				qcom,led-name = "led:flash_3";
				qcom,max-current-ma = <1500>;
				qcom,default-led-trigger = "flash3_trigger";
				qcom,id = <3>;
				qcom,duration-ms = <1280>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_torch0: qcom,torch_0 {
				label = "torch";
				qcom,led-name = "led:torch_0";
				qcom,max-current-ma = <500>;
				qcom,default-led-trigger = "torch0_trigger";
				qcom,id = <0>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_torch1: qcom,torch_1 {
				label = "torch";
				qcom,led-name = "led:torch_1";
				qcom,max-current-ma = <500>;
				qcom,default-led-trigger = "torch1_trigger";
				qcom,id = <1>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_torch2: qcom,torch_2 {
				label = "torch";
				qcom,led-name = "led:torch_2";
				qcom,max-current-ma = <500>;
				qcom,default-led-trigger = "torch2_trigger";
				qcom,id = <2>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_torch3: qcom,torch_3 {
				label = "torch";
				qcom,led-name = "led:torch_3";
				qcom,max-current-ma = <500>;
				qcom,default-led-trigger = "torch3_trigger";
				qcom,id = <3>;
				qcom,ires-ua = <12500>;
			};

			pmxr2230_switch0: qcom,led_switch_0 {
				label = "switch";
				qcom,led-name = "led:switch_0";
				qcom,default-led-trigger = "switch0_trigger";
			};

			pmxr2230_switch1: qcom,led_switch_1 {
				label = "switch";
				qcom,led-name = "led:switch_1";
				qcom,default-led-trigger = "switch1_trigger";
			};

			pmxr2230_switch2: qcom,led_switch_2 {
				label = "switch";
				qcom,led-name = "led:switch_2";
				qcom,default-led-trigger = "switch2_trigger";
			};
		};

		pmxr2230_bcl: bcl@4700 {
			compatible = "qcom,bcl-v5";
			reg = <0x4700 0x100>;
			interrupts = <0x1 0x47 0x0 IRQ_TYPE_NONE>,
					<0x1 0x47 0x1 IRQ_TYPE_NONE>,
					<0x1 0x47 0x2 IRQ_TYPE_NONE>;
			interrupt-names = "bcl-lvl0",
					"bcl-lvl1",
					"bcl-lvl2";
			qcom,pmic7-threshold;
			#thermal-sensor-cells = <1>;
		};
	};
};

&thermal_zones {
	pmxr2230_temp_alarm: pmxr2230_tz {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pmxr2230_tz>;

		trips {
			pmxr2230_trip0: trip0 {
				temperature = <95000>;
				hysteresis = <0>;
				type = "passive";
			};

			pmxr2230_trip1: trip1 {
				temperature = <115000>;
				hysteresis = <0>;
				type = "passive";
			};

			pmxr2230_trip2: trip2 {
				temperature = <145000>;
				hysteresis = <0>;
				type = "critical";
			};
		};
	};

	pmxr2230-bcl-lvl0 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pmxr2230_bcl 5>;

		trips {
			bcl_lvl0: bcl-lvl0 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};

	pmxr2230-bcl-lvl1 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pmxr2230_bcl 6>;

		trips {
			bcl_lvl1: bcl-lvl1 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};

	pmxr2230-bcl-lvl2 {
		polling-delay-passive = <100>;
		polling-delay = <0>;
		thermal-governor = "step_wise";
		thermal-sensors = <&pmxr2230_bcl 7>;

		trips {
			bcl_lvl2: bcl-lvl2 {
				temperature = <1>;
				hysteresis = <1>;
				type = "passive";
			};
		};
	};
};
