Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries |
| 4 | * |
| 5 | * Author: Sandeep Sheriker M <sandeep.sheriker@microchip.com> |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | 9b4a205 | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 11 | #include <asm/io.h> |
Tudor Ambarus | 8ed15e4 | 2019-09-27 13:09:07 +0000 | [diff] [blame] | 12 | #include <asm/arch/at91sam9_smc.h> |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 13 | #include <asm/arch/at91_common.h> |
| 14 | #include <asm/arch/at91_rstc.h> |
Tudor Ambarus | 8ed15e4 | 2019-09-27 13:09:07 +0000 | [diff] [blame] | 15 | #include <asm/arch/at91_sfr.h> |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 16 | #include <asm/arch/clk.h> |
| 17 | #include <asm/arch/gpio.h> |
| 18 | #include <debug_uart.h> |
| 19 | #include <asm/mach-types.h> |
| 20 | |
Eugen Hristev | 34c53a9 | 2019-09-30 07:29:01 +0000 | [diff] [blame] | 21 | extern void at91_pda_detect(void); |
| 22 | |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
| 25 | void at91_prepare_cpu_var(void); |
| 26 | |
Mihai Sain | 77aa645 | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 27 | static void board_leds_init(void) |
| 28 | { |
| 29 | at91_set_pio_output(AT91_PIO_PORTB, 11, 0); /* LED RED */ |
| 30 | at91_set_pio_output(AT91_PIO_PORTB, 12, 0); /* LED GREEN */ |
| 31 | at91_set_pio_output(AT91_PIO_PORTB, 13, 1); /* LED BLUE */ |
| 32 | } |
| 33 | |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 34 | #ifdef CONFIG_BOARD_LATE_INIT |
| 35 | int board_late_init(void) |
| 36 | { |
| 37 | at91_prepare_cpu_var(); |
Eugen Hristev | 34c53a9 | 2019-09-30 07:29:01 +0000 | [diff] [blame] | 38 | |
| 39 | at91_pda_detect(); |
| 40 | |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 41 | return 0; |
| 42 | } |
| 43 | #endif |
| 44 | |
| 45 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 46 | void board_debug_uart_init(void) |
| 47 | { |
| 48 | at91_seriald_hw_init(); |
| 49 | } |
| 50 | #endif |
| 51 | |
| 52 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 53 | int board_early_init_f(void) |
| 54 | { |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 55 | return 0; |
| 56 | } |
| 57 | #endif |
| 58 | |
Eugen Hristev | 522bac8 | 2019-10-09 09:23:43 +0000 | [diff] [blame] | 59 | #define MAC24AA_MAC_OFFSET 0xfa |
| 60 | |
| 61 | #ifdef CONFIG_MISC_INIT_R |
| 62 | int misc_init_r(void) |
| 63 | { |
| 64 | #ifdef CONFIG_I2C_EEPROM |
| 65 | at91_set_ethaddr(MAC24AA_MAC_OFFSET); |
| 66 | #endif |
| 67 | return 0; |
| 68 | } |
| 69 | #endif |
| 70 | |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 71 | int board_init(void) |
| 72 | { |
| 73 | /* address of boot parameters */ |
Tom Rini | aa6e94d | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 74 | gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100; |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 75 | |
Mihai Sain | 77aa645 | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 76 | board_leds_init(); |
| 77 | |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | int dram_init(void) |
| 82 | { |
Tom Rini | aa6e94d | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 83 | gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE, |
| 84 | CFG_SYS_SDRAM_SIZE); |
Sandeep Sheriker Mallikarjun | 5142266 | 2019-09-27 13:08:52 +0000 | [diff] [blame] | 85 | return 0; |
| 86 | } |