/*
 * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

&soc {
	apc_apm: apm@b111000 {
		compatible = "qcom,ipq807x-apm";
		reg = <0x0 0xb111000 0x0 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-ipq6018-apss-regulator";
		reg = <0x0 0xb018000 0x0 0x4000>, <0x0 0xa4000 0x0 0x1000>, <0x0 0x0193d008 0x0 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 = <0>;
		qcom,cpr-step-quot-init-max = <15>;
		qcom,cpr-count-mode = <0>;		/* All-at-once */
		qcom,cpr-count-repeat = <1>;
		qcom,cpr-down-error-step-limit = <1>;
		qcom,cpr-up-error-step-limit = <1>;
		qcom,apm-ctrl = <&apc_apm>;
		qcom,apm-threshold-voltage = <850000>;
		vdd-supply = <&ipq6018_s2>;
		qcom,voltage-step = <12500>;

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

			apc_vreg: regulator {
				regulator-name = "apc_corner";
				regulator-min-microvolt = <1>;
				regulator-max-microvolt = <6>;
				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-voltage-ceiling =
					<725000 787500 862500
					 925000 987500 1062500>;
				qcom,cpr-voltage-floor =
					<587500 650000 712500
					 750000 787500 850000>;
				qcom,corner-frequencies =
					<864000000 1056000000 1320000000
					1440000000 1608000000 1800000000>;
				qcom,cpr-ro-sel =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					<     7      7      7     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>;

				qcom,cpr-open-loop-voltage-fuse-adjustment =
					/* Speed bin 0; CPR rev 0..7 */
					/*   SVS  Nominal Turbo Turbo_L1 */
					<     0      0      0     0>,
					<     0      0  15000     0>,
					<     0      0  15000     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>,
					<     0      0      0     0>;

				qcom,cpr-closed-loop-voltage-fuse-adjustment =
					/* Speed bin 0; CPR rev 0..7 */
					<     0      0      0     0>,
					< 13000      0  13000 13000>,
					< 13000      0  13000 13000>,
					<     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 =
					< 2000 1770 1900 1670 1930 1770 1910 1800
					  1870 1730 2000 1840 1800 2030 1700 1890 >,
					< 2000 1770 1900 1670 1930 1770 1910 1800
					  1870 1730 2000 1840 1800 2030 1700 1890 >,
					< 2000 1770 1900 1670 1930 1770 1910 1800
					  1870 1730 2000 1840 1800 2030 1700 1890 >,
					< 2000 1770 1900 1670 1930 1770 1910 1800
					  1870 1730 2000 1840 1800 2030 1700 1890 >;
				regulator-always-on;
			};
		};
	};
};
