blob: 2e5073f02b3e0d17e73f8ba27f491c00e135cd5e [file] [log] [blame]
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries
4 *
5 * Author: Sandeep Sheriker M <sandeep.sheriker@microchip.com>
6 */
7
Tom Rinidec7ea02024-05-20 13:35:03 -06008#include <config.h>
Simon Glass8e16b1e2019-12-28 10:45:05 -07009#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000011#include <asm/io.h>
Tudor Ambaruse76c66a2019-09-27 13:09:07 +000012#include <asm/arch/at91sam9_smc.h>
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000013#include <asm/arch/at91_common.h>
14#include <asm/arch/at91_rstc.h>
Tudor Ambaruse76c66a2019-09-27 13:09:07 +000015#include <asm/arch/at91_sfr.h>
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000016#include <asm/arch/clk.h>
17#include <asm/arch/gpio.h>
18#include <debug_uart.h>
19#include <asm/mach-types.h>
20
Eugen Hristevf9990dc2019-09-30 07:29:01 +000021extern void at91_pda_detect(void);
22
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000023DECLARE_GLOBAL_DATA_PTR;
24
25void at91_prepare_cpu_var(void);
26
Mihai Sain647089c2022-12-23 08:39:36 +020027static void board_leds_init(void)
28{
29 at91_set_pio_output(AT91_PIO_PORTB, 11, 0); /* LED RED */
30 at91_set_pio_output(AT91_PIO_PORTB, 12, 0); /* LED GREEN */
31 at91_set_pio_output(AT91_PIO_PORTB, 13, 1); /* LED BLUE */
32}
33
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000034#ifdef CONFIG_BOARD_LATE_INIT
35int board_late_init(void)
36{
37 at91_prepare_cpu_var();
Eugen Hristevf9990dc2019-09-30 07:29:01 +000038
39 at91_pda_detect();
40
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000041 return 0;
42}
43#endif
44
45#ifdef CONFIG_DEBUG_UART_BOARD_INIT
46void board_debug_uart_init(void)
47{
48 at91_seriald_hw_init();
49}
50#endif
51
52#ifdef CONFIG_BOARD_EARLY_INIT_F
53int board_early_init_f(void)
54{
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000055 return 0;
56}
57#endif
58
Eugen Hristeva4f51ce2019-10-09 09:23:43 +000059#define MAC24AA_MAC_OFFSET 0xfa
60
61#ifdef CONFIG_MISC_INIT_R
62int misc_init_r(void)
63{
64#ifdef CONFIG_I2C_EEPROM
65 at91_set_ethaddr(MAC24AA_MAC_OFFSET);
66#endif
67 return 0;
68}
69#endif
70
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000071int board_init(void)
72{
73 /* address of boot parameters */
Tom Rinibb4dd962022-11-16 13:10:37 -050074 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000075
Mihai Sain647089c2022-12-23 08:39:36 +020076 board_leds_init();
77
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000078 return 0;
79}
80
81int dram_init(void)
82{
Tom Rinibb4dd962022-11-16 13:10:37 -050083 gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE,
84 CFG_SYS_SDRAM_SIZE);
Sandeep Sheriker Mallikarjun641b3352019-09-27 13:08:52 +000085 return 0;
86}