tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / mainboard / google / veyron_rialto / chromeos.c
blob3b4dc33922df8a3cbcf91519f3ca9885066c463a
1 /*
2 * This file is part of the coreboot project.
4 * Copyright 2014 Rockchip 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 <console/console.h>
18 #include <gpio.h>
19 #include <string.h>
20 #include <vendorcode/google/chromeos/chromeos.h>
22 #include "board.h"
24 #define GPIO_WP GPIO(7, A, 6)
25 #define GPIO_POWER GPIO(0, A, 5)
26 #define GPIO_RECOVERY_SERVO GPIO(0, B, 1)
27 #define GPIO_RECOVERY_PUSHKEY GPIO(7, B, 1)
28 #define GPIO_DEVELOPER_SWITCH GPIO(7, B, 2)
31 void setup_chromeos_gpios(void)
33 gpio_input(GPIO_WP);
34 gpio_input(GPIO_POWER);
35 gpio_input_pullup(GPIO_RECOVERY_SERVO);
36 gpio_input_pullup(GPIO_RECOVERY_PUSHKEY);
37 gpio_input(GPIO_DEVELOPER_SWITCH); // board has pull up/down resistor.
40 void fill_lb_gpios(struct lb_gpios *gpios)
42 int count = 0;
44 /* Write Protect: active low */
45 gpios->gpios[count].port = GPIO_WP.raw;
46 gpios->gpios[count].polarity = ACTIVE_LOW;
47 gpios->gpios[count].value = gpio_get(GPIO_WP);
48 strncpy((char *)gpios->gpios[count].name, "write protect",
49 GPIO_MAX_NAME_LENGTH);
50 count++;
52 /* Recovery: active low */
53 /* Note for early development, we want to support both servo and
54 * pushkey recovery buttons in firmware boot stages.
56 gpios->gpios[count].port = GPIO_RECOVERY_PUSHKEY.raw;
57 gpios->gpios[count].polarity = ACTIVE_LOW;
58 gpios->gpios[count].value = !get_recovery_mode_switch();
59 strncpy((char *)gpios->gpios[count].name, "recovery",
60 GPIO_MAX_NAME_LENGTH);
61 count++;
63 /* Power Button: GPIO active low */
64 gpios->gpios[count].port = GPIO_POWER.raw;
65 gpios->gpios[count].polarity = ACTIVE_LOW;
66 gpios->gpios[count].value = -1;
67 strncpy((char *)gpios->gpios[count].name, "power",
68 GPIO_MAX_NAME_LENGTH);
69 count++;
71 /* Developer: GPIO active high */
72 gpios->gpios[count].port = GPIO_DEVELOPER_SWITCH.raw;
73 gpios->gpios[count].polarity = ACTIVE_HIGH;
74 gpios->gpios[count].value = get_developer_mode_switch();
75 strncpy((char *)gpios->gpios[count].name, "developer",
76 GPIO_MAX_NAME_LENGTH);
77 count++;
79 /* Reset: GPIO active high (output) */
80 gpios->gpios[count].port = GPIO_RESET.raw;
81 gpios->gpios[count].polarity = ACTIVE_HIGH;
82 gpios->gpios[count].value = -1;
83 strncpy((char *)gpios->gpios[count].name, "reset",
84 GPIO_MAX_NAME_LENGTH);
85 count++;
87 gpios->size = sizeof(*gpios) + (count * sizeof(struct lb_gpio));
88 gpios->count = count;
90 printk(BIOS_ERR, "Added %d GPIOS size %d\n", count, gpios->size);
93 int get_developer_mode_switch(void)
95 // GPIO_DEVELOPER_SWITCH is active high.
96 return gpio_get(GPIO_DEVELOPER_SWITCH);
99 int get_recovery_mode_switch(void)
101 // Both RECOVERY_SERVO and RECOVERY_PUSHKEY are low active.
102 return !(gpio_get(GPIO_RECOVERY_SERVO) &&
103 gpio_get(GPIO_RECOVERY_PUSHKEY));
106 int get_write_protect_state(void)
108 return !gpio_get(GPIO_WP);