blob: 14da49c71d9d264e1fd5dbbcbd3566e0cc9a72ee [file] [log] [blame]
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Google, Inc.
5 *
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.
9 *
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.
14 *
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
18 */
19
20#include <console/console.h>
21#include <string.h>
22#include <vendorcode/google/chromeos/chromeos.h>
23#include <arch/io.h>
24
David Hendricksd9b16f32013-03-06 19:16:10 -080025#include <cpu/samsung/exynos5250/cpu.h>
26#include <cpu/samsung/exynos5250/gpio.h>
27#include <cpu/samsung/exynos5-common/gpio.h>
28
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080029#include <device/device.h>
30
31#define ACTIVE_LOW 0
32#define ACTIVE_HIGH 1
33#define WP_GPIO 6
34#define DEVMODE_GPIO 54
35#define FORCE_RECOVERY_MODE 0
36#define FORCE_DEVELOPER_MODE 0
David Hendricksd9b16f32013-03-06 19:16:10 -080037#define LID_OPEN 3
38#define POWER_BUTTON 3
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080039
40#include <boot/coreboot_tables.h>
41#include <arch/coreboot_tables.h>
42
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080043#define GPIO_COUNT 6
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080044
45void fill_lb_gpios(struct lb_gpios *gpios)
46{
David Hendricksd9b16f32013-03-06 19:16:10 -080047 struct exynos5_gpio_part1 *gpio_pt1;
48 struct exynos5_gpio_part2 *gpio_pt2;
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080049
50 gpios->size = sizeof(*gpios) + (GPIO_COUNT * sizeof(struct lb_gpio));
51 gpios->count = GPIO_COUNT;
52
David Hendricksd9b16f32013-03-06 19:16:10 -080053 gpio_pt1 = (struct exynos5_gpio_part1 *)EXYNOS5_GPIO_PART1_BASE;
54 gpio_pt2 = (struct exynos5_gpio_part2 *)EXYNOS5_GPIO_PART2_BASE;
55
56 /* Write Protect: active Low */
57 gpios->gpios[0].port = EXYNOS5_GPD1;
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080058 gpios->gpios[0].polarity = ACTIVE_LOW;
David Hendricksd9b16f32013-03-06 19:16:10 -080059 gpios->gpios[0].value = s5p_gpio_get_value(&gpio_pt1->d1, WP_GPIO);
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080060 strncpy((char *)gpios->gpios[0].name,"write protect",
61 GPIO_MAX_NAME_LENGTH);
62
David Hendricksd9b16f32013-03-06 19:16:10 -080063 /* Recovery: active high */
64 gpios->gpios[1].port = EXYNOS5_GPY1;
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080065 gpios->gpios[1].polarity = ACTIVE_HIGH;
David Hendricksd9b16f32013-03-06 19:16:10 -080066 gpios->gpios[2].value = s5p_gpio_get_value(&gpio_pt1->y1, FORCE_RECOVERY_MODE);
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080067 strncpy((char *)gpios->gpios[1].name,"recovery", GPIO_MAX_NAME_LENGTH);
68
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080069 /* Lid: the "switch" comes from the EC */
David Hendricksd9b16f32013-03-06 19:16:10 -080070 gpios->gpios[2].port = EXYNOS5_GPX3;
71 gpios->gpios[2].polarity = ACTIVE_LOW;
72 gpios->gpios[2].value = s5p_gpio_get_value(&gpio_pt2->x3, LID_OPEN);
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080073 strncpy((char *)gpios->gpios[2].name,"lid", GPIO_MAX_NAME_LENGTH);
74
David Hendricksd9b16f32013-03-06 19:16:10 -080075 /* Power: virtual GPIO active low */
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080076 gpios->gpios[3].port = -1;
David Hendricksd9b16f32013-03-06 19:16:10 -080077 gpios->gpios[3].polarity = ACTIVE_LOW;
78 gpios->gpios[3].value = 1;
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080079 strncpy((char *)gpios->gpios[3].name,"power", GPIO_MAX_NAME_LENGTH);
80
81 /* Developer: virtual GPIO active high */
82 gpios->gpios[4].port = -1;
83 gpios->gpios[4].polarity = ACTIVE_HIGH;
84 gpios->gpios[4].value = 0;
85 strncpy((char *)gpios->gpios[4].name,"developer",
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080086 GPIO_MAX_NAME_LENGTH);
87
88 /* Was VGA Option ROM loaded? */
Ronald G. Minnicheeb36322013-02-27 10:12:03 -080089 gpios->gpios[5].port = -1; /* Indicate that this is a pseudo GPIO */
90 gpios->gpios[5].polarity = ACTIVE_HIGH;
91 gpios->gpios[5].value = 0;
92 strncpy((char *)gpios->gpios[5].name,"oprom", GPIO_MAX_NAME_LENGTH);
Ronald G. Minnich3faa2c72013-02-20 15:46:46 -080093
94 printk(BIOS_ERR, "Added %d GPIOS size %d\n", GPIO_COUNT, gpios->size);
95
96}
97
98int get_developer_mode_switch(void)
99{
100 int dev_mode = 0;
101
102 printk(BIOS_DEBUG,"FORCING DEVELOPER MODE.\n");
103
104 dev_mode = 1;
105 printk(BIOS_DEBUG,"DEVELOPER MODE FROM GPIO %d: %x\n",DEVMODE_GPIO,
106 dev_mode);
107
108 return dev_mode;
109}
110
111int get_recovery_mode_switch(void)
112{
113 int ec_rec_mode = 0;
114
115 return ec_rec_mode;
116}
117
118int get_recovery_mode_from_vbnv(void)
119{
120 return 1;
121}