blob: f4187eb4f2646bab8c73b852af699701406e6d08 [file] [log] [blame]
Angel Pons96d93d12020-04-05 13:22:23 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauera7198b32012-12-11 16:00:47 -08002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
Stefan Reinauera7198b32012-12-11 16:00:47 -08004#include <types.h>
5#include <console/console.h>
6#include <device/device.h>
Stefan Reinauera7198b32012-12-11 16:00:47 -08007#include <ec/compal/ene932/ec.h>
8#include "ec.h"
9
Stefan Reinauera7198b32012-12-11 16:00:47 -080010void parrot_ec_init(void)
11{
12 printk(BIOS_DEBUG, "Parrot EC Init\n");
13
14 /* Clean up the buffers. We don't know the initial condition. */
15 kbc_cleanup_buffers();
16
17 /* Report EC info */
18 /* EC version: cmd 0x51 - returns three bytes */
19 ec_kbc_write_cmd(0x51);
Felix Singer98b51f4cf2021-01-07 02:40:36 +000020 printk(BIOS_DEBUG, " EC version %x.%x.%x\n",
Stefan Reinauera7198b32012-12-11 16:00:47 -080021 ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob());
22
23 /* EC Project name: cmd 0x52, 0xA0 - returns five bytes */
24 ec_kbc_write_cmd(0x52);
25 ec_kbc_write_ib(0xA0);
Felix Singer98b51f4cf2021-01-07 02:40:36 +000026 printk(BIOS_DEBUG, " EC Project: %c%c%c%c%c\n",
27 ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob(),
Stefan Reinauera7198b32012-12-11 16:00:47 -080028 ec_kbc_read_ob(), ec_kbc_read_ob());
29
30 /* Print the hardware revision */
Felix Singer98b51f4cf2021-01-07 02:40:36 +000031 printk(BIOS_DEBUG, " Parrot Revision %x\n", parrot_rev());
Stefan Reinauera7198b32012-12-11 16:00:47 -080032
33 /* US Keyboard */
34 ec_kbc_write_cmd(0x59);
35 ec_kbc_write_ib(0xE5);
36
37 /* Enable IRQ1 */
38 ec_kbc_write_cmd(0x59);
39 ec_kbc_write_ib(0xD1);
40
41 /* TODO - Do device detection and device maintain state (nvs) */
42 /* Enable Wireless and Bluetooth */
43 ec_kbc_write_cmd(0x45);
44 ec_kbc_write_ib(0xAD);
45
46 /* Set Wireless and Bluetooth Available */
47 ec_kbc_write_cmd(0x45);
48 ec_kbc_write_ib(0xA8);
49
50 /* Set Wireless and Bluetooth Enable */
51 ec_kbc_write_cmd(0x45);
52 ec_kbc_write_ib(0xA2);
53}
54
Stefan Reinauera7198b32012-12-11 16:00:47 -080055/* Parrot Hardware Revision */
56u8 parrot_rev(void)
57{
58 ec_kbc_write_cmd(0x45);
59 ec_kbc_write_ib(0x40);
60 return ec_kbc_read_ob();
61}