2 * This file is part of the coreboot project.
4 * Copyright 2014 Google Inc.
5 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
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.
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.
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>
23 #include <vendorcode/google/chromeos/chromeos.h>
25 void fill_lb_gpios(struct lb_gpios
*gpios
)
29 /* TBD(twarren@nvidia.com): Any analogs for these on Foster-FFD? */
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
);
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
);
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
);
55 /* Developer: virtual GPIO active high */
56 gpios
->gpios
[count
].port
= -1;
57 gpios
->gpios
[count
].polarity
= ACTIVE_HIGH
;
58 gpios
->gpios
[count
].value
= get_developer_mode_switch();
59 strncpy((char *)gpios
->gpios
[count
].name
, "developer",
60 GPIO_MAX_NAME_LENGTH
);
63 /* TODO: Reset: active low (output) */
64 gpios
->gpios
[count
].port
= GPIO(I5
);
65 gpios
->gpios
[count
].polarity
= ACTIVE_LOW
;
66 gpios
->gpios
[count
].value
= -1;
67 strncpy((char *)gpios
->gpios
[count
].name
, "reset",
68 GPIO_MAX_NAME_LENGTH
);
71 gpios
->size
= sizeof(*gpios
) + (count
* sizeof(struct lb_gpio
));
74 printk(BIOS_ERR
, "Added %d GPIOS size %d\n", count
, gpios
->size
);
77 int get_developer_mode_switch(void)
82 int get_recovery_mode_switch(void)
84 #if CONFIG_EC_GOOGLE_CHROMEEC
87 ec_events
= google_chromeec_get_events_b();
89 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY
));
95 int get_write_protect_state(void)