blob: 3fbfca4acc96d7d133790e426dce55f6ab541d4b [file] [log] [blame]
Sandeep Sheriker Mallikarjun51422662019-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
8#include <common.h>
Simon Glass9b4a2052019-12-28 10:45:05 -07009#include <init.h>
Simon Glass401d1c42020-10-30 21:38:53 -060010#include <asm/global_data.h>
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000011#include <asm/io.h>
Tudor Ambarus8ed15e42019-09-27 13:09:07 +000012#include <asm/arch/at91sam9_smc.h>
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000013#include <asm/arch/at91_common.h>
14#include <asm/arch/at91_rstc.h>
Tudor Ambarus8ed15e42019-09-27 13:09:07 +000015#include <asm/arch/at91_sfr.h>
Sandeep Sheriker Mallikarjun51422662019-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 Hristev34c53a92019-09-30 07:29:01 +000021extern void at91_pda_detect(void);
22
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000023DECLARE_GLOBAL_DATA_PTR;
24
25void at91_prepare_cpu_var(void);
26
Mihai Sain77aa6452022-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 Mallikarjun51422662019-09-27 13:08:52 +000034#ifdef CONFIG_BOARD_LATE_INIT
35int board_late_init(void)
36{
37 at91_prepare_cpu_var();
Eugen Hristev34c53a92019-09-30 07:29:01 +000038
39 at91_pda_detect();
40
Sandeep Sheriker Mallikarjun51422662019-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 Mallikarjun51422662019-09-27 13:08:52 +000055 return 0;
56}
57#endif
58
Eugen Hristev522bac82019-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 Mallikarjun51422662019-09-27 13:08:52 +000071int board_init(void)
72{
73 /* address of boot parameters */
Tom Riniaa6e94d2022-11-16 13:10:37 -050074 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000075
Mihai Sain77aa6452022-12-23 08:39:36 +020076 board_leds_init();
77
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000078 return 0;
79}
80
81int dram_init(void)
82{
Tom Riniaa6e94d2022-11-16 13:10:37 -050083 gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE,
84 CFG_SYS_SDRAM_SIZE);
Sandeep Sheriker Mallikarjun51422662019-09-27 13:08:52 +000085 return 0;
86}