blob: a061d7d8afbc5a11993bfd9588698fa931c24399 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Boris BREZILLON7832bf32015-03-04 13:13:05 +01002/*
3 * Copyright (C) 2013 Freescale Semiconductor, Inc.
4 * Copyright (C) 2015 ECA Sinters
5 *
6 * Author: Fabio Estevam <fabio.estevam@freescale.com>
7 * Modified by: Boris Brezillon <boris.brezillon@free-electrons.com>
Boris BREZILLON7832bf32015-03-04 13:13:05 +01008 */
9
Simon Glass8e16b1e2019-12-28 10:45:05 -070010#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <net.h>
Boris BREZILLON7832bf32015-03-04 13:13:05 +010012#include <asm/arch/clock.h>
13#include <asm/arch/imx-regs.h>
14#include <asm/arch/iomux.h>
15#include <asm/arch/mx6-pins.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060016#include <asm/global_data.h>
Simon Glassdbd79542020-05-10 11:40:11 -060017#include <linux/delay.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090018#include <linux/errno.h>
Boris BREZILLON7832bf32015-03-04 13:13:05 +010019#include <asm/gpio.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020020#include <asm/mach-imx/iomux-v3.h>
21#include <asm/mach-imx/boot_mode.h>
Boris BREZILLON7832bf32015-03-04 13:13:05 +010022#include <malloc.h>
23#include <mmc.h>
Yangbo Lu73340382019-06-21 11:42:28 +080024#include <fsl_esdhc_imx.h>
Boris BREZILLON7832bf32015-03-04 13:13:05 +010025#include <miiphy.h>
26#include <netdev.h>
27#include <asm/arch/mxc_hdmi.h>
28#include <asm/arch/crm_regs.h>
29#include <linux/fb.h>
30#include <ipu_pixfmt.h>
31#include <asm/io.h>
32#include <asm/arch/sys_proto.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020033#include <asm/mach-imx/mxc_i2c.h>
Boris BREZILLON7832bf32015-03-04 13:13:05 +010034#include <i2c.h>
35
36#include "../common/mx6.h"
37
38DECLARE_GLOBAL_DATA_PTR;
39
40int dram_init(void)
41{
42 gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
43
44 return 0;
45}
46
47int board_early_init_f(void)
48{
49 seco_mx6_setup_uart_iomux();
50
51 return 0;
52}
53
54int board_phy_config(struct phy_device *phydev)
55{
56 seco_mx6_rgmii_rework(phydev);
57 if (phydev->drv->config)
58 phydev->drv->config(phydev);
59
60 return 0;
61}
62
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +090063int board_eth_init(struct bd_info *bis)
Boris BREZILLON7832bf32015-03-04 13:13:05 +010064{
65 uint32_t base = IMX_FEC_BASE;
66 struct mii_dev *bus = NULL;
67 struct phy_device *phydev = NULL;
68 int ret = 0;
69
70 seco_mx6_setup_enet_iomux();
71
72#ifdef CONFIG_FEC_MXC
73 bus = fec_get_miibus(base, -1);
74 if (!bus)
75 return -ENOMEM;
76
77 /* scan phy 4,5,6,7 */
78 phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
79 if (!phydev) {
80 free(bus);
81 return -ENOMEM;
82 }
83
84 printf("using phy at %d\n", phydev->addr);
85 ret = fec_probe(bis, -1, base, bus, phydev);
86 if (ret) {
87 free(phydev);
88 free(bus);
89 printf("FEC MXC: %s:failed\n", __func__);
90 }
91#endif
92
93 return ret;
94}
95
Julien CORJON01d63982016-02-05 16:19:33 +010096#define USDHC4_CD_GPIO IMX_GPIO_NR(2, 6)
97
Boris BREZILLON7832bf32015-03-04 13:13:05 +010098static struct fsl_esdhc_cfg usdhc_cfg[2] = {
Julien CORJONacd0aa82016-02-05 16:19:32 +010099 {USDHC3_BASE_ADDR, 0, 4},
100 {USDHC4_BASE_ADDR, 0, 4},
Boris BREZILLON7832bf32015-03-04 13:13:05 +0100101};
102
Julien CORJON01d63982016-02-05 16:19:33 +0100103int board_mmc_getcd(struct mmc *mmc)
104{
105 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
106 int ret = 0;
107
108 switch (cfg->esdhc_base) {
109 case USDHC3_BASE_ADDR:
110 ret = 1; /* Assume eMMC is always present */
111 break;
112 case USDHC4_BASE_ADDR:
113 ret = !gpio_get_value(USDHC4_CD_GPIO);
114 break;
115 }
116
117 return ret;
118}
119
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900120int board_mmc_init(struct bd_info *bis)
Boris BREZILLON7832bf32015-03-04 13:13:05 +0100121{
122 u32 index = 0;
123 int ret;
124
125 /*
126 * Following map is done:
Bin Meng75574052016-02-05 19:30:11 -0800127 * (U-Boot device node) (Physical Port)
Boris BREZILLON7832bf32015-03-04 13:13:05 +0100128 * mmc0 eMMC on Board
129 * mmc1 Ext SD
130 */
131 for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
132 switch (index) {
133 case 0:
134 seco_mx6_setup_usdhc_iomux(3);
135 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
Boris BREZILLON7832bf32015-03-04 13:13:05 +0100136 break;
137 case 1:
138 seco_mx6_setup_usdhc_iomux(4);
139 usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK);
Boris BREZILLON7832bf32015-03-04 13:13:05 +0100140 break;
141
142 default:
143 printf("Warning: %d exceed maximum number of SD ports %d\n",
144 index + 1, CONFIG_SYS_FSL_USDHC_NUM);
145 return -EINVAL;
146 }
147
148 ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
149 if (ret)
150 return ret;
151 }
152
153 return 0;
154}
155
156int board_init(void)
157{
158 /* address of boot parameters */
159 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
160
161 imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D4__GPIO2_IO04 |
162 MUX_PAD_CTRL(NO_PAD_CTRL));
163
164 gpio_direction_output(IMX_GPIO_NR(2, 4), 0);
165
166 /* Set Low */
167 gpio_set_value(IMX_GPIO_NR(2, 4), 0);
168 udelay(1000);
169
170 /* Set High */
171 gpio_set_value(IMX_GPIO_NR(2, 4), 1);
172
173 return 0;
174}
175
176int checkboard(void)
177{
178 puts("Board: SECO uQ7\n");
179
180 return 0;
181}