wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 4 | * Marius Groeger <mgroeger@sysgo.de> |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 26 | #include <asm/arch/AT91RM9200.h> |
Wolfgang Denk | bc650fa | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 27 | #include <at91rm9200_net.h> |
| 28 | #include <dm9161.h> |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 29 | |
| 30 | /* ------------------------------------------------------------------------- */ |
| 31 | /* |
| 32 | * Miscelaneous platform dependent initialisations |
| 33 | */ |
| 34 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 35 | int board_init (void) |
| 36 | { |
| 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
| 39 | /* Enable Ctrlc */ |
| 40 | console_init_f (); |
| 41 | |
| 42 | /* Correct IRDA resistor problem */ |
| 43 | /* Set PA23_TXD in Output */ |
| 44 | (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 45 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 46 | /* memory and cpu-speed are setup before relocation */ |
| 47 | /* so we do _nothing_ here */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 48 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 49 | /* arch number of AT91RM9200DK-Board */ |
wdenk | 767fbd4 | 2004-10-10 18:41:04 +0000 | [diff] [blame] | 50 | gd->bd->bi_arch_number = MACH_TYPE_AT91RM9200; |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 51 | /* adress of boot parameters */ |
| 52 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 53 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 54 | return 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 55 | } |
| 56 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 57 | int dram_init (void) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 58 | { |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 59 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 60 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 61 | gd->bd->bi_dram[0].start = PHYS_SDRAM; |
| 62 | gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; |
| 63 | return 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Wolfgang Denk | bc650fa | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 66 | #ifdef CONFIG_DRIVER_ETHER |
| 67 | #if (CONFIG_COMMANDS & CFG_CMD_NET) |
| 68 | |
| 69 | /* |
| 70 | * Name: |
| 71 | * at91rm9200_GetPhyInterface |
| 72 | * Description: |
| 73 | * Initialise the interface functions to the PHY |
| 74 | * Arguments: |
| 75 | * None |
| 76 | * Return value: |
| 77 | * None |
| 78 | */ |
| 79 | void at91rm9200_GetPhyInterface(AT91PS_PhyOps p_phyops) |
| 80 | { |
| 81 | p_phyops->Init = dm9161_InitPhy; |
| 82 | p_phyops->IsPhyConnected = dm9161_IsPhyConnected; |
| 83 | p_phyops->GetLinkSpeed = dm9161_GetLinkSpeed; |
| 84 | p_phyops->AutoNegotiate = dm9161_AutoNegotiate; |
| 85 | } |
| 86 | |
| 87 | #endif /* CONFIG_COMMANDS & CFG_CMD_NET */ |
| 88 | #endif /* CONFIG_DRIVER_ETHER */ |
| 89 | |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 90 | /* |
| 91 | * Disk On Chip (NAND) Millenium initialization. |
| 92 | * The NAND lives in the CS2* space |
| 93 | */ |
| 94 | #if (CONFIG_COMMANDS & CFG_CMD_NAND) |
wdenk | 934c4f8 | 2003-09-11 19:48:06 +0000 | [diff] [blame] | 95 | extern ulong nand_probe (ulong physadr); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 96 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 97 | #define AT91_SMARTMEDIA_BASE 0x40000000 /* physical address to access memory on NCS3 */ |
| 98 | void nand_init (void) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 99 | { |
| 100 | /* Setup Smart Media, fitst enable the address range of CS3 */ |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 101 | *AT91C_EBI_CSA |= AT91C_EBI_CS3A_SMC_SmartMedia; |
| 102 | /* set the bus interface characteristics based on |
| 103 | tDS Data Set up Time 30 - ns |
| 104 | tDH Data Hold Time 20 - ns |
| 105 | tALS ALE Set up Time 20 - ns |
| 106 | 16ns at 60 MHz ~= 3 */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 107 | /*memory mapping structures */ |
| 108 | #define SM_ID_RWH (5 << 28) |
| 109 | #define SM_RWH (1 << 28) |
| 110 | #define SM_RWS (0 << 24) |
| 111 | #define SM_TDF (1 << 8) |
| 112 | #define SM_NWS (3) |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 113 | AT91C_BASE_SMC2->SMC2_CSR[3] = (SM_RWH | SM_RWS | |
| 114 | AT91C_SMC2_ACSS_STANDARD | AT91C_SMC2_DBW_8 | |
| 115 | SM_TDF | AT91C_SMC2_WSEN | SM_NWS); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 116 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 117 | /* enable the SMOE line PC0=SMCE, A21=CLE, A22=ALE */ |
| 118 | *AT91C_PIOC_ASR = AT91C_PC0_BFCK | AT91C_PC1_BFRDY_SMOE | |
| 119 | AT91C_PC3_BFBAA_SMWE; |
| 120 | *AT91C_PIOC_PDR = AT91C_PC0_BFCK | AT91C_PC1_BFRDY_SMOE | |
| 121 | AT91C_PC3_BFBAA_SMWE; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 122 | |
| 123 | /* Configure PC2 as input (signal READY of the SmartMedia) */ |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 124 | *AT91C_PIOC_PER = AT91C_PC2_BFAVD; /* enable direct output enable */ |
| 125 | *AT91C_PIOC_ODR = AT91C_PC2_BFAVD; /* disable output */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 126 | |
| 127 | /* Configure PB1 as input (signal Card Detect of the SmartMedia) */ |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 128 | *AT91C_PIOB_PER = AT91C_PIO_PB1; /* enable direct output enable */ |
| 129 | *AT91C_PIOB_ODR = AT91C_PIO_PB1; /* disable output */ |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 130 | |
wdenk | 3203c8f | 2004-07-10 21:45:47 +0000 | [diff] [blame] | 131 | /* PIOB and PIOC clock enabling */ |
| 132 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; |
| 133 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOC; |
| 134 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 135 | if (*AT91C_PIOB_PDSR & AT91C_PIO_PB1) |
wdenk | 934c4f8 | 2003-09-11 19:48:06 +0000 | [diff] [blame] | 136 | printf (" No SmartMedia card inserted\n"); |
| 137 | #ifdef DEBUG |
| 138 | printf (" SmartMedia card inserted\n"); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 139 | |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 140 | printf ("Probing at 0x%.8x\n", AT91_SMARTMEDIA_BASE); |
wdenk | 934c4f8 | 2003-09-11 19:48:06 +0000 | [diff] [blame] | 141 | #endif |
| 142 | printf ("%4lu MB\n", nand_probe(AT91_SMARTMEDIA_BASE) >> 20); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 143 | } |
| 144 | #endif |