blob: c07115a2119527e9335b3eb05689b3ad2eb05ac8 [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
Tom Rini5f201cd2024-04-30 20:41:08 -06007#include <config.h>
Eugen Hristev0de35aa2020-03-10 11:56:38 +02008#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{
Eugen Hristev0de35aa2020-03-10 11:56:38 +020051 return 0;
52}
53
Eugen Hristevb9a9f4a2020-07-31 15:20:56 +030054#define MAC24AA_MAC_OFFSET 0xfa
55
56#if (IS_ENABLED(CONFIG_MISC_INIT_R))
57int misc_init_r(void)
58{
59#if (IS_ENABLED(CONFIG_I2C_EEPROM))
60 at91_set_ethaddr(MAC24AA_MAC_OFFSET);
61 at91_set_eth1addr(MAC24AA_MAC_OFFSET);
62#endif
63 return 0;
64}
65#endif
66
Eugen Hristev0de35aa2020-03-10 11:56:38 +020067int board_init(void)
68{
69 /* address of boot parameters */
Tom Rinibb4dd962022-11-16 13:10:37 -050070 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
Eugen Hristev0de35aa2020-03-10 11:56:38 +020071
Mihai Sain597de982021-12-20 10:12:39 +020072 board_leds_init();
73
Eugen Hristev0de35aa2020-03-10 11:56:38 +020074 return 0;
75}
76
77int dram_init(void)
78{
Tom Rinibb4dd962022-11-16 13:10:37 -050079 gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE,
80 CFG_SYS_SDRAM_SIZE);
Eugen Hristev0de35aa2020-03-10 11:56:38 +020081 return 0;
82}