sx1.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * (C) Copyright 2004
  3. * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
  4. *
  5. * (C) Copyright 2003
  6. * Texas Instruments, <www.ti.com>
  7. * Kshitij Gupta <Kshitij@ti.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. static void flash__init (void);
  29. static void ether__init (void);
  30. static inline void delay (unsigned long loops)
  31. {
  32. __asm__ volatile ("1:\n"
  33. "subs %0, %1, #1\n"
  34. "bne 1b":"=r" (loops):"0" (loops));
  35. }
  36. /*
  37. * Miscellaneous platform dependent initialisations
  38. */
  39. int board_init (void)
  40. {
  41. DECLARE_GLOBAL_DATA_PTR;
  42. /* arch number of SX1 Board */
  43. gd->bd->bi_arch_number = 241;
  44. /* adress of boot parameters */
  45. gd->bd->bi_boot_params = 0x10000100;
  46. /* kk - this speeds up your boot a quite a bit. However to make it
  47. * work, you need make sure your kernel startup flush bug is fixed.
  48. * ... rkw ...
  49. */
  50. icache_enable ();
  51. flash__init ();
  52. ether__init ();
  53. return 0;
  54. }
  55. int misc_init_r (void)
  56. {
  57. /* volatile ushort *gdir = (ushort *) (GPIO_DIR_CONTROL_REG); */
  58. /* volatile ushort *mdir = (ushort *) (MPUIO_DIR_CONTROL_REG); */
  59. /* setup gpio direction to match board (no floats!) */
  60. /**gdir = 0xCFF9; */
  61. /**mdir = 0x103F; */
  62. return (0);
  63. }
  64. /******************************
  65. Routine:
  66. Description:
  67. ******************************/
  68. static void flash__init (void)
  69. {
  70. #define CS0_CHIP_SELECT_REG 0xfffecc10
  71. #define CS3_CHIP_SELECT_REG 0xfffecc1c
  72. #define EMIFS_GlB_Config_REG 0xfffecc0c
  73. unsigned int regval;
  74. regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG);
  75. regval = regval | 0x0001; /* Turn off write protection for flash devices. */
  76. if (regval & 0x0002) {
  77. regval = regval & 0xfffd; /* Swap CS0 and CS3 so that flash is visible at 0x0 and eeprom at 0x0c000000. */
  78. /* If, instead, you want to reference flash at 0x0c000000, then it seemed the following were necessary. */
  79. /* *((volatile unsigned int *)CS0_CHIP_SELECT_REG) = 0x202090; / * Overrides head.S setting of 0x212090 */
  80. /* *((volatile unsigned int *)CS3_CHIP_SELECT_REG) = 0x202090; / * Let's flash chips be fully functional. */
  81. }
  82. *((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval;
  83. }
  84. /******************************
  85. Routine:
  86. Description:
  87. ******************************/
  88. static void ether__init (void)
  89. {
  90. #define ETH_CONTROL_REG 0x0800000b
  91. /* take the Ethernet controller out of reset and wait
  92. * for the EEPROM load to complete.
  93. */
  94. *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
  95. udelay (3);
  96. }
  97. int dram_init (void)
  98. {
  99. DECLARE_GLOBAL_DATA_PTR;
  100. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  101. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  102. return 0;
  103. }