blob: 4ccce8a736112a3dbbb9b89e143a1388007a2290 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Andy Fleming3c98e7b2015-11-04 15:48:32 -06002/*
3 * Based on corenet_ds.c
Andy Fleming3c98e7b2015-11-04 15:48:32 -06004 */
5
6#include <common.h>
7#include <command.h>
8#include <netdev.h>
9#include <linux/compiler.h>
10#include <asm/mmu.h>
11#include <asm/processor.h>
12#include <asm/cache.h>
13#include <asm/immap_85xx.h>
14#include <asm/fsl_law.h>
15#include <asm/fsl_serdes.h>
16#include <asm/fsl_portals.h>
17#include <asm/fsl_liodn.h>
18#include <fm_eth.h>
19#include <pci.h>
20
21#include "cyrus.h"
22#include "../common/eeprom.h"
23
Andy Fleming3c98e7b2015-11-04 15:48:32 -060024#define GPIO_OPENDRAIN 0x30000000
25#define GPIO_DIR 0x3c000004
26#define GPIO_INITIAL 0x30000000
27#define GPIO_VGA_SWITCH 0x00001000
28
29int checkboard(void)
30{
31 printf("Board: CYRUS\n");
32
33 return 0;
34}
35
36int board_early_init_f(void)
37{
38 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
39 ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
40
41 /*
42 * Only use DDR1_MCK0/3 and DDR2_MCK0/3
43 * disable DDR1_MCK1/2/4/5 and DDR2_MCK1/2/4/5 to reduce
44 * the noise introduced by these unterminated and unused clock pairs.
45 */
46 setbits_be32(&gur->ddrclkdr, 0x001B001B);
47
48 /* Set GPIO reset lines to open-drain, tristate */
49 setbits_be32(&pgpio->gpdat, GPIO_INITIAL);
50 setbits_be32(&pgpio->gpodr, GPIO_OPENDRAIN);
51
52 /* Set GPIO Direction */
53 setbits_be32(&pgpio->gpdir, GPIO_DIR);
54
55 return 0;
56}
57
58int board_early_init_r(void)
59{
60 fsl_lbc_t *lbc = LBC_BASE_ADDR;
61
62 out_be32(&lbc->lbcr, 0);
63 /* 1 clock LALE cycle */
64 out_be32(&lbc->lcrr, 0x80000000 | CONFIG_SYS_LBC_LCRR);
65
66 set_liodns();
67
68#ifdef CONFIG_SYS_DPAA_QBMAN
Ahmed Mansouraa270b42017-12-15 16:01:00 -050069 setup_qbman_portals();
Andy Fleming3c98e7b2015-11-04 15:48:32 -060070#endif
71 print_lbc_regs();
72 return 0;
73}
74
75int misc_init_r(void)
76{
77 return 0;
78}
79
80int ft_board_setup(void *blob, bd_t *bd)
81{
82 phys_addr_t base;
83 phys_size_t size;
84
85 ft_cpu_setup(blob, bd);
86
Simon Glassda1a1342017-08-03 12:22:15 -060087 base = env_get_bootm_low();
88 size = env_get_bootm_size();
Andy Fleming3c98e7b2015-11-04 15:48:32 -060089
90 fdt_fixup_memory(blob, (u64)base, (u64)size);
91
92#ifdef CONFIG_PCI
93 pci_of_setup(blob, bd);
94#endif
95
96 fdt_fixup_liodn(blob);
Sriram Dash9fd465c2016-09-16 17:12:15 +053097 fsl_fdt_fixup_dr_usb(blob, bd);
Andy Fleming3c98e7b2015-11-04 15:48:32 -060098
99#ifdef CONFIG_SYS_DPAA_FMAN
100 fdt_fixup_fman_ethernet(blob);
101#endif
102
103 return 0;
104}
105
106int mac_read_from_eeprom(void)
107{
108 init_eeprom(CONFIG_SYS_EEPROM_BUS_NUM,
109 CONFIG_SYS_I2C_EEPROM_ADDR,
110 CONFIG_SYS_I2C_EEPROM_ADDR_LEN);
111
112 return mac_read_from_eeprom_common();
113}