blob: b5c0cb7487465605b0e156d6b6471854a3a3e229 [file] [log] [blame]
Ian Campbell6efe3692014-05-05 11:52:26 +01001/*
2 * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
3 *
4 * (C) Copyright 2007-2011
5 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
6 * Tom Cubie <tangliang@allwinnertech.com>
7 *
8 * Some init for sunxi platform.
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 */
12
13#include <common.h>
14#include <serial.h>
15#ifdef CONFIG_SPL_BUILD
16#include <spl.h>
17#endif
18#include <asm/gpio.h>
19#include <asm/io.h>
20#include <asm/arch/clock.h>
21#include <asm/arch/gpio.h>
22#include <asm/arch/sys_proto.h>
23#include <asm/arch/timer.h>
24
25#ifdef CONFIG_SPL_BUILD
26/* Pointer to the global data structure for SPL */
27DECLARE_GLOBAL_DATA_PTR;
28
29/* The sunxi internal brom will try to loader external bootloader
30 * from mmc0, nand flash, mmc2.
31 * Unfortunately we can't check how SPL was loaded so assume
32 * it's always the first SD/MMC controller
33 */
34u32 spl_boot_device(void)
35{
36 return BOOT_DEVICE_MMC1;
37}
38
39/* No confirmation data available in SPL yet. Hardcode bootmode */
40u32 spl_boot_mode(void)
41{
42 return MMCSD_MODE_RAW;
43}
44#endif
45
46int gpio_init(void)
47{
48 sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB22_UART0_TX);
49 sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB23_UART0_RX);
50 sunxi_gpio_set_pull(SUNXI_GPB(23), 1);
51
52 return 0;
53}
54
55void reset_cpu(ulong addr)
56{
57}
58
59/* do some early init */
60void s_init(void)
61{
62#if !defined CONFIG_SPL_BUILD && (defined CONFIG_SUN7I || defined CONFIG_SUN6I)
63 /* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */
64 asm volatile(
65 "mrc p15, 0, r0, c1, c0, 1\n"
66 "orr r0, r0, #1 << 6\n"
67 "mcr p15, 0, r0, c1, c0, 1\n");
68#endif
69
70 clock_init();
71 timer_init();
72 gpio_init();
73
74#ifdef CONFIG_SPL_BUILD
75 gd = &gdata;
76 preloader_console_init();
77
78 sunxi_board_init();
79#endif
80}
81
82#ifndef CONFIG_SYS_DCACHE_OFF
83void enable_caches(void)
84{
85 /* Enable D-cache. I-cache is already enabled in start.S */
86 dcache_enable();
87}
88#endif