wdenk | 9d5028c | 2004-11-21 00:06:33 +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 | * Modified for CMC_PU2 (removed Smart Media support) by Gary Jennejohn |
| 7 | * (2004) garyj@denx.de |
| 8 | * |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 9 | * Modified for CMC_BASIC by Martin Krause (2005), TQ-Systems GmbH |
| 10 | * |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 27 | * MA 02111-1307 USA |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/arch/AT91RM9200.h> |
Jens Scharsig | c041e9d | 2010-01-23 12:03:45 +0100 | [diff] [blame] | 33 | #include <asm/io.h> |
| 34 | #include <netdev.h> |
| 35 | #if defined(CONFIG_DRIVER_ETHER) |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 36 | #include <at91rm9200_net.h> |
| 37 | #include <dm9161.h> |
Jens Scharsig | c041e9d | 2010-01-23 12:03:45 +0100 | [diff] [blame] | 38 | #endif |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 39 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 42 | /* ------------------------------------------------------------------------- */ |
| 43 | /* |
| 44 | * Miscelaneous platform dependent initialisations |
| 45 | */ |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 46 | #define CMC_HP_BASIC 1 |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 47 | #define CMC_PU2 2 |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 48 | #define CMC_BASIC 4 |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 49 | |
| 50 | int hw_detect (void); |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 51 | |
| 52 | int board_init (void) |
| 53 | { |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 54 | AT91PS_PIO piob = AT91C_BASE_PIOB; |
| 55 | AT91PS_PIO pioc = AT91C_BASE_PIOC; |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 56 | |
| 57 | /* Enable Ctrlc */ |
| 58 | console_init_f (); |
| 59 | |
| 60 | /* Correct IRDA resistor problem */ |
| 61 | /* Set PA23_TXD in Output */ |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 62 | /* (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2; */ |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 63 | |
| 64 | /* memory and cpu-speed are setup before relocation */ |
| 65 | /* so we do _nothing_ here */ |
| 66 | |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 67 | /* PIOB and PIOC clock enabling */ |
| 68 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; |
| 69 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOC; |
| 70 | |
| 71 | /* |
| 72 | * configure PC0-PC3 as input without pull ups, so RS485 driver enable |
| 73 | * (CMC-PU2) and digital outputs (CMC-BASIC) are deactivated. |
| 74 | */ |
| 75 | pioc->PIO_ODR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
| 76 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
| 77 | pioc->PIO_PPUDR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
| 78 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
| 79 | pioc->PIO_PER = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 80 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * On CMC-PU2 board configure PB3-PB6 to input without pull ups to |
| 84 | * clear the duo LEDs (the external pull downs assure a proper |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 85 | * signal). On CMC-BASIC and CMC-HP-BASIC set PB3-PB6 to output and |
| 86 | * drive it high, to configure current measurement on AINx. |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 87 | */ |
| 88 | if (hw_detect() & CMC_PU2) { |
| 89 | piob->PIO_ODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 90 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 91 | } |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 92 | else if ((hw_detect() & CMC_BASIC) || (hw_detect() & CMC_HP_BASIC)) { |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 93 | piob->PIO_SODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 94 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 95 | piob->PIO_OER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 96 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 97 | } |
| 98 | piob->PIO_PPUDR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 99 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 100 | piob->PIO_PER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 101 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 102 | |
| 103 | /* |
| 104 | * arch number of CMC_PU2-Board. MACH_TYPE_CMC_PU2 is not supported in |
| 105 | * the linuxarm kernel, yet. |
| 106 | */ |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 107 | /* gd->bd->bi_arch_number = MACH_TYPE_CMC_PU2; */ |
| 108 | gd->bd->bi_arch_number = 251; |
| 109 | /* adress of boot parameters */ |
| 110 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 111 | |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | int dram_init (void) |
| 116 | { |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 117 | gd->bd->bi_dram[0].start = PHYS_SDRAM; |
| 118 | gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; |
| 119 | return 0; |
| 120 | } |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 121 | |
| 122 | int checkboard (void) |
| 123 | { |
| 124 | if (hw_detect() & CMC_PU2) |
| 125 | puts ("Board: CMC-PU2 (Rittal GmbH)\n"); |
| 126 | else if (hw_detect() & CMC_BASIC) |
| 127 | puts ("Board: CMC-BASIC (Rittal GmbH)\n"); |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 128 | else if (hw_detect() & CMC_HP_BASIC) |
| 129 | puts ("Board: CMC-HP-BASIC (Rittal GmbH)\n"); |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 130 | else |
| 131 | puts ("Board: unknown\n"); |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | int hw_detect (void) |
| 136 | { |
| 137 | AT91PS_PIO pio = AT91C_BASE_PIOB; |
| 138 | |
| 139 | /* PIOB clock enabling */ |
| 140 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; |
| 141 | |
| 142 | /* configure PB12 as input without pull up */ |
| 143 | pio->PIO_ODR = AT91C_PIO_PB12; |
| 144 | pio->PIO_PPUDR = AT91C_PIO_PB12; |
| 145 | pio->PIO_PER = AT91C_PIO_PB12; |
Wolfgang Denk | 6617aae | 2005-08-19 00:46:54 +0200 | [diff] [blame] | 146 | |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 147 | /* configure PB13 as input without pull up */ |
| 148 | pio->PIO_ODR = AT91C_PIO_PB13; |
| 149 | pio->PIO_PPUDR = AT91C_PIO_PB13; |
| 150 | pio->PIO_PER = AT91C_PIO_PB13; |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 151 | |
| 152 | /* read board identification pin */ |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 153 | if (pio->PIO_PDSR & AT91C_PIO_PB12) |
| 154 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) |
| 155 | ? CMC_PU2 : 0); |
| 156 | else |
| 157 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) |
| 158 | ? CMC_HP_BASIC : CMC_BASIC); |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 159 | } |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 160 | |
| 161 | #ifdef CONFIG_DRIVER_ETHER |
Jon Loeliger | fcec2eb | 2007-07-09 18:19:09 -0500 | [diff] [blame] | 162 | #if defined(CONFIG_CMD_NET) |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * Name: |
| 166 | * at91rm9200_GetPhyInterface |
| 167 | * Description: |
| 168 | * Initialise the interface functions to the PHY |
| 169 | * Arguments: |
| 170 | * None |
| 171 | * Return value: |
| 172 | * None |
| 173 | */ |
| 174 | void at91rm9200_GetPhyInterface(AT91PS_PhyOps p_phyops) |
| 175 | { |
| 176 | p_phyops->Init = dm9161_InitPhy; |
| 177 | p_phyops->IsPhyConnected = dm9161_IsPhyConnected; |
| 178 | p_phyops->GetLinkSpeed = dm9161_GetLinkSpeed; |
| 179 | p_phyops->AutoNegotiate = dm9161_AutoNegotiate; |
| 180 | } |
| 181 | |
Jon Loeliger | fcec2eb | 2007-07-09 18:19:09 -0500 | [diff] [blame] | 182 | #endif |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame] | 183 | #endif /* CONFIG_DRIVER_ETHER */ |
Jens Scharsig | c041e9d | 2010-01-23 12:03:45 +0100 | [diff] [blame] | 184 | |
| 185 | #ifdef CONFIG_DRIVER_AT91EMAC |
| 186 | int board_eth_init(bd_t *bis) |
| 187 | { |
| 188 | int rc = 0; |
| 189 | rc = at91emac_register(bis, 0); |
| 190 | return rc; |
| 191 | } |
| 192 | #endif |