1 /*
2  * (C) Copyright 2015 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <dm.h>
9 #include <asm/io.h>
10 #include <asm/arch/uart.h>
11 #include <asm/arch/sdram_rk3036.h>
12 #include <asm/gpio.h>
13 
14 void get_ddr_config(struct rk3036_ddr_config *config)
15 {
16 	/* K4B4G1646Q config */
17 	config->ddr_type = 3;
18 	config->rank = 1;
19 	config->cs0_row = 15;
20 	config->cs1_row = 15;
21 
22 	/* 8bank */
23 	config->bank = 3;
24 	config->col = 10;
25 
26 	/* 16bit bw */
27 	config->bw = 1;
28 }
29 
30 #define FASTBOOT_KEY_GPIO 93
31 
32 int fastboot_key_pressed(void)
33 {
34 	gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key");
35 	gpio_direction_input(FASTBOOT_KEY_GPIO);
36 	return !gpio_get_value(FASTBOOT_KEY_GPIO);
37 }
38 
39 #define ROCKCHIP_BOOT_MODE_FASTBOOT	0x5242C309
40 
41 int rk_board_late_init(void)
42 {
43 	if (fastboot_key_pressed()) {
44 		printf("enter fastboot!\n");
45 		env_set("preboot", "setenv preboot; fastboot usb0");
46 	}
47 
48 	return 0;
49 }
50