1 /*
2  * (C) Copyright 2016 Savoir-faire Linux Inc.
3  *
4  * Author: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
5  *
6  * Based on work from TS7680 code by:
7  *   Kris Bahnsen <kris@embeddedarm.com>
8  *   Mark Featherston <mark@embeddedarm.com>
9  *   https://github.com/embeddedarm/u-boot/tree/master/board/technologic/ts7680
10  *
11  * Derived from MX28EVK code by
12  *   Freescale Semiconductor, Inc.
13  *
14  * SPDX-License-Identifier:	GPL-2.0+
15  */
16 
17 #include <common.h>
18 #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>
24 #include <linux/mii.h>
25 #include <miiphy.h>
26 #include <netdev.h>
27 #include <errno.h>
28 
29 DECLARE_GLOBAL_DATA_PTR;
30 
31 int board_early_init_f(void)
32 {
33 	/* IO0 clock at 480MHz */
34 	mxs_set_ioclk(MXC_IOCLK0, 480000);
35 	/* IO1 clock at 480MHz */
36 	mxs_set_ioclk(MXC_IOCLK1, 480000);
37 
38 	/* SSP0 clocks at 96MHz */
39 	mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
40 
41 	return 0;
42 }
43 
44 int dram_init(void)
45 {
46 	return mxs_dram_init();
47 }
48 
49 int board_init(void)
50 {
51 	/* Adress of boot parameters */
52 	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
53 
54 	return 0;
55 }
56 
57 #ifdef CONFIG_CMD_MMC
58 static int ts4600_mmc_cd(int id)
59 {
60 	return 1;
61 }
62 
63 int board_mmc_init(bd_t *bis)
64 {
65 	int ret;
66 
67 	mxs_iomux_setup_pad(MX28_PAD_PWM3__GPIO_3_28);
68 
69 	/* Power-on SD */
70 	gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 1);
71 	udelay(1000);
72 	gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
73 
74 	/* SD card */
75 	ret = mxsmmc_initialize(bis, 0, NULL, ts4600_mmc_cd);
76 	if(ret != 0) {
77 		printf("SD controller initialized with %d\n", ret);
78 	}
79 
80 	return ret;
81 }
82 #endif
83 
84 int checkboard(void)
85 {
86 	puts("Board: TS4600\n");
87 
88 	return 0;
89 }
90