tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / mainboard / google / nyan / chromeos.c
blob5b423907f4eaedf53d1f853365a90b97e46cf3be
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.
16 #include <boot/coreboot_tables.h>
17 #include <bootmode.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>
25 void fill_lb_gpios(struct lb_gpios *gpios)
27 int count = 0;
29 /* Write Protect: active low */
30 gpios->gpios[count].port = GPIO(R1);
31 gpios->gpios[count].polarity = ACTIVE_LOW;
32 gpios->gpios[count].value = gpio_get(GPIO(R1));
33 strncpy((char *)gpios->gpios[count].name, "write protect",
34 GPIO_MAX_NAME_LENGTH);
35 count++;
37 /* Recovery: active high */
38 gpios->gpios[count].port = -1;
39 gpios->gpios[count].polarity = ACTIVE_HIGH;
40 gpios->gpios[count].value = get_recovery_mode_switch();
41 strncpy((char *)gpios->gpios[count].name, "recovery",
42 GPIO_MAX_NAME_LENGTH);
43 count++;
45 /* Lid: active high */
46 gpios->gpios[count].port = GPIO(R4);
47 gpios->gpios[count].polarity = ACTIVE_HIGH;
48 gpios->gpios[count].value = -1;
49 strncpy((char *)gpios->gpios[count].name, "lid", GPIO_MAX_NAME_LENGTH);
50 count++;
52 /* Power: active low */
53 gpios->gpios[count].port = GPIO(Q0);
54 gpios->gpios[count].polarity = ACTIVE_LOW;
55 gpios->gpios[count].value = -1;
56 strncpy((char *)gpios->gpios[count].name, "power",
57 GPIO_MAX_NAME_LENGTH);
58 count++;
60 /* Developer: virtual GPIO active high */
61 gpios->gpios[count].port = -1;
62 gpios->gpios[count].polarity = ACTIVE_HIGH;
63 gpios->gpios[count].value = get_developer_mode_switch();
64 strncpy((char *)gpios->gpios[count].name, "developer",
65 GPIO_MAX_NAME_LENGTH);
66 count++;
68 /* EC in RW: active high */
69 gpios->gpios[count].port = GPIO(U4);
70 gpios->gpios[count].polarity = ACTIVE_HIGH;
71 gpios->gpios[count].value = -1;
72 strncpy((char *)gpios->gpios[count].name, "EC in RW",
73 GPIO_MAX_NAME_LENGTH);
74 count++;
76 /* Reset: active low (output) */
77 gpios->gpios[count].port = GPIO(I5);
78 gpios->gpios[count].polarity = ACTIVE_LOW;
79 gpios->gpios[count].value = -1;
80 strncpy((char *)gpios->gpios[count].name, "reset",
81 GPIO_MAX_NAME_LENGTH);
82 count++;
84 gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio));
85 gpios->count = count;
87 printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
90 int get_developer_mode_switch(void)
92 return 0;
95 int get_recovery_mode_switch(void)
97 uint32_t ec_events;
99 ec_events = google_chromeec_get_events_b();
100 return !!(ec_events &
101 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY));
104 int get_write_protect_state(void)
106 return !gpio_get(GPIO(R1));