huangcm
2025-02-26 a813214788f6e7b512df54f1c659cd0bdc9ac175
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
68
69
70
/*
 * drivers/input/sensor/sunxi_tpadc.h
 *
 * Copyright (C) 2017 Allwinner.
 * fuzhaoke <yangshounan@allwinnertech.com>
 *
 * SUNXI tPADC Controller Driver Header
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */
 
#ifndef SUNXI_GPADC_H
#define SUNXI_GPADC_H
 
#define TPADC_DEV_NAME        ("sunxi-tpadc")
#define CLK_IN            (12000000)
/* TPADC register offset */
#define TP_CTRL0_REG        0x00
#define TP_CTRL1_REG        0x04
#define TP_CTRL2_REG        0x08
#define TP_CTRL3_REG        0x0c
#define TP_INT_FIFOC_REG    0x10
#define    TP_INT_FIFOS_REG    0x14
#define TP_TPR_REG        0x18
#define TP_CDAT_REG        0x1c
#define TP_TEMP_DATA_REG    0x20
#define TP_DATA_REG        0x24
#define TP_IO_CONFIG_REG    0x28
#define TP_PORT_DATA_REG    0x2c
 
#define ADC_CLK_DIVIDER        20
#define FS_DIVIDER        16
#define TP_CLOCK        (1<<22)
#define ADC_ENABLE        (1<<4)
#define TP_DATA_IRQ_EN        (1<<16)
#define SUNXI_FIFO_DATA        (1<<16)
#define RTP_MODE_ENABLE        (1<<5)
#define RTP_FILTER_ENABLE    (1<<2)
#define RTP_FILTER_TYPE    (0x2<<0)
 
#define HOSC            1
#define TP_IO_INPUT_MODE    0xfffff
 
#define TP_CH3_SELECT        (1 << 3) /* channale 3 select enable,  0:disable, 1:enable */
#define TP_CH2_SELECT        (1 << 2) /* channale 2 select enable,  0:disable, 1:enable */
#define TP_CH1_SELECT        (1 << 1) /* channale 1 select enable,  0:disable, 1:enable */
#define TP_CH0_SELECT        (1 << 0) /* channale 0 select enable,  0:disable, 1:enable */
 
enum tp_channel_id {
   TP_CH_0 = 0,
   TP_CH_1,
   TP_CH_2,
   TP_CH_3,
};
 
struct sunxi_tpadc {
   struct platform_device    *pdev;
   struct input_dev *input_channel0;
   struct input_dev *input_channel2;
   struct clk *mclk;
   struct clk *pclk;
   void __iomem *reg_base;
   int irq_num;
   struct timer_list timer;
};
 
#endif