Remove address from GPLv2 headers
[coreboot.git] / src / mainboard / google / daisy / chromeos.c
blobdfd8858a5c46f73158dd8525d5142d8e08fb3994
1 /*
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
17 * Foundation, Inc.
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>
24 #include <soc/cpu.h>
25 #include <soc/gpio.h>
26 #include <string.h>
27 #include <vendorcode/google/chromeos/chromeos.h>
28 #include <bootmode.h>
30 void fill_lb_gpios(struct lb_gpios *gpios)
32 int count = 0;
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);
40 count++;
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);
48 count++;
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);
55 count++;
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);
64 count++;
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);
72 count++;
74 gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio));
75 gpios->count = count;
77 printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
80 int get_developer_mode_switch(void)
82 return 0;
85 int get_recovery_mode_switch(void)
87 uint32_t ec_events;
89 /* The GPIO is active low. */
90 if (!gpio_get_value(GPIO_Y10)) // RECMODE_GPIO
91 return 1;
93 ec_events = google_chromeec_get_events_b();
94 return !!(ec_events &
95 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY));
98 int get_write_protect_state(void)
100 return !gpio_get_value(GPIO_D16);