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> |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame^] | 33 | #include <at91rm9200_net.h> |
| 34 | #include <dm9161.h> |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 35 | |
| 36 | /* ------------------------------------------------------------------------- */ |
| 37 | /* |
| 38 | * Miscelaneous platform dependent initialisations |
| 39 | */ |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 40 | #define CMC_HP_BASIC 1 |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 41 | #define CMC_PU2 2 |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 42 | #define CMC_BASIC 4 |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 43 | |
| 44 | int hw_detect (void); |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 45 | |
| 46 | int board_init (void) |
| 47 | { |
| 48 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 49 | AT91PS_PIO piob = AT91C_BASE_PIOB; |
| 50 | AT91PS_PIO pioc = AT91C_BASE_PIOC; |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 51 | |
| 52 | /* Enable Ctrlc */ |
| 53 | console_init_f (); |
| 54 | |
| 55 | /* Correct IRDA resistor problem */ |
| 56 | /* Set PA23_TXD in Output */ |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 57 | /* (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2; */ |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 58 | |
| 59 | /* memory and cpu-speed are setup before relocation */ |
| 60 | /* so we do _nothing_ here */ |
| 61 | |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 62 | /* PIOB and PIOC clock enabling */ |
| 63 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; |
| 64 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOC; |
| 65 | |
| 66 | /* |
| 67 | * configure PC0-PC3 as input without pull ups, so RS485 driver enable |
| 68 | * (CMC-PU2) and digital outputs (CMC-BASIC) are deactivated. |
| 69 | */ |
| 70 | pioc->PIO_ODR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
| 71 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
| 72 | pioc->PIO_PPUDR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
| 73 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
| 74 | pioc->PIO_PER = AT91C_PIO_PC0 | AT91C_PIO_PC1 | |
| 75 | AT91C_PIO_PC2 | AT91C_PIO_PC3; |
| 76 | |
| 77 | /* |
| 78 | * On CMC-PU2 board configure PB3-PB6 to input without pull ups to |
| 79 | * clear the duo LEDs (the external pull downs assure a proper |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 80 | * signal). On CMC-BASIC and CMC-HP-BASIC set PB3-PB6 to output and |
| 81 | * drive it high, to configure current measurement on AINx. |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 82 | */ |
| 83 | if (hw_detect() & CMC_PU2) { |
| 84 | piob->PIO_ODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 85 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 86 | } |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 87 | else if ((hw_detect() & CMC_BASIC) || (hw_detect() & CMC_HP_BASIC)) { |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 88 | piob->PIO_SODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 89 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 90 | piob->PIO_OER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 91 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 92 | } |
| 93 | piob->PIO_PPUDR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 94 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 95 | piob->PIO_PER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
| 96 | AT91C_PIO_PB5 | AT91C_PIO_PB6; |
| 97 | |
| 98 | /* |
| 99 | * arch number of CMC_PU2-Board. MACH_TYPE_CMC_PU2 is not supported in |
| 100 | * the linuxarm kernel, yet. |
| 101 | */ |
wdenk | 9d5028c | 2004-11-21 00:06:33 +0000 | [diff] [blame] | 102 | /* gd->bd->bi_arch_number = MACH_TYPE_CMC_PU2; */ |
| 103 | gd->bd->bi_arch_number = 251; |
| 104 | /* adress of boot parameters */ |
| 105 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | int dram_init (void) |
| 111 | { |
| 112 | DECLARE_GLOBAL_DATA_PTR; |
| 113 | |
| 114 | gd->bd->bi_dram[0].start = PHYS_SDRAM; |
| 115 | gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; |
| 116 | return 0; |
| 117 | } |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 118 | |
| 119 | int checkboard (void) |
| 120 | { |
| 121 | if (hw_detect() & CMC_PU2) |
| 122 | puts ("Board: CMC-PU2 (Rittal GmbH)\n"); |
| 123 | else if (hw_detect() & CMC_BASIC) |
| 124 | puts ("Board: CMC-BASIC (Rittal GmbH)\n"); |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 125 | else if (hw_detect() & CMC_HP_BASIC) |
| 126 | puts ("Board: CMC-HP-BASIC (Rittal GmbH)\n"); |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 127 | else |
| 128 | puts ("Board: unknown\n"); |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | int hw_detect (void) |
| 133 | { |
| 134 | AT91PS_PIO pio = AT91C_BASE_PIOB; |
| 135 | |
| 136 | /* PIOB clock enabling */ |
| 137 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; |
| 138 | |
| 139 | /* configure PB12 as input without pull up */ |
| 140 | pio->PIO_ODR = AT91C_PIO_PB12; |
| 141 | pio->PIO_PPUDR = AT91C_PIO_PB12; |
| 142 | pio->PIO_PER = AT91C_PIO_PB12; |
Wolfgang Denk | 6617aae | 2005-08-19 00:46:54 +0200 | [diff] [blame] | 143 | |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 144 | /* configure PB13 as input without pull up */ |
| 145 | pio->PIO_ODR = AT91C_PIO_PB13; |
| 146 | pio->PIO_PPUDR = AT91C_PIO_PB13; |
| 147 | pio->PIO_PER = AT91C_PIO_PB13; |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 148 | |
| 149 | /* read board identification pin */ |
Wolfgang Denk | 601aed1 | 2005-08-19 00:08:55 +0200 | [diff] [blame] | 150 | if (pio->PIO_PDSR & AT91C_PIO_PB12) |
| 151 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) |
| 152 | ? CMC_PU2 : 0); |
| 153 | else |
| 154 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) |
| 155 | ? CMC_HP_BASIC : CMC_BASIC); |
wdenk | be6b6e4 | 2005-04-01 15:18:44 +0000 | [diff] [blame] | 156 | } |
Wolfgang Denk | 080bdb7 | 2005-10-05 01:51:29 +0200 | [diff] [blame^] | 157 | |
| 158 | #ifdef CONFIG_DRIVER_ETHER |
| 159 | #if (CONFIG_COMMANDS & CFG_CMD_NET) |
| 160 | |
| 161 | /* |
| 162 | * Name: |
| 163 | * at91rm9200_GetPhyInterface |
| 164 | * Description: |
| 165 | * Initialise the interface functions to the PHY |
| 166 | * Arguments: |
| 167 | * None |
| 168 | * Return value: |
| 169 | * None |
| 170 | */ |
| 171 | void at91rm9200_GetPhyInterface(AT91PS_PhyOps p_phyops) |
| 172 | { |
| 173 | p_phyops->Init = dm9161_InitPhy; |
| 174 | p_phyops->IsPhyConnected = dm9161_IsPhyConnected; |
| 175 | p_phyops->GetLinkSpeed = dm9161_GetLinkSpeed; |
| 176 | p_phyops->AutoNegotiate = dm9161_AutoNegotiate; |
| 177 | } |
| 178 | |
| 179 | #endif /* CONFIG_COMMANDS & CFG_CMD_NET */ |
| 180 | #endif /* CONFIG_DRIVER_ETHER */ |