Commit 4e736869c6e0df7a955fd000681d6ceea636928c
Committed by
Marek Vasut
1 parent
45d6e67710
Exists in
v2017.01-smarct4x
and in
37 other branches
arm: socfpga: misc: Add SD controller init
Add CPU function to register and initialize the dw_mmc SD controller. This allows us to use the HPS SDMMC block. Signed-off-by: Pavel Machek <pavel@denx.de> Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <clsee@altera.com> Cc: Dinh Nguyen <dinguyen@altera.com> Cc: Albert Aribaud <albert.u.boot@aribaud.net> Cc: Tom Rini <trini@ti.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Pavel Machek <pavel@denx.de>
Showing 1 changed file with 13 additions and 0 deletions Inline Diff
arch/arm/cpu/armv7/socfpga/misc.c
1 | /* | 1 | /* |
2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> | 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: GPL-2.0+ | 4 | * SPDX-License-Identifier: GPL-2.0+ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <common.h> | 7 | #include <common.h> |
8 | #include <asm/io.h> | 8 | #include <asm/io.h> |
9 | #include <miiphy.h> | 9 | #include <miiphy.h> |
10 | #include <netdev.h> | 10 | #include <netdev.h> |
11 | #include <asm/arch/reset_manager.h> | 11 | #include <asm/arch/reset_manager.h> |
12 | #include <asm/arch/system_manager.h> | 12 | #include <asm/arch/system_manager.h> |
13 | #include <asm/arch/dwmmc.h> | ||
13 | 14 | ||
14 | DECLARE_GLOBAL_DATA_PTR; | 15 | DECLARE_GLOBAL_DATA_PTR; |
15 | 16 | ||
16 | static struct socfpga_system_manager *sysmgr_regs = | 17 | static struct socfpga_system_manager *sysmgr_regs = |
17 | (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS; | 18 | (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS; |
18 | 19 | ||
19 | int dram_init(void) | 20 | int dram_init(void) |
20 | { | 21 | { |
21 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); | 22 | gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); |
22 | return 0; | 23 | return 0; |
23 | } | 24 | } |
24 | 25 | ||
25 | /* | 26 | /* |
26 | * DesignWare Ethernet initialization | 27 | * DesignWare Ethernet initialization |
27 | */ | 28 | */ |
28 | #ifdef CONFIG_DESIGNWARE_ETH | 29 | #ifdef CONFIG_DESIGNWARE_ETH |
29 | int cpu_eth_init(bd_t *bis) | 30 | int cpu_eth_init(bd_t *bis) |
30 | { | 31 | { |
31 | #if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS | 32 | #if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS |
32 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB; | 33 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB; |
33 | #elif CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS | 34 | #elif CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS |
34 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB; | 35 | const int physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB; |
35 | #else | 36 | #else |
36 | #error "Incorrect CONFIG_EMAC_BASE value!" | 37 | #error "Incorrect CONFIG_EMAC_BASE value!" |
37 | #endif | 38 | #endif |
38 | 39 | ||
39 | /* Initialize EMAC. This needs to be done at least once per boot. */ | 40 | /* Initialize EMAC. This needs to be done at least once per boot. */ |
40 | 41 | ||
41 | /* | 42 | /* |
42 | * Putting the EMAC controller to reset when configuring the PHY | 43 | * Putting the EMAC controller to reset when configuring the PHY |
43 | * interface select at System Manager | 44 | * interface select at System Manager |
44 | */ | 45 | */ |
45 | socfpga_emac_reset(1); | 46 | socfpga_emac_reset(1); |
46 | 47 | ||
47 | /* Clearing emac0 PHY interface select to 0 */ | 48 | /* Clearing emac0 PHY interface select to 0 */ |
48 | clrbits_le32(&sysmgr_regs->emacgrp_ctrl, | 49 | clrbits_le32(&sysmgr_regs->emacgrp_ctrl, |
49 | SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift); | 50 | SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift); |
50 | 51 | ||
51 | /* configure to PHY interface select choosed */ | 52 | /* configure to PHY interface select choosed */ |
52 | setbits_le32(&sysmgr_regs->emacgrp_ctrl, | 53 | setbits_le32(&sysmgr_regs->emacgrp_ctrl, |
53 | SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII << physhift); | 54 | SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII << physhift); |
54 | 55 | ||
55 | /* Release the EMAC controller from reset */ | 56 | /* Release the EMAC controller from reset */ |
56 | socfpga_emac_reset(0); | 57 | socfpga_emac_reset(0); |
57 | 58 | ||
58 | /* initialize and register the emac */ | 59 | /* initialize and register the emac */ |
59 | return designware_initialize(CONFIG_EMAC_BASE, | 60 | return designware_initialize(CONFIG_EMAC_BASE, |
60 | CONFIG_PHY_INTERFACE_MODE); | 61 | CONFIG_PHY_INTERFACE_MODE); |
62 | } | ||
63 | #endif | ||
64 | |||
65 | #ifdef CONFIG_DWMMC | ||
66 | /* | ||
67 | * Initializes MMC controllers. | ||
68 | * to override, implement board_mmc_init() | ||
69 | */ | ||
70 | int cpu_mmc_init(bd_t *bis) | ||
71 | { | ||
72 | return socfpga_dwmmc_init(SOCFPGA_SDMMC_ADDRESS, | ||
73 | CONFIG_HPS_SDMMC_BUSWIDTH, 0); | ||
61 | } | 74 | } |
62 | #endif | 75 | #endif |
63 | 76 | ||
64 | #if defined(CONFIG_DISPLAY_CPUINFO) | 77 | #if defined(CONFIG_DISPLAY_CPUINFO) |
65 | /* | 78 | /* |
66 | * Print CPU information | 79 | * Print CPU information |
67 | */ | 80 | */ |
68 | int print_cpuinfo(void) | 81 | int print_cpuinfo(void) |
69 | { | 82 | { |
70 | puts("CPU : Altera SOCFPGA Platform\n"); | 83 | puts("CPU : Altera SOCFPGA Platform\n"); |
71 | return 0; | 84 | return 0; |
72 | } | 85 | } |
73 | #endif | 86 | #endif |
74 | 87 | ||
75 | #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \ | 88 | #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \ |
76 | defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE) | 89 | defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE) |
77 | int overwrite_console(void) | 90 | int overwrite_console(void) |
78 | { | 91 | { |
79 | return 0; | 92 | return 0; |
80 | } | 93 | } |
81 | #endif | 94 | #endif |
82 | 95 | ||
83 | int arch_cpu_init(void) | 96 | int arch_cpu_init(void) |
84 | { | 97 | { |
85 | /* | 98 | /* |
86 | * If the HW watchdog is NOT enabled, make sure it is not running, | 99 | * 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 | 100 | * for example because it was enabled in the preloader. This might |
88 | * trigger a watchdog-triggered reboot of Linux kernel later. | 101 | * trigger a watchdog-triggered reboot of Linux kernel later. |
89 | */ | 102 | */ |
90 | #ifndef CONFIG_HW_WATCHDOG | 103 | #ifndef CONFIG_HW_WATCHDOG |
91 | socfpga_watchdog_reset(); | 104 | socfpga_watchdog_reset(); |
92 | #endif | 105 | #endif |
93 | return 0; | 106 | return 0; |
94 | } | 107 | } |
95 | 108 | ||
96 | int misc_init_r(void) | 109 | int misc_init_r(void) |
97 | { | 110 | { |
98 | return 0; | 111 | return 0; |
99 | } | 112 | } |
100 | 113 |