Angel Pons | 96d93d1 | 2020-04-05 13:22:23 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 4 | #include <types.h> |
| 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 7 | #include <ec/compal/ene932/ec.h> |
| 8 | #include "ec.h" |
| 9 | |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 10 | void 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 Singer | 98b51f4cf | 2021-01-07 02:40:36 +0000 | [diff] [blame] | 20 | printk(BIOS_DEBUG, " EC version %x.%x.%x\n", |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 21 | 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 Singer | 98b51f4cf | 2021-01-07 02:40:36 +0000 | [diff] [blame] | 26 | 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 Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 28 | ec_kbc_read_ob(), ec_kbc_read_ob()); |
| 29 | |
| 30 | /* Print the hardware revision */ |
Felix Singer | 98b51f4cf | 2021-01-07 02:40:36 +0000 | [diff] [blame] | 31 | printk(BIOS_DEBUG, " Parrot Revision %x\n", parrot_rev()); |
Stefan Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 32 | |
| 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 Reinauer | a7198b3 | 2012-12-11 16:00:47 -0800 | [diff] [blame] | 55 | /* Parrot Hardware Revision */ |
| 56 | u8 parrot_rev(void) |
| 57 | { |
| 58 | ec_kbc_write_cmd(0x45); |
| 59 | ec_kbc_write_ib(0x40); |
| 60 | return ec_kbc_read_ob(); |
| 61 | } |