2 * This file is part of the coreboot project.
4 * Copyright (C) 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <console/console.h>
21 #include <ec/google/chromeec/ec.h>
22 #include <ec/google/chromeec/ec_commands.h>
24 #include <vendorcode/google/chromeos/chromeos.h>
26 #include <cpu/samsung/exynos5250/cpu.h>
27 #include <cpu/samsung/exynos5250/gpio.h>
28 #include <cpu/samsung/exynos5-common/gpio.h>
33 #define DEVMODE_GPIO 54
34 #define RECMODE_GPIO 0
35 #define FORCE_RECOVERY_MODE 0
36 #define FORCE_DEVELOPER_MODE 0
38 #define POWER_BUTTON 3
40 #include <boot/coreboot_tables.h>
44 static struct exynos5_gpio_part1
*gpio_pt1
=
45 (struct exynos5_gpio_part1
*)EXYNOS5_GPIO_PART1_BASE
;
46 static struct exynos5_gpio_part2
*gpio_pt2
=
47 (struct exynos5_gpio_part2
*)EXYNOS5_GPIO_PART2_BASE
;
49 void fill_lb_gpios(struct lb_gpios
*gpios
)
51 gpios
->size
= sizeof(*gpios
) + (GPIO_COUNT
* sizeof(struct lb_gpio
));
52 gpios
->count
= GPIO_COUNT
;
54 /* Write Protect: active low */
55 gpios
->gpios
[0].port
= EXYNOS5_GPD1
;
56 gpios
->gpios
[0].polarity
= ACTIVE_LOW
;
57 gpios
->gpios
[0].value
= s5p_gpio_get_value(&gpio_pt1
->d1
, WP_GPIO
);
58 strncpy((char *)gpios
->gpios
[0].name
,"write protect",
59 GPIO_MAX_NAME_LENGTH
);
61 /* Recovery: active low */
62 gpios
->gpios
[1].port
= -1;
63 gpios
->gpios
[1].polarity
= ACTIVE_HIGH
;
64 gpios
->gpios
[1].value
= get_recovery_mode_switch();
65 strncpy((char *)gpios
->gpios
[1].name
,"recovery", GPIO_MAX_NAME_LENGTH
);
67 /* Lid: active high */
68 gpios
->gpios
[2].port
= EXYNOS5_GPX3
;
69 gpios
->gpios
[2].polarity
= ACTIVE_HIGH
;
70 gpios
->gpios
[2].value
= s5p_gpio_get_value(&gpio_pt2
->x3
, LID_OPEN
);
71 strncpy((char *)gpios
->gpios
[2].name
,"lid", GPIO_MAX_NAME_LENGTH
);
73 /* Power: virtual GPIO active low */
74 gpios
->gpios
[3].port
= -1;
75 gpios
->gpios
[3].polarity
= ACTIVE_LOW
;
76 gpios
->gpios
[3].value
= 1;
77 strncpy((char *)gpios
->gpios
[3].name
,"power", GPIO_MAX_NAME_LENGTH
);
79 /* Developer: virtual GPIO active high */
80 gpios
->gpios
[4].port
= -1;
81 gpios
->gpios
[4].polarity
= ACTIVE_HIGH
;
82 gpios
->gpios
[4].value
= 0;
83 strncpy((char *)gpios
->gpios
[4].name
,"developer",
84 GPIO_MAX_NAME_LENGTH
);
86 /* Was VGA Option ROM loaded? */
87 gpios
->gpios
[5].port
= -1; /* Indicate that this is a pseudo GPIO */
88 gpios
->gpios
[5].polarity
= ACTIVE_HIGH
;
89 gpios
->gpios
[5].value
= 0;
90 strncpy((char *)gpios
->gpios
[5].name
,"oprom", GPIO_MAX_NAME_LENGTH
);
92 printk(BIOS_ERR
, "Added %d GPIOS size %d\n", GPIO_COUNT
, gpios
->size
);
96 int get_developer_mode_switch(void)
100 printk(BIOS_DEBUG
,"FORCING DEVELOPER MODE.\n");
103 printk(BIOS_DEBUG
,"DEVELOPER MODE FROM GPIO %d: %x\n",DEVMODE_GPIO
,
109 int get_recovery_mode_switch(void)
113 /* The GPIO is active low. */
114 if (!s5p_gpio_get_value(&gpio_pt1
->y1
, RECMODE_GPIO
))
117 ec_events
= google_chromeec_get_events_b();
118 return !!(ec_events
&
119 EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY
));
122 int get_recovery_mode_from_vbnv(void)