xref: /aosp_15_r20/external/coreboot/src/soc/qualcomm/ipq40xx/soc.c (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <symbols.h>
6 #include <soc/ipq_uart.h>
7 
8 /* CONFIG_DRAM_SIZE_MB effectively extends hlos2. */
9 typedef 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 
soc_read_resources(struct device * dev)17 static void soc_read_resources(struct device *dev)
18 {
19 	ipq_mem_map_t *ipq_mem_map = ((ipq_mem_map_t *)_dram);
20 	uint64_t ram_end = (uintptr_t)_dram + CONFIG_DRAM_SIZE_MB * (uint64_t)MiB;
21 
22 	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);
25 
26 	/* 0x88000000 to end, is the second region for Linux */
27 	ram_from_to(dev, 2, (uintptr_t)ipq_mem_map->hlos2, ram_end);
28 }
29 
soc_init(struct device * dev)30 static void soc_init(struct device *dev)
31 {
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 
41 static struct device_operations soc_ops = {
42 	.read_resources = soc_read_resources,
43 	.init		= soc_init,
44 };
45 
enable_soc_dev(struct device * dev)46 static void enable_soc_dev(struct device *dev)
47 {
48 	dev->ops = &soc_ops;
49 }
50 
51 struct chip_operations soc_qualcomm_ipq40xx_ops = {
52 	.name = "SOC QCA 40xx",
53 	.enable_dev = enable_soc_dev,
54 };
55