aboutsummaryrefslogtreecommitdiff
path: root/drivers/sound/maxim_codec.h
blob: deaefd93eb1bced4993a89ccc920561f27db3047 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * maxim_codec.h -- MAXIM codec common interface file
 *
 * Copyright (C) 2013 Samsung Electronics
 * D Krishna Mohan <krishna.md@samsung.com>
 */

#ifndef __MAXIM_COMMON_H__
#define __MAXIM_COMMON_H__

enum maxim_codec_type {
	MAX98095,
	MAX98090,
};

struct maxim_priv {
	enum maxim_codec_type devtype;
	unsigned int sysclk;
	unsigned int rate;
	unsigned int fmt;
	struct udevice *dev;
};

#define MAXIM_AUDIO_I2C_BUS		7
#define MAXIM_AUDIO_I2C_REG_98095	0x22

#define MAXIM_AUDIO_I2C_REG		MAXIM_AUDIO_I2C_REG_98095

/*
 * 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.
 */
int maxim_i2c_write(struct maxim_priv *priv, unsigned int reg,
		    unsigned char data);

/*
 * 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.
 */
unsigned int maxim_i2c_read(struct maxim_priv *priv, unsigned int reg,
			    unsigned char *data);

/*
 * 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 0 for success, non-zero error code.
 */
int maxim_bic_or(struct maxim_priv *priv, unsigned int reg, unsigned char mask,
		 unsigned char value);

#endif /* __MAXIM_COMMON_H__ */