blob: cb9b4e3b0a9f95429f690ae0cd419915e979469e [file] [log] [blame]
Igor Opaniuk309e65b2020-01-28 14:42:25 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2020 Toradex
4 */
5
6#include <common.h>
7#include <asm/arch/clock.h>
Igor Opaniukd1b4d0d2020-03-27 12:28:18 +02008#include <asm/arch/sys_proto.h>
Igor Opaniuk309e65b2020-01-28 14:42:25 +01009#include <asm/io.h>
10#include <miiphy.h>
11#include <netdev.h>
12
13DECLARE_GLOBAL_DATA_PTR;
14
15int dram_init(void)
16{
Igor Opaniukd1b4d0d2020-03-27 12:28:18 +020017 /* rom_pointer[1] contains the size of TEE occupies */
18 if (rom_pointer[1])
19 gd->ram_size = PHYS_SDRAM_SIZE - rom_pointer[1];
20 else
21 gd->ram_size = PHYS_SDRAM_SIZE;
Igor Opaniuk309e65b2020-01-28 14:42:25 +010022
23 return 0;
24}
25
26#if IS_ENABLED(CONFIG_FEC_MXC)
27static int setup_fec(void)
28{
29 struct iomuxc_gpr_base_regs *gpr =
30 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
31
32 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
33 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
34
35 return 0;
36}
37
38int board_phy_config(struct phy_device *phydev)
39{
40 /* enable rgmii rxc skew and phy mode select to RGMII copper */
41 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
42 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
43
44 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
45 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
46 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
47 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
48
49 if (phydev->drv->config)
50 phydev->drv->config(phydev);
51 return 0;
52}
53#endif
54
55int board_init(void)
56{
57 if (IS_ENABLED(CONFIG_FEC_MXC))
58 setup_fec();
59
60 return 0;
61}
62
63int board_mmc_get_env_dev(int devno)
64{
65 return devno;
66}
67
68int board_late_init(void)
69{
70 return 0;
71}
72
73#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
74int ft_board_setup(void *blob, bd_t *bd)
75{
76 return 0;
77}
78#endif