Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 1 | /* |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 2 | * U-boot - main board file |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 3 | * |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 5 | * |
| 6 | * (C) Copyright 2000-2004 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
Aubrey Li | 155fd76 | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 25 | * MA 02110-1301 USA |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <config.h> |
| 30 | #include <command.h> |
| 31 | #include <asm/blackfin.h> |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 32 | #include <asm/net.h> |
Jean-Christophe PLAGNIOL-VILLARD | b8f4162 | 2007-12-10 22:32:14 +0100 | [diff] [blame] | 33 | #include <net.h> |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 34 | #include <asm/mach-common/bits/bootrom.h> |
Ben Warren | 89973f8 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 35 | #include <netdev.h> |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 36 | |
Wolfgang Denk | 1218abf | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 39 | int checkboard(void) |
| 40 | { |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 41 | printf("Board: ADI BF537 stamp board\n"); |
| 42 | printf(" Support: http://blackfin.uclinux.org/\n"); |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | #if defined(CONFIG_BFIN_IDE) |
| 47 | |
| 48 | void cf_outb(unsigned char val, volatile unsigned char *addr) |
| 49 | { |
| 50 | *(addr) = val; |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 51 | SSYNC(); |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | unsigned char cf_inb(volatile unsigned char *addr) |
| 55 | { |
| 56 | volatile unsigned char c; |
| 57 | |
| 58 | c = *(addr); |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 59 | SSYNC(); |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 60 | |
| 61 | return c; |
| 62 | } |
| 63 | |
| 64 | void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words) |
| 65 | { |
| 66 | int i; |
| 67 | |
| 68 | for (i = 0; i < words; i++) |
| 69 | *(sect_buf + i) = *(addr); |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 70 | SSYNC(); |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words) |
| 74 | { |
| 75 | int i; |
| 76 | |
| 77 | for (i = 0; i < words; i++) |
| 78 | *(addr) = *(sect_buf + i); |
Mike Frysinger | d4d7730 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 79 | SSYNC(); |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 80 | } |
| 81 | #endif /* CONFIG_BFIN_IDE */ |
| 82 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 83 | phys_size_t initdram(int board_type) |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 84 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; |
| 86 | gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE; |
Mike Frysinger | 41f3325 | 2008-10-11 20:31:17 -0400 | [diff] [blame] | 87 | return gd->bd->bi_memsize; |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 88 | } |
| 89 | |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 90 | void board_reset(void) |
| 91 | { |
| 92 | /* workaround for weak pull ups on ssel */ |
| 93 | if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER) { |
| 94 | bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~PF10); |
| 95 | bfin_write_PORTFIO_SET(PF10); |
| 96 | udelay(1); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | #ifdef CONFIG_BFIN_MAC |
| 101 | static void board_init_enetaddr(uchar *mac_addr) |
| 102 | { |
| 103 | #ifdef CONFIG_SYS_NO_FLASH |
| 104 | # define USE_MAC_IN_FLASH 0 |
| 105 | #else |
| 106 | # define USE_MAC_IN_FLASH 1 |
| 107 | #endif |
| 108 | bool valid_mac = false; |
| 109 | |
| 110 | if (USE_MAC_IN_FLASH) { |
| 111 | /* we cram the MAC in the last flash sector */ |
| 112 | uchar *board_mac_addr = (uchar *)0x203F0000; |
| 113 | if (is_valid_ether_addr(board_mac_addr)) { |
| 114 | memcpy(mac_addr, board_mac_addr, 6); |
| 115 | valid_mac = true; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (!valid_mac) { |
| 120 | puts("Warning: Generating 'random' MAC address\n"); |
| 121 | bfin_gen_rand_mac(mac_addr); |
| 122 | } |
| 123 | |
| 124 | eth_setenv_enetaddr("ethaddr", mac_addr); |
| 125 | } |
| 126 | |
| 127 | int board_eth_init(bd_t *bis) |
| 128 | { |
| 129 | return bfin_EMAC_initialize(bis); |
| 130 | } |
| 131 | #endif |
| 132 | |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 133 | #if defined(CONFIG_MISC_INIT_R) |
| 134 | /* miscellaneous platform dependent initialisations */ |
| 135 | int misc_init_r(void) |
| 136 | { |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 137 | #ifdef CONFIG_BFIN_MAC |
| 138 | uchar enetaddr[6]; |
| 139 | if (!eth_getenv_enetaddr("ethaddr", enetaddr)) |
| 140 | board_init_enetaddr(enetaddr); |
| 141 | #endif |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 142 | |
Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 143 | #ifndef CONFIG_SYS_NO_FLASH |
| 144 | /* we use the last sector for the MAC address / POST LDR */ |
| 145 | extern flash_info_t flash_info[]; |
| 146 | flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]); |
Jon Loeliger | fcec2eb | 2007-07-09 18:19:09 -0500 | [diff] [blame] | 147 | #endif |
Aubrey Li | 26bf7de | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 148 | |
| 149 | #if defined(CONFIG_BFIN_IDE) |
| 150 | #if defined(CONFIG_BFIN_TRUE_IDE) |
| 151 | /* Enable ATASEL when in True IDE mode */ |
| 152 | printf("Using CF True IDE Mode\n"); |
| 153 | cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA); |
| 154 | udelay(1000); |
| 155 | #elif defined(CONFIG_BFIN_CF_IDE) |
| 156 | /* Disable ATASEL when we're in Common Memory Mode */ |
| 157 | printf("Using CF Common Memory Mode\n"); |
| 158 | cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS); |
| 159 | udelay(1000); |
| 160 | #elif defined(CONFIG_BFIN_HDD_IDE) |
| 161 | printf("Using HDD IDE Mode\n"); |
| 162 | #endif |
| 163 | ide_init(); |
| 164 | #endif /* CONFIG_BFIN_IDE */ |
| 165 | return 0; |
| 166 | } |
| 167 | #endif /* CONFIG_MISC_INIT_R */ |