• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <types.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <ec/compal/ene932/ec.h>
7 #include "ec.h"
8 
parrot_ec_init(void)9 void parrot_ec_init(void)
10 {
11 	printk(BIOS_DEBUG, "Parrot EC Init\n");
12 
13 	/* Clean up the buffers. We don't know the initial condition. */
14 	kbc_cleanup_buffers();
15 
16 	/* Report EC info */
17 	/* EC version: cmd 0x51 - returns three bytes */
18 	ec_kbc_write_cmd(0x51);
19 	printk(BIOS_DEBUG, "  EC version %x.%x.%x\n",
20 		   ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob());
21 
22 	/* EC Project name: cmd 0x52, 0xA0 - returns five bytes */
23 	ec_kbc_write_cmd(0x52);
24 	ec_kbc_write_ib(0xA0);
25 	printk(BIOS_DEBUG, "  EC Project: %c%c%c%c%c\n",
26 		   ec_kbc_read_ob(), ec_kbc_read_ob(), ec_kbc_read_ob(),
27 		   ec_kbc_read_ob(), ec_kbc_read_ob());
28 
29 	/* Print the hardware revision */
30 	printk(BIOS_DEBUG, "  Parrot Revision %x\n", parrot_rev());
31 
32 	/* US Keyboard */
33 	ec_kbc_write_cmd(0x59);
34 	ec_kbc_write_ib(0xE5);
35 
36 	/* Enable IRQ1 */
37 	ec_kbc_write_cmd(0x59);
38 	ec_kbc_write_ib(0xD1);
39 
40 	/* TODO - Do device detection and device maintain state (nvs) */
41 	/* Enable Wireless and Bluetooth */
42 	ec_kbc_write_cmd(0x45);
43 	ec_kbc_write_ib(0xAD);
44 
45 	/* Set Wireless and Bluetooth Available */
46 	ec_kbc_write_cmd(0x45);
47 	ec_kbc_write_ib(0xA8);
48 
49 	/* Set Wireless and Bluetooth Enable */
50 	ec_kbc_write_cmd(0x45);
51 	ec_kbc_write_ib(0xA2);
52 }
53 
54 /* Parrot Hardware Revision */
parrot_rev(void)55 u8 parrot_rev(void)
56 {
57 	ec_kbc_write_cmd(0x45);
58 	ec_kbc_write_ib(0x40);
59 	return ec_kbc_read_ob();
60 }
61