blob: 2995c8f105054edae5ed822e026bf029b61ef1bb [file] [log] [blame]
Helmut Raiger4d86dd02011-10-27 01:31:15 +00001/*
2 * (C) Copyright 2011 HALE electronic <helmut.raiger@hale.at>
3 * (C) Copyright 2009 Magnus Lilja <lilja.magnus@gmail.com>
4 * (c) 2007 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <common.h>
26#include <netdev.h>
27#include <command.h>
28#include <pmic.h>
29#include <asm/arch/clock.h>
30#include <asm/arch/sys_proto.h>
31#include <asm/io.h>
32
33DECLARE_GLOBAL_DATA_PTR;
34
35#define BOARD_STRING "Board: HALE TT-01"
36
37/* Clock configuration */
38#define CCM_CCMR_SETUP 0x074B0BF5
39
40static void board_setup_clocks(void)
41{
42 struct clock_control_regs *ccm = (struct clock_control_regs *) CCM_BASE;
43 volatile int wait = 0x10000;
44
45 writel(CCM_CCMR_SETUP, &ccm->ccmr);
46 while (wait--)
47 ;
48
49 writel(CCM_CCMR_SETUP | CCMR_MPE, &ccm->ccmr);
50 writel((CCM_CCMR_SETUP | CCMR_MPE) & ~CCMR_MDS, &ccm->ccmr);
51
52 /* Set up clock to 532MHz */
53 writel(PDR0_CSI_PODF(0x1ff) | PDR0_PER_PODF(7) |
54 PDR0_HSP_PODF(3) | PDR0_NFC_PODF(5) |
55 PDR0_IPG_PODF(1) | PDR0_MAX_PODF(3) |
56 PDR0_MCU_PODF(0), &ccm->pdr0);
57 writel(PLL_PD(0) | PLL_MFD(51) | PLL_MFI(10) | PLL_MFN(12),
58 &ccm->mpctl);
59 writel(PLL_PD(1) | PLL_MFD(4) | PLL_MFI(12) | PLL_MFN(1),
60 &ccm->spctl);
61}
62
63/* DRAM configuration */
64
65#define ESDMISC_MDDR_SETUP 0x00000004
66#define ESDMISC_MDDR_RESET_DL 0x0000000c
67/*
68 * decoding magic 0x6ac73a = 0b 0110 1010 1100 0111 0011 1010 below:
69 * tXP = 11, tWTR = 0, tRP = 10, tMRD = 10
70 * tWR = 1, tRAS = 100, tRRD = 01, tCAS = 11
71 * tRCD = 011, tRC = 010
72 * note: all but tWTR (1), tRC (111) are reset defaults,
73 * the same values work in the jtag configuration
74 *
75 * Bluetechnix setup has 0x75e73a (for 128MB) =
76 * 0b 0111 0101 1110 0111 0011 1010
77 * tXP = 11, tWTR = 1, tRP = 01, tMRD = 01
78 * tWR = 1, tRAS = 110, tRRD = 01, tCAS = 11
79 * tRCD = 011, tRC = 010
80 */
81#define ESDCFG0_MDDR_SETUP 0x006ac73a
82#define ESDCTL_ROW_COL (ESDCTL_SDE | ESDCTL_ROW(2) | ESDCTL_COL(2))
83#define ESDCTL_SETTINGS (ESDCTL_ROW_COL | ESDCTL_SREFR(3) | \
84 ESDCTL_DSIZ(2) | ESDCTL_BL(1))
85#define ESDCTL_PRECHARGE (ESDCTL_ROW_COL | ESDCTL_CMD_PRECHARGE)
86#define ESDCTL_AUTOREFRESH (ESDCTL_ROW_COL | ESDCTL_CMD_AUTOREFRESH)
87#define ESDCTL_LOADMODEREG (ESDCTL_ROW_COL | ESDCTL_CMD_LOADMODEREG)
88#define ESDCTL_RW ESDCTL_SETTINGS
89
90static void board_setup_sdram(void)
91{
92 u32 *pad;
93 struct esdc_regs *esdc = (struct esdc_regs *)ESDCTL_BASE_ADDR;
94
95 /*
96 * setup pad control for the controller pins
97 * no loopback, no pull, no keeper, no open drain,
98 * standard input, standard drive, slow slew rate
99 */
100 for (pad = (u32 *) IOMUXC_SW_PAD_CTL_SDCKE1_SDCLK_SDCLK_B;
101 pad <= (u32 *) IOMUXC_SW_PAD_CTL_VPG0_VPG1_A0; pad++)
102 *pad = 0;
103
104 /* set up MX31 DDR Memory Controller */
105 writel(ESDMISC_MDDR_SETUP, &esdc->misc);
106 writel(ESDCFG0_MDDR_SETUP, &esdc->cfg0);
107
108 /* perform DDR init sequence for CSD0 */
109 writel(ESDCTL_PRECHARGE, &esdc->ctl0);
110 writel(0x12344321, CSD0_BASE+0x0f00);
111 writel(ESDCTL_AUTOREFRESH, &esdc->ctl0);
112 writel(0x12344321, CSD0_BASE);
113 writel(0x12344321, CSD0_BASE);
114 writel(ESDCTL_LOADMODEREG, &esdc->ctl0);
115 writeb(0xda, CSD0_BASE+0x33);
116 writeb(0xff, CSD0_BASE+0x1000000);
117 writel(ESDCTL_RW, &esdc->ctl0);
118 writel(0xDEADBEEF, CSD0_BASE);
119 writel(ESDMISC_MDDR_RESET_DL, &esdc->misc);
120}
121
122static void tt01_spi3_hw_init(void)
123{
124 /* CSPI3 */
125 mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_MISO, MUX_CTL_FUNC));
126 mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_MOSI, MUX_CTL_FUNC));
127 mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_SCLK, MUX_CTL_FUNC));
128 /* CSPI3, SS0 = Atlas */
129 mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI2_SS0, MUX_CTL_ALT1));
130
131 /* start CSPI3 clock (3 = always on except if PLL off) */
132 setbits_le32(CCM_CGR0, 3 << 16);
133}
134
135int dram_init(void)
136{
137 /* dram_init must store complete ramsize in gd->ram_size */
138 gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE,
139 PHYS_SDRAM_1_SIZE);
140 return 0;
141}
142
143int board_early_init_f(void)
144{
145 /* CS4: FPGA incl. network controller */
146 struct mxc_weimcs cs4 = {
147 /* sp wp bcd bcs psz pme sync dol cnc wsc ew wws edc */
148 CSCR_U(0, 0, 0, 0, 0, 0, 0, 0, 3, 28, 1, 7, 6),
149 /* oea oen ebwa ebwn csa ebc dsz csn psr cre wrap csen */
150 CSCR_L(4, 4, 4, 10, 4, 0, 5, 4, 0, 0, 0, 1),
151 /* ebra ebrn rwa rwn mum lah lbn lba dww dct wwu age cnc2 fce*/
152 CSCR_A(4, 4, 4, 4, 0, 1, 4, 3, 0, 0, 0, 0, 1, 0)
153 };
154
155 /* this seems essential, won't start without, but why? */
156 writel(IPU_CONF_DI_EN, (u32 *) IPU_CONF);
157
158 board_setup_clocks();
159 board_setup_sdram();
160 mxc_setup_weimcs(4, &cs4);
161
162 /* Setup UART2 and SPI3 pins */
163 mx31_uart2_hw_init();
164 tt01_spi3_hw_init();
165
166 return 0;
167}
168
169int board_init(void)
170{
171 /* address of boot parameters */
172 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
173 return 0;
174}
175
176int board_late_init(void)
177{
178 pmic_init();
179
180#ifdef CONFIG_HW_WATCHDOG
181 mxc_hw_watchdog_enable();
182#endif
183
184 return 0;
185}
186
187int checkboard(void)
188{
189 puts(BOARD_STRING "\n");
190 return 0;
191}
192
193int board_eth_init(bd_t *bis)
194{
195 int rc = 0;
196#ifdef CONFIG_SMC911X
197 rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
198#endif
199 return rc;
200}