blob: f5c3258de563326bb02a5d8d498d9e2fef87dcc1 [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 * ----------------------------------------------------------------------------
Wolfgang Denk1a459662013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Sergey Kubushync74b2102007-08-10 20:26:18 +020012 * ----------------------------------------------------------------------------
13 */
14
15#include <common.h>
David Brownell154b5482009-05-10 15:43:01 -070016#include <nand.h>
Khoronzhuk, Ivan3e01ed02014-06-07 04:22:52 +030017#include <asm/ti-common/davinci_nand.h>
Sergey Kubushync74b2102007-08-10 20:26:18 +020018#include <asm/arch/hardware.h>
Sughosh Ganud7f9b502010-11-28 20:21:27 -050019#include <asm/arch/davinci_misc.h>
Sergey Kubushync74b2102007-08-10 20:26:18 +020020
Dirk Behme66b3f242007-09-15 11:55:42 +020021DECLARE_GLOBAL_DATA_PTR;
22
Sergey Kubushync74b2102007-08-10 20:26:18 +020023int board_init(void)
24{
Sergey Kubushync74b2102007-08-10 20:26:18 +020025 /* address of boot parameters */
26 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
27
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050028 /* Configure AEMIF pins (although this should be configured at boot time
29 * with pull-up/pull-down resistors) */
30 REG(PINMUX0) = 0x00000c1f;
31
32 davinci_errata_workarounds();
Sergey Kubushync74b2102007-08-10 20:26:18 +020033
34 /* Power on required peripherals */
Sergey Kubushync74b2102007-08-10 20:26:18 +020035 lpsc_on(DAVINCI_LPSC_GPIO);
36
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020037#if !defined(CONFIG_SYS_USE_DSPLINK)
Sergey Kubushync74b2102007-08-10 20:26:18 +020038 /* Powerup the DSP */
39 dsp_on();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020040#endif /* CONFIG_SYS_USE_DSPLINK */
Sergey Kubushync74b2102007-08-10 20:26:18 +020041
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050042 davinci_enable_uart0();
43 davinci_enable_emac();
44 davinci_enable_i2c();
Sergey Kubushync74b2102007-08-10 20:26:18 +020045
Hugo Villeneuve0cd18fa2008-11-21 14:35:56 -050046 lpsc_on(DAVINCI_LPSC_TIMER1);
Sergey Kubushync74b2102007-08-10 20:26:18 +020047 timer_init();
48
49 return(0);
50}
51
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040052int misc_init_r(void)
Sergey Kubushync74b2102007-08-10 20:26:18 +020053{
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040054 uint8_t eeprom_enetaddr[6];
Sergey Kubushync74b2102007-08-10 20:26:18 +020055
Hugo Villeneuve264bbdd2008-07-11 15:10:13 -040056 /* Read Ethernet MAC address from EEPROM if available. */
57 if (dvevm_read_mac_address(eeprom_enetaddr))
Ben Gardiner7b37a272010-09-23 09:58:43 -040058 davinci_sync_env_enetaddr(eeprom_enetaddr);
Sergey Kubushync74b2102007-08-10 20:26:18 +020059
Sergey Kubushync74b2102007-08-10 20:26:18 +020060 return(0);
61}
David Brownell154b5482009-05-10 15:43:01 -070062
63#ifdef CONFIG_NAND_DAVINCI
64
65/* Set WP on deselect, write enable on select */
66static void nand_sonata_select_chip(struct mtd_info *mtd, int chip)
67{
68#define GPIO_SET_DATA01 0x01c67018
69#define GPIO_CLR_DATA01 0x01c6701c
70#define GPIO_NAND_WP (1 << 4)
71#ifdef SONATA_BOARD_GPIOWP
72 if (chip < 0) {
73 REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP;
74 } else {
75 REG(GPIO_SET_DATA01) |= GPIO_NAND_WP;
76 }
77#endif
78}
79
80int board_nand_init(struct nand_chip *nand)
81{
82 davinci_nand_init(nand);
83 nand->select_chip = nand_sonata_select_chip;
84 return 0;
85}
86
87#endif /* CONFIG_NAND_DAVINCI */