Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2018 Cisco Systems, Inc. |
Thomas Fitzsimmons | 06edafb | 2019-05-17 08:17:07 -0400 | [diff] [blame] | 4 | * (C) Copyright 2019 Synamedia |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 5 | * |
| 6 | * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org> |
| 7 | */ |
| 8 | |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Simon Glass | 495a5dc | 2019-11-14 12:57:30 -0700 | [diff] [blame] | 12 | #include <time.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 14 | #include <linux/types.h> |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 15 | #include <common.h> |
Simon Glass | 313112a | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 16 | #include <env.h> |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 17 | #include <asm/io.h> |
| 18 | #include <asm/bootm.h> |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 19 | #include <mach/timer.h> |
| 20 | #include <mmc.h> |
| 21 | #include <fdtdec.h> |
| 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Marek BehĂșn | 4bebdd3 | 2021-05-20 13:23:52 +0200 | [diff] [blame] | 25 | #define BCMSTB_DATA_SECTION __section(".data") |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 26 | |
| 27 | struct bcmstb_boot_parameters bcmstb_boot_parameters BCMSTB_DATA_SECTION; |
| 28 | |
| 29 | phys_addr_t prior_stage_fdt_address BCMSTB_DATA_SECTION; |
| 30 | |
| 31 | union reg_value_union { |
| 32 | const char *data; |
| 33 | const phys_addr_t *address; |
| 34 | }; |
| 35 | |
| 36 | int board_init(void) |
| 37 | { |
| 38 | return 0; |
| 39 | } |
| 40 | |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 41 | void reset_cpu(void) |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 42 | { |
| 43 | } |
| 44 | |
| 45 | int print_cpuinfo(void) |
| 46 | { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int dram_init(void) |
| 51 | { |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 52 | if (fdtdec_setup_mem_size_base() != 0) |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 53 | return -EINVAL; |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | int dram_init_banksize(void) |
| 59 | { |
| 60 | fdtdec_setup_memory_banksize(); |
| 61 | |
| 62 | /* |
| 63 | * On this SoC, U-Boot is running as an ELF file. Change the |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 64 | * relocation address to CONFIG_TEXT_BASE, so that in |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 65 | * setup_reloc, gd->reloc_off works out to 0, effectively |
| 66 | * disabling relocation. Otherwise U-Boot hangs in the setup |
| 67 | * instructions just before relocate_code in |
| 68 | * arch/arm/lib/crt0.S. |
| 69 | */ |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 70 | gd->relocaddr = CONFIG_TEXT_BASE; |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | void enable_caches(void) |
| 76 | { |
| 77 | /* |
| 78 | * This port assumes that the prior stage bootloader has |
| 79 | * enabled I-cache and D-cache already. Implementing this |
| 80 | * function silences the warning in the default function. |
| 81 | */ |
| 82 | } |
| 83 | |
Thomas Fitzsimmons | 919646d | 2018-06-08 17:59:45 -0400 | [diff] [blame] | 84 | int timer_init(void) |
| 85 | { |
| 86 | gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY); |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | ulong get_tbclk(void) |
| 92 | { |
| 93 | return gd->arch.timer_rate_hz; |
| 94 | } |
| 95 | |
| 96 | uint64_t get_ticks(void) |
| 97 | { |
| 98 | gd->timebase_h = readl(BCMSTB_TIMER_HIGH); |
| 99 | gd->timebase_l = readl(BCMSTB_TIMER_LOW); |
| 100 | |
| 101 | return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l; |
| 102 | } |
| 103 | |
| 104 | int board_late_init(void) |
| 105 | { |
| 106 | debug("Arguments from prior stage bootloader:\n"); |
| 107 | debug("General Purpose Register 0: 0x%x\n", bcmstb_boot_parameters.r0); |
| 108 | debug("General Purpose Register 1: 0x%x\n", bcmstb_boot_parameters.r1); |
| 109 | debug("General Purpose Register 2: 0x%x\n", bcmstb_boot_parameters.r2); |
| 110 | debug("General Purpose Register 3: 0x%x\n", bcmstb_boot_parameters.r3); |
| 111 | debug("Stack Pointer Register: 0x%x\n", bcmstb_boot_parameters.sp); |
| 112 | debug("Link Register: 0x%x\n", bcmstb_boot_parameters.lr); |
| 113 | debug("Assuming timer frequency register at: 0x%p\n", |
| 114 | (void *)BCMSTB_TIMER_FREQUENCY); |
| 115 | debug("Read timer frequency (in Hz): %ld\n", gd->arch.timer_rate_hz); |
| 116 | debug("Prior stage provided DTB at: 0x%p\n", |
| 117 | (void *)prior_stage_fdt_address); |
| 118 | |
| 119 | /* |
| 120 | * Set fdtcontroladdr in the environment so that scripts can |
| 121 | * refer to it, for example, to reuse it for fdtaddr. |
| 122 | */ |
| 123 | env_set_hex("fdtcontroladdr", prior_stage_fdt_address); |
| 124 | |
| 125 | /* |
| 126 | * Do not set machid to the machine identifier value provided |
| 127 | * by the prior stage bootloader (bcmstb_boot_parameters.r1) |
| 128 | * because we're using a device tree to boot Linux. |
| 129 | */ |
| 130 | |
| 131 | return 0; |
| 132 | } |
Ilias Apalodimas | cd851d0 | 2021-10-12 00:00:14 +0300 | [diff] [blame] | 133 | |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 134 | void *board_fdt_blob_setup(int *err) |
Ilias Apalodimas | cd851d0 | 2021-10-12 00:00:14 +0300 | [diff] [blame] | 135 | { |
Ilias Apalodimas | ab5348a | 2021-10-26 09:12:33 +0300 | [diff] [blame] | 136 | *err = 0; |
Ilias Apalodimas | cd851d0 | 2021-10-12 00:00:14 +0300 | [diff] [blame] | 137 | /* Stored the DTB address there during our init */ |
| 138 | return (void *)prior_stage_fdt_address; |
| 139 | } |