1 // SPDX-License-Identifier: GPL-2.0+
3 * K+P iMX6Q KP_IMX6Q_TPC board configuration
5 * Copyright (C) 2018 Lukasz Majewski <lukma@denx.de>
9 #include <asm/arch/clock.h>
10 #include <asm/arch/crm_regs.h>
11 #include <asm/arch/imx-regs.h>
12 #include <asm/arch/mx6-pins.h>
13 #include <asm/arch/sys_proto.h>
14 #include <asm/mach-imx/boot_mode.h>
19 #include <usb/ehci-ci.h>
22 DECLARE_GLOBAL_DATA_PTR;
26 gd->ram_size = imx_ddr_size();
31 * Do not overwrite the console
32 * Use always serial for U-Boot console
34 int overwrite_console(void)
40 static int setup_fec_clock(void)
42 struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
44 /* set gpr1[21] to select anatop clock */
45 clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUXC_GPR1_ENET_CLK_SEL_MASK,
46 IOMUXC_GPR1_ENET_CLK_SEL_MASK);
48 return enable_fec_anatop_clock(0, ENET_50MHZ);
51 static int ar8031_phy_fixup(struct phy_device *phydev)
55 /* To enable AR8031 output a 125MHz clk from CLK_25M */
56 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7);
57 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
58 phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
60 val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
63 phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val);
65 /* introduce tx clock delay */
66 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
67 val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
69 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val);
74 int board_phy_config(struct phy_device *phydev)
76 ar8031_phy_fixup(phydev);
78 if (phydev->drv->config)
79 phydev->drv->config(phydev);
85 #ifdef CONFIG_USB_EHCI_MX6
86 static void setup_usb(void)
89 * Set daisy chain for otg_pin_id on MX6Q.
90 * For MX6DL, this bit is reserved.
92 imx_iomux_set_gpr_register(1, 13, 1, 0);
96 int board_early_init_f(void)
98 #ifdef CONFIG_USB_EHCI_MX6
102 #ifdef CONFIG_FEC_MXC
111 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
113 /* address of boot parameters */
114 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
116 /* Enable eim_slow clocks */
117 setbits_le32(&mxc_ccm->CCGR6, 0x1 << MXC_CCM_CCGR6_EMI_SLOW_OFFSET);
122 #ifdef CONFIG_CMD_BMODE
123 static const struct boot_mode board_boot_modes[] = {
124 /* 4 bit bus width */
125 {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
126 /* 8 bit bus width */
127 {"emmc", MAKE_CFGVAL(0x60, 0x58, 0x00, 0x00)},
132 int board_late_init(void)
134 #ifdef CONFIG_CMD_BMODE
135 add_board_boot_modes(board_boot_modes);
138 if (IS_ENABLED(CONFIG_LED))
141 env_set("boardname", "kp-tpc");
142 env_set("boardsoc", "imx6q");
148 puts("Board: K+P KP_IMX6Q_TPC i.MX6Q\n");