/*
 * ALSA SoC - Samsung ABOX driver
 *
 * Copyright (c) 2016 Samsung Electronics Co. Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __ABOX_H
#define __ABOX_H

#include <linux/device.h>
#include <linux/irqreturn.h>
#include <linux/scatterlist.h>
#include <sound/soc.h>
#include <sound/samsung/abox_ipc.h>

#ifdef CONFIG_SND_SOC_SAMSUNG_AUDIO
#define CHANGE_DEV_PRINT
#include <sound/samsung/sec_audio_debug.h>
#endif

/**
 * abox irq handler type definition
 * @param[in]	ipc_id	id of ipc
 * @param[in]	dev_id	dev_id from abox_register_irq_handler
 * @param[in]	msg	message data
 * @return	reference irqreturn_t
 */
typedef irqreturn_t (*abox_irq_handler_t)(int ipc_id, void *dev_id,
		ABOX_IPC_MSG *msg);

#ifdef CONFIG_SND_SOC_SAMSUNG_ABOX
/**
 * Check ABOX is on
 * @return		true if A-Box is on, false on otherwise
 */
extern bool abox_is_on(void);

/**
 * Get INT frequency required by ABOX
 * @return		INT frequency in kHz
 */
extern unsigned int abox_get_requiring_int_freq_in_khz(void);

/**
 * Get AUD frequency required by ABOX
 * @return		AUD frequency in kHz
 */
extern unsigned int abox_get_requiring_aud_freq_in_khz(void);

/**
 * Start abox IPC
 * @param[in]	dev		pointer to abox device
 * @param[in]	hw_irq		hardware IRQ number
 * @param[in]	supplement	pointer to data
 * @param[in]	size		size of data which are pointed by supplement
 * @param[in]	atomic		1, if caller context is atomic. 0, if not.
 * @param[in]	sync		1 to wait for ack. 0 if not.
 * @return	error code if any
 */
extern int abox_request_ipc(struct device *dev,
		int hw_irq, const void *supplement,
		size_t size, int atomic, int sync);

/**
 * Start abox IPC
 * @param[in]	dev		pointer to abox device
 * @param[in]	hw_irq		hardware IRQ number
 * @param[in]	supplement	pointer to data
 * @param[in]	size		size of data which are pointed by supplement
 * @param[in]	atomic		1, if caller context is atomic. 0, if not.
 * @param[in]	sync		1 to wait for ack. 0 if not.
 * @return	error code if any
 */
static inline int abox_start_ipc_transaction(struct device *dev,
		int hw_irq, const void *supplement,
		size_t size, int atomic, int sync)
{
	return abox_request_ipc(dev, hw_irq, supplement, size, atomic, sync);
}

/**
 * Register irq handler to abox
 * @param[in]	dev		pointer to abox device
 * @param[in]	ipc_id		id of ipc
 * @param[in]	irq_handler	abox irq handler to register
 * @param[in]	dev_id		cookie which would be summitted with irq_handler
 * @return	error code if any
 */
extern int abox_register_irq_handler(struct device *dev, int ipc_id,
		abox_irq_handler_t irq_handler, void *dev_id);

/**
 * UAIF/DSIF hw params fixup helper
 * @param[in]	rtd	snd_soc_pcm_runtime
 * @param[out]	params	snd_pcm_hw_params
 * @param[in]	stream	SNDRV_PCM_STREAM_PLAYBACK or SNDRV_PCM_STREAM_CAPTURE
 * @return		error code if any
 */
extern int abox_hw_params_fixup_helper(struct snd_soc_pcm_runtime *rtd,
		struct snd_pcm_hw_params *params, int stream);

/**
 * Request or release dram during cpuidle (count based API)
 * @param[in]   pdev_abox       pointer to abox platform device
 * @param[in]   id              key which is used as unique handle
 * @param[in]   on              true for requesting, false on otherwise
 */
extern void abox_request_dram_on(struct platform_device *pdev_abox, void *id, bool on);

/**
 * iommu map for abox
 * @param[in]	dev	pointer to abox device
 * @param[in]	iova	device virtual address
 * @param[in]	addr	kernel physical address
 * @param[in]	bytes	size of the mapping area
 * @param[in]	area	kernel virtual address
 * @return	error code if any
 */
extern int abox_iommu_map(struct device *dev, unsigned long iova,
		phys_addr_t addr, size_t bytes, void *area);

/**
 * iommu map for abox
 * @param[in]	dev	pointer to abox device
 * @param[in]	iova	device virtual address
 * @param[in]	sg	scatter list
 * @param[in]	nents	nents of scatter list
 * @param[in]	prot	protection parameter
 * @param[in]	bytes	size of the mapping area
 * @param[in]	area	kernel virtual address
 * @return	error code if any
 */
extern int abox_iommu_map_sg(struct device *dev, unsigned long iova,
		struct scatterlist *sg, unsigned int nents,
		int prot, size_t bytes, void *area);

/**
 * iommu unmap for abox
 * @param[in]	dev	pointer to abox device
 * @param[in]	iova	device virtual address
 * @return	error code if any
 */
extern int abox_iommu_unmap(struct device *dev, unsigned long iova);

/**
 * query physical address from device virtual address
 * @param[in]	dev		pointer to abox device
 * @param[in]	iova		device virtual address
 * @return	physical address. 0 if not mapped
 */
extern phys_addr_t abox_iova_to_phys(struct device *dev, unsigned long iova);

/**
 * query virtual address from device virtual address
 * @param[in]	dev		pointer to abox device
 * @param[in]	iova		device virtual address
 * @return	virtual address. undefined if not mapped
 */
extern void *abox_iova_to_virt(struct device *dev, unsigned long iova);

/**
 * power off abox
 */
extern void abox_poweroff(void);

#else /* !CONFIG_SND_SOC_SAMSUNG_ABOX */

static inline bool abox_is_on(void)
{
	return false;
}

static inline unsigned int abox_get_requiring_int_freq_in_khz(void)
{
	return 0;
}

static inline int abox_request_ipc(struct device *dev,
		int hw_irq, const void *supplement,
		size_t size, int atomic, int sync)
{
	return -ENODEV;
}

static inline int abox_register_irq_handler(struct device *dev, int ipc_id,
		abox_irq_handler_t irq_handler, void *dev_id)
{
	return -ENODEV;
}

static inline int abox_hw_params_fixup_helper(struct snd_soc_pcm_runtime *rtd,
		struct snd_pcm_hw_params *params)
{
	return -ENODEV;
}

static inline int abox_iommu_map(struct device *dev, unsigned long iova,
		phys_addr_t addr, size_t bytes, void *addr)
{
	return -ENODEV;
}

static inline int abox_iommu_unmap(struct device *dev, unsigned long iova)
{
	return -ENODEV;
}

static inline int abox_iommu_map_sg(struct device *dev, unsigned long iova,
		struct scatterlist *sg, unsigned int nents,
		int prot, size_t bytes, void *area)
{
	return -ENODEV;
}

static inline phys_addr_t abox_iova_to_phys(struct device *dev,
		unsigned long iova)
{
	return 0;
}

static inline void *abox_iova_to_virt(struct device *dev, unsigned long iova)
{
	return ERR_PTR(-ENODEV);
}

static inline void abox_poweroff(void) {}

#endif /* !CONFIG_SND_SOC_SAMSUNG_ABOX */

#endif /* __ABOX_H */
