dm: arm: bcmstb: Enable driver model MMC support
[platform/kernel/u-boot.git] / board / broadcom / bcmstb / bcmstb.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2018  Cisco Systems, Inc.
4  * (C) Copyright 2019  Synamedia
5  *
6  * Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
7  */
8
9 #include <linux/types.h>
10 #include <common.h>
11 #include <asm/io.h>
12 #include <asm/bootm.h>
13 #include <mach/timer.h>
14 #include <mmc.h>
15 #include <fdtdec.h>
16
17 DECLARE_GLOBAL_DATA_PTR;
18
19 #define BCMSTB_DATA_SECTION __attribute__((section(".data")))
20
21 struct bcmstb_boot_parameters bcmstb_boot_parameters BCMSTB_DATA_SECTION;
22
23 phys_addr_t prior_stage_fdt_address BCMSTB_DATA_SECTION;
24
25 union reg_value_union {
26         const char *data;
27         const phys_addr_t *address;
28 };
29
30 int board_init(void)
31 {
32         return 0;
33 }
34
35 u32 get_board_rev(void)
36 {
37         return 0;
38 }
39
40 void reset_cpu(ulong ignored)
41 {
42 }
43
44 int print_cpuinfo(void)
45 {
46         return 0;
47 }
48
49 int dram_init(void)
50 {
51         if (fdtdec_setup_mem_size_base() != 0)
52                 return -EINVAL;
53
54         return 0;
55 }
56
57 int dram_init_banksize(void)
58 {
59         fdtdec_setup_memory_banksize();
60
61         /*
62          * On this SoC, U-Boot is running as an ELF file.  Change the
63          * relocation address to CONFIG_SYS_TEXT_BASE, so that in
64          * setup_reloc, gd->reloc_off works out to 0, effectively
65          * disabling relocation.  Otherwise U-Boot hangs in the setup
66          * instructions just before relocate_code in
67          * arch/arm/lib/crt0.S.
68          */
69         gd->relocaddr = CONFIG_SYS_TEXT_BASE;
70
71         return 0;
72 }
73
74 void enable_caches(void)
75 {
76         /*
77          * This port assumes that the prior stage bootloader has
78          * enabled I-cache and D-cache already.  Implementing this
79          * function silences the warning in the default function.
80          */
81 }
82
83 int timer_init(void)
84 {
85         gd->arch.timer_rate_hz = readl(BCMSTB_TIMER_FREQUENCY);
86
87         return 0;
88 }
89
90 ulong get_tbclk(void)
91 {
92         return gd->arch.timer_rate_hz;
93 }
94
95 uint64_t get_ticks(void)
96 {
97         gd->timebase_h = readl(BCMSTB_TIMER_HIGH);
98         gd->timebase_l = readl(BCMSTB_TIMER_LOW);
99
100         return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l;
101 }
102
103 int board_late_init(void)
104 {
105         debug("Arguments from prior stage bootloader:\n");
106         debug("General Purpose Register 0: 0x%x\n", bcmstb_boot_parameters.r0);
107         debug("General Purpose Register 1: 0x%x\n", bcmstb_boot_parameters.r1);
108         debug("General Purpose Register 2: 0x%x\n", bcmstb_boot_parameters.r2);
109         debug("General Purpose Register 3: 0x%x\n", bcmstb_boot_parameters.r3);
110         debug("Stack Pointer Register:     0x%x\n", bcmstb_boot_parameters.sp);
111         debug("Link Register:              0x%x\n", bcmstb_boot_parameters.lr);
112         debug("Assuming timer frequency register at: 0x%p\n",
113               (void *)BCMSTB_TIMER_FREQUENCY);
114         debug("Read timer frequency (in Hz): %ld\n", gd->arch.timer_rate_hz);
115         debug("Prior stage provided DTB at: 0x%p\n",
116               (void *)prior_stage_fdt_address);
117
118         /*
119          * Set fdtcontroladdr in the environment so that scripts can
120          * refer to it, for example, to reuse it for fdtaddr.
121          */
122         env_set_hex("fdtcontroladdr", prior_stage_fdt_address);
123
124         /*
125          * Do not set machid to the machine identifier value provided
126          * by the prior stage bootloader (bcmstb_boot_parameters.r1)
127          * because we're using a device tree to boot Linux.
128          */
129
130         return 0;
131 }