// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2012 Samsung Electronics
 * R. Chandrasekar <rcsekar@samsung.com>
 */
#include <audio_codec.h>
#include <dm.h>
#include <div64.h>
#include <fdtdec.h>
#include <i2c.h>
#include <i2s.h>
#include <log.h>
#include <sound.h>
#include <asm/gpio.h>
#include <asm/io.h>
#include <asm/arch/clk.h>
#include <asm/arch/cpu.h>
#include <asm/arch/sound.h>
#include "wm8994.h"
#include "wm8994_registers.h"

/* defines for wm8994 system clock selection */
#define SEL_MCLK1	0x00
#define SEL_MCLK2	0x08
#define SEL_FLL1	0x10
#define SEL_FLL2	0x18

/* fll config to configure fll */
struct wm8994_fll_config {
	int src;	/* Source */
	int in;		/* Input frequency in Hz */
	int out;	/* output frequency in Hz */
};

/* codec private data */
struct wm8994_priv {
	enum wm8994_type type;		/* codec type of wolfson */
	int revision;			/* Revision */
	int sysclk[WM8994_MAX_AIF];	/* System clock frequency in Hz  */
	int mclk[WM8994_MAX_AIF];	/* master clock frequency in Hz */
	int aifclk[WM8994_MAX_AIF];	/* audio interface clock in Hz   */
	struct wm8994_fll_config fll[2]; /* fll config to configure fll */
	struct udevice *dev;
};

/* wm 8994 supported sampling rate values */
static unsigned int src_rate[] = {
			 8000, 11025, 12000, 16000, 22050, 24000,
			 32000, 44100, 48000, 88200, 96000
};

/* op clock divisions */
static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 };

/* lr clock frame size ratio */
static int fs_ratios[] = {
	64, 128, 192, 256, 348, 512, 768, 1024, 1408, 1536
};

/* bit clock divisors */
static int bclk_divs[] = {
	10, 15, 20, 30, 40, 50, 60, 80, 110, 120, 160, 220, 240, 320, 440, 480,
	640, 880, 960, 1280, 1760, 1920
};

/*
 * Writes value to a device register through i2c
 *
 * @param priv	Private data for driver
 * @param reg	reg number to be write
 * @param data	data to be writen to the above registor
 *
 * Return:	int value 1 for change, 0 for no change or negative error code.
 */
static int wm8994_i2c_write(struct wm8994_priv *priv, unsigned int reg,
			    unsigned short data)
{
	unsigned char val[2];

	val[0] = (unsigned char)((data >> 8) & 0xff);
	val[1] = (unsigned char)(data & 0xff);
	debug("Write Addr : 0x%04X, Data :  0x%04X\n", reg, data);

	return dm_i2c_write(priv->dev, reg, val, 2);
}

/*
 * Read a value from a device register through i2c
 *
 * @param priv	Private data for driver
 * @param reg	reg number to be read
 * @param data	address of read data to be stored
 *
 * Return:	int value 0 for success, -1 in case of error.
 */
static unsigned int wm8994_i2c_read(struct wm8994_priv *priv, unsigned int reg,
				    unsigned short *data)
{
	unsigned char val[2];
	int ret;

	ret = dm_i2c_read(priv->dev, reg, val, 1);
	if (ret != 0) {
		debug("%s: Error while reading register %#04x\n",
		      __func__, reg);
		return -1;
	}

	*data = val[0];
	*data <<= 8;
	*data |= val[1];

	return 0;
}

/*
 * update device register bits through i2c
 *
 * @param priv	Private data for driver
 * @param reg	codec register
 * @param mask	register mask
 * @param value	new value
 *
 * Return: int value 1 if change in the register value,
 * 0 for no change or negative error code.
 */
static int wm8994_bic_or(struct wm8994_priv *priv, unsigned int reg,
			 unsigned short mask, unsigned short value)
{
	int change , ret = 0;
	unsigned short old, new;

	if (wm8994_i2c_read(priv, reg, &old) != 0)
		return -1;
	new = (old & ~mask) | (value & mask);
	change  = (old != new) ? 1 : 0;
	if (change)
		ret = wm8994_i2c_write(priv, reg, new);
	if (ret < 0)
		return ret;

	return change;
}

/*
 * Sets i2s set format
 *
 * @param priv		wm8994 information
 * @param aif_id	Interface ID
 * @param fmt		i2S format
 *
 * Return: -1 for error and 0  Success.
 */
static int wm8994_set_fmt(struct wm8994_priv *priv, int aif_id, uint fmt)
{
	int ms_reg;
	int aif_reg;
	int ms = 0;
	int aif = 0;
	int aif_clk = 0;
	int error = 0;

	switch (aif_id) {
	case 1:
		ms_reg = WM8994_AIF1_MASTER_SLAVE;
		aif_reg = WM8994_AIF1_CONTROL_1;
		aif_clk = WM8994_AIF1_CLOCKING_1;
		break;
	case 2:
		ms_reg = WM8994_AIF2_MASTER_SLAVE;
		aif_reg = WM8994_AIF2_CONTROL_1;
		aif_clk = WM8994_AIF2_CLOCKING_1;
		break;
	default:
		debug("%s: Invalid audio interface selection\n", __func__);
		return -1;
	}

	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
	case SND_SOC_DAIFMT_CBS_CFS:
		break;
	case SND_SOC_DAIFMT_CBM_CFM:
		ms = WM8994_AIF1_MSTR;
		break;
	default:
		debug("%s: Invalid i2s master selection\n", __func__);
		return -1;
	}

	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
	case SND_SOC_DAIFMT_DSP_B:
		aif |= WM8994_AIF1_LRCLK_INV;
	case SND_SOC_DAIFMT_DSP_A:
		aif |= 0x18;
		break;
	case SND_SOC_DAIFMT_I2S:
		aif |= 0x10;
		break;
	case SND_SOC_DAIFMT_RIGHT_J:
		break;
	case SND_SOC_DAIFMT_LEFT_J:
		aif |= 0x8;
		break;
	default:
		debug("%s: Invalid i2s format selection\n", __func__);
		return -1;
	}

	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
	case SND_SOC_DAIFMT_DSP_A:
	case SND_SOC_DAIFMT_DSP_B:
		/* frame inversion not valid for DSP modes */
		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
		case SND_SOC_DAIFMT_NB_NF:
			break;
		case SND_SOC_DAIFMT_IB_NF:
			aif |= WM8994_AIF1_BCLK_INV;
			break;
		default:
			debug("%s: Invalid i2s frame inverse selection\n",
			      __func__);
			return -1;
		}
		break;

	case SND_SOC_DAIFMT_I2S:
	case SND_SOC_DAIFMT_RIGHT_J:
	case SND_SOC_DAIFMT_LEFT_J:
		switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
		case SND_SOC_DAIFMT_NB_NF:
			break;
		case SND_SOC_DAIFMT_IB_IF:
			aif |= WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV;
			break;
		case SND_SOC_DAIFMT_IB_NF:
			aif |= WM8994_AIF1_BCLK_INV;
			break;
		case SND_SOC_DAIFMT_NB_IF:
			aif |= WM8994_AIF1_LRCLK_INV;
			break;
		default:
			debug("%s: Invalid i2s clock polarity selection\n",
			      __func__);
			return -1;
		}
		break;
	default:
		debug("%s: Invalid i2s format selection\n", __func__);
		return -1;
	}

	error = wm8994_bic_or(priv, aif_reg, WM8994_AIF1_BCLK_INV |
			      WM8994_AIF1_LRCLK_INV_MASK |
			       WM8994_AIF1_FMT_MASK, aif);

	error |= wm8994_bic_or(priv, ms_reg, WM8994_AIF1_MSTR_MASK, ms);
	error |= wm8994_bic_or(priv, aif_clk, WM8994_AIF1CLK_ENA_MASK,
			       WM8994_AIF1CLK_ENA);
	if (error < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Sets hw params FOR WM8994
 *
 * @param priv			wm8994 information pointer
 * @param aif_id		Audio interface ID
 * @param sampling_rate		Sampling rate
 * @param bits_per_sample	Bits per sample
 * @param Channels		Channels in the given audio input
 *
 * Return: -1 for error  and 0  Success.
 */
static int wm8994_hw_params(struct wm8994_priv *priv, int aif_id,
			    uint sampling_rate, uint bits_per_sample,
			    uint channels)
{
	int aif1_reg;
	int aif2_reg;
	int bclk_reg;
	int bclk = 0;
	int rate_reg;
	int aif1 = 0;
	int aif2 = 0;
	int rate_val = 0;
	int id = aif_id - 1;
	int i, cur_val, best_val, bclk_rate, best;
	unsigned short reg_data;
	int ret = 0;

	switch (aif_id) {
	case 1:
		aif1_reg = WM8994_AIF1_CONTROL_1;
		aif2_reg = WM8994_AIF1_CONTROL_2;
		bclk_reg = WM8994_AIF1_BCLK;
		rate_reg = WM8994_AIF1_RATE;
		break;
	case 2:
		aif1_reg = WM8994_AIF2_CONTROL_1;
		aif2_reg = WM8994_AIF2_CONTROL_2;
		bclk_reg = WM8994_AIF2_BCLK;
		rate_reg = WM8994_AIF2_RATE;
		break;
	default:
		return -1;
	}

	bclk_rate = sampling_rate * 32;
	switch (bits_per_sample) {
	case 16:
		bclk_rate *= 16;
		break;
	case 20:
		bclk_rate *= 20;
		aif1 |= 0x20;
		break;
	case 24:
		bclk_rate *= 24;
		aif1 |= 0x40;
		break;
	case 32:
		bclk_rate *= 32;
		aif1 |= 0x60;
		break;
	default:
		return -1;
	}

	/* Try to find an appropriate sample rate; look for an exact match. */
	for (i = 0; i < ARRAY_SIZE(src_rate); i++)
		if (src_rate[i] == sampling_rate)
			break;

	if (i == ARRAY_SIZE(src_rate)) {
		debug("%s: Could not get the best matching samplingrate\n",
		      __func__);
		return -1;
	}

	rate_val |= i << WM8994_AIF1_SR_SHIFT;

	/* AIFCLK/fs ratio; look for a close match in either direction */
	best = 0;
	best_val = abs((fs_ratios[0] * sampling_rate) - priv->aifclk[id]);

	for (i = 1; i < ARRAY_SIZE(fs_ratios); i++) {
		cur_val = abs(fs_ratios[i] * sampling_rate - priv->aifclk[id]);
		if (cur_val >= best_val)
			continue;
		best = i;
		best_val = cur_val;
	}

	rate_val |= best;

	/*
	 * We may not get quite the right frequency if using
	 * approximate clocks so look for the closest match that is
	 * higher than the target (we need to ensure that there enough
	 * BCLKs to clock out the samples).
	 */
	best = 0;
	for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) {
		cur_val = (priv->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate;
		if (cur_val < 0) /* BCLK table is sorted */
			break;
		best = i;
	}

	if (i ==  ARRAY_SIZE(bclk_divs)) {
		debug("%s: Could not get the best matching bclk division\n",
		      __func__);
		return -1;
	}

	bclk_rate = priv->aifclk[id] * 10 / bclk_divs[best];
	bclk |= best << WM8994_AIF1_BCLK_DIV_SHIFT;

	if (wm8994_i2c_read(priv, aif1_reg, &reg_data) != 0) {
		debug("%s: AIF1 register read Failed\n", __func__);
		return -1;
	}

	if ((channels == 1) && ((reg_data & 0x18) == 0x18))
		aif2 |= WM8994_AIF1_MONO;

	if (priv->aifclk[id] == 0) {
		debug("%s:Audio interface clock not set\n", __func__);
		return -1;
	}

	ret = wm8994_bic_or(priv, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
	ret |= wm8994_bic_or(priv, aif2_reg, WM8994_AIF1_MONO, aif2);
	ret |= wm8994_bic_or(priv, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK,
				  bclk);
	ret |= wm8994_bic_or(priv, rate_reg, WM8994_AIF1_SR_MASK |
				  WM8994_AIF1CLK_RATE_MASK, rate_val);

	debug("rate vale = %x , bclk val= %x\n", rate_val, bclk);

	if (ret < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Configures Audio interface Clock
 *
 * @param priv		wm8994 information pointer
 * @param aif		Audio Interface ID
 *
 * Return: -1 for error  and 0  Success.
 */
static int configure_aif_clock(struct wm8994_priv *priv, int aif)
{
	int rate;
	int reg1 = 0;
	int offset;
	int ret;

	/* AIF(1/0) register adress offset calculated */
	if (aif-1)
		offset = 4;
	else
		offset = 0;

	switch (priv->sysclk[aif - 1]) {
	case WM8994_SYSCLK_MCLK1:
		reg1 |= SEL_MCLK1;
		rate = priv->mclk[0];
		break;

	case WM8994_SYSCLK_MCLK2:
		reg1 |= SEL_MCLK2;
		rate = priv->mclk[1];
		break;

	case WM8994_SYSCLK_FLL1:
		reg1 |= SEL_FLL1;
		rate = priv->fll[0].out;
		break;

	case WM8994_SYSCLK_FLL2:
		reg1 |= SEL_FLL2;
		rate = priv->fll[1].out;
		break;

	default:
		debug("%s: Invalid input clock selection [%d]\n",
		      __func__, priv->sysclk[aif - 1]);
		return -1;
	}

	/* if input clock frequenct is more than 135Mhz then divide */
	if (rate >= WM8994_MAX_INPUT_CLK_FREQ) {
		rate /= 2;
		reg1 |= WM8994_AIF1CLK_DIV;
	}

	priv->aifclk[aif - 1] = rate;

	ret = wm8994_bic_or(priv, WM8994_AIF1_CLOCKING_1 + offset,
			    WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV,
			    reg1);

	if (aif == WM8994_AIF1)
		ret |= wm8994_bic_or(priv, WM8994_CLOCKING_1,
			WM8994_AIF1DSPCLK_ENA_MASK | WM8994_SYSDSPCLK_ENA_MASK,
			WM8994_AIF1DSPCLK_ENA | WM8994_SYSDSPCLK_ENA);
	else if (aif == WM8994_AIF2)
		ret |= wm8994_bic_or(priv, WM8994_CLOCKING_1,
			WM8994_SYSCLK_SRC | WM8994_AIF2DSPCLK_ENA_MASK |
			WM8994_SYSDSPCLK_ENA_MASK, WM8994_SYSCLK_SRC |
			WM8994_AIF2DSPCLK_ENA | WM8994_SYSDSPCLK_ENA);

	if (ret < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Configures Audio interface  for the given frequency
 *
 * @param priv		wm8994 information
 * @param aif_id	Audio Interface
 * @param clk_id	Input Clock ID
 * @param freq		Sampling frequency in Hz
 *
 * Return: -1 for error and 0 success.
 */
static int wm8994_set_sysclk(struct wm8994_priv *priv, int aif_id, int clk_id,
			     unsigned int freq)
{
	int i;
	int ret = 0;

	priv->sysclk[aif_id - 1] = clk_id;

	switch (clk_id) {
	case WM8994_SYSCLK_MCLK1:
		priv->mclk[0] = freq;
		if (aif_id == 2) {
			ret = wm8994_bic_or(priv, WM8994_AIF1_CLOCKING_2,
					    WM8994_AIF2DAC_DIV_MASK, 0);
		}
		break;

	case WM8994_SYSCLK_MCLK2:
		/* TODO: Set GPIO AF */
		priv->mclk[1] = freq;
		break;

	case WM8994_SYSCLK_FLL1:
	case WM8994_SYSCLK_FLL2:
		break;

	case WM8994_SYSCLK_OPCLK:
		/*
		 * Special case - a division (times 10) is given and
		 * no effect on main clocking.
		 */
		if (freq) {
			for (i = 0; i < ARRAY_SIZE(opclk_divs); i++)
				if (opclk_divs[i] == freq)
					break;
			if (i == ARRAY_SIZE(opclk_divs)) {
				debug("%s frequency divisor not found\n",
				      __func__);
				return -1;
			}
			ret = wm8994_bic_or(priv, WM8994_CLOCKING_2,
					    WM8994_OPCLK_DIV_MASK, i);
			ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_2,
					     WM8994_OPCLK_ENA,
					     WM8994_OPCLK_ENA);
		} else {
			ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_2,
					     WM8994_OPCLK_ENA, 0);
		}

	default:
		debug("%s Invalid input clock selection [%d]\n",
		      __func__, clk_id);
		return -1;
	}

	ret |= configure_aif_clock(priv, aif_id);

	if (ret < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Initializes Volume for AIF2 to HP path
 *
 * @param priv		wm8994 information
 * @returns -1 for error  and 0 Success.
 *
 */
static int wm8994_init_volume_aif2_dac1(struct wm8994_priv *priv)
{
	int ret;

	/* Unmute AIF2DAC */
	ret = wm8994_bic_or(priv, WM8994_AIF2_DAC_FILTERS_1,
			    WM8994_AIF2DAC_MUTE_MASK, 0);

	ret |= wm8994_bic_or(priv, WM8994_AIF2_DAC_LEFT_VOLUME,
			     WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACL_VOL_MASK,
			     WM8994_AIF2DAC_VU | 0xff);

	ret |= wm8994_bic_or(priv, WM8994_AIF2_DAC_RIGHT_VOLUME,
			     WM8994_AIF2DAC_VU_MASK | WM8994_AIF2DACR_VOL_MASK,
			     WM8994_AIF2DAC_VU | 0xff);

	ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_VOLUME,
			     WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK |
			     WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0);

	ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_VOLUME,
			     WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK |
			     WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0);
	/* Head Phone Volume */
	ret |= wm8994_i2c_write(priv, WM8994_LEFT_OUTPUT_VOLUME, 0x12D);
	ret |= wm8994_i2c_write(priv, WM8994_RIGHT_OUTPUT_VOLUME, 0x12D);

	if (ret < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Initializes Volume for AIF1 to HP path
 *
 * @param priv		wm8994 information
 * @returns -1 for error  and 0 Success.
 *
 */
static int wm8994_init_volume_aif1_dac1(struct wm8994_priv *priv)
{
	int ret = 0;

	/* Unmute AIF1DAC */
	ret |= wm8994_i2c_write(priv, WM8994_AIF1_DAC_FILTERS_1, 0x0000);

	ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_VOLUME,
			     WM8994_DAC1_VU_MASK | WM8994_DAC1L_VOL_MASK |
			     WM8994_DAC1L_MUTE_MASK, WM8994_DAC1_VU | 0xc0);

	ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_VOLUME,
			     WM8994_DAC1_VU_MASK | WM8994_DAC1R_VOL_MASK |
			     WM8994_DAC1R_MUTE_MASK, WM8994_DAC1_VU | 0xc0);
	/* Head Phone Volume */
	ret |= wm8994_i2c_write(priv, WM8994_LEFT_OUTPUT_VOLUME, 0x12D);
	ret |= wm8994_i2c_write(priv, WM8994_RIGHT_OUTPUT_VOLUME, 0x12D);

	if (ret < 0) {
		debug("%s: codec register access error\n", __func__);
		return -1;
	}

	return 0;
}

/*
 * Intialise wm8994 codec device
 *
 * @param priv		wm8994 information
 *
 * @returns -1 for error  and 0 Success.
 */
static int wm8994_device_init(struct wm8994_priv *priv)
{
	const char *devname;
	unsigned short reg_data;
	int ret;

	wm8994_i2c_write(priv, WM8994_SOFTWARE_RESET, WM8994_SW_RESET);

	ret = wm8994_i2c_read(priv, WM8994_SOFTWARE_RESET, &reg_data);
	if (ret < 0) {
		debug("Failed to read ID register\n");
		return ret;
	}

	if (reg_data == WM8994_ID) {
		devname = "WM8994";
		debug("Device registered as type %d\n", priv->type);
		priv->type = WM8994;
	} else {
		debug("Device is not a WM8994, ID is %x\n", ret);
		return -ENXIO;
	}

	ret = wm8994_i2c_read(priv, WM8994_CHIP_REVISION, &reg_data);
	if (ret < 0) {
		debug("Failed to read revision register: %d\n", ret);
		return ret;
	}
	priv->revision = reg_data;
	debug("%s revision %c\n", devname, 'A' + priv->revision);

	return 0;
}

static int wm8994_setup_interface(struct wm8994_priv *priv,
				  enum en_audio_interface aif_id)
{
	int ret;

	/* VMID Selection */
	ret = wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1,
			    WM8994_VMID_SEL_MASK | WM8994_BIAS_ENA_MASK, 0x3);

	/* Charge Pump Enable */
	ret |= wm8994_bic_or(priv, WM8994_CHARGE_PUMP_1, WM8994_CP_ENA_MASK,
			     WM8994_CP_ENA);

	/* Head Phone Power Enable */
	ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1,
			     WM8994_HPOUT1L_ENA_MASK, WM8994_HPOUT1L_ENA);

	ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_1,
			     WM8994_HPOUT1R_ENA_MASK, WM8994_HPOUT1R_ENA);

	if (aif_id == WM8994_AIF1) {
		ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_2,
					WM8994_TSHUT_ENA | WM8994_MIXINL_ENA |
					WM8994_MIXINR_ENA | WM8994_IN2L_ENA |
					WM8994_IN2R_ENA);

		ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_4,
					WM8994_ADCL_ENA | WM8994_ADCR_ENA |
					WM8994_AIF1ADC1R_ENA |
					WM8994_AIF1ADC1L_ENA);

		/* Power enable for AIF1 and DAC1 */
		ret |= wm8994_i2c_write(priv, WM8994_POWER_MANAGEMENT_5,
					WM8994_AIF1DACL_ENA |
					WM8994_AIF1DACR_ENA |
					WM8994_DAC1L_ENA | WM8994_DAC1R_ENA);
	} else if (aif_id == WM8994_AIF2) {
		/* Power enable for AIF2 and DAC1 */
		ret |= wm8994_bic_or(priv, WM8994_POWER_MANAGEMENT_5,
			WM8994_AIF2DACL_ENA_MASK | WM8994_AIF2DACR_ENA_MASK |
			WM8994_DAC1L_ENA_MASK | WM8994_DAC1R_ENA_MASK,
			WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA |
			WM8994_DAC1L_ENA | WM8994_DAC1R_ENA);
	}
	/* Head Phone Initialisation */
	ret |= wm8994_bic_or(priv, WM8994_ANALOGUE_HP_1,
		WM8994_HPOUT1L_DLY_MASK | WM8994_HPOUT1R_DLY_MASK,
		WM8994_HPOUT1L_DLY | WM8994_HPOUT1R_DLY);

	ret |= wm8994_bic_or(priv, WM8994_DC_SERVO_1,
			WM8994_DCS_ENA_CHAN_0_MASK |
			WM8994_DCS_ENA_CHAN_1_MASK , WM8994_DCS_ENA_CHAN_0 |
			WM8994_DCS_ENA_CHAN_1);

	ret |= wm8994_bic_or(priv, WM8994_ANALOGUE_HP_1,
			WM8994_HPOUT1L_DLY_MASK |
			WM8994_HPOUT1R_DLY_MASK | WM8994_HPOUT1L_OUTP_MASK |
			WM8994_HPOUT1R_OUTP_MASK |
			WM8994_HPOUT1L_RMV_SHORT_MASK |
			WM8994_HPOUT1R_RMV_SHORT_MASK, WM8994_HPOUT1L_DLY |
			WM8994_HPOUT1R_DLY | WM8994_HPOUT1L_OUTP |
			WM8994_HPOUT1R_OUTP | WM8994_HPOUT1L_RMV_SHORT |
			WM8994_HPOUT1R_RMV_SHORT);

	/* MIXER Config DAC1 to HP */
	ret |= wm8994_bic_or(priv, WM8994_OUTPUT_MIXER_1,
			     WM8994_DAC1L_TO_HPOUT1L_MASK,
			     WM8994_DAC1L_TO_HPOUT1L);

	ret |= wm8994_bic_or(priv, WM8994_OUTPUT_MIXER_2,
			     WM8994_DAC1R_TO_HPOUT1R_MASK,
			     WM8994_DAC1R_TO_HPOUT1R);

	if (aif_id == WM8994_AIF1) {
		/* Routing AIF1 to DAC1 */
		ret |= wm8994_i2c_write(priv, WM8994_DAC1_LEFT_MIXER_ROUTING,
					WM8994_AIF1DAC1L_TO_DAC1L);

		ret |= wm8994_i2c_write(priv, WM8994_DAC1_RIGHT_MIXER_ROUTING,
					WM8994_AIF1DAC1R_TO_DAC1R);

		/* GPIO Settings for AIF1 */
		ret |=  wm8994_i2c_write(priv, WM8994_GPIO_1,
					 WM8994_GPIO_DIR_OUTPUT |
					 WM8994_GPIO_FUNCTION_I2S_CLK |
					 WM8994_GPIO_INPUT_DEBOUNCE);

		ret |= wm8994_init_volume_aif1_dac1(priv);
	} else if (aif_id == WM8994_AIF2) {
		/* Routing AIF2 to DAC1 */
		ret |= wm8994_bic_or(priv, WM8994_DAC1_LEFT_MIXER_ROUTING,
				     WM8994_AIF2DACL_TO_DAC1L_MASK,
				     WM8994_AIF2DACL_TO_DAC1L);

		ret |= wm8994_bic_or(priv, WM8994_DAC1_RIGHT_MIXER_ROUTING,
				     WM8994_AIF2DACR_TO_DAC1R_MASK,
				     WM8994_AIF2DACR_TO_DAC1R);

		/* GPIO Settings for AIF2 */
		/* B CLK */
		ret |= wm8994_bic_or(priv, WM8994_GPIO_3, WM8994_GPIO_DIR_MASK |
				     WM8994_GPIO_FUNCTION_MASK,
				     WM8994_GPIO_DIR_OUTPUT);

		/* LR CLK */
		ret |= wm8994_bic_or(priv, WM8994_GPIO_4, WM8994_GPIO_DIR_MASK |
				     WM8994_GPIO_FUNCTION_MASK,
				     WM8994_GPIO_DIR_OUTPUT);

		/* DATA */
		ret |= wm8994_bic_or(priv, WM8994_GPIO_5, WM8994_GPIO_DIR_MASK |
				     WM8994_GPIO_FUNCTION_MASK,
				     WM8994_GPIO_DIR_OUTPUT);

		ret |= wm8994_init_volume_aif2_dac1(priv);
	}

	if (ret < 0)
		goto err;

	debug("%s: Codec chip setup ok\n", __func__);
	return 0;
err:
	debug("%s: Codec chip setup error\n", __func__);
	return -1;
}

static int _wm8994_init(struct wm8994_priv *priv,
			enum en_audio_interface aif_id, int sampling_rate,
			int mclk_freq, int bits_per_sample,
			unsigned int channels)
{
	int ret;

	ret = wm8994_setup_interface(priv, aif_id);
	if (ret < 0) {
		debug("%s: wm8994 codec chip init failed\n", __func__);
		return ret;
	}

	ret = wm8994_set_sysclk(priv, aif_id, WM8994_SYSCLK_MCLK1, mclk_freq);
	if (ret < 0) {
		debug("%s: wm8994 codec set sys clock failed\n", __func__);
		return ret;
	}

	ret = wm8994_hw_params(priv, aif_id, sampling_rate, bits_per_sample,
			       channels);

	if (ret == 0) {
		ret = wm8994_set_fmt(priv, aif_id, SND_SOC_DAIFMT_I2S |
				     SND_SOC_DAIFMT_NB_NF |
				     SND_SOC_DAIFMT_CBS_CFS);
	}

	return ret;
}

static int wm8994_set_params(struct udevice *dev, int interface, int rate,
			     int mclk_freq, int bits_per_sample, uint channels)
{
	struct wm8994_priv *priv = dev_get_priv(dev);

	return _wm8994_init(priv, interface, rate, mclk_freq, bits_per_sample,
			    channels);
}

static int wm8994_probe(struct udevice *dev)
{
	struct wm8994_priv *priv = dev_get_priv(dev);

	priv->dev = dev;
	return wm8994_device_init(priv);
}

static const struct audio_codec_ops wm8994_ops = {
	.set_params	= wm8994_set_params,
};

static const struct udevice_id wm8994_ids[] = {
	{ .compatible = "wolfson,wm8994" },
	{ }
};

U_BOOT_DRIVER(wm8994) = {
	.name		= "wm8994",
	.id		= UCLASS_AUDIO_CODEC,
	.of_match	= wm8994_ids,
	.probe		= wm8994_probe,
	.ops		= &wm8994_ops,
	.priv_auto	= sizeof(struct wm8994_priv),
};
