blob: 1e3a14f490d5c769ebe55fdf8f496f7740a50523 [file] [log] [blame]
Sandeep Paulraj2d4072c2009-08-15 11:20:58 -04001/*
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 */
17
18#include <common.h>
19#include <nand.h>
Sandeep Paulraj4df30f32009-09-29 09:43:04 -040020#include <asm/io.h>
Sandeep Paulraj2d4072c2009-08-15 11:20:58 -040021#include <asm/arch/hardware.h>
22#include <asm/arch/emif_defs.h>
23#include <asm/arch/nand_defs.h>
Sandeep Paulraj4df30f32009-09-29 09:43:04 -040024#include <asm/arch/gpio_defs.h>
25#include <netdev.h>
Sandeep Paulraj2d4072c2009-08-15 11:20:58 -040026#include "../common/misc.h"
27
28DECLARE_GLOBAL_DATA_PTR;
29
30int board_init(void)
31{
32 gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM365_EVM;
33 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
34
35 return 0;
36}
37
Sandeep Paulraj4df30f32009-09-29 09:43:04 -040038#ifdef CONFIG_DRIVER_TI_EMAC
39int board_eth_init(bd_t *bis)
40{
41 uint8_t eeprom_enetaddr[6];
42 int i;
43 struct davinci_gpio *gpio1_base =
44 (struct davinci_gpio *)DAVINCI_GPIO_BANK01;
45
46 /* Configure PINMUX 3 to enable EMAC pins */
47 writel((readl(PINMUX3) | 0x1affff), PINMUX3);
48
49 /* Configure GPIO20 as output */
50 writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir);
51
52 /* Toggle GPIO 20 */
53 for (i = 0; i < 20; i++) {
54 /* GPIO 20 low */
55 writel((readl(&gpio1_base->out_data) & ~(1 << 20)),
56 &gpio1_base->out_data);
57
58 udelay(1000);
59
60 /* GPIO 20 high */
61 writel((readl(&gpio1_base->out_data) | (1 << 20)),
62 &gpio1_base->out_data);
63 }
64
65 /* Configure I2C pins so that EEPROM can be read */
66 writel((readl(PINMUX3) | 0x01400000), PINMUX3);
67
68 /* Read Ethernet MAC address from EEPROM */
69 if (dvevm_read_mac_address(eeprom_enetaddr))
70 dv_configure_mac_address(eeprom_enetaddr);
71
72 davinci_emac_initialize();
73
74 return 0;
75}
76#endif
77
Sandeep Paulraj2d4072c2009-08-15 11:20:58 -040078#ifdef CONFIG_NAND_DAVINCI
79static void nand_dm365evm_select_chip(struct mtd_info *mtd, int chip)
80{
81 struct nand_chip *this = mtd->priv;
Sandeep Paulrajd884f642009-10-01 20:22:09 -040082 unsigned long wbase = (unsigned long) this->IO_ADDR_W;
83 unsigned long rbase = (unsigned long) this->IO_ADDR_R;
Sandeep Paulraj2d4072c2009-08-15 11:20:58 -040084
85 if (chip == 1) {
86 __set_bit(14, &wbase);
87 __set_bit(14, &rbase);
88 } else {
89 __clear_bit(14, &wbase);
90 __clear_bit(14, &rbase);
91 }
92 this->IO_ADDR_W = (void *)wbase;
93 this->IO_ADDR_R = (void *)rbase;
94}
95
96int board_nand_init(struct nand_chip *nand)
97{
98 davinci_nand_init(nand);
99 nand->select_chip = nand_dm365evm_select_chip;
100 return 0;
101}
102#endif