blob: b4cb33238fb63f751a22703acd525d778b2e54b5 [file] [log] [blame]
Patrick Georgifd49d6f2015-06-22 19:43:18 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2014 Google Inc.
5 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Patrick Georgifd49d6f2015-06-22 19:43:18 +020015 */
16
17#include <boot/coreboot_tables.h>
18#include <console/console.h>
19#include <ec/google/chromeec/ec.h>
20#include <ec/google/chromeec/ec_commands.h>
21#include <gpio.h>
22#include <string.h>
23#include <vendorcode/google/chromeos/chromeos.h>
24
25void fill_lb_gpios(struct lb_gpios *gpios)
26{
27 int count = 0;
28
29 /* TBD(twarren@nvidia.com): Any analogs for these on Foster-FFD? */
30
31 /* Write Protect: active low */
32 gpios->gpios[count].port = -1;
33 gpios->gpios[count].polarity = ACTIVE_LOW;
34 gpios->gpios[count].value = get_write_protect_state();
35 strncpy((char *)gpios->gpios[count].name, "write protect",
36 GPIO_MAX_NAME_LENGTH);
37 count++;
38
39 /* Recovery: active high */
40 gpios->gpios[count].port = -1;
41 gpios->gpios[count].polarity = ACTIVE_HIGH;
42 gpios->gpios[count].value = get_recovery_mode_switch();
43 strncpy((char *)gpios->gpios[count].name, "recovery",
44 GPIO_MAX_NAME_LENGTH);
45 count++;
46
47 /* TODO: Power: active low / high depending on board id */
48 gpios->gpios[count].port = GPIO(X5);
49 gpios->gpios[count].polarity = ACTIVE_LOW;
50 gpios->gpios[count].value = -1;
51 strncpy((char *)gpios->gpios[count].name, "power",
52 GPIO_MAX_NAME_LENGTH);
53 count++;
54
Patrick Georgifd49d6f2015-06-22 19:43:18 +020055 /* TODO: Reset: active low (output) */
56 gpios->gpios[count].port = GPIO(I5);
57 gpios->gpios[count].polarity = ACTIVE_LOW;
58 gpios->gpios[count].value = -1;
59 strncpy((char *)gpios->gpios[count].name, "reset",
60 GPIO_MAX_NAME_LENGTH);
61 count++;
62
63 gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio));
64 gpios->count = count;
65
66 printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
67}
68
Patrick Georgifd49d6f2015-06-22 19:43:18 +020069int get_recovery_mode_switch(void)
70{
Martin Roth356b5192017-06-24 21:53:37 -060071#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)
Furquan Shaikh8788fd62017-11-20 20:28:18 -080072 uint64_t ec_events;
Patrick Georgifd49d6f2015-06-22 19:43:18 +020073
74 ec_events = google_chromeec_get_events_b();
75 return !!(ec_events &
76 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY));
77#else
78 return 0;
79#endif
80}
81
82int get_write_protect_state(void)
83{
84 return 0;
85}