Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 1 | /* |
| 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 Brownell | 154b548 | 2009-05-10 15:43:01 -0700 | [diff] [blame] | 28 | #include <nand.h> |
| 29 | #include <asm/arch/nand_defs.h> |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 30 | #include <asm/arch/hardware.h> |
Sughosh Ganu | d7f9b50 | 2010-11-28 20:21:27 -0500 | [diff] [blame] | 31 | #include <asm/arch/davinci_misc.h> |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 32 | |
Dirk Behme | 66b3f24 | 2007-09-15 11:55:42 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 35 | int board_init(void) |
| 36 | { |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 37 | /* address of boot parameters */ |
| 38 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 39 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 40 | /* Configure AEMIF pins (although this should be configured at boot time |
| 41 | * with pull-up/pull-down resistors) */ |
| 42 | REG(PINMUX0) = 0x00000c1f; |
| 43 | |
| 44 | davinci_errata_workarounds(); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 45 | |
| 46 | /* Power on required peripherals */ |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 47 | lpsc_on(DAVINCI_LPSC_GPIO); |
| 48 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | #if !defined(CONFIG_SYS_USE_DSPLINK) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 50 | /* Powerup the DSP */ |
| 51 | dsp_on(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #endif /* CONFIG_SYS_USE_DSPLINK */ |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 53 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 54 | davinci_enable_uart0(); |
| 55 | davinci_enable_emac(); |
| 56 | davinci_enable_i2c(); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 57 | |
Hugo Villeneuve | 0cd18fa | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 58 | lpsc_on(DAVINCI_LPSC_TIMER1); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 59 | timer_init(); |
| 60 | |
| 61 | return(0); |
| 62 | } |
| 63 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 64 | int misc_init_r(void) |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 65 | { |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 66 | uint8_t eeprom_enetaddr[6]; |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 67 | |
Hugo Villeneuve | 264bbdd | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 68 | /* Read Ethernet MAC address from EEPROM if available. */ |
| 69 | if (dvevm_read_mac_address(eeprom_enetaddr)) |
Ben Gardiner | 7b37a27 | 2010-09-23 09:58:43 -0400 | [diff] [blame] | 70 | davinci_sync_env_enetaddr(eeprom_enetaddr); |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 71 | |
Sergey Kubushyn | c74b210 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 72 | return(0); |
| 73 | } |
David Brownell | 154b548 | 2009-05-10 15:43:01 -0700 | [diff] [blame] | 74 | |
| 75 | #ifdef CONFIG_NAND_DAVINCI |
| 76 | |
| 77 | /* Set WP on deselect, write enable on select */ |
| 78 | static void nand_sonata_select_chip(struct mtd_info *mtd, int chip) |
| 79 | { |
| 80 | #define GPIO_SET_DATA01 0x01c67018 |
| 81 | #define GPIO_CLR_DATA01 0x01c6701c |
| 82 | #define GPIO_NAND_WP (1 << 4) |
| 83 | #ifdef SONATA_BOARD_GPIOWP |
| 84 | if (chip < 0) { |
| 85 | REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP; |
| 86 | } else { |
| 87 | REG(GPIO_SET_DATA01) |= GPIO_NAND_WP; |
| 88 | } |
| 89 | #endif |
| 90 | } |
| 91 | |
| 92 | int board_nand_init(struct nand_chip *nand) |
| 93 | { |
| 94 | davinci_nand_init(nand); |
| 95 | nand->select_chip = nand_sonata_select_chip; |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #endif /* CONFIG_NAND_DAVINCI */ |