Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Pavel Machek | ce340e9 | 2014-07-14 14:14:17 +0200 | [diff] [blame] | 9 | #include <miiphy.h> |
| 10 | #include <netdev.h> |
Pavel Machek | 56a00ab | 2014-09-09 14:03:28 +0200 | [diff] [blame] | 11 | #include <asm/arch/reset_manager.h> |
Pavel Machek | 57d75eb | 2014-09-08 14:08:45 +0200 | [diff] [blame^] | 12 | #include <asm/arch/system_manager.h> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
Pavel Machek | 57d75eb | 2014-09-08 14:08:45 +0200 | [diff] [blame^] | 16 | static struct socfpga_system_manager *sysmgr_regs = |
| 17 | (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS; |
| 18 | |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 19 | int dram_init(void) |
| 20 | { |
| 21 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); |
| 22 | return 0; |
| 23 | } |
Pavel Machek | 57d75eb | 2014-09-08 14:08:45 +0200 | [diff] [blame^] | 24 | |
| 25 | /* |
| 26 | * DesignWare Ethernet initialization |
| 27 | */ |
| 28 | #ifdef CONFIG_DESIGNWARE_ETH |
| 29 | int cpu_eth_init(bd_t *bis) |
| 30 | { |
| 31 | #if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS |
| 32 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB; |
| 33 | #elif CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS |
| 34 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB; |
| 35 | #else |
| 36 | #error "Incorrect CONFIG_EMAC_BASE value!" |
| 37 | #endif |
| 38 | |
| 39 | /* Initialize EMAC. This needs to be done at least once per boot. */ |
| 40 | |
| 41 | /* |
| 42 | * Putting the EMAC controller to reset when configuring the PHY |
| 43 | * interface select at System Manager |
| 44 | */ |
| 45 | socfpga_emac_reset(1); |
| 46 | |
| 47 | /* Clearing emac0 PHY interface select to 0 */ |
| 48 | clrbits_le32(&sysmgr_regs->emacgrp_ctrl, |
| 49 | SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift); |
| 50 | |
| 51 | /* configure to PHY interface select choosed */ |
| 52 | setbits_le32(&sysmgr_regs->emacgrp_ctrl, |
| 53 | SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII << physhift); |
| 54 | |
| 55 | /* Release the EMAC controller from reset */ |
| 56 | socfpga_emac_reset(0); |
| 57 | |
| 58 | /* initialize and register the emac */ |
| 59 | return designware_initialize(CONFIG_EMAC_BASE, |
| 60 | CONFIG_PHY_INTERFACE_MODE); |
| 61 | } |
| 62 | #endif |
Chin Liang See | bff262c | 2014-06-10 02:23:45 -0500 | [diff] [blame] | 63 | |
| 64 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 65 | /* |
| 66 | * Print CPU information |
| 67 | */ |
| 68 | int print_cpuinfo(void) |
| 69 | { |
| 70 | puts("CPU : Altera SOCFPGA Platform\n"); |
| 71 | return 0; |
| 72 | } |
| 73 | #endif |
| 74 | |
| 75 | #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \ |
| 76 | defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE) |
| 77 | int overwrite_console(void) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | #endif |
| 82 | |
Pavel Machek | 56a00ab | 2014-09-09 14:03:28 +0200 | [diff] [blame] | 83 | int arch_cpu_init(void) |
| 84 | { |
| 85 | /* |
| 86 | * If the HW watchdog is NOT enabled, make sure it is not running, |
| 87 | * for example because it was enabled in the preloader. This might |
| 88 | * trigger a watchdog-triggered reboot of Linux kernel later. |
| 89 | */ |
| 90 | #ifndef CONFIG_HW_WATCHDOG |
| 91 | socfpga_watchdog_reset(); |
| 92 | #endif |
| 93 | return 0; |
| 94 | } |
| 95 | |
Chin Liang See | bff262c | 2014-06-10 02:23:45 -0500 | [diff] [blame] | 96 | int misc_init_r(void) |
| 97 | { |
| 98 | return 0; |
| 99 | } |