Skip to content

Commit 2522ee3

Browse files
marvintwentyfourkwizart
authored andcommitted
ARM: tegra: add nvec driver
Adopted version of nvec driver from linux kernel with keyboard support only. Signed-off-by: Andrey Danin <danindrey@mail.ru> [squashed, forward ported, and cleaned up] Signed-off-by: Marc Dietrich <marvin24@gmx.de>
1 parent 60fe365 commit 2522ee3

File tree

8 files changed

+681
-0
lines changed

8 files changed

+681
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* (C) Copyright 2013
3+
* Andrey Danin <andreydanin@mail.ru>
4+
*
5+
* See file CREDITS for list of people who contributed to this
6+
* project.
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation; either version 2 of
11+
* the License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21+
* MA 02111-1307 USA
22+
*/
23+
24+
#ifndef _TEGRA_NVEC_H_
25+
#define _TEGRA_NVEC_H_
26+
27+
#define I2C_CNFG 0x00
28+
#define I2C_CNFG_PACKET_MODE_EN (1<<10)
29+
#define I2C_CNFG_NEW_MASTER_SFM (1<<11)
30+
#define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12
31+
32+
#define I2C_SL_CNFG 0x20
33+
#define I2C_SL_NEWSL (1<<2)
34+
#define I2C_SL_NACK (1<<1)
35+
#define I2C_SL_RESP (1<<0)
36+
#define I2C_SL_IRQ (1<<3)
37+
#define END_TRANS (1<<4)
38+
#define RCVD (1<<2)
39+
#define RNW (1<<1)
40+
41+
#define I2C_SL_RCVD 0x24
42+
#define I2C_SL_STATUS 0x28
43+
#define I2C_SL_ADDR1 0x2c
44+
#define I2C_SL_ADDR2 0x30
45+
#define I2C_SL_DELAY_COUNT 0x3c
46+
47+
48+
enum nvec_msg_type {
49+
NVEC_KEYBOARD = 0,
50+
NVEC_SYS = 1,
51+
NVEC_BAT,
52+
NVEC_GPIO,
53+
NVEC_SLEEP,
54+
NVEC_KBD,
55+
NVEC_PS2,
56+
NVEC_CNTL,
57+
NVEC_OEM0 = 0x0d,
58+
NVEC_KB_EVT = 0x80,
59+
NVEC_PS2_EVT,
60+
};
61+
62+
enum nvec_event_size {
63+
NVEC_2BYTES,
64+
NVEC_3BYTES,
65+
NVEC_VAR_SIZE,
66+
};
67+
68+
enum sys_subcmds {
69+
SYS_GET_STATUS,
70+
SYS_CNFG_EVENT_REPORTING,
71+
SYS_ACK_STATUS,
72+
SYS_CNFG_WAKE = 0xfd,
73+
};
74+
75+
enum kbd_subcmds {
76+
CNFG_WAKE = 3,
77+
CNFG_WAKE_KEY_REPORTING,
78+
SET_LEDS = 0xed,
79+
ENABLE_KBD = 0xf4,
80+
DISABLE_KBD,
81+
};
82+
83+
enum cntl_subcmds {
84+
CNTL_RESET_EC = 0x00,
85+
CNTL_SELF_TEST = 0x01,
86+
CNTL_NOOP = 0x02,
87+
CNTL_GET_EC_SPEC_VER = 0x10,
88+
CNTL_GET_FIRMWARE_VERSION = 0x15,
89+
};
90+
91+
enum nvec_sleep_subcmds {
92+
GLOBAL_EVENTS,
93+
AP_PWR_DOWN,
94+
AP_SUSPEND,
95+
};
96+
97+
#define MOUSE_SEND_CMD 0x01
98+
#define MOUSE_RESET 0xff
99+
100+
101+
int board_nvec_init(void);
102+
103+
int nvec_msg_is_event(const unsigned char *msg);
104+
int nvec_msg_event_type(const unsigned char *msg);
105+
106+
/**
107+
* Send request and read response. If write or read failed
108+
* operation will be repeated NVEC_ATTEMPTS_MAX times.
109+
*
110+
* @param buf request data
111+
* @param size request data size
112+
* @return 0 if ok, -1 on error
113+
*/
114+
int nvec_do_request(char *buf, int size);
115+
116+
117+
#endif /* _TEGRA_NVEC_H_ */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* (C) Copyright 2013
3+
* Andrey Danin <andreydanin@mail.ru>
4+
*
5+
* See file CREDITS for list of people who contributed to this
6+
* project.
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation; either version 2 of
11+
* the License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21+
* MA 02111-1307 USA
22+
*/
23+
24+
#ifndef _TEGRA_NVEC_EVENTS_H_
25+
#define _TEGRA_NVEC_EVENTS_H_
26+
27+
28+
int nvec_read_events(void);
29+
30+
31+
#endif /* _TEGRA_NVEC_EVENTS_H_ */

drivers/i2c/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ config SYS_I2C_IHS
696696
help
697697
Support for gdsys IHS I2C driver on FPGA bus.
698698

699+
config TEGRA_NVEC
700+
bool "Enable Tegra 2 NVEC driver"
701+
help
702+
Support for Tegra 2 I2C NVEC keyboard.
703+
699704
source "drivers/i2c/muxes/Kconfig"
700705

701706
endif

drivers/i2c/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ obj-$(CONFIG_$(SPL_)I2C_CROS_EC_TUNNEL) += cros_ec_tunnel.o
1111
obj-$(CONFIG_$(SPL_)I2C_CROS_EC_LDO) += cros_ec_ldo.o
1212

1313
obj-$(CONFIG_$(SPL_)SYS_I2C_LEGACY) += i2c_core.o
14+
obj-$(CONFIG_TEGRA_NVEC) += tegra_nvec.o
1415
obj-$(CONFIG_SYS_I2C_ASPEED) += ast_i2c.o
1516
obj-$(CONFIG_SYS_I2C_AT91) += at91_i2c.o
1617
obj-$(CONFIG_SYS_I2C_CADENCE) += i2c-cdns.o

0 commit comments

Comments
 (0)