summaryrefstree
path: root/kernel/sound/soc/codecs/dbmdx/dbmdx-i2c.h
blob: 57e336ff454d95c02959bebd51893b2a0f39e5a6 (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
/*
 * dbmdx-i2c.h  --  DBMDX I2C interface common functions
 *
 * Copyright (C) 2014 DSP Group
 *
 * 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 _DBMDX_I2C_COMMON_H
#define _DBMDX_I2C_COMMON_H

#ifdef CONFIG_PM_WAKELOCKS
#include <linux/wakelock.h>
#endif

#define RETRY_COUNT				5

struct dbmdx_i2c_private;

struct dbmdx_i2c_data {
	u32	boot_addr;
	u32	operation_addr;
	u32	read_chunk_size;
	u32	write_chunk_size;
	u8	read_buf[MAX_REQ_SIZE];
};


struct dbmdx_i2c_private {
	struct device			*dev;
	struct dbmdx_i2c_data		*pdata;
	struct i2c_client		*client;
	struct chip_interface		chip;
#ifdef CONFIG_PM_WAKELOCKS
	struct wake_lock		ps_nosuspend_wl;
#endif
	u32				interface_enabled;
};

ssize_t write_i2c_data(struct dbmdx_private *p, const void *buf,
			      size_t len);
ssize_t read_i2c_data(struct dbmdx_private *p, void *buf, size_t len);
ssize_t send_i2c_cmd_va(struct dbmdx_private *p, u32 command,
				  u16 *response);
ssize_t send_i2c_cmd_vqe(struct dbmdx_private *p,
	u32 command, u16 *response);

int send_i2c_cmd_boot(struct dbmdx_private *p, u32 command);
int i2c_verify_boot_checksum(struct dbmdx_private *p,
	const void *checksum, size_t chksum_len);
int i2c_common_probe(struct i2c_client *client,
		const struct i2c_device_id *id);

int i2c_common_remove(struct i2c_client *client);
void i2c_interface_resume(struct dbmdx_i2c_private *i2c_p);
void i2c_interface_suspend(struct dbmdx_i2c_private *i2c_p);


#endif