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 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 8 | #include <debug_uart.h> |
| 9 | #include <fdtdec.h> |
| 10 | #include <init.h> |
Alexander Dahl | 23f626d | 2023-08-23 15:58:55 +0200 | [diff] [blame] | 11 | #include <led.h> |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 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> |
Alexander Dahl | 23f626d | 2023-08-23 15:58:55 +0200 | [diff] [blame] | 21 | #include <dm/ofnode.h> |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 22 | |
Durai Manickam KR | 98676a9 | 2022-07-07 16:40:55 +0530 | [diff] [blame] | 23 | extern void at91_pda_detect(void); |
| 24 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
| 27 | void at91_prepare_cpu_var(void); |
| 28 | |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 29 | static void board_leds_init(void) |
| 30 | { |
Alexander Dahl | 23f626d | 2023-08-23 15:58:55 +0200 | [diff] [blame] | 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 |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 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 */ |
Alexander Dahl | 23f626d | 2023-08-23 15:58:55 +0200 | [diff] [blame] | 49 | #endif |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 52 | int board_late_init(void) |
| 53 | { |
| 54 | at91_prepare_cpu_var(); |
| 55 | |
Durai Manickam KR | 98676a9 | 2022-07-07 16:40:55 +0530 | [diff] [blame] | 56 | at91_pda_detect(); |
| 57 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | #ifdef CONFIG_DEBUG_UART_BOARD_INIT |
| 62 | void board_debug_uart_init(void) |
| 63 | { |
| 64 | at91_seriald_hw_init(); |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | int board_early_init_f(void) |
| 69 | { |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | #define MAC24AA_MAC_OFFSET 0xfa |
| 74 | |
| 75 | #ifdef CONFIG_MISC_INIT_R |
| 76 | int 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 | |
| 85 | int board_init(void) |
| 86 | { |
| 87 | /* address of boot parameters */ |
| 88 | gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100; |
Mihai Sain | 647089c | 2022-12-23 08:39:36 +0200 | [diff] [blame] | 89 | |
| 90 | board_leds_init(); |
| 91 | |
Durai Manickam KR | 2e7bc61 | 2022-04-04 11:23:18 +0530 | [diff] [blame] | 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | int dram_init_banksize(void) |
| 96 | { |
| 97 | return fdtdec_setup_memory_banksize(); |
| 98 | } |
| 99 | |
| 100 | int dram_init(void) |
| 101 | { |
| 102 | return fdtdec_setup_mem_size_base(); |
| 103 | } |