David Brownell | 28b0032 | 2009-05-15 23:48:37 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2009 David Brownell |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 17 | */ |
| 18 | |
| 19 | #include <common.h> |
| 20 | #include <nand.h> |
| 21 | #include <asm/io.h> |
| 22 | #include <asm/arch/hardware.h> |
| 23 | #include <asm/arch/emif_defs.h> |
| 24 | #include <asm/arch/nand_defs.h> |
| 25 | #include "../common/misc.h" |
| 26 | |
| 27 | |
| 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
| 30 | /* |
| 31 | * With the DM355 EVM, u-boot is *always* a third stage loader, |
| 32 | * unless a JTAG debugger handles the first two stages: |
| 33 | * |
| 34 | * - 1st stage is ROM Boot Loader (RBL), which searches for a |
| 35 | * second stage loader in one of three places based on SW7: |
| 36 | * NAND (with MMC/SD fallback), MMC/SD, or UART. |
| 37 | * |
| 38 | * - 2nd stage is User Boot Loader (UBL), using at most 30KB |
| 39 | * of on-chip SRAM, responsible for lowlevel init, and for |
| 40 | * loading the third stage loader into DRAM. |
| 41 | * |
| 42 | * - 3rd stage, that's us! |
| 43 | */ |
| 44 | |
| 45 | int board_init(void) |
| 46 | { |
| 47 | gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM355_EVM; |
| 48 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 49 | |
| 50 | /* We expect the UBL to have handled "lowlevel init", which |
| 51 | * involves setting up at least: |
| 52 | * - clocks |
| 53 | * + PLL1 (for ARM and peripherals) and PLL2 (for DDR) |
| 54 | * + clock divisors for those PLLs |
| 55 | * + LPSC_DDR module enabled |
| 56 | * + LPSC_TIMER0 module (still) enabled |
| 57 | * - EMIF |
| 58 | * + DDR init and timings |
| 59 | * + AEMIF timings (for NAND and DM9000) |
| 60 | * - pinmux |
| 61 | * |
| 62 | * Some of that is repeated here, mostly as a precaution. |
| 63 | */ |
| 64 | |
| 65 | /* AEMIF: Some "address" lines are available as GPIOs. A3..A13 |
| 66 | * could be too if we used A12 as a GPIO during NAND chipselect |
| 67 | * (and Linux did too), letting us control the LED on A7/GPIO61. |
| 68 | */ |
| 69 | REG(PINMUX2) = 0x0c08; |
| 70 | |
| 71 | /* UART0 may still be in SyncReset if we didn't boot from UART */ |
| 72 | davinci_enable_uart0(); |
| 73 | |
| 74 | /* EDMA may be in SyncReset too; turn it on, Linux won't (yet) */ |
| 75 | lpsc_on(DAVINCI_LPSC_TPCC); |
| 76 | lpsc_on(DAVINCI_LPSC_TPTC0); |
| 77 | lpsc_on(DAVINCI_LPSC_TPTC1); |
| 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | #ifdef CONFIG_NAND_DAVINCI |
| 83 | |
| 84 | static void nand_dm355evm_select_chip(struct mtd_info *mtd, int chip) |
| 85 | { |
| 86 | struct nand_chip *this = mtd->priv; |
| 87 | u32 wbase = (u32) this->IO_ADDR_W; |
| 88 | u32 rbase = (u32) this->IO_ADDR_R; |
| 89 | |
| 90 | if (chip == 1) { |
| 91 | __set_bit(14, &wbase); |
| 92 | __set_bit(14, &rbase); |
| 93 | } else { |
| 94 | __clear_bit(14, &wbase); |
| 95 | __clear_bit(14, &rbase); |
| 96 | } |
| 97 | this->IO_ADDR_W = (void *)wbase; |
| 98 | this->IO_ADDR_R = (void *)rbase; |
| 99 | } |
| 100 | |
| 101 | int board_nand_init(struct nand_chip *nand) |
| 102 | { |
| 103 | davinci_nand_init(nand); |
| 104 | nand->select_chip = nand_dm355evm_select_chip; |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | #endif |