Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2005 2N TELEKOMUNIKACE, Ladislav Michl |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
Ladislav Michl | 04531f3 | 2009-03-25 23:43:58 +0100 | [diff] [blame] | 24 | #include <i2c.h> |
Ladislav Michl | 71f7bd3 | 2009-03-25 23:43:50 +0100 | [diff] [blame] | 25 | #include <flash.h> |
Ladislav Michl | 0fc4f64 | 2009-03-31 13:43:10 +0200 | [diff] [blame] | 26 | #include <nand.h> |
| 27 | |
| 28 | #include <asm/io.h> |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 29 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 32 | int board_init(void) |
| 33 | { |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 34 | /* arch number of NetStar board */ |
Stefan Roese | 1265581 | 2006-10-28 17:12:58 +0200 | [diff] [blame] | 35 | gd->bd->bi_arch_number = MACH_TYPE_NETSTAR; |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 36 | |
| 37 | /* adress of boot parameters */ |
| 38 | gd->bd->bi_boot_params = 0x10000100; |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | int dram_init(void) |
| 44 | { |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 45 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 46 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 47 | |
| 48 | /* Take the Ethernet controller out of reset and wait |
| 49 | * for the EEPROM load to complete. */ |
| 50 | *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80; |
Jean-Christophe PLAGNIOL-VILLARD | b54384e | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 51 | udelay(10); /* doesn't work before timer_init call */ |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 52 | *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80; |
| 53 | udelay(500); |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 58 | int misc_init_r(void) |
| 59 | { |
Ladislav Michl | 04531f3 | 2009-03-25 23:43:58 +0100 | [diff] [blame] | 60 | #if defined(CONFIG_RTC_DS1307) |
| 61 | /* enable trickle charge */ |
| 62 | i2c_reg_write(CONFIG_SYS_I2C_RTC_ADDR, 0x10, 0xaa); |
| 63 | #endif |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | |
Wolfgang Denk | ac7eb8a3 | 2005-09-14 23:53:32 +0200 | [diff] [blame] | 67 | int board_late_init(void) |
| 68 | { |
| 69 | return 0; |
| 70 | } |
Ladislav Michl | 71f7bd3 | 2009-03-25 23:43:50 +0100 | [diff] [blame] | 71 | |
| 72 | #if defined(CONFIG_CMD_FLASH) |
| 73 | ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t * info) |
| 74 | { |
| 75 | if (banknum == 0) { /* AM29LV800 boot flash */ |
| 76 | info->portwidth = FLASH_CFI_16BIT; |
| 77 | info->chipwidth = FLASH_CFI_BY16; |
| 78 | info->interface = FLASH_CFI_X16; |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | #endif |
Ladislav Michl | 0fc4f64 | 2009-03-31 13:43:10 +0200 | [diff] [blame] | 85 | |
| 86 | #if defined(CONFIG_CMD_NAND) |
| 87 | /* |
| 88 | * hardware specific access to control-lines |
| 89 | * |
| 90 | * NAND_NCE: bit 0 - don't care |
| 91 | * NAND_CLE: bit 1 -> bit 1 (0x0002) |
| 92 | * NAND_ALE: bit 2 -> bit 2 (0x0004) |
| 93 | */ |
| 94 | static void netstar_nand_hwcontrol(struct mtd_info *mtd, int cmd, |
| 95 | unsigned int ctrl) |
| 96 | { |
| 97 | struct nand_chip *chip = mtd->priv; |
| 98 | unsigned long mask; |
| 99 | |
| 100 | if (cmd == NAND_CMD_NONE) |
| 101 | return; |
| 102 | |
| 103 | mask = (ctrl & NAND_CLE) ? 0x02 : 0; |
| 104 | if (ctrl & NAND_ALE) |
| 105 | mask |= 0x04; |
| 106 | writeb(cmd, (unsigned long)chip->IO_ADDR_W | mask); |
| 107 | } |
| 108 | |
| 109 | int board_nand_init(struct nand_chip *nand) |
| 110 | { |
| 111 | nand->options = NAND_SAMSUNG_LP_OPTIONS; |
| 112 | nand->ecc.mode = NAND_ECC_SOFT; |
| 113 | nand->cmd_ctrl = netstar_nand_hwcontrol; |
| 114 | nand->chip_delay = 400; |
| 115 | return 0; |
| 116 | } |
| 117 | #endif |