Angel Pons | 7c1d70e | 2020-04-04 18:51:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/device.h> |
| 5 | #include <symbols.h> |
| 6 | #include <soc/ipq_uart.h> |
| 7 | |
Kyösti Mälkki | 7ffbe0a | 2021-06-26 14:25:56 +0300 | [diff] [blame] | 8 | /* CONFIG_DRAM_SIZE_MB effectively extends hlos2. */ |
Varadarajan Narayanan | a86a183 | 2016-02-01 11:36:51 +0530 | [diff] [blame] | 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 | |
Elyes HAOUAS | d6cd255 | 2018-05-25 10:01:13 +0200 | [diff] [blame] | 17 | static void soc_read_resources(struct device *dev) |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 18 | { |
Varadarajan Narayanan | a86a183 | 2016-02-01 11:36:51 +0530 | [diff] [blame] | 19 | ipq_mem_map_t *ipq_mem_map = ((ipq_mem_map_t *)_dram); |
Kyösti Mälkki | 7ffbe0a | 2021-06-26 14:25:56 +0300 | [diff] [blame] | 20 | uint64_t ram_end = (uintptr_t)_dram + CONFIG_DRAM_SIZE_MB * (uint64_t)MiB; |
Varadarajan Narayanan | a86a183 | 2016-02-01 11:36:51 +0530 | [diff] [blame] | 21 | |
Kyösti Mälkki | 7ffbe0a | 2021-06-26 14:25:56 +0300 | [diff] [blame] | 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); |
Varadarajan Narayanan | a86a183 | 2016-02-01 11:36:51 +0530 | [diff] [blame] | 25 | |
| 26 | /* 0x88000000 to end, is the second region for Linux */ |
Kyösti Mälkki | 7ffbe0a | 2021-06-26 14:25:56 +0300 | [diff] [blame] | 27 | ram_from_to(dev, 2, (uintptr_t)ipq_mem_map->hlos2, ram_end); |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 28 | } |
| 29 | |
Elyes HAOUAS | d6cd255 | 2018-05-25 10:01:13 +0200 | [diff] [blame] | 30 | static void soc_init(struct device *dev) |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 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 | |
Elyes HAOUAS | d6cd255 | 2018-05-25 10:01:13 +0200 | [diff] [blame] | 46 | static void enable_soc_dev(struct device *dev) |
Varadarajan Narayanan | a6935c2 | 2016-03-02 16:57:10 +0530 | [diff] [blame] | 47 | { |
| 48 | dev->ops = &soc_ops; |
| 49 | } |
| 50 | |
| 51 | struct chip_operations soc_qualcomm_ipq40xx_ops = { |
| 52 | CHIP_NAME("SOC QCA 40xx") |
| 53 | .enable_dev = enable_soc_dev, |
| 54 | }; |