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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* Raydium RM31080 touchscreen driver
*
* Copyright (C) 2012-2013, Raydium Semiconductor Corporation. All Rights Reserved.
* Copyright (C) 2012-2013, NVIDIA Corporation. 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 as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
/*=============================================================================
INCLUDED FILES
=============================================================================*/
#include <linux/device.h>
#include <asm/uaccess.h> /* copy_to_user() */
#include <linux/delay.h>
#include <linux/module.h> /* Module definition */
#include <linux/spi/rm31080a_ts.h>
#include <linux/spi/rm31080a_ctrl.h>
/*=============================================================================
GLOBAL VARIABLES DECLARATION
=============================================================================*/
struct rm_tch_ctrl_para g_stCtrl;
/*=============================================================================
FUNCTION DECLARATION
=============================================================================*/
/*=============================================================================
Description:
Control functions for Touch IC
Input:
Output:
=============================================================================*/
int rm_tch_ctrl_clear_int(void)
{
u8 flag;
if (g_stCtrl.bICVersion >= 0xD0)
return rm_tch_spi_byte_read(0x72, &flag);
else
return rm_tch_spi_byte_read(0x02, &flag);
}
int rm_tch_ctrl_scan_start(void)
{
return rm_tch_spi_byte_write(RM31080_REG_11, 0x17);
}
void rm_tch_ctrl_wait_for_scan_finish(void)
{
u8 u8reg11;
int i;
/*50ms = 20Hz*/
for (i = 0; i < 50; i++) {
rm_tch_spi_byte_read(RM31080_REG_11, &u8reg11);
if (u8reg11 & 0x01)
usleep_range(1000, 2000);/* msleep(1); */
else
break;
}
}
/*=============================================================================
Description:
Input:
N/A
Output:
N/A
=============================================================================*/
void rm_set_repeat_times(u8 u8Times)
{
u8 bReg1_1Fh = 0x00;
rm_tch_spi_byte_write(0x0E, u8Times&0x1F);
bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
if (u8Times != REPEAT_1)
bReg1_1Fh |= 0x44;
rm_tch_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
}
/*=============================================================================
Description:
Input:
N/A
Output:
N/A
=============================================================================*/
void rm_tch_ctrl_init(void)
{
memset(&g_stCtrl, 0, sizeof(struct rm_tch_ctrl_para));
}
/*=============================================================================
Description: To transfer the value to HAL layer
Input:
N/A
Output:
N/A
=============================================================================*/
unsigned char rm_tch_ctrl_get_idle_mode(u8 *p)
{
u32 u32Ret;
u32Ret = copy_to_user(p, &g_stCtrl.bfIdleModeCheck, 1);
if (u32Ret != 0)
return 0;
return 1;
}
/*=============================================================================
Description:
Input:
N/A
Output:
N/A
=============================================================================*/
void rm_tch_ctrl_set_parameter(void *arg)
{
memcpy(&g_stCtrl, arg, sizeof(struct rm_tch_ctrl_para));
}
/*=============================================================================*/
MODULE_AUTHOR("xxxxxxxxxx <xxxxxxxx@rad-ic.com>");
MODULE_DESCRIPTION("Raydium touchscreen control functions");
MODULE_LICENSE("GPL");
|