Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 1 | // 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 | |
| 8 | #include <common.h> |
| 9 | #include <debug_uart.h> |
| 10 | #include <fdtdec.h> |
| 11 | #include <init.h> |
| 12 | #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> |
| 21 | |
Durai Manickam KR | 98676a9 | 2022-07-07 16:40:55 +0530 | [diff] [blame] | 22 | extern void at91_pda_detect(void); |
| 23 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 24 | DECLARE_GLOBAL_DATA_PTR; |
| 25 | |
| 26 | void at91_prepare_cpu_var(void); |
| 27 | |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 28 | static void board_leds_init(void) |
| 29 | { |
| 30 | at91_set_pio_output(AT91_PIO_PORTD, 17, 0); /* LED RED */ |
| 31 | at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* LED GREEN */ |
| 32 | at91_set_pio_output(AT91_PIO_PORTD, 21, 1); /* LED BLUE */ |
| 33 | } |
| 34 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 35 | int board_late_init(void) |
| 36 | { |
| 37 | at91_prepare_cpu_var(); |
| 38 | |
Durai Manickam KR | 98676a9 | 2022-07-07 16:40:55 +0530 | [diff] [blame] | 39 | at91_pda_detect(); |
| 40 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 45 | void board_debug_uart_init(void) |
| 46 | { |
| 47 | at91_seriald_hw_init(); |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | int board_early_init_f(void) |
| 52 | { |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | #define MAC24AA_MAC_OFFSET 0xfa |
| 57 | |
| 58 | #ifdef CONFIG_MISC_INIT_R |
| 59 | int misc_init_r(void) |
| 60 | { |
| 61 | #ifdef CONFIG_I2C_EEPROM |
| 62 | at91_set_ethaddr(MAC24AA_MAC_OFFSET); |
| 63 | #endif |
| 64 | return 0; |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | int board_init(void) |
| 69 | { |
| 70 | /* address of boot parameters */ |
| 71 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 72 | |
| 73 | board_leds_init(); |
| 74 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int dram_init_banksize(void) |
| 79 | { |
| 80 | return fdtdec_setup_memory_banksize(); |
| 81 | } |
| 82 | |
| 83 | int dram_init(void) |
| 84 | { |
| 85 | return fdtdec_setup_mem_size_base(); |
| 86 | } |