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


#ifndef __SOC_QCOM_CRM_H__
#define __SOC_QCOM_CRM_H__

#include <linux/platform_device.h>


enum crm_hw_drv_state {
	CRM_PWR_STATE0,
	CRM_PWR_STATE1,
	CRM_PWR_STATE2,
	CRM_PWR_STATE3,
	CRM_PWR_STATE4,
};


enum crm_sw_drv_state {
	CRM_ACTIVE_STATE,
	CRM_SLEEP_STATE,
	CRM_WAKE_STATE,
};

union power_state {
	enum crm_hw_drv_state hw;
	enum crm_sw_drv_state sw;
};


enum crm_drv_type {
	CRM_HW_DRV,
	CRM_SW_DRV,
};


struct crm_cmd {
	union power_state pwr_state;
	u32 resource_idx;
	u32 data;
	bool wait;
};

#if IS_ENABLED(CONFIG_QCOM_CRM)
int crm_write_perf_ol(const struct device *dev, enum crm_drv_type drv,
		      u32 drv_id, const struct crm_cmd *cmd);
int crm_write_bw_vote(const struct device *dev, enum crm_drv_type drv,
		      u32 drv_id, const struct crm_cmd *cmd);
int crm_write_pwr_states(const struct device *dev, u32 drv_id);

const struct device *crm_get_device(const char *name);
#else

static inline int crm_write_perf_ol(const struct device *dev,
				    enum crm_drv_type drv,
				    u32 drv_id,
				    const struct crm_cmd *cmd)
{ return -ENODEV; }

static inline int crm_write_bw_vote(const struct device *dev,
				    enum crm_drv_type drv,
				    u32 drv_id,
				    const struct crm_cmd *cmd)
{ return -ENODEV; }

static inline int crm_write_pwr_states(const struct device *dev, u32 drv_id)
{ return -ENODEV; }

static inline const struct device *crm_get_device(const char *name)
{ return ERR_PTR(-ENODEV); }
#endif 

#endif 
