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> |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 11 | #include <asm/arch-rockchip/grf_rk3036.h> |
huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 12 | #include <asm/arch/sdram_rk3036.h> |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 13 | #include <asm/gpio.h> |
huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 17 | #define GRF_BASE 0x20008000 |
| 18 | |
huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 19 | void get_ddr_config(struct rk3036_ddr_config *config) |
| 20 | { |
| 21 | /* K4B4G1646Q config */ |
| 22 | config->ddr_type = 3; |
| 23 | config->rank = 1; |
| 24 | config->cs0_row = 15; |
| 25 | config->cs1_row = 15; |
| 26 | |
| 27 | /* 8bank */ |
| 28 | config->bank = 3; |
| 29 | config->col = 10; |
| 30 | |
| 31 | /* 16bit bw */ |
| 32 | config->bw = 1; |
| 33 | } |
| 34 | |
Jeffy Chen | a32d009 | 2016-01-14 10:19:40 +0800 | [diff] [blame] | 35 | #define FASTBOOT_KEY_GPIO 93 |
| 36 | |
| 37 | int fastboot_key_pressed(void) |
| 38 | { |
| 39 | gpio_request(FASTBOOT_KEY_GPIO, "fastboot_key"); |
| 40 | gpio_direction_input(FASTBOOT_KEY_GPIO); |
| 41 | return !gpio_get_value(FASTBOOT_KEY_GPIO); |
| 42 | } |
| 43 | |
| 44 | #define ROCKCHIP_BOOT_MODE_FASTBOOT 0x5242C309 |
| 45 | |
| 46 | int board_late_init(void) |
| 47 | { |
| 48 | struct rk3036_grf * const grf = (void *)GRF_BASE; |
| 49 | int boot_mode = readl(&grf->os_reg[4]); |
| 50 | |
| 51 | /* Clear boot mode */ |
| 52 | writel(0, &grf->os_reg[4]); |
| 53 | |
| 54 | if (boot_mode == ROCKCHIP_BOOT_MODE_FASTBOOT || |
| 55 | fastboot_key_pressed()) { |
| 56 | printf("enter fastboot!\n"); |
| 57 | setenv("preboot", "setenv preboot; fastboot usb0"); |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
huang lin | a77e50c | 2015-12-07 11:08:57 +0800 | [diff] [blame] | 63 | int board_init(void) |
| 64 | { |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | int dram_init(void) |
| 69 | { |
| 70 | gd->ram_size = sdram_size(); |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 76 | void enable_caches(void) |
| 77 | { |
| 78 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 79 | dcache_enable(); |
| 80 | } |
| 81 | #endif |