Sergey Kubushyn | e8f3912 | 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 | * ---------------------------------------------------------------------------- |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 12 | * ---------------------------------------------------------------------------- |
| 13 | */ |
| 14 | |
| 15 | #include <common.h> |
David Brownell | f4b0b9d | 2009-05-10 15:43:01 -0700 | [diff] [blame] | 16 | #include <nand.h> |
Khoronzhuk, Ivan | 753a00a | 2014-06-07 04:22:52 +0300 | [diff] [blame] | 17 | #include <asm/ti-common/davinci_nand.h> |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 18 | #include <asm/arch/hardware.h> |
Sughosh Ganu | 80995f9 | 2010-11-28 20:21:27 -0500 | [diff] [blame] | 19 | #include <asm/arch/davinci_misc.h> |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 20 | |
Dirk Behme | f2b171c | 2007-09-15 11:55:42 +0200 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 23 | int board_init(void) |
| 24 | { |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 25 | /* address of boot parameters */ |
| 26 | gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR; |
| 27 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 28 | /* 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 Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 33 | |
| 34 | /* Power on required peripherals */ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 35 | lpsc_on(DAVINCI_LPSC_GPIO); |
| 36 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | #if !defined(CONFIG_SYS_USE_DSPLINK) |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 38 | /* Powerup the DSP */ |
| 39 | dsp_on(); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | #endif /* CONFIG_SYS_USE_DSPLINK */ |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 41 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 42 | davinci_enable_uart0(); |
| 43 | davinci_enable_emac(); |
| 44 | davinci_enable_i2c(); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 45 | |
Hugo Villeneuve | c9a2137 | 2008-11-21 14:35:56 -0500 | [diff] [blame] | 46 | lpsc_on(DAVINCI_LPSC_TIMER1); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 47 | timer_init(); |
| 48 | |
| 49 | return(0); |
| 50 | } |
| 51 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 52 | int misc_init_r(void) |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 53 | { |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 54 | uint8_t eeprom_enetaddr[6]; |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 55 | |
Hugo Villeneuve | 4e352ef | 2008-07-11 15:10:13 -0400 | [diff] [blame] | 56 | /* Read Ethernet MAC address from EEPROM if available. */ |
| 57 | if (dvevm_read_mac_address(eeprom_enetaddr)) |
Ben Gardiner | 1fb49e3 | 2010-09-23 09:58:43 -0400 | [diff] [blame] | 58 | davinci_sync_env_enetaddr(eeprom_enetaddr); |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 59 | |
Sergey Kubushyn | e8f3912 | 2007-08-10 20:26:18 +0200 | [diff] [blame] | 60 | return(0); |
| 61 | } |
David Brownell | f4b0b9d | 2009-05-10 15:43:01 -0700 | [diff] [blame] | 62 | |
| 63 | #ifdef CONFIG_NAND_DAVINCI |
| 64 | |
| 65 | /* Set WP on deselect, write enable on select */ |
| 66 | static 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 | |
| 80 | int 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 */ |