2 * This file is part of the coreboot project.
4 * Copyright 2013 Google Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
20 #include <boot/coreboot_tables.h>
21 #include <console/console.h>
22 #include <ec/google/chromeec/ec.h>
23 #include <ec/google/chromeec/ec_commands.h>
27 #include <vendorcode/google/chromeos/chromeos.h>
30 void fill_lb_gpios(struct lb_gpios
*gpios
)
34 /* Write Protect: active low */
35 gpios
->gpios
[count
].port
= EXYNOS5_GPD1
;
36 gpios
->gpios
[count
].polarity
= ACTIVE_LOW
;
37 gpios
->gpios
[count
].value
= gpio_get_value(GPIO_D16
); // WP_GPIO
38 strncpy((char *)gpios
->gpios
[count
].name
, "write protect",
39 GPIO_MAX_NAME_LENGTH
);
42 /* Recovery: active low */
43 gpios
->gpios
[count
].port
= -1;
44 gpios
->gpios
[count
].polarity
= ACTIVE_HIGH
;
45 gpios
->gpios
[count
].value
= get_recovery_mode_switch();
46 strncpy((char *)gpios
->gpios
[count
].name
, "recovery",
47 GPIO_MAX_NAME_LENGTH
);
50 /* Lid: active high */
51 gpios
->gpios
[count
].port
= EXYNOS5_GPX3
;
52 gpios
->gpios
[count
].polarity
= ACTIVE_HIGH
;
53 gpios
->gpios
[count
].value
= gpio_get_value(GPIO_X35
); // LID_GPIO
54 strncpy((char *)gpios
->gpios
[count
].name
, "lid", GPIO_MAX_NAME_LENGTH
);
57 /* Power: virtual GPIO active low */
58 gpios
->gpios
[count
].port
= EXYNOS5_GPX1
;
59 gpios
->gpios
[count
].polarity
= ACTIVE_LOW
;
60 gpios
->gpios
[count
].value
=
61 gpio_get_value(GPIO_X13
); // POWER_GPIO
62 strncpy((char *)gpios
->gpios
[count
].name
, "power",
63 GPIO_MAX_NAME_LENGTH
);
66 /* Developer: virtual GPIO active high */
67 gpios
->gpios
[count
].port
= -1;
68 gpios
->gpios
[count
].polarity
= ACTIVE_HIGH
;
69 gpios
->gpios
[count
].value
= get_developer_mode_switch();
70 strncpy((char *)gpios
->gpios
[count
].name
, "developer",
71 GPIO_MAX_NAME_LENGTH
);
74 gpios
->size
= sizeof(*gpios
) + (count
* sizeof(struct lb_gpio
));
77 printk(BIOS_ERR
, "Added %d GPIOS size %d\n", count
, gpios
->size
);
80 int get_developer_mode_switch(void)
85 int get_recovery_mode_switch(void)
89 /* The GPIO is active low. */
90 if (!gpio_get_value(GPIO_Y10
)) // RECMODE_GPIO
93 ec_events
= google_chromeec_get_events_b();
95 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY
));
98 int get_write_protect_state(void)
100 return !gpio_get_value(GPIO_D16
);