hi3660_hkadc.h 2.08 KB
Newer Older
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
/*
 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#ifndef __HI3660_HKADC_H__
#define __HI3660_HKADC_H__

#define HKADC_SSI_REG_BASE			0xE82B8000

#define HKADC_DSP_START_REG			(HKADC_SSI_REG_BASE + 0x000)
#define HKADC_WR_NUM_REG			(HKADC_SSI_REG_BASE + 0x008)
#define HKADC_DSP_START_CLR_REG			(HKADC_SSI_REG_BASE + 0x01C)
#define HKADC_WR01_DATA_REG			(HKADC_SSI_REG_BASE + 0x020)

#define WR1_WRITE_MODE				(1 << 31)
#define WR1_READ_MODE				(0 << 31)
#define WR1_ADDR(x)				(((x) & 0x7F) << 24)
#define WR1_DATA(x)				(((x) & 0xFF) << 16)
#define WR0_WRITE_MODE				(1 << 15)
#define WR0_READ_MODE				(0 << 15)
#define WR0_ADDR(x)				(((x) & 0x7F) << 8)
#define WR0_DATA(x)				((x) & 0xFF)

#define HKADC_WR23_DATA_REG			(HKADC_SSI_REG_BASE + 0x024)
#define HKADC_WR45_DATA_REG			(HKADC_SSI_REG_BASE + 0x028)
#define HKADC_DELAY01_REG			(HKADC_SSI_REG_BASE + 0x030)
#define HKADC_DELAY23_REG			(HKADC_SSI_REG_BASE + 0x034)
#define HKADC_DELAY45_REG			(HKADC_SSI_REG_BASE + 0x038)
#define HKADC_DSP_RD2_DATA_REG			(HKADC_SSI_REG_BASE + 0x048)
#define HKADC_DSP_RD3_DATA_REG			(HKADC_SSI_REG_BASE + 0x04C)

/* HKADC Internal Registers */
#define HKADC_CTRL_ADDR				0x00
#define HKADC_START_ADDR			0x01
#define HKADC_DATA1_ADDR			0x03   /* high 8 bits */
#define HKADC_DATA0_ADDR			0x04   /* low 8 bits */
#define HKADC_MODE_CFG				0x0A

#define HKADC_VALUE_HIGH			0x0FF0
#define HKADC_VALUE_LOW				0x000F
#define HKADC_VALID_VALUE			0x0FFF

#define HKADC_CHANNEL_MAX			15
#define HKADC_VREF_1V8				1800
#define HKADC_ACCURACY				0x0FFF

#define HKADC_WR01_VALUE			((HKADC_START_ADDR << 24) | \
						 (0x1 << 16))
#define HKADC_WR23_VALUE			((0x1 << 31) |		\
						 (HKADC_DATA0_ADDR << 24) | \
						 (1 << 15) |		\
						 (HKADC_DATA1_ADDR << 8))
#define HKADC_WR45_VALUE			(0x80)
#define HKADC_CHANNEL0_DELAY01_VALUE		((0x0700 << 16) | 0xFFFF)
#define HKADC_DELAY01_VALUE			((0x0700 << 16) | 0x0200)
#define HKADC_DELAY23_VALUE			((0x00C8 << 16) | 0x00C8)
#define START_DELAY_TIMEOUT			2000
#define HKADC_WR_NUM_VALUE			4

#endif /* __HI3660_HKADC_H__ */