huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 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> |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 12 | #include <asm/gpio.h> |
huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | void get_ddr_config(struct rk3036_ddr_config *config) |
| 17 | { |
| 18 | /* K4B4G1646Q config */ |
| 19 | config->ddr_type = 3; |
| 20 | config->rank = 1; |
| 21 | config->cs0_row = 15; |
| 22 | config->cs1_row = 15; |
| 23 | |
| 24 | /* 8bank */ |
| 25 | config->bank = 3; |
| 26 | config->col = 10; |
| 27 | |
| 28 | /* 16bit bw */ |
| 29 | config->bw = 1; |
| 30 | } |
| 31 | |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 32 | #define FASTBOOT_KEY_GPIO 93 |
| 33 | |
| 34 | int fastboot_key_pressed(void) |
| 35 | { |
| 36 | gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key"); |
| 37 | gpio_direction_input(FASTBOOT_KEY_GPIO); |
| 38 | return !gpio_get_value(FASTBOOT_KEY_GPIO); |
| 39 | } |
| 40 | |
| 41 | #define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309 |
| 42 | |
Jacob Chen | c95f378 | 2016-09-19 18:46:28 +0800 | [diff] [blame] | 43 | int rk_board_late_init(void) |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 44 | { |
Jacob Chen | c95f378 | 2016-09-19 18:46:28 +0800 | [diff] [blame] | 45 | if (fastboot_key_pressed()) { |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 46 | printf("enter fastboot!\n"); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 47 | env_set("preboot", "setenv preboot; fastboot usb0"); |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | return 0; |
| 51 | } |