blob: f482cff30bc7c1638826f6a1a9463e97402ffb39 [file] [log] [blame]
Angel Pons7c1d70e2020-04-04 18:51:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Varadarajan Narayanana6935c22016-03-02 16:57:10 +05302
3#include <console/console.h>
4#include <device/device.h>
5#include <symbols.h>
6#include <soc/ipq_uart.h>
7
Kyösti Mälkki7ffbe0a2021-06-26 14:25:56 +03008/* CONFIG_DRAM_SIZE_MB effectively extends hlos2. */
Varadarajan Narayanana86a1832016-02-01 11:36:51 +05309typedef struct {
10 uint8_t hlos1[112 * MiB], /* <-- 0x80000000 */
11 appsbl[4 * MiB], /* <-- 0x87000000 */
12 sbl[1 * MiB], /* <-- 0x87400000 */
13 rsvd[11 * MiB], /* <-- 0x87500000 */
14 hlos2[128 * MiB]; /* <-- 0x88000000 */
15} ipq_mem_map_t;
16
Elyes HAOUASd6cd2552018-05-25 10:01:13 +020017static void soc_read_resources(struct device *dev)
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053018{
Varadarajan Narayanana86a1832016-02-01 11:36:51 +053019 ipq_mem_map_t *ipq_mem_map = ((ipq_mem_map_t *)_dram);
Kyösti Mälkki7ffbe0a2021-06-26 14:25:56 +030020 uint64_t ram_end = (uintptr_t)_dram + CONFIG_DRAM_SIZE_MB * (uint64_t)MiB;
Varadarajan Narayanana86a1832016-02-01 11:36:51 +053021
Kyösti Mälkki7ffbe0a2021-06-26 14:25:56 +030022 ram_from_to(dev, 0, (uintptr_t)ipq_mem_map->hlos1, (uintptr_t)ipq_mem_map->rsvd);
23 reserved_ram_from_to(dev, 1, (uintptr_t)ipq_mem_map->rsvd,
24 (uintptr_t)ipq_mem_map->hlos2);
Varadarajan Narayanana86a1832016-02-01 11:36:51 +053025
26 /* 0x88000000 to end, is the second region for Linux */
Kyösti Mälkki7ffbe0a2021-06-26 14:25:56 +030027 ram_from_to(dev, 2, (uintptr_t)ipq_mem_map->hlos2, ram_end);
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053028}
29
Elyes HAOUASd6cd2552018-05-25 10:01:13 +020030static void soc_init(struct device *dev)
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053031{
32 /*
33 * Do this in case console is not enabled: kernel's earlyprintk()
34 * should work no matter what the firmware console configuration is.
35 */
36 ipq40xx_uart_init();
37
38 printk(BIOS_INFO, "CPU: QCA 40xx\n");
39}
40
41static struct device_operations soc_ops = {
42 .read_resources = soc_read_resources,
43 .init = soc_init,
44};
45
Elyes HAOUASd6cd2552018-05-25 10:01:13 +020046static void enable_soc_dev(struct device *dev)
Varadarajan Narayanana6935c22016-03-02 16:57:10 +053047{
48 dev->ops = &soc_ops;
49}
50
51struct chip_operations soc_qualcomm_ipq40xx_ops = {
52 CHIP_NAME("SOC QCA 40xx")
53 .enable_dev = enable_soc_dev,
54};