1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Freescale MX23EVK board
4  *
5  * (C) Copyright 2013 O.S. Systems Software LTDA.
6  *
7  * Author: Otavio Salvador <otavio@ossystems.com.br>
8  *
9  * Based on m28evk.c:
10  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
11  * on behalf of DENX Software Engineering GmbH
12  */
13 
14 #include <common.h>
15 #include <asm/gpio.h>
16 #include <asm/arch/imx-regs.h>
17 #include <asm/arch/clock.h>
18 #include <asm/arch/iomux-mx23.h>
19 #include <asm/arch/sys_proto.h>
20 
21 DECLARE_GLOBAL_DATA_PTR;
22 
23 /*
24  * Functions
25  */
26 int board_early_init_f(void)
27 {
28 	/* IO0 clock at 480MHz */
29 	mxs_set_ioclk(MXC_IOCLK0, 480000);
30 
31 	/* SSP0 clock at 96MHz */
32 	mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
33 
34 	/* Power on LCD */
35 	gpio_direction_output(MX23_PAD_LCD_RESET__GPIO_1_18, 1);
36 
37 	/* Set contrast to maximum */
38 	gpio_direction_output(MX23_PAD_PWM2__GPIO_1_28, 1);
39 
40 	return 0;
41 }
42 
43 int dram_init(void)
44 {
45 	return mxs_dram_init();
46 }
47 
48 int board_init(void)
49 {
50 	/* Adress of boot parameters */
51 	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
52 
53 	return 0;
54 }
55 
56 #ifdef	CONFIG_CMD_MMC
57 static int mx23evk_mmc_wp(int id)
58 {
59 	if (id != 0) {
60 		printf("MXS MMC: Invalid card selected (card id = %d)\n", id);
61 		return 1;
62 	}
63 
64 	return gpio_get_value(MX23_PAD_PWM4__GPIO_1_30);
65 }
66 
67 int board_mmc_init(bd_t *bis)
68 {
69 	/* Configure WP as input */
70 	gpio_direction_input(MX23_PAD_PWM4__GPIO_1_30);
71 
72 	/* Configure MMC0 Power Enable */
73 	gpio_direction_output(MX23_PAD_PWM3__GPIO_1_29, 0);
74 
75 	return mxsmmc_initialize(bis, 0, mx23evk_mmc_wp, NULL);
76 }
77 #endif
78