blob: ae18ed05e05a82a8508b073d8a547a134590785b [file] [log] [blame]
Eugen Hristev0de35aa2020-03-10 11:56:38 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Microchip Technology, Inc.
4 * Eugen Hristev <eugen.hristev@microchip.com>
5 */
6
7#include <common.h>
8#include <debug_uart.h>
9#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060010#include <asm/global_data.h>
Eugen Hristev0de35aa2020-03-10 11:56:38 +020011#include <asm/io.h>
12#include <asm/arch/at91_common.h>
13#include <asm/arch/atmel_pio4.h>
14#include <asm/arch/clk.h>
15#include <asm/arch/gpio.h>
16#include <asm/arch/sama7g5.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
Mihai Sain597de982021-12-20 10:12:39 +020020static void board_leds_init(void)
21{
22 atmel_pio4_set_pio_output(AT91_PIO_PORTB, 8, 0); /* LED RED */
23 atmel_pio4_set_pio_output(AT91_PIO_PORTA, 13, 0); /* LED GREEN */
24 atmel_pio4_set_pio_output(AT91_PIO_PORTD, 20, 1); /* LED BLUE */
25}
26
Eugen Hristev0de35aa2020-03-10 11:56:38 +020027int board_late_init(void)
28{
29 return 0;
30}
31
32#if (IS_ENABLED(CONFIG_DEBUG_UART_BOARD_INIT))
33static void board_uart0_hw_init(void)
34{
35 /* FLEXCOM3 IO0 */
36 atmel_pio4_set_f_periph(AT91_PIO_PORTD, 17, ATMEL_PIO_PUEN_MASK);
37 /* FLEXCOM3 IO1 */
38 atmel_pio4_set_f_periph(AT91_PIO_PORTD, 16, 0);
39
40 at91_periph_clk_enable(ATMEL_ID_FLEXCOM3);
41}
42
43void board_debug_uart_init(void)
44{
45 board_uart0_hw_init();
46}
47#endif
48
49int board_early_init_f(void)
50{
51#if (IS_ENABLED(CONFIG_DEBUG_UART))
52 debug_uart_init();
53#endif
54 return 0;
55}
56
Eugen Hristevb9a9f4a2020-07-31 15:20:56 +030057#define MAC24AA_MAC_OFFSET 0xfa
58
59#if (IS_ENABLED(CONFIG_MISC_INIT_R))
60int misc_init_r(void)
61{
62#if (IS_ENABLED(CONFIG_I2C_EEPROM))
63 at91_set_ethaddr(MAC24AA_MAC_OFFSET);
64 at91_set_eth1addr(MAC24AA_MAC_OFFSET);
65#endif
66 return 0;
67}
68#endif
69
Eugen Hristev0de35aa2020-03-10 11:56:38 +020070int board_init(void)
71{
72 /* address of boot parameters */
73 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
74
Mihai Sain597de982021-12-20 10:12:39 +020075 board_leds_init();
76
Eugen Hristev0de35aa2020-03-10 11:56:38 +020077 return 0;
78}
79
80int dram_init(void)
81{
82 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
83 CONFIG_SYS_SDRAM_SIZE);
84 return 0;
85}