// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2021, Linaro Limited
 */

#include <dt-bindings/input/input.h>
#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/spmi/spmi.h>

/* (Sadly) this PMIC can be configured to be at different SIDs */
#ifndef PMK8350_SID
	#define PMK8350_SID 0
#endif

/ {
	reboot-mode {
		compatible = "nvmem-reboot-mode";
		nvmem-cells = <&reboot_reason>;
		nvmem-cell-names = "reboot-mode";
		mode-recovery = <0x01>;
		mode-bootloader = <0x02>;
	};
};
	
&spmi_bus {
	pmk8350: pmic@PMK8350_SID {
		compatible = "qcom,pmk8350", "qcom,spmi-pmic";
		reg = <PMK8350_SID SPMI_USID>;
		#address-cells = <1>;
		#size-cells = <0>;

		pmk8350_pon: pon@1300 {
			compatible = "qcom,pmk8350-pon";
			reg = <0x1300>, <0x800>;
			reg-names = "hlos", "pbs";

			pon_pwrkey: pwrkey {
				compatible = "qcom,pmk8350-pwrkey";
				interrupts = <PMK8350_SID 0x13 0x7 IRQ_TYPE_EDGE_BOTH>;
				linux,code = <KEY_POWER>;
				status = "disabled";
			};

			pon_resin: resin {
				compatible = "qcom,pmk8350-resin";
				interrupts = <PMK8350_SID 0x13 0x6 IRQ_TYPE_EDGE_BOTH>;
				status = "disabled";
			};
		};

		pmk8350_vadc: adc@3100 {
			compatible = "qcom,spmi-adc7";
			reg = <0x3100>;
			#address-cells = <1>;
			#size-cells = <0>;
			interrupts = <PMK8350_SID 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
			#io-channel-cells = <1>;
		};

		pmk8350_adc_tm: adc-tm@3400 {
			compatible = "qcom,spmi-adc-tm5-gen2";
			reg = <0x3400>;
			interrupts = <PMK8350_SID 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
			#address-cells = <1>;
			#size-cells = <0>;
			#thermal-sensor-cells = <1>;
			status = "disabled";
		};

		pmk8350_rtc: rtc@6100 {
			compatible = "qcom,pmk8350-rtc";
			reg = <0x6100>, <0x6200>;
			reg-names = "rtc", "alarm";
			interrupts = <PMK8350_SID 0x62 0x1 IRQ_TYPE_EDGE_RISING>;
			status = "disabled";
		};

		pmk8350_sdam_2: nvram@7100 {
			compatible = "qcom,spmi-sdam";
			reg = <0x7100>;
			#address-cells = <1>;
			#size-cells = <1>;
			ranges = <0 0x7100 0x100>;

			reboot_reason: reboot-reason@48 {
				reg = <0x48 0x1>;
				bits = <1 7>;
			};
		};

		pmk8350_gpios: gpio@b000 {
			compatible = "qcom,pmk8350-gpio", "qcom,spmi-gpio";
			reg = <0xb000>;
			gpio-controller;
			gpio-ranges = <&pmk8350_gpios 0 0 4>;
			#gpio-cells = <2>;
			interrupt-controller;
			#interrupt-cells = <2>;
		};
	};
};