blob: b99d86a87a030367abf0d1ffe95dfa3f25e90399 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Stefan Roese93e6bf42014-10-22 12:13:17 +02002/*
3 * (C) Copyright 2009
4 * Marvell Semiconductor <www.marvell.com>
5 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
Stefan Roese93e6bf42014-10-22 12:13:17 +02006 */
7
Stefan Roeseebda3ec2015-04-25 06:29:47 +02008#ifndef _MVEBU_CPU_H
9#define _MVEBU_CPU_H
Stefan Roese93e6bf42014-10-22 12:13:17 +020010
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
18enum memory_bank {
19 BANK0,
20 BANK1,
21 BANK2,
22 BANK3
23};
24
25enum cpu_winen {
26 CPU_WIN_DISABLE,
27 CPU_WIN_ENABLE
28};
29
30enum 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 Packhama8f845e2019-04-11 22:22:50 +120037 CPU_TARGET_DFX = 0x8,
Stefan Roese93e6bf42014-10-22 12:13:17 +020038 CPU_TARGET_SASRAM = 0x9,
Mario Six10d14492017-01-11 16:01:00 +010039 CPU_TARGET_SATA01 = 0xa, /* A38X */
Stefan Roese93e6bf42014-10-22 12:13:17 +020040 CPU_TARGET_NAND = 0xd,
Mario Six10d14492017-01-11 16:01:00 +010041 CPU_TARGET_SATA23_DFX = 0xe, /* A38X */
Stefan Roese93e6bf42014-10-22 12:13:17 +020042};
43
44enum 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 Roesebca3d862016-02-12 13:52:16 +010052 CPU_ATTR_SPI0_CS0 = 0x1e,
53 CPU_ATTR_SPI0_CS1 = 0x5e,
54 CPU_ATTR_SPI1_CS2 = 0x9a,
Stefan Roese93e6bf42014-10-22 12:13:17 +020055 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 Roese174d23e2015-04-25 06:29:51 +020064enum {
65 MVEBU_SOC_AXP,
Stefan Roese479f9af2016-02-10 07:23:00 +010066 MVEBU_SOC_A375,
Stefan Roese174d23e2015-04-25 06:29:51 +020067 MVEBU_SOC_A38X,
Chris Packham348109d2017-09-04 17:38:31 +120068 MVEBU_SOC_MSYS,
Stefan Roese174d23e2015-04-25 06:29:51 +020069 MVEBU_SOC_UNKNOWN,
70};
71
Stefan Roese10fa44b2018-10-22 14:21:17 +020072#define MVEBU_SDRAM_SIZE_MAX 0xc0000000
73
Stefan Roese93e6bf42014-10-22 12:13:17 +020074/*
75 * Default Device Address MAP BAR values
76 */
Pali Rohárca69af42021-12-21 12:20:13 +010077#define MBUS_PCI_MAX_PORTS 6
Stefan Roese10fa44b2018-10-22 14:21:17 +020078#define MBUS_PCI_MEM_BASE MVEBU_SDRAM_SIZE_MAX
Pali Rohárca69af42021-12-21 12:20:13 +010079#define MBUS_PCI_MEM_SIZE ((MBUS_PCI_MAX_PORTS * 128) << 20)
Stefan Roese13b109f2015-07-01 12:55:07 +020080#define MBUS_PCI_IO_BASE 0xF1100000
Pali Rohárca69af42021-12-21 12:20:13 +010081#define MBUS_PCI_IO_SIZE ((MBUS_PCI_MAX_PORTS * 64) << 10)
Stefan Roese13b109f2015-07-01 12:55:07 +020082#define MBUS_SPI_BASE 0xF4000000
83#define MBUS_SPI_SIZE (8 << 20)
Chris Packhama8f845e2019-04-11 22:22:50 +120084#define MBUS_DFX_BASE 0xF6000000
85#define MBUS_DFX_SIZE (1 << 20)
Stefan Roese13b109f2015-07-01 12:55:07 +020086#define MBUS_BOOTROM_BASE 0xF8000000
87#define MBUS_BOOTROM_SIZE (8 << 20)
Stefan Roese93e6bf42014-10-22 12:13:17 +020088
89struct mbus_win {
90 u32 base;
91 u32 size;
92 u8 target;
93 u8 attr;
94};
95
96/*
97 * System registers
98 * Ref: Datasheet sec:A.28
99 */
100struct mvebu_system_registers {
Stefan Roese479f9af2016-02-10 07:23:00 +0100101#if defined(CONFIG_ARMADA_375)
102 u8 pad1[0x54];
103#else
Stefan Roese93e6bf42014-10-22 12:13:17 +0200104 u8 pad1[0x60];
Stefan Roese479f9af2016-02-10 07:23:00 +0100105#endif
Stefan Roese93e6bf42014-10-22 12:13:17 +0200106 u32 rstoutn_mask; /* 0x60 */
107 u32 sys_soft_rst; /* 0x64 */
108};
109
110/*
111 * GPIO Registers
112 * Ref: Datasheet sec:A.19
113 */
114struct kwgpio_registers {
115 u32 dout;
116 u32 oe;
117 u32 blink_en;
118 u32 din_pol;
119 u32 din;
120 u32 irq_cause;
121 u32 irq_mask;
122 u32 irq_level;
123};
124
Stefan Roese2a539c82015-12-21 12:36:40 +0100125struct sar_freq_modes {
126 u8 val;
127 u8 ffc; /* Fabric Frequency Configuration */
128 u32 p_clk;
129 u32 nb_clk;
130 u32 d_clk;
131};
132
Stefan Roese1a16a0c2015-01-19 11:33:47 +0100133/* Needed for dynamic (board-specific) mbus configuration */
134extern struct mvebu_mbus_state mbus_state;
135
Stefan Roese93e6bf42014-10-22 12:13:17 +0200136/*
137 * functions
138 */
139unsigned int mvebu_sdram_bar(enum memory_bank bank);
140unsigned int mvebu_sdram_bs(enum memory_bank bank);
141void mvebu_sdram_size_adjust(enum memory_bank bank);
142int mvebu_mbus_probe(struct mbus_win windows[], int count);
Stefan Roese174d23e2015-04-25 06:29:51 +0200143int mvebu_soc_family(void);
Stefan Roesebadccc32015-07-16 10:40:05 +0200144u32 mvebu_get_nand_clock(void);
Stefan Roesee463bf32015-01-19 11:33:42 +0100145
Pali Rohára59971b2021-07-23 11:14:24 +0200146void __noreturn return_to_bootrom(void);
Stefan Roese99b3ea72015-08-25 13:49:41 +0200147
Pierre Bourdonb9af62d2019-04-11 04:56:58 +0200148#ifndef CONFIG_DM_MMC
Stefan Roesed3e34732015-06-29 14:58:10 +0200149int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
Pierre Bourdonb9af62d2019-04-11 04:56:58 +0200150#endif
Stefan Roesed3e34732015-06-29 14:58:10 +0200151
Marek Behúnee76b4a2021-08-16 15:19:37 +0200152u32 get_boot_device(void);
153
Stefan Roese2a539c82015-12-21 12:36:40 +0100154void get_sar_freq(struct sar_freq_modes *sar_freq);
155
Stefan Roesee463bf32015-01-19 11:33:42 +0100156/*
157 * Highspeed SERDES PHY config init, ported from bin_hdr
158 * to mainline U-Boot
159 */
160int serdes_phy_config(void);
161
162/*
163 * DDR3 init / training code ported from Marvell bin_hdr. Now
164 * available in mainline U-Boot in:
Stefan Roeseeb753e92015-03-25 12:51:18 +0100165 * drivers/ddr/marvell
Stefan Roesee463bf32015-01-19 11:33:42 +0100166 */
167int ddr3_init(void);
Stefan Roeseab91fd52016-01-20 08:13:28 +0100168
Baruch Siach056e1072019-07-10 18:23:04 +0300169/* Auto Voltage Scaling */
Pali Rohár9a365e32021-03-05 15:52:42 +0100170#if defined(CONFIG_ARMADA_38X)
Baruch Siach056e1072019-07-10 18:23:04 +0300171void mv_avs_init(void);
Chris Packham3667bec2020-02-26 19:53:50 +1300172void mv_rtc_config(void);
Baruch Siach056e1072019-07-10 18:23:04 +0300173#else
174static inline void mv_avs_init(void) {}
Chris Packham3667bec2020-02-26 19:53:50 +1300175static inline void mv_rtc_config(void) {}
Baruch Siach056e1072019-07-10 18:23:04 +0300176#endif
177
Marek Behúne577cc32020-04-08 19:25:18 +0200178/* A8K dram functions */
179u64 a8k_dram_scan_ap_sz(void);
180int a8k_dram_init_banksize(void);
181
Marek Behúnf9d5e732020-04-08 19:25:19 +0200182/* A3700 dram functions */
183int a3700_dram_init(void);
184int a3700_dram_init_banksize(void);
185
Marek Behún41d2c402020-04-08 19:25:21 +0200186/* A3700 PCIe regions fixer for device tree */
187int a3700_fdt_fix_pcie_regions(void *blob);
188
Stefan Roese05b17652016-05-17 15:00:30 +0200189/*
190 * get_ref_clk
191 *
192 * return: reference clock in MHz (25 or 40)
193 */
194u32 get_ref_clk(void);
195
Stefan Roese93e6bf42014-10-22 12:13:17 +0200196#endif /* __ASSEMBLY__ */
Stefan Roeseebda3ec2015-04-25 06:29:47 +0200197#endif /* _MVEBU_CPU_H */