Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2020 Microchip Technology, Inc. |
| 4 | * Eugen Hristev <eugen.hristev@microchip.com> |
| 5 | */ |
| 6 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 7 | #include <config.h> |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 8 | #include <debug_uart.h> |
| 9 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 11 | #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 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
Mihai Sain | 597de98 | 2021-12-20 10:12:39 +0200 | [diff] [blame] | 20 | static 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 Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 27 | int board_late_init(void) |
| 28 | { |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | #if (IS_ENABLED(CONFIG_DEBUG_UART_BOARD_INIT)) |
| 33 | static 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 | |
| 43 | void board_debug_uart_init(void) |
| 44 | { |
| 45 | board_uart0_hw_init(); |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | int board_early_init_f(void) |
| 50 | { |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Eugen Hristev | b9a9f4a | 2020-07-31 15:20:56 +0300 | [diff] [blame] | 54 | #define MAC24AA_MAC_OFFSET 0xfa |
| 55 | |
| 56 | #if (IS_ENABLED(CONFIG_MISC_INIT_R)) |
| 57 | int 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 Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 67 | int board_init(void) |
| 68 | { |
| 69 | /* address of boot parameters */ |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 70 | gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100; |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 71 | |
Mihai Sain | 597de98 | 2021-12-20 10:12:39 +0200 | [diff] [blame] | 72 | board_leds_init(); |
| 73 | |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int dram_init(void) |
| 78 | { |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 79 | gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, |
| 80 | CFG_SYS_SDRAM_SIZE); |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 81 | return 0; |
| 82 | } |