summaryrefslogtreecommitdiff
path: root/src/mainboard/google/parrot/ec.c
blob: d75cc29fa8dd15a53cb68611d376011f3f2b0b05 (plain)
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
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2012 The Chromium OS Authors. 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; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <arch/acpi.h>
#include <types.h>
#include <console/console.h>
#include <device/device.h>
#include <arch/io.h>
#include <ec/compal/ene932/ec.h>
#include "ec.h"


void parrot_ec_init(void)
{
	printk(BIOS_DEBUG, "Parrot EC Init\n");

	/* Clean up the buffers. We don't know the initial condition. */
	kbc_cleanup_buffers();

	/* Report EC info */
	/* EC version: cmd 0x51 - returns three bytes */
	ec_kbc_write_cmd(0x51);
	printk(BIOS_DEBUG,"  EC version %x.%x.%x\n",
		   ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob());

	/* EC Project name: cmd 0x52, 0xA0 - returns five bytes */
	ec_kbc_write_cmd(0x52);
	ec_kbc_write_ib(0xA0);
	printk(BIOS_DEBUG,"  EC Project: %c%c%c%c%c\n",
		   ec_kbc_read_ob(),ec_kbc_read_ob(),ec_kbc_read_ob(),
		   ec_kbc_read_ob(), ec_kbc_read_ob());

	/* Print the hardware revision */
	printk(BIOS_DEBUG,"  Parrot Revision %x\n", parrot_rev());

	/* US Keyboard */
	ec_kbc_write_cmd(0x59);
	ec_kbc_write_ib(0xE5);

	/* Enable IRQ1 */
	ec_kbc_write_cmd(0x59);
	ec_kbc_write_ib(0xD1);

	/* TODO - Do device detection and device maintain state (nvs) */
	/* Enable Wireless and Bluetooth */
	ec_kbc_write_cmd(0x45);
	ec_kbc_write_ib(0xAD);

	/* Set Wireless and Bluetooth Available */
	ec_kbc_write_cmd(0x45);
	ec_kbc_write_ib(0xA8);

	/* Set Wireless and Bluetooth Enable */
	ec_kbc_write_cmd(0x45);
	ec_kbc_write_ib(0xA2);
}


/* Parrot Hardware Revision */
u8 parrot_rev(void)
{
	ec_kbc_write_cmd(0x45);
	ec_kbc_write_ib(0x40);
	return ec_kbc_read_ob();
}