huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2015 MediaTek 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 | |
Shunqian Zheng | d1cec75 | 2016-05-04 16:21:36 +0800 | [diff] [blame] | 16 | #include <bootmode.h> |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 17 | #include <console/console.h> |
Lin Huang | 19eb750 | 2016-03-26 11:50:05 +0800 | [diff] [blame] | 18 | #include <cpu/cpu.h> |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 19 | #include <device/device.h> |
Lin Huang | 19eb750 | 2016-03-26 11:50:05 +0800 | [diff] [blame] | 20 | #include <soc/addressmap.h> |
Shunqian Zheng | d1cec75 | 2016-05-04 16:21:36 +0800 | [diff] [blame] | 21 | #include <soc/display.h> |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 22 | #include <stddef.h> |
Lin Huang | 19eb750 | 2016-03-26 11:50:05 +0800 | [diff] [blame] | 23 | #include <stdlib.h> |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 24 | #include <string.h> |
| 25 | #include <symbols.h> |
| 26 | |
| 27 | static void soc_read_resources(device_t dev) |
| 28 | { |
| 29 | ram_resource(dev, 0, (uintptr_t)_dram / KiB, |
Lin Huang | 19eb750 | 2016-03-26 11:50:05 +0800 | [diff] [blame] | 30 | min(CONFIG_DRAM_SIZE_MB * KiB, MAX_DRAM_ADDRESS / KiB)); |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static void soc_init(device_t dev) |
| 34 | { |
| 35 | /* reserve bl31 image, which define in |
| 36 | * arm-trusted-firmware/plat/rockchip/rk3399/include/platform_def.h |
| 37 | */ |
Caesar Wang | 905a933 | 2016-04-28 14:37:48 +0800 | [diff] [blame] | 38 | mmio_resource(dev, 1, (0x10000 / KiB), (0x80000 / KiB)); |
Shunqian Zheng | d1cec75 | 2016-05-04 16:21:36 +0800 | [diff] [blame] | 39 | |
| 40 | if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT) && display_init_required()) |
| 41 | rk_display_init(dev, (uintptr_t)_framebuffer, |
| 42 | _framebuffer_size); |
| 43 | else |
| 44 | printk(BIOS_INFO, "Display initialization disabled.\n"); |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static struct device_operations soc_ops = { |
| 48 | .read_resources = soc_read_resources, |
| 49 | .init = soc_init, |
| 50 | }; |
| 51 | |
| 52 | static void enable_soc_dev(device_t dev) |
| 53 | { |
| 54 | dev->ops = &soc_ops; |
| 55 | } |
| 56 | |
| 57 | struct chip_operations soc_rockchip_rk3399_ops = { |
Paul Menzel | 3727776 | 2016-07-03 09:45:26 +0200 | [diff] [blame^] | 58 | CHIP_NAME("SOC Rockchip RK3399") |
huang lin | c14b54d | 2016-03-02 18:38:40 +0800 | [diff] [blame] | 59 | .enable_dev = enable_soc_dev, |
| 60 | }; |