blob: 21c9cb11283614cbc5c6449b17ef5f9e4a52651e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Fabio Estevam29f75a52011-12-20 05:46:34 +00002/*
3 * Freescale MX28EVK board
4 *
5 * (C) Copyright 2011 Freescale Semiconductor, Inc.
6 *
7 * Author: Fabio Estevam <fabio.estevam@freescale.com>
8 *
9 * Based on m28evk.c:
10 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
11 * on behalf of DENX Software Engineering GmbH
Fabio Estevam29f75a52011-12-20 05:46:34 +000012 */
13
14#include <common.h>
Simon Glass691d7192020-05-10 11:40:02 -060015#include <init.h>
Simon Glass90526e92020-05-10 11:39:56 -060016#include <net.h>
Simon Glass401d1c42020-10-30 21:38:53 -060017#include <asm/global_data.h>
Fabio Estevam29f75a52011-12-20 05:46:34 +000018#include <asm/gpio.h>
19#include <asm/io.h>
20#include <asm/arch/imx-regs.h>
21#include <asm/arch/iomux-mx28.h>
22#include <asm/arch/clock.h>
23#include <asm/arch/sys_proto.h>
Simon Glassc05ed002020-05-10 11:40:11 -060024#include <linux/delay.h>
Fabio Estevam29f75a52011-12-20 05:46:34 +000025#include <linux/mii.h>
26#include <miiphy.h>
27#include <netdev.h>
28#include <errno.h>
29
30DECLARE_GLOBAL_DATA_PTR;
31
32/*
33 * Functions
34 */
35int board_early_init_f(void)
36{
37 /* IO0 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000038 mxs_set_ioclk(MXC_IOCLK0, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000039 /* IO1 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000040 mxs_set_ioclk(MXC_IOCLK1, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000041
42 /* SSP0 clock at 96MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000043 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
Otavio Salvador4f434e32012-08-27 23:56:40 +000044 /* SSP2 clock at 160MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000045 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
Fabio Estevam29f75a52011-12-20 05:46:34 +000046
Matthias Fuchs598aa2b2012-01-18 01:33:08 +000047#ifdef CONFIG_CMD_USB
48 mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
49 mxs_iomux_setup_pad(MX28_PAD_AUART2_RX__GPIO_3_8 |
50 MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL);
51 gpio_direction_output(MX28_PAD_AUART2_RX__GPIO_3_8, 1);
52#endif
53
Fabio Estevam68661db2013-05-10 09:14:09 +000054 /* Power on LCD */
55 gpio_direction_output(MX28_PAD_LCD_RESET__GPIO_3_30, 1);
56
57 /* Set contrast to maximum */
58 gpio_direction_output(MX28_PAD_PWM2__GPIO_3_18, 1);
59
Fabio Estevam29f75a52011-12-20 05:46:34 +000060 return 0;
61}
62
63int dram_init(void)
64{
Otavio Salvador72f8ebf2012-08-19 04:58:30 +000065 return mxs_dram_init();
Fabio Estevam29f75a52011-12-20 05:46:34 +000066}
67
68int board_init(void)
69{
70 /* Adress of boot parameters */
71 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
72
73 return 0;
74}
75
76#ifdef CONFIG_CMD_MMC
77static int mx28evk_mmc_wp(int id)
78{
79 if (id != 0) {
80 printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
81 return 1;
82 }
83
84 return gpio_get_value(MX28_PAD_SSP1_SCK__GPIO_2_12);
85}
86
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +090087int board_mmc_init(struct bd_info *bis)
Fabio Estevam29f75a52011-12-20 05:46:34 +000088{
89 /* Configure WP as input */
90 gpio_direction_input(MX28_PAD_SSP1_SCK__GPIO_2_12);
91
92 /* Configure MMC0 Power Enable */
93 gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
94
Marek Vasut90bc2bf2013-01-22 15:01:03 +000095 return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
Fabio Estevam29f75a52011-12-20 05:46:34 +000096}
97#endif
98
99#ifdef CONFIG_CMD_NET
100
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900101int board_eth_init(struct bd_info *bis)
Fabio Estevam29f75a52011-12-20 05:46:34 +0000102{
Otavio Salvador9c471142012-08-05 09:05:31 +0000103 struct mxs_clkctrl_regs *clkctrl_regs =
104 (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000105 struct eth_device *dev;
106 int ret;
107
108 ret = cpu_eth_init(bis);
Fabio Estevam2cba60a2013-09-20 16:30:48 -0300109 if (ret)
110 return ret;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000111
112 /* MX28EVK uses ENET_CLK PAD to drive FEC clock */
113 writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN,
Fabio Estevam71d8b012013-09-14 19:34:17 -0300114 &clkctrl_regs->hw_clkctrl_enet);
Fabio Estevam29f75a52011-12-20 05:46:34 +0000115
116 /* Power-on FECs */
117 gpio_direction_output(MX28_PAD_SSP1_DATA3__GPIO_2_15, 0);
118
119 /* Reset FEC PHYs */
120 gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
121 udelay(200);
122 gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
123
124 ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
125 if (ret) {
126 puts("FEC MXS: Unable to init FEC0\n");
127 return ret;
128 }
129
130 ret = fecmxc_initialize_multi(bis, 1, 3, MXS_ENET1_BASE);
131 if (ret) {
132 puts("FEC MXS: Unable to init FEC1\n");
133 return ret;
134 }
135
136 dev = eth_get_dev_by_name("FEC0");
137 if (!dev) {
138 puts("FEC MXS: Unable to get FEC0 device entry\n");
139 return -EINVAL;
140 }
141
Fabio Estevam29f75a52011-12-20 05:46:34 +0000142 dev = eth_get_dev_by_name("FEC1");
143 if (!dev) {
144 puts("FEC MXS: Unable to get FEC1 device entry\n");
145 return -EINVAL;
146 }
147
Fabio Estevam29f75a52011-12-20 05:46:34 +0000148 return ret;
149}
150
151#endif