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 | |
| 7 | #include <common.h> |
| 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 | { |
| 51 | #if (IS_ENABLED(CONFIG_DEBUG_UART)) |
| 52 | debug_uart_init(); |
| 53 | #endif |
| 54 | return 0; |
| 55 | } |
| 56 | |
Eugen Hristev | b9a9f4a | 2020-07-31 15:20:56 +0300 | [diff] [blame] | 57 | #define MAC24AA_MAC_OFFSET 0xfa |
| 58 | |
| 59 | #if (IS_ENABLED(CONFIG_MISC_INIT_R)) |
| 60 | int 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 Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 70 | int board_init(void) |
| 71 | { |
| 72 | /* address of boot parameters */ |
| 73 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
| 74 | |
Mihai Sain | 597de98 | 2021-12-20 10:12:39 +0200 | [diff] [blame] | 75 | board_leds_init(); |
| 76 | |
Eugen Hristev | 0de35aa | 2020-03-10 11:56:38 +0200 | [diff] [blame] | 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | int 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 | } |