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 <debug_uart.h> 9 #include <fdtdec.h> 10 #include <init.h> 11 #include <led.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 #include <dm/ofnode.h> 22 23 extern void at91_pda_detect(void); 24 25 DECLARE_GLOBAL_DATA_PTR; 26 27 void at91_prepare_cpu_var(void); 28 board_leds_init(void)29static void board_leds_init(void) 30 { 31 #if CONFIG_IS_ENABLED(LED) 32 const char *led_name; 33 struct udevice *dev; 34 int ret; 35 36 led_name = ofnode_conf_read_str("u-boot,boot-led"); 37 if (!led_name) 38 return; 39 40 ret = led_get_by_label(led_name, &dev); 41 if (ret) 42 return; 43 44 led_set_state(dev, LEDST_ON); 45 #else 46 at91_set_pio_output(AT91_PIO_PORTD, 17, 0); /* LED RED */ 47 at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* LED GREEN */ 48 at91_set_pio_output(AT91_PIO_PORTD, 21, 1); /* LED BLUE */ 49 #endif 50 } 51 board_late_init(void)52int board_late_init(void) 53 { 54 at91_prepare_cpu_var(); 55 56 at91_pda_detect(); 57 58 return 0; 59 } 60 61 #ifdef CONFIG_DEBUG_UART_BOARD_INIT board_debug_uart_init(void)62void board_debug_uart_init(void) 63 { 64 at91_seriald_hw_init(); 65 } 66 #endif 67 board_early_init_f(void)68int board_early_init_f(void) 69 { 70 return 0; 71 } 72 73 #define MAC24AA_MAC_OFFSET 0xfa 74 75 #ifdef CONFIG_MISC_INIT_R misc_init_r(void)76int misc_init_r(void) 77 { 78 #ifdef CONFIG_I2C_EEPROM 79 at91_set_ethaddr(MAC24AA_MAC_OFFSET); 80 #endif 81 return 0; 82 } 83 #endif 84 board_init(void)85int board_init(void) 86 { 87 /* address of boot parameters */ 88 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; 89 90 board_leds_init(); 91 92 return 0; 93 } 94 dram_init_banksize(void)95int dram_init_banksize(void) 96 { 97 return fdtdec_setup_memory_banksize(); 98 } 99 dram_init(void)100int dram_init(void) 101 { 102 return fdtdec_setup_mem_size_base(); 103 } 104