Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2009 |
| 4 | * Marvell Semiconductor <www.marvell.com> |
| 5 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Stefan Roese | ebda3ec | 2015-04-25 06:29:47 +0200 | [diff] [blame] | 8 | #ifndef _MVEBU_CPU_H |
| 9 | #define _MVEBU_CPU_H |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 10 | |
| 11 | #include <asm/system.h> |
| 12 | |
| 13 | #ifndef __ASSEMBLY__ |
| 14 | |
| 15 | #define MVEBU_REG_PCIE_DEVID (MVEBU_REG_PCIE_BASE + 0x00) |
| 16 | #define MVEBU_REG_PCIE_REVID (MVEBU_REG_PCIE_BASE + 0x08) |
| 17 | |
| 18 | enum memory_bank { |
| 19 | BANK0, |
| 20 | BANK1, |
| 21 | BANK2, |
| 22 | BANK3 |
| 23 | }; |
| 24 | |
| 25 | enum cpu_winen { |
| 26 | CPU_WIN_DISABLE, |
| 27 | CPU_WIN_ENABLE |
| 28 | }; |
| 29 | |
| 30 | enum cpu_target { |
| 31 | CPU_TARGET_DRAM = 0x0, |
| 32 | CPU_TARGET_DEVICEBUS_BOOTROM_SPI = 0x1, |
| 33 | CPU_TARGET_ETH23 = 0x3, |
| 34 | CPU_TARGET_PCIE02 = 0x4, |
| 35 | CPU_TARGET_ETH01 = 0x7, |
| 36 | CPU_TARGET_PCIE13 = 0x8, |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 37 | CPU_TARGET_DFX = 0x8, |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 38 | CPU_TARGET_SASRAM = 0x9, |
Mario Six | 10d1449 | 2017-01-11 16:01:00 +0100 | [diff] [blame] | 39 | CPU_TARGET_SATA01 = 0xa, /* A38X */ |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 40 | CPU_TARGET_NAND = 0xd, |
Mario Six | 10d1449 | 2017-01-11 16:01:00 +0100 | [diff] [blame] | 41 | CPU_TARGET_SATA23_DFX = 0xe, /* A38X */ |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | enum cpu_attrib { |
| 45 | CPU_ATTR_SASRAM = 0x01, |
| 46 | CPU_ATTR_DRAM_CS0 = 0x0e, |
| 47 | CPU_ATTR_DRAM_CS1 = 0x0d, |
| 48 | CPU_ATTR_DRAM_CS2 = 0x0b, |
| 49 | CPU_ATTR_DRAM_CS3 = 0x07, |
| 50 | CPU_ATTR_NANDFLASH = 0x2f, |
| 51 | CPU_ATTR_SPIFLASH = 0x1e, |
Stefan Roese | bca3d86 | 2016-02-12 13:52:16 +0100 | [diff] [blame] | 52 | CPU_ATTR_SPI0_CS0 = 0x1e, |
| 53 | CPU_ATTR_SPI0_CS1 = 0x5e, |
| 54 | CPU_ATTR_SPI1_CS2 = 0x9a, |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 55 | CPU_ATTR_BOOTROM = 0x1d, |
| 56 | CPU_ATTR_PCIE_IO = 0xe0, |
| 57 | CPU_ATTR_PCIE_MEM = 0xe8, |
| 58 | CPU_ATTR_DEV_CS0 = 0x3e, |
| 59 | CPU_ATTR_DEV_CS1 = 0x3d, |
| 60 | CPU_ATTR_DEV_CS2 = 0x3b, |
| 61 | CPU_ATTR_DEV_CS3 = 0x37, |
| 62 | }; |
| 63 | |
Stefan Roese | 10fa44b | 2018-10-22 14:21:17 +0200 | [diff] [blame] | 64 | #define MVEBU_SDRAM_SIZE_MAX 0xc0000000 |
| 65 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 66 | /* |
| 67 | * Default Device Address MAP BAR values |
| 68 | */ |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 69 | #ifdef CONFIG_SPL_BUILD |
| 70 | #ifdef CONFIG_ARMADA_38X |
| 71 | #define MBUS_PCI_MEM_BASE 0x88000000 |
| 72 | #define MBUS_PCI_MEM_SIZE ((3 * 128) << 20) |
| 73 | #else |
| 74 | #define MBUS_PCI_MEM_BASE 0x80000000 |
| 75 | #define MBUS_PCI_MEM_SIZE ((4 * 128) << 20) |
| 76 | #endif |
| 77 | #else |
Pali Rohár | ca69af4 | 2021-12-21 12:20:13 +0100 | [diff] [blame] | 78 | #define MBUS_PCI_MAX_PORTS 6 |
Stefan Roese | 10fa44b | 2018-10-22 14:21:17 +0200 | [diff] [blame] | 79 | #define MBUS_PCI_MEM_BASE MVEBU_SDRAM_SIZE_MAX |
Pali Rohár | ca69af4 | 2021-12-21 12:20:13 +0100 | [diff] [blame] | 80 | #define MBUS_PCI_MEM_SIZE ((MBUS_PCI_MAX_PORTS * 128) << 20) |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 81 | #define MBUS_PCI_IO_BASE 0xF1100000 |
Pali Rohár | ca69af4 | 2021-12-21 12:20:13 +0100 | [diff] [blame] | 82 | #define MBUS_PCI_IO_SIZE ((MBUS_PCI_MAX_PORTS * 64) << 10) |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 83 | #endif |
Pali Rohár | 465ecee | 2023-02-03 21:41:45 +0100 | [diff] [blame] | 84 | #ifdef CONFIG_SPL_BUILD |
| 85 | #define MBUS_SPI_BASE 0xD4000000 |
| 86 | #define MBUS_SPI_SIZE (64 << 20) |
| 87 | #else |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 88 | #define MBUS_SPI_BASE 0xF4000000 |
| 89 | #define MBUS_SPI_SIZE (8 << 20) |
Pali Rohár | 465ecee | 2023-02-03 21:41:45 +0100 | [diff] [blame] | 90 | #endif |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 91 | #ifndef CONFIG_SPL_BUILD |
Chris Packham | a8f845e | 2019-04-11 22:22:50 +1200 | [diff] [blame] | 92 | #define MBUS_DFX_BASE 0xF6000000 |
| 93 | #define MBUS_DFX_SIZE (1 << 20) |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 94 | #endif |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 95 | #define MBUS_BOOTROM_BASE 0xF8000000 |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 96 | #ifdef CONFIG_SPL_BUILD |
| 97 | #define MBUS_BOOTROM_SIZE (128 << 20) |
| 98 | #else |
Stefan Roese | 13b109f | 2015-07-01 12:55:07 +0200 | [diff] [blame] | 99 | #define MBUS_BOOTROM_SIZE (8 << 20) |
Pali Rohár | 2d26ac1 | 2023-02-03 22:26:37 +0100 | [diff] [blame^] | 100 | #endif |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 101 | |
| 102 | struct mbus_win { |
| 103 | u32 base; |
| 104 | u32 size; |
| 105 | u8 target; |
| 106 | u8 attr; |
| 107 | }; |
| 108 | |
| 109 | /* |
| 110 | * System registers |
| 111 | * Ref: Datasheet sec:A.28 |
| 112 | */ |
| 113 | struct mvebu_system_registers { |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 114 | #if defined(CONFIG_ARMADA_375) |
| 115 | u8 pad1[0x54]; |
| 116 | #else |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 117 | u8 pad1[0x60]; |
Stefan Roese | 479f9af | 2016-02-10 07:23:00 +0100 | [diff] [blame] | 118 | #endif |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 119 | u32 rstoutn_mask; /* 0x60 */ |
| 120 | u32 sys_soft_rst; /* 0x64 */ |
| 121 | }; |
| 122 | |
| 123 | /* |
| 124 | * GPIO Registers |
| 125 | * Ref: Datasheet sec:A.19 |
| 126 | */ |
| 127 | struct kwgpio_registers { |
| 128 | u32 dout; |
| 129 | u32 oe; |
| 130 | u32 blink_en; |
| 131 | u32 din_pol; |
| 132 | u32 din; |
| 133 | u32 irq_cause; |
| 134 | u32 irq_mask; |
| 135 | u32 irq_level; |
| 136 | }; |
| 137 | |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 138 | struct sar_freq_modes { |
| 139 | u8 val; |
| 140 | u8 ffc; /* Fabric Frequency Configuration */ |
| 141 | u32 p_clk; |
| 142 | u32 nb_clk; |
| 143 | u32 d_clk; |
| 144 | }; |
| 145 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 146 | /* |
| 147 | * functions |
| 148 | */ |
| 149 | unsigned int mvebu_sdram_bar(enum memory_bank bank); |
| 150 | unsigned int mvebu_sdram_bs(enum memory_bank bank); |
| 151 | void mvebu_sdram_size_adjust(enum memory_bank bank); |
Pali Rohár | 32301ee | 2022-09-09 14:41:28 +0200 | [diff] [blame] | 152 | int mvebu_mbus_probe(const struct mbus_win windows[], int count); |
Stefan Roese | badccc3 | 2015-07-16 10:40:05 +0200 | [diff] [blame] | 153 | u32 mvebu_get_nand_clock(void); |
Stefan Roese | e463bf3 | 2015-01-19 11:33:42 +0100 | [diff] [blame] | 154 | |
Pali Rohár | a59971b | 2021-07-23 11:14:24 +0200 | [diff] [blame] | 155 | void __noreturn return_to_bootrom(void); |
Stefan Roese | 99b3ea7 | 2015-08-25 13:49:41 +0200 | [diff] [blame] | 156 | |
Pierre Bourdon | b9af62d | 2019-04-11 04:56:58 +0200 | [diff] [blame] | 157 | #ifndef CONFIG_DM_MMC |
Stefan Roese | d3e3473 | 2015-06-29 14:58:10 +0200 | [diff] [blame] | 158 | int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks); |
Pierre Bourdon | b9af62d | 2019-04-11 04:56:58 +0200 | [diff] [blame] | 159 | #endif |
Stefan Roese | d3e3473 | 2015-06-29 14:58:10 +0200 | [diff] [blame] | 160 | |
Marek Behún | ee76b4a | 2021-08-16 15:19:37 +0200 | [diff] [blame] | 161 | u32 get_boot_device(void); |
| 162 | |
Stefan Roese | 2a539c8 | 2015-12-21 12:36:40 +0100 | [diff] [blame] | 163 | void get_sar_freq(struct sar_freq_modes *sar_freq); |
| 164 | |
Stefan Roese | e463bf3 | 2015-01-19 11:33:42 +0100 | [diff] [blame] | 165 | /* |
| 166 | * Highspeed SERDES PHY config init, ported from bin_hdr |
| 167 | * to mainline U-Boot |
| 168 | */ |
| 169 | int serdes_phy_config(void); |
| 170 | |
| 171 | /* |
| 172 | * DDR3 init / training code ported from Marvell bin_hdr. Now |
| 173 | * available in mainline U-Boot in: |
Stefan Roese | eb753e9 | 2015-03-25 12:51:18 +0100 | [diff] [blame] | 174 | * drivers/ddr/marvell |
Stefan Roese | e463bf3 | 2015-01-19 11:33:42 +0100 | [diff] [blame] | 175 | */ |
| 176 | int ddr3_init(void); |
Stefan Roese | ab91fd5 | 2016-01-20 08:13:28 +0100 | [diff] [blame] | 177 | |
Baruch Siach | 056e107 | 2019-07-10 18:23:04 +0300 | [diff] [blame] | 178 | /* Auto Voltage Scaling */ |
Pali Rohár | 9a365e3 | 2021-03-05 15:52:42 +0100 | [diff] [blame] | 179 | #if defined(CONFIG_ARMADA_38X) |
Baruch Siach | 056e107 | 2019-07-10 18:23:04 +0300 | [diff] [blame] | 180 | void mv_avs_init(void); |
Chris Packham | 3667bec | 2020-02-26 19:53:50 +1300 | [diff] [blame] | 181 | void mv_rtc_config(void); |
Baruch Siach | 056e107 | 2019-07-10 18:23:04 +0300 | [diff] [blame] | 182 | #else |
| 183 | static inline void mv_avs_init(void) {} |
Chris Packham | 3667bec | 2020-02-26 19:53:50 +1300 | [diff] [blame] | 184 | static inline void mv_rtc_config(void) {} |
Baruch Siach | 056e107 | 2019-07-10 18:23:04 +0300 | [diff] [blame] | 185 | #endif |
| 186 | |
Marek Behún | e577cc3 | 2020-04-08 19:25:18 +0200 | [diff] [blame] | 187 | /* A8K dram functions */ |
| 188 | u64 a8k_dram_scan_ap_sz(void); |
| 189 | int a8k_dram_init_banksize(void); |
| 190 | |
Marek Behún | f9d5e73 | 2020-04-08 19:25:19 +0200 | [diff] [blame] | 191 | /* A3700 dram functions */ |
| 192 | int a3700_dram_init(void); |
| 193 | int a3700_dram_init_banksize(void); |
| 194 | |
Marek Behún | 41d2c40 | 2020-04-08 19:25:21 +0200 | [diff] [blame] | 195 | /* A3700 PCIe regions fixer for device tree */ |
| 196 | int a3700_fdt_fix_pcie_regions(void *blob); |
| 197 | |
Chris Packham | eaab461 | 2022-11-05 17:23:59 +1300 | [diff] [blame] | 198 | /* Alleycat5 dram functions */ |
| 199 | int alleycat5_dram_init(void); |
| 200 | int alleycat5_dram_init_banksize(void); |
| 201 | |
Stefan Roese | 05b1765 | 2016-05-17 15:00:30 +0200 | [diff] [blame] | 202 | /* |
| 203 | * get_ref_clk |
| 204 | * |
| 205 | * return: reference clock in MHz (25 or 40) |
| 206 | */ |
| 207 | u32 get_ref_clk(void); |
| 208 | |
Stefan Roese | 93e6bf4 | 2014-10-22 12:13:17 +0200 | [diff] [blame] | 209 | #endif /* __ASSEMBLY__ */ |
Stefan Roese | ebda3ec | 2015-04-25 06:29:47 +0200 | [diff] [blame] | 210 | #endif /* _MVEBU_CPU_H */ |