blob: 313ab20e26ea734e5e2fa76c7c0aae9af1faa21d [file] [log] [blame]
Marek Vasut189e35b2013-01-12 07:11:11 +00001/*
2 * Olimex MX23 Olinuxino board
3 *
4 * Copyright (C) 2013 Marek Vasut <marex@denx.de>
5 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Marek Vasut189e35b2013-01-12 07:11:11 +00007 */
8
9#include <common.h>
Otavio Salvador3600ec32013-03-07 07:32:53 +000010#include <asm/gpio.h>
Marek Vasut73f2b032013-01-22 15:01:05 +000011#include <asm/io.h>
12#include <asm/arch/iomux-mx23.h>
Marek Vasut189e35b2013-01-12 07:11:11 +000013#include <asm/arch/imx-regs.h>
Marek Vasut73f2b032013-01-22 15:01:05 +000014#include <asm/arch/clock.h>
Marek Vasut189e35b2013-01-12 07:11:11 +000015#include <asm/arch/sys_proto.h>
Otavio Salvadorfcc76892013-02-23 02:43:09 +000016#ifdef CONFIG_STATUS_LED
17#include <status_led.h>
18#endif
Marek Vasut189e35b2013-01-12 07:11:11 +000019
20DECLARE_GLOBAL_DATA_PTR;
21
22/*
23 * Functions
24 */
25int board_early_init_f(void)
26{
Marek Vasut73f2b032013-01-22 15:01:05 +000027 /* IO0 clock at 480MHz */
28 mxs_set_ioclk(MXC_IOCLK0, 480000);
29
30 /* SSP0 clock at 96MHz */
31 mxs_set_sspclk(MXC_SSPCLK0, 96000, 0);
32
Marek Vasut3f302a72014-04-28 03:38:42 +020033 return 0;
34}
35
Otavio Salvador801fa152013-03-02 05:17:29 +000036#ifdef CONFIG_CMD_USB
Marek Vasut3f302a72014-04-28 03:38:42 +020037int board_ehci_hcd_init(int port)
38{
39 /* Enable LAN9512 (Maxi) or GL850G (Mini) USB HUB power. */
Otavio Salvador801fa152013-03-02 05:17:29 +000040 gpio_direction_output(MX23_PAD_GPMI_ALE__GPIO_0_17, 1);
Marek Vasut3f302a72014-04-28 03:38:42 +020041 udelay(100);
42 return 0;
43}
Otavio Salvador801fa152013-03-02 05:17:29 +000044
Marek Vasut3f302a72014-04-28 03:38:42 +020045int board_ehci_hcd_exit(int port)
46{
47 /* Enable LAN9512 (Maxi) or GL850G (Mini) USB HUB power. */
48 gpio_direction_output(MX23_PAD_GPMI_ALE__GPIO_0_17, 0);
Marek Vasut189e35b2013-01-12 07:11:11 +000049 return 0;
50}
Marek Vasut3f302a72014-04-28 03:38:42 +020051#endif
Marek Vasut189e35b2013-01-12 07:11:11 +000052
53int dram_init(void)
54{
55 return mxs_dram_init();
56}
Marek Vasut73f2b032013-01-22 15:01:05 +000057
58#ifdef CONFIG_CMD_MMC
59static int mx23_olx_mmc_cd(int id)
60{
61 return 1; /* Card always present */
62}
63
64int board_mmc_init(bd_t *bis)
65{
66 return mxsmmc_initialize(bis, 0, NULL, mx23_olx_mmc_cd);
67}
68#endif
Marek Vasut189e35b2013-01-12 07:11:11 +000069
70int board_init(void)
71{
72 /* Adress of boot parameters */
73 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
74
Otavio Salvadorfcc76892013-02-23 02:43:09 +000075#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
76 status_led_set(STATUS_LED_BOOT, STATUS_LED_STATE);
77#endif
78
Marek Vasut189e35b2013-01-12 07:11:11 +000079 return 0;
80}
Marek Vasutdce22782014-04-28 03:38:43 +020081
82/* Fine-tune the DRAM configuration. */
83void mxs_adjust_memory_params(uint32_t *dram_vals)
84{
85 /* Enable Auto Precharge. */
86 dram_vals[3] |= 1 << 8;
87 /* Enable Fast Writes. */
88 dram_vals[5] |= 1 << 8;
89 /* tEMRS = 3*tCK */
90 dram_vals[10] &= ~(0x3 << 8);
91 dram_vals[10] |= (0x3 << 8);
92 /* CASLAT = 3*tCK */
93 dram_vals[11] &= ~(0x3 << 0);
94 dram_vals[11] |= (0x3 << 0);
95 /* tCKE = 1*tCK */
96 dram_vals[12] &= ~(0x7 << 0);
97 dram_vals[12] |= (0x1 << 0);
98 /* CASLAT_LIN_GATE = 3*tCK , CASLAT_LIN = 3*tCK, tWTR=2*tCK */
99 dram_vals[13] &= ~((0xf << 16) | (0xf << 24) | (0xf << 0));
100 dram_vals[13] |= (0x6 << 16) | (0x6 << 24) | (0x2 << 0);
101 /* tDAL = 6*tCK */
102 dram_vals[15] &= ~(0xf << 16);
103 dram_vals[15] |= (0x6 << 16);
104 /* tREF = 1040*tCK */
105 dram_vals[26] &= ~0xffff;
106 dram_vals[26] |= 0x0410;
107 /* tRAS_MAX = 9334*tCK */
108 dram_vals[32] &= ~0xffff;
109 dram_vals[32] |= 0x2475;
110}