blob: a6b66d99ccb11bae42cdd1c09c48866b50b489e7 [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>
Fabio Estevam29f75a52011-12-20 05:46:34 +000017#include <asm/gpio.h>
18#include <asm/io.h>
19#include <asm/arch/imx-regs.h>
20#include <asm/arch/iomux-mx28.h>
21#include <asm/arch/clock.h>
22#include <asm/arch/sys_proto.h>
Simon Glassc05ed002020-05-10 11:40:11 -060023#include <linux/delay.h>
Fabio Estevam29f75a52011-12-20 05:46:34 +000024#include <linux/mii.h>
25#include <miiphy.h>
26#include <netdev.h>
27#include <errno.h>
28
29DECLARE_GLOBAL_DATA_PTR;
30
31/*
32 * Functions
33 */
34int board_early_init_f(void)
35{
36 /* IO0 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000037 mxs_set_ioclk(MXC_IOCLK0, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000038 /* IO1 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000039 mxs_set_ioclk(MXC_IOCLK1, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000040
41 /* SSP0 clock at 96MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000042 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
Otavio Salvador4f434e32012-08-27 23:56:40 +000043 /* SSP2 clock at 160MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000044 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
Fabio Estevam29f75a52011-12-20 05:46:34 +000045
Matthias Fuchs598aa2b2012-01-18 01:33:08 +000046#ifdef CONFIG_CMD_USB
47 mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
48 mxs_iomux_setup_pad(MX28_PAD_AUART2_RX__GPIO_3_8 |
49 MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL);
50 gpio_direction_output(MX28_PAD_AUART2_RX__GPIO_3_8, 1);
51#endif
52
Fabio Estevam68661db2013-05-10 09:14:09 +000053 /* Power on LCD */
54 gpio_direction_output(MX28_PAD_LCD_RESET__GPIO_3_30, 1);
55
56 /* Set contrast to maximum */
57 gpio_direction_output(MX28_PAD_PWM2__GPIO_3_18, 1);
58
Fabio Estevam29f75a52011-12-20 05:46:34 +000059 return 0;
60}
61
62int dram_init(void)
63{
Otavio Salvador72f8ebf2012-08-19 04:58:30 +000064 return mxs_dram_init();
Fabio Estevam29f75a52011-12-20 05:46:34 +000065}
66
67int board_init(void)
68{
69 /* Adress of boot parameters */
70 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
71
72 return 0;
73}
74
75#ifdef CONFIG_CMD_MMC
76static int mx28evk_mmc_wp(int id)
77{
78 if (id != 0) {
79 printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
80 return 1;
81 }
82
83 return gpio_get_value(MX28_PAD_SSP1_SCK__GPIO_2_12);
84}
85
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +090086int board_mmc_init(struct bd_info *bis)
Fabio Estevam29f75a52011-12-20 05:46:34 +000087{
88 /* Configure WP as input */
89 gpio_direction_input(MX28_PAD_SSP1_SCK__GPIO_2_12);
90
91 /* Configure MMC0 Power Enable */
92 gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
93
Marek Vasut90bc2bf2013-01-22 15:01:03 +000094 return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
Fabio Estevam29f75a52011-12-20 05:46:34 +000095}
96#endif
97
98#ifdef CONFIG_CMD_NET
99
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900100int board_eth_init(struct bd_info *bis)
Fabio Estevam29f75a52011-12-20 05:46:34 +0000101{
Otavio Salvador9c471142012-08-05 09:05:31 +0000102 struct mxs_clkctrl_regs *clkctrl_regs =
103 (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000104 struct eth_device *dev;
105 int ret;
106
107 ret = cpu_eth_init(bis);
Fabio Estevam2cba60a2013-09-20 16:30:48 -0300108 if (ret)
109 return ret;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000110
111 /* MX28EVK uses ENET_CLK PAD to drive FEC clock */
112 writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN,
Fabio Estevam71d8b012013-09-14 19:34:17 -0300113 &clkctrl_regs->hw_clkctrl_enet);
Fabio Estevam29f75a52011-12-20 05:46:34 +0000114
115 /* Power-on FECs */
116 gpio_direction_output(MX28_PAD_SSP1_DATA3__GPIO_2_15, 0);
117
118 /* Reset FEC PHYs */
119 gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
120 udelay(200);
121 gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
122
123 ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
124 if (ret) {
125 puts("FEC MXS: Unable to init FEC0\n");
126 return ret;
127 }
128
129 ret = fecmxc_initialize_multi(bis, 1, 3, MXS_ENET1_BASE);
130 if (ret) {
131 puts("FEC MXS: Unable to init FEC1\n");
132 return ret;
133 }
134
135 dev = eth_get_dev_by_name("FEC0");
136 if (!dev) {
137 puts("FEC MXS: Unable to get FEC0 device entry\n");
138 return -EINVAL;
139 }
140
Fabio Estevam29f75a52011-12-20 05:46:34 +0000141 dev = eth_get_dev_by_name("FEC1");
142 if (!dev) {
143 puts("FEC MXS: Unable to get FEC1 device entry\n");
144 return -EINVAL;
145 }
146
Fabio Estevam29f75a52011-12-20 05:46:34 +0000147 return ret;
148}
149
150#endif