blob: 0fe0de9fde93bce02205523f5394d06205bbeff7 [file] [log] [blame]
Durai Manickam KR2e7bc612022-04-04 11:23:18 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
4 *
5 * Author: Durai Manickam KR <durai.manickamkr@microchip.com>
6 */
7
8#include <common.h>
9#include <debug_uart.h>
10#include <fdtdec.h>
11#include <init.h>
12#include <asm/arch/at91_common.h>
13#include <asm/arch/at91_rstc.h>
14#include <asm/arch/at91_sfr.h>
15#include <asm/arch/at91sam9_smc.h>
16#include <asm/arch/clk.h>
17#include <asm/arch/gpio.h>
18#include <asm/global_data.h>
19#include <asm/io.h>
20#include <asm/mach-types.h>
21
Durai Manickam KR98676a92022-07-07 16:40:55 +053022extern void at91_pda_detect(void);
23
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053024DECLARE_GLOBAL_DATA_PTR;
25
26void at91_prepare_cpu_var(void);
27
Mihai Sain647089c2022-12-23 08:39:36 +020028static void board_leds_init(void)
29{
30 at91_set_pio_output(AT91_PIO_PORTD, 17, 0); /* LED RED */
31 at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* LED GREEN */
32 at91_set_pio_output(AT91_PIO_PORTD, 21, 1); /* LED BLUE */
33}
34
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053035int board_late_init(void)
36{
37 at91_prepare_cpu_var();
38
Durai Manickam KR98676a92022-07-07 16:40:55 +053039 at91_pda_detect();
40
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053041 return 0;
42}
43
44#ifdef CONFIG_DEBUG_UART_BOARD_INIT
45void board_debug_uart_init(void)
46{
47 at91_seriald_hw_init();
48}
49#endif
50
51int board_early_init_f(void)
52{
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053053 return 0;
54}
55
56#define MAC24AA_MAC_OFFSET 0xfa
57
58#ifdef CONFIG_MISC_INIT_R
59int misc_init_r(void)
60{
61#ifdef CONFIG_I2C_EEPROM
62 at91_set_ethaddr(MAC24AA_MAC_OFFSET);
63#endif
64 return 0;
65}
66#endif
67
68int board_init(void)
69{
70 /* address of boot parameters */
71 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
Mihai Sain647089c2022-12-23 08:39:36 +020072
73 board_leds_init();
74
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053075 return 0;
76}
77
78int dram_init_banksize(void)
79{
80 return fdtdec_setup_memory_banksize();
81}
82
83int dram_init(void)
84{
85 return fdtdec_setup_mem_size_base();
86}