aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/codecs/tfa9887_init.c
blob: 2f465bd9df7d0109aaa8e877147e587ff15e7e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

#include "tfa_dsp_fw.h"
#include "tfa_service.h"
#include "tfa_internal.h"

#include "tfa98xx_tfafieldnames.h"

static enum Tfa98xx_Error tfa9887_specific(Tfa98xx_handle_t handle)
{
	enum Tfa98xx_Error error = Tfa98xx_Error_Ok;
	int result;

	if (!tfa98xx_handle_is_open(handle))
		return Tfa98xx_Error_NotOpen;

	/* all i2C registers are already set to default */

	result = TFA_SET_BF(handle, AMPE, 1);
	if (result < 0)
		return -result;

	/* some other registers must be set for optimal amplifier behaviour */
	tfa98xx_write_register16(handle, 0x05, 0x13AB);
	tfa98xx_write_register16(handle, 0x06, 0x001F);
	tfa98xx_write_register16(handle, 0x08, 0x3C4E);
	/*TFA98XX_SYSCTRL_DCA=0*/
	tfa98xx_write_register16(handle, 0x09, 0x024D);
	tfa98xx_write_register16(handle, 0x0A, 0x3EC3);
	tfa98xx_write_register16(handle, 0x41, 0x0308);
	error = tfa98xx_write_register16(handle, 0x49, 0x0E82);

	return error;
}

/*
 * register device specifics functions
 */
void tfa9887_ops(struct tfa_device_ops *ops)
{
	ops->tfa_init = tfa9887_specific;
}