blob: e75043ec00f9028bf81e32244d6d38fb3eb03618 [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
Durai Manickam KR2e7bc612022-04-04 11:23:18 +05308#include <debug_uart.h>
9#include <fdtdec.h>
10#include <init.h>
Alexander Dahl23f626d2023-08-23 15:58:55 +020011#include <led.h>
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053012#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>
Alexander Dahl23f626d2023-08-23 15:58:55 +020021#include <dm/ofnode.h>
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053022
Durai Manickam KR98676a92022-07-07 16:40:55 +053023extern void at91_pda_detect(void);
24
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053025DECLARE_GLOBAL_DATA_PTR;
26
27void at91_prepare_cpu_var(void);
28
Mihai Sain647089c2022-12-23 08:39:36 +020029static void board_leds_init(void)
30{
Alexander Dahl23f626d2023-08-23 15:58:55 +020031#if CONFIG_IS_ENABLED(LED)
32 const char *led_name;
33 struct udevice *dev;
34 int ret;
35
36 led_name = ofnode_conf_read_str("u-boot,boot-led");
37 if (!led_name)
38 return;
39
40 ret = led_get_by_label(led_name, &dev);
41 if (ret)
42 return;
43
44 led_set_state(dev, LEDST_ON);
45#else
Mihai Sain647089c2022-12-23 08:39:36 +020046 at91_set_pio_output(AT91_PIO_PORTD, 17, 0); /* LED RED */
47 at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* LED GREEN */
48 at91_set_pio_output(AT91_PIO_PORTD, 21, 1); /* LED BLUE */
Alexander Dahl23f626d2023-08-23 15:58:55 +020049#endif
Mihai Sain647089c2022-12-23 08:39:36 +020050}
51
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053052int board_late_init(void)
53{
54 at91_prepare_cpu_var();
55
Durai Manickam KR98676a92022-07-07 16:40:55 +053056 at91_pda_detect();
57
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053058 return 0;
59}
60
61#ifdef CONFIG_DEBUG_UART_BOARD_INIT
62void board_debug_uart_init(void)
63{
64 at91_seriald_hw_init();
65}
66#endif
67
68int board_early_init_f(void)
69{
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053070 return 0;
71}
72
73#define MAC24AA_MAC_OFFSET 0xfa
74
75#ifdef CONFIG_MISC_INIT_R
76int misc_init_r(void)
77{
78#ifdef CONFIG_I2C_EEPROM
79 at91_set_ethaddr(MAC24AA_MAC_OFFSET);
80#endif
81 return 0;
82}
83#endif
84
85int board_init(void)
86{
87 /* address of boot parameters */
88 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
Mihai Sain647089c2022-12-23 08:39:36 +020089
90 board_leds_init();
91
Durai Manickam KR2e7bc612022-04-04 11:23:18 +053092 return 0;
93}
94
95int dram_init_banksize(void)
96{
97 return fdtdec_setup_memory_banksize();
98}
99
100int dram_init(void)
101{
102 return fdtdec_setup_mem_size_base();
103}