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