cmc_pu2.c 5.1 KB

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