blob: 839bc458152c1417442a36f3af15e912241a62db [file] [log] [blame]
Stefan Reinauerd8a5fd22012-12-11 15:51:47 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Stefan Reinauerd8a5fd22012-12-11 15:51:47 -080014 */
15
16/*
17 * EC communication interface for COMPAL ENE932 Embedded Controller.
18 */
19
20#ifndef _EC_COMPAL_ENE932_EC_H
21#define _EC_COMPAL_ENE932_EC_H
22
Alexandru Gagniucb1e63e42014-04-06 23:48:44 -050023#include <stdint.h>
24
Stefan Reinauerd8a5fd22012-12-11 15:51:47 -080025#define EC_IO 0xfd60 /* Mainboard specific. Could be Kconfig option */
26#define EC_IO_HIGH EC_IO + 1
27#define EC_IO_LOW EC_IO + 2
28#define EC_IO_DATA EC_IO + 3
29
30/* ENE EC internal address space */
31#define REG_SPI_DATA 0xfeab
32#define REG_SPI_COMMAND 0xfeac
33#define REG_SPI_CONFIG 0xfead
34#define CFG_CSn_FORCE_LOW (1 << 4)
35#define CFG_COMMAND_WRITE_ENABLE (1 << 3)
36#define CFG_STATUS (1 << 1)
37
38
39#define KBD_DATA 0x60
40#define KBD_COMMAND 0x64
41#define KBD_STATUS 0x64
42#define KBD_IBF (1 << 1) // 1: input buffer full (data ready for ec)
43#define KBD_OBF (1 << 0) // 1: output buffer full (data ready for host)
44
45
46/* Wait 400ms for keyboard controller answers */
47#define KBC_TIMEOUT_IN_MS 400
48
49u8 ec_kbc_read_ob(void);
50void ec_kbc_write_cmd(u8 cmd);
51void ec_kbc_write_ib(u8 data);
52int kbc_cleanup_buffers(void);
53
54#endif /* _EC_COMPAL_ENE932_EC_H */