blob: 4272bacf5e6738d3f9f1c9b46988c366a12e1180 [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>
23#include <linux/mii.h>
24#include <miiphy.h>
25#include <netdev.h>
26#include <errno.h>
27
28DECLARE_GLOBAL_DATA_PTR;
29
30/*
31 * Functions
32 */
33int board_early_init_f(void)
34{
35 /* IO0 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000036 mxs_set_ioclk(MXC_IOCLK0, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000037 /* IO1 clock at 480MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000038 mxs_set_ioclk(MXC_IOCLK1, 480000);
Fabio Estevam29f75a52011-12-20 05:46:34 +000039
40 /* SSP0 clock at 96MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000041 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
Otavio Salvador4f434e32012-08-27 23:56:40 +000042 /* SSP2 clock at 160MHz */
Otavio Salvadorbf48fcb2013-01-11 03:19:03 +000043 mxs_set_sspclk(MXC_SSPCLK2, 160000, 0);
Fabio Estevam29f75a52011-12-20 05:46:34 +000044
Matthias Fuchs598aa2b2012-01-18 01:33:08 +000045#ifdef CONFIG_CMD_USB
46 mxs_iomux_setup_pad(MX28_PAD_SSP2_SS1__USB1_OVERCURRENT);
47 mxs_iomux_setup_pad(MX28_PAD_AUART2_RX__GPIO_3_8 |
48 MXS_PAD_4MA | MXS_PAD_3V3 | MXS_PAD_NOPULL);
49 gpio_direction_output(MX28_PAD_AUART2_RX__GPIO_3_8, 1);
50#endif
51
Fabio Estevam68661db2013-05-10 09:14:09 +000052 /* Power on LCD */
53 gpio_direction_output(MX28_PAD_LCD_RESET__GPIO_3_30, 1);
54
55 /* Set contrast to maximum */
56 gpio_direction_output(MX28_PAD_PWM2__GPIO_3_18, 1);
57
Fabio Estevam29f75a52011-12-20 05:46:34 +000058 return 0;
59}
60
61int dram_init(void)
62{
Otavio Salvador72f8ebf2012-08-19 04:58:30 +000063 return mxs_dram_init();
Fabio Estevam29f75a52011-12-20 05:46:34 +000064}
65
66int board_init(void)
67{
68 /* Adress of boot parameters */
69 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
70
71 return 0;
72}
73
74#ifdef CONFIG_CMD_MMC
75static int mx28evk_mmc_wp(int id)
76{
77 if (id != 0) {
78 printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
79 return 1;
80 }
81
82 return gpio_get_value(MX28_PAD_SSP1_SCK__GPIO_2_12);
83}
84
85int board_mmc_init(bd_t *bis)
86{
87 /* Configure WP as input */
88 gpio_direction_input(MX28_PAD_SSP1_SCK__GPIO_2_12);
89
90 /* Configure MMC0 Power Enable */
91 gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
92
Marek Vasut90bc2bf2013-01-22 15:01:03 +000093 return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
Fabio Estevam29f75a52011-12-20 05:46:34 +000094}
95#endif
96
97#ifdef CONFIG_CMD_NET
98
Fabio Estevam29f75a52011-12-20 05:46:34 +000099int board_eth_init(bd_t *bis)
100{
Otavio Salvador9c471142012-08-05 09:05:31 +0000101 struct mxs_clkctrl_regs *clkctrl_regs =
102 (struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000103 struct eth_device *dev;
104 int ret;
105
106 ret = cpu_eth_init(bis);
Fabio Estevam2cba60a2013-09-20 16:30:48 -0300107 if (ret)
108 return ret;
Fabio Estevam29f75a52011-12-20 05:46:34 +0000109
110 /* MX28EVK uses ENET_CLK PAD to drive FEC clock */
111 writel(CLKCTRL_ENET_TIME_SEL_RMII_CLK | CLKCTRL_ENET_CLK_OUT_EN,
Fabio Estevam71d8b012013-09-14 19:34:17 -0300112 &clkctrl_regs->hw_clkctrl_enet);
Fabio Estevam29f75a52011-12-20 05:46:34 +0000113
114 /* Power-on FECs */
115 gpio_direction_output(MX28_PAD_SSP1_DATA3__GPIO_2_15, 0);
116
117 /* Reset FEC PHYs */
118 gpio_direction_output(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 0);
119 udelay(200);
120 gpio_set_value(MX28_PAD_ENET0_RX_CLK__GPIO_4_13, 1);
121
122 ret = fecmxc_initialize_multi(bis, 0, 0, MXS_ENET0_BASE);
123 if (ret) {
124 puts("FEC MXS: Unable to init FEC0\n");
125 return ret;
126 }
127
128 ret = fecmxc_initialize_multi(bis, 1, 3, MXS_ENET1_BASE);
129 if (ret) {
130 puts("FEC MXS: Unable to init FEC1\n");
131 return ret;
132 }
133
134 dev = eth_get_dev_by_name("FEC0");
135 if (!dev) {
136 puts("FEC MXS: Unable to get FEC0 device entry\n");
137 return -EINVAL;
138 }
139
Fabio Estevam29f75a52011-12-20 05:46:34 +0000140 dev = eth_get_dev_by_name("FEC1");
141 if (!dev) {
142 puts("FEC MXS: Unable to get FEC1 device entry\n");
143 return -EINVAL;
144 }
145
Fabio Estevam29f75a52011-12-20 05:46:34 +0000146 return ret;
147}
148
149#endif