blob: c194290c09e88ab4125951b7d61a4683f4c23a3d [file] [log] [blame]
Sergey Kubushync74b2102007-08-10 20:26:18 +02001/*
2 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
3 *
4 * Parts are shamelessly stolen from various TI sources, original copyright
5 * follows:
6 * -----------------------------------------------------------------
7 *
8 * Copyright (C) 2004 Texas Instruments.
9 *
10 * ----------------------------------------------------------------------------
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * ----------------------------------------------------------------------------
25 */
26
27#include <common.h>
David Brownell154b5482009-05-10 15:43:01 -070028#include <nand.h>
29#include <asm/arch/nand_defs.h>
Sergey Kubushync74b2102007-08-10 20:26:18 +020030#include <asm/arch/hardware.h>
Sughosh Ganua63fbf62010-11-28 20:21:27 -050031#include <asm/arch/davinci_misc.h>
Sergey Kubushync74b2102007-08-10 20:26:18 +020032
Dirk Behme66b3f242007-09-15 11:55:42 +020033DECLARE_GLOBAL_DATA_PTR;
34
Sergey Kubushync74b2102007-08-10 20:26:18 +020035int board_init(void)
36{
Sergey Kubushync74b2102007-08-10 20:26:18 +020037 /* arch number of the board */
38 gd->bd->bi_arch_number = MACH_TYPE_SONATA;
39
40 /* address of boot parameters */
41 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
42
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050043 /* Configure AEMIF pins (although this should be configured at boot time
44 * with pull-up/pull-down resistors) */
45 REG(PINMUX0) = 0x00000c1f;
46
47 davinci_errata_workarounds();
Sergey Kubushync74b2102007-08-10 20:26:18 +020048
49 /* Power on required peripherals */
Sergey Kubushync74b2102007-08-10 20:26:18 +020050 lpsc_on(DAVINCI_LPSC_GPIO);
51
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052#if !defined(CONFIG_SYS_USE_DSPLINK)
Sergey Kubushync74b2102007-08-10 20:26:18 +020053 /* Powerup the DSP */
54 dsp_on();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020055#endif /* CONFIG_SYS_USE_DSPLINK */
Sergey Kubushync74b2102007-08-10 20:26:18 +020056
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050057 davinci_enable_uart0();
58 davinci_enable_emac();
59 davinci_enable_i2c();
Sergey Kubushync74b2102007-08-10 20:26:18 +020060
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050061 lpsc_on(DAVINCI_LPSC_TIMER1);
Sergey Kubushync74b2102007-08-10 20:26:18 +020062 timer_init();
63
64 return(0);
65}
66
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040067int misc_init_r(void)
Sergey Kubushync74b2102007-08-10 20:26:18 +020068{
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040069 uint8_t eeprom_enetaddr[6];
Sergey Kubushync74b2102007-08-10 20:26:18 +020070
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040071 /* Read Ethernet MAC address from EEPROM if available. */
72 if (dvevm_read_mac_address(eeprom_enetaddr))
Ben Gardiner7b37a272010-09-23 09:58:43 -040073 davinci_sync_env_enetaddr(eeprom_enetaddr);
Sergey Kubushync74b2102007-08-10 20:26:18 +020074
Sergey Kubushync74b2102007-08-10 20:26:18 +020075 return(0);
76}
David Brownell154b5482009-05-10 15:43:01 -070077
78#ifdef CONFIG_NAND_DAVINCI
79
80/* Set WP on deselect, write enable on select */
81static void nand_sonata_select_chip(struct mtd_info *mtd, int chip)
82{
83#define GPIO_SET_DATA01 0x01c67018
84#define GPIO_CLR_DATA01 0x01c6701c
85#define GPIO_NAND_WP (1 << 4)
86#ifdef SONATA_BOARD_GPIOWP
87 if (chip < 0) {
88 REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP;
89 } else {
90 REG(GPIO_SET_DATA01) |= GPIO_NAND_WP;
91 }
92#endif
93}
94
95int board_nand_init(struct nand_chip *nand)
96{
97 davinci_nand_init(nand);
98 nand->select_chip = nand_sonata_select_chip;
99 return 0;
100}
101
102#endif /* CONFIG_NAND_DAVINCI */