blob: 16b9fa1ec1882834a7d20035b4a8fa8883206a44 [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>
8#include <asm/io.h>
9#include <miiphy.h>
10#include <netdev.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14int dram_init(void)
15{
16 gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
17
18 return 0;
19}
20
21#if IS_ENABLED(CONFIG_FEC_MXC)
22static int setup_fec(void)
23{
24 struct iomuxc_gpr_base_regs *gpr =
25 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
26
27 /* Use 125M anatop REF_CLK1 for ENET1, not from external */
28 clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
29
30 return 0;
31}
32
33int board_phy_config(struct phy_device *phydev)
34{
35 /* enable rgmii rxc skew and phy mode select to RGMII copper */
36 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
37 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x8);
38
39 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x00);
40 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x82ee);
41 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
42 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
43
44 if (phydev->drv->config)
45 phydev->drv->config(phydev);
46 return 0;
47}
48#endif
49
50int board_init(void)
51{
52 if (IS_ENABLED(CONFIG_FEC_MXC))
53 setup_fec();
54
55 return 0;
56}
57
58int board_mmc_get_env_dev(int devno)
59{
60 return devno;
61}
62
63int board_late_init(void)
64{
65 return 0;
66}
67
68#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
69int ft_board_setup(void *blob, bd_t *bd)
70{
71 return 0;
72}
73#endif