blob: f5c3258de563326bb02a5d8d498d9e2fef87dcc1 [file] [log] [blame]
Sergey Kubushyne8f39122007-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 Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Sergey Kubushyne8f39122007-08-10 20:26:18 +020012 * ----------------------------------------------------------------------------
13 */
14
15#include <common.h>
David Brownellf4b0b9d2009-05-10 15:43:01 -070016#include <nand.h>
Khoronzhuk, Ivan753a00a2014-06-07 04:22:52 +030017#include <asm/ti-common/davinci_nand.h>
Sergey Kubushyne8f39122007-08-10 20:26:18 +020018#include <asm/arch/hardware.h>
Sughosh Ganu80995f92010-11-28 20:21:27 -050019#include <asm/arch/davinci_misc.h>
Sergey Kubushyne8f39122007-08-10 20:26:18 +020020
Dirk Behmef2b171c2007-09-15 11:55:42 +020021DECLARE_GLOBAL_DATA_PTR;
22
Sergey Kubushyne8f39122007-08-10 20:26:18 +020023int board_init(void)
24{
Sergey Kubushyne8f39122007-08-10 20:26:18 +020025 /* address of boot parameters */
26 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
27
Hugo Villeneuvec9a21372008-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 Kubushyne8f39122007-08-10 20:26:18 +020033
34 /* Power on required peripherals */
Sergey Kubushyne8f39122007-08-10 20:26:18 +020035 lpsc_on(DAVINCI_LPSC_GPIO);
36
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020037#if !defined(CONFIG_SYS_USE_DSPLINK)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020038 /* Powerup the DSP */
39 dsp_on();
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020040#endif /* CONFIG_SYS_USE_DSPLINK */
Sergey Kubushyne8f39122007-08-10 20:26:18 +020041
Hugo Villeneuvec9a21372008-11-21 14:35:56 -050042 davinci_enable_uart0();
43 davinci_enable_emac();
44 davinci_enable_i2c();
Sergey Kubushyne8f39122007-08-10 20:26:18 +020045
Hugo Villeneuvec9a21372008-11-21 14:35:56 -050046 lpsc_on(DAVINCI_LPSC_TIMER1);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020047 timer_init();
48
49 return(0);
50}
51
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040052int misc_init_r(void)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020053{
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040054 uint8_t eeprom_enetaddr[6];
Sergey Kubushyne8f39122007-08-10 20:26:18 +020055
Hugo Villeneuve4e352ef2008-07-11 15:10:13 -040056 /* Read Ethernet MAC address from EEPROM if available. */
57 if (dvevm_read_mac_address(eeprom_enetaddr))
Ben Gardiner1fb49e32010-09-23 09:58:43 -040058 davinci_sync_env_enetaddr(eeprom_enetaddr);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020059
Sergey Kubushyne8f39122007-08-10 20:26:18 +020060 return(0);
61}
David Brownellf4b0b9d2009-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 */