// SPDX-License-Identifier: GPL-2.0-only

#include "pmp8074.dtsi"

&soc {
	apc_apm: apm@b111000 {
		compatible = "qcom,ipq807x-apm";
		reg = <0xb111000 0x1000>;
		reg-names = "pm-apcc-glb";
		qcom,apm-post-halt-delay = <0x2>;
		qcom,apm-halt-clk-delay = <0x11>;
		qcom,apm-resume-clk-delay = <0x10>;
		qcom,apm-sel-switch-delay = <0x01>;
	};

	apc_cpr: cpr4-ctrl@b018000 {
		compatible = "qcom,cpr4-ipq807x-apss-regulator";
		reg = <0xb018000 0x4000>, <0xa4000 0x1000>, <0x0193d008 0x4>;
		reg-names = "cpr_ctrl", "fuse_base", "cpr_tcsr_reg";
		interrupts = <GIC_SPI 15 IRQ_TYPE_EDGE_RISING>;
		interrupt-names = "cpr";
		qcom,cpr-ctrl-name = "apc";
		qcom,cpr-sensor-time = <1000>;
		qcom,cpr-loop-time = <5000000>;
		qcom,cpr-idle-cycles = <15>;
		qcom,cpr-step-quot-init-min = <12>;
		qcom,cpr-step-quot-init-max = <14>;
		qcom,cpr-count-mode = <0>;		/* All-at-once */
		qcom,cpr-count-repeat = <14>;
		qcom,cpr-down-error-step-limit = <1>;
		qcom,cpr-up-error-step-limit = <1>;
		qcom,apm-ctrl = <&apc_apm>;
		qcom,apm-threshold-voltage = <848000>;
		vdd-supply = <&s3>;
		qcom,voltage-step = <8000>;

		thread@0 {
			qcom,cpr-thread-id = <0>;
			qcom,cpr-consecutive-up = <0>;
			qcom,cpr-consecutive-down = <0>;
			qcom,cpr-up-threshold = <4>;
			qcom,cpr-down-threshold = <1>;

			apc_vreg: regulator {
				regulator-name = "apc_corner";
				regulator-min-microvolt = <1>;
				regulator-max-microvolt = <6>;
				qcom,cpr-part-types = <2>;
				qcom,cpr-parts-voltage = <1048000>;
				qcom,cpr-parts-voltage-v2 = <992000>;
				qcom,cpr-fuse-corners = <4>;
				qcom,cpr-fuse-combos = <8>;
				qcom,cpr-corners = <6>;
				qcom,cpr-speed-bins = <1>;
				qcom,cpr-speed-bin-corners = <6>;
				qcom,cpr-corner-fmax-map = <1 3 5 6>;
				qcom,allow-voltage-interpolation;
				qcom,allow-quotient-interpolation;
				qcom,cpr-scaled-open-loop-voltage-as-ceiling;
				qcom,cpr-voltage-ceiling =
					<840000 904000 944000
					 984000 992000 1064000>;
				qcom,cpr-voltage-floor =
					<592000 648000 712000
					 744000 784000 848000>;
				qcom,corner-frequencies =
					<1017600000 1382400000 1651200000
					1843200000 1920000000 2208000000>;

				/* TT/FF parts i.e. turbo L1 OL voltage < 1048 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-0 =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0 12000>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				/* SS parts i.e turbo L1 OL voltage >= 1048 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-1 =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					< 20000  26000      0 20000>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				/* v2 - FF parts i.e. turbo L1 OL voltage < 992 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-v2-0 =
                                        /* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				/* v2 - SS/TT parts i.e turbo L1 OL voltage >= 992 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-v2-1 =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0   7000  36000  4000>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				/* v2 - FF parts i.e. turbo L1 OL voltage < 992 mV */
				qcom,cpr-closed-loop-voltage-adjustment-v2-0 =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				/* v2 - SS/TT parts i.e turbo L1 OL voltage >= 992 mV */
				qcom,cpr-closed-loop-voltage-adjustment-v2-1 =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     0      0      19000 0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				qcom,cpr-ro-scaling-factor =
					< 3970 4150 0    2280 2520 2470 2250 2280
					  2390 2330 2530 2500  850 2900 2510 2170 >,
					< 3970 4150 0    2280 2520 2470 2250 2280
					  2390 2330 2530 2500  850 2900 2510 2170 >,
					< 3970 4150 0    2280 2520 2470 2250 2280
					  2390 2330 2530 2500  850 2900 2510 2170 >,
					< 3970 4150 0    2280 2520 2470 2250 2280
					  2390 2330 2530 2500  850 2900 2510 2170 >;

				qcom,cpr-floor-to-ceiling-max-range =
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>,
					< 40000 40000 40000 40000 40000 40000>;
				regulator-always-on;
			};
		};
	};

	npu_cpr: npu-cpr {
		compatible = "qcom,cpr3-ipq807x-npu-regulator";
		reg = <0xa4000 0x1000>, <0x0193d008 0x4>;
		reg-names = "fuse_base", "cpr_tcsr_reg";
		qcom,cpr-ctrl-name = "npu";
		vdd-supply = <&s4>;
		qcom,voltage-step = <8000>;
		thread@0 {
			qcom,cpr-thread-id = <0>;
			qcom,cpr-consecutive-up = <0>;
			qcom,cpr-consecutive-down = <2>;
			qcom,cpr-up-threshold = <2>;
			qcom,cpr-down-threshold = <1>;

			npu_vreg: regulator {
				regulator-name = "npu_corner";
				regulator-min-microvolt = <1>;
				regulator-max-microvolt = <3>;
				qcom,cpr-part-types = <2>;
				qcom,cpr-parts-voltage = <968000>;
				qcom,cpr-parts-voltage-v2 = <832001>;
				qcom,cpr-cold-temp-threshold-v2 = <30>;
				qcom,cpr-fuse-corners = <2>;
				qcom,cpr-fuse-combos = <1>;
				qcom,cpr-corners = <2>;
				qcom,cpr-speed-bins = <1>;
				qcom,cpr-speed-bin-corners = <2>;
				qcom,allow-voltage-interpolation;
				qcom,cpr-corner-fmax-map = <1 2>;
				qcom,cpr-voltage-ceiling =
					<912000 992000>;
				qcom,cpr-voltage-floor =
					<752000 792000>;
				qcom,corner-frequencies =
					<1497600000 1689600000>;

				/* TT/FF parts i.e. turbo OL voltage < 968 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-0 =
					< 40000   40000>;

				/* SS parts i.e turbo OL voltage >= 968 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-1 =
					< 24000   24000>;

				/* FF parts i.e. turbo OL voltage <= 832 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-v2-0=
					<40000   40000>;

				 /* TT/SS parts i.e turbo OL voltage > 832 mV */
				qcom,cpr-open-loop-voltage-fuse-adjustment-v2-1=
					<40000   40000>;

				/* FF parts i.e. turbo OL voltage <= 832 mV */
				qcom,cpr-cold-temp-voltage-adjustment-v2-0 =
					<0   0>;

				/* TT/SS parts i.e turbo OL voltage > 832 mV */
				qcom,cpr-cold-temp-voltage-adjustment-v2-1 =
					<35000   27000>;
			};
		};
	};
};
