blob: e5a958f7e0cb9c077e84117859113dd27c868efc [file] [log] [blame]
David Brownell28b00322009-05-15 23:48:37 +02001/*
2 * Copyright (C) 2009 David Brownell
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
David Brownell28b00322009-05-15 23:48:37 +02005 */
6
7#include <common.h>
8#include <nand.h>
9#include <asm/io.h>
10#include <asm/arch/hardware.h>
Khoronzhuk, Ivan3e01ed02014-06-07 04:22:52 +030011#include <asm/ti-common/davinci_nand.h>
Sughosh Ganud7f9b502010-11-28 20:21:27 -050012#include <asm/arch/davinci_misc.h>
Sandeep Paulrajb3af1d62009-08-10 12:24:40 -040013#include <net.h>
14#include <netdev.h>
Sandeep Paulraj073eacf2010-12-18 18:14:49 -050015#ifdef CONFIG_DAVINCI_MMC
16#include <mmc.h>
17#include <asm/arch/sdmmc_defs.h>
18#endif
David Brownell28b00322009-05-15 23:48:37 +020019
20DECLARE_GLOBAL_DATA_PTR;
21
22/*
23 * With the DM355 EVM, u-boot is *always* a third stage loader,
24 * unless a JTAG debugger handles the first two stages:
25 *
26 * - 1st stage is ROM Boot Loader (RBL), which searches for a
27 * second stage loader in one of three places based on SW7:
28 * NAND (with MMC/SD fallback), MMC/SD, or UART.
29 *
30 * - 2nd stage is User Boot Loader (UBL), using at most 30KB
31 * of on-chip SRAM, responsible for lowlevel init, and for
32 * loading the third stage loader into DRAM.
33 *
34 * - 3rd stage, that's us!
35 */
36
37int board_init(void)
38{
39 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM355_EVM;
40 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
41
42 /* We expect the UBL to have handled "lowlevel init", which
43 * involves setting up at least:
44 * - clocks
45 * + PLL1 (for ARM and peripherals) and PLL2 (for DDR)
46 * + clock divisors for those PLLs
47 * + LPSC_DDR module enabled
48 * + LPSC_TIMER0 module (still) enabled
49 * - EMIF
50 * + DDR init and timings
51 * + AEMIF timings (for NAND and DM9000)
52 * - pinmux
53 *
54 * Some of that is repeated here, mostly as a precaution.
55 */
56
57 /* AEMIF: Some "address" lines are available as GPIOs. A3..A13
58 * could be too if we used A12 as a GPIO during NAND chipselect
59 * (and Linux did too), letting us control the LED on A7/GPIO61.
60 */
61 REG(PINMUX2) = 0x0c08;
62
63 /* UART0 may still be in SyncReset if we didn't boot from UART */
64 davinci_enable_uart0();
65
66 /* EDMA may be in SyncReset too; turn it on, Linux won't (yet) */
67 lpsc_on(DAVINCI_LPSC_TPCC);
68 lpsc_on(DAVINCI_LPSC_TPTC0);
69 lpsc_on(DAVINCI_LPSC_TPTC1);
70
71 return 0;
72}
73
Sandeep Paulrajb3af1d62009-08-10 12:24:40 -040074#ifdef CONFIG_DRIVER_DM9000
75int board_eth_init(bd_t *bis)
76{
77 return dm9000_initialize(bis);
78}
79#endif
80
David Brownell28b00322009-05-15 23:48:37 +020081#ifdef CONFIG_NAND_DAVINCI
82
83static void nand_dm355evm_select_chip(struct mtd_info *mtd, int chip)
84{
85 struct nand_chip *this = mtd->priv;
Sandeep Paulraj6fe5e872009-10-01 20:21:13 -040086 unsigned long wbase = (unsigned long) this->IO_ADDR_W;
87 unsigned long rbase = (unsigned long) this->IO_ADDR_R;
David Brownell28b00322009-05-15 23:48:37 +020088
89 if (chip == 1) {
90 __set_bit(14, &wbase);
91 __set_bit(14, &rbase);
92 } else {
93 __clear_bit(14, &wbase);
94 __clear_bit(14, &rbase);
95 }
96 this->IO_ADDR_W = (void *)wbase;
97 this->IO_ADDR_R = (void *)rbase;
98}
99
100int board_nand_init(struct nand_chip *nand)
101{
102 davinci_nand_init(nand);
103 nand->select_chip = nand_dm355evm_select_chip;
104 return 0;
105}
106
107#endif
Sandeep Paulraj073eacf2010-12-18 18:14:49 -0500108
109#ifdef CONFIG_DAVINCI_MMC
110static struct davinci_mmc mmc_sd0 = {
111 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
112 .input_clk = 108000000,
113 .host_caps = MMC_MODE_4BIT,
114 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
115 .version = MMC_CTLR_VERSION_1,
116};
117
118#ifdef CONFIG_DAVINCI_MMC_SD1
119static struct davinci_mmc mmc_sd1 = {
120 .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD1_BASE,
121 .input_clk = 108000000,
122 .host_caps = MMC_MODE_4BIT,
123 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
124 .version = MMC_CTLR_VERSION_1,
125};
126#endif
127
128int board_mmc_init(bd_t *bis)
129{
130 int err;
131
132 /* Add slot-0 to mmc subsystem */
133 err = davinci_mmc_init(bis, &mmc_sd0);
134 if (err)
135 return err;
136
137#ifdef CONFIG_DAVINCI_MMC_SD1
138 /* Add slot-1 to mmc subsystem */
139 err = davinci_mmc_init(bis, &mmc_sd1);
140#endif
141
142 return err;
143}
144#endif