sbc2410x.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * (C) Copyright 2002
  3. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  4. * Marius Groeger <mgroeger@sysgo.de>
  5. *
  6. * (C) Copyright 2002
  7. * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
  8. *
  9. * (C) Copyright 2005
  10. * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28. * MA 02111-1307 USA
  29. */
  30. #include <common.h>
  31. #include <netdev.h>
  32. #include <asm/arch/s3c24x0_cpu.h>
  33. #if defined(CONFIG_CMD_NAND)
  34. #include <linux/mtd/nand.h>
  35. #endif
  36. DECLARE_GLOBAL_DATA_PTR;
  37. #define FCLK_SPEED 1
  38. #if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */
  39. #define M_MDIV 0xC3
  40. #define M_PDIV 0x4
  41. #define M_SDIV 0x1
  42. #elif FCLK_SPEED==1 /* Fout = 202.8MHz */
  43. #define M_MDIV 0x5c
  44. #define M_PDIV 0x4
  45. #define M_SDIV 0x0
  46. #endif
  47. #define USB_CLOCK 1
  48. #if USB_CLOCK==0
  49. #define U_M_MDIV 0xA1
  50. #define U_M_PDIV 0x3
  51. #define U_M_SDIV 0x1
  52. #elif USB_CLOCK==1
  53. #define U_M_MDIV 0x48
  54. #define U_M_PDIV 0x3
  55. #define U_M_SDIV 0x2
  56. #endif
  57. static inline void delay (unsigned long loops)
  58. {
  59. __asm__ volatile ("1:\n"
  60. "subs %0, %1, #1\n"
  61. "bne 1b":"=r" (loops):"0" (loops));
  62. }
  63. /*
  64. * Miscellaneous platform dependent initialisations
  65. */
  66. int board_init (void)
  67. {
  68. struct s3c24x0_clock_power * const clk_power =
  69. s3c24x0_get_base_clock_power();
  70. struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
  71. /* to reduce PLL lock time, adjust the LOCKTIME register */
  72. clk_power->LOCKTIME = 0xFFFFFF;
  73. /* configure MPLL */
  74. clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
  75. /* some delay between MPLL and UPLL */
  76. delay (4000);
  77. /* configure UPLL */
  78. clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
  79. /* some delay between MPLL and UPLL */
  80. delay (8000);
  81. /* set up the I/O ports */
  82. gpio->GPACON = 0x007FFFFF;
  83. gpio->GPBCON = 0x00044556;
  84. gpio->GPBUP = 0x000007FF;
  85. gpio->GPCCON = 0xAAAAAAAA;
  86. gpio->GPCUP = 0x0000FFFF;
  87. gpio->GPDCON = 0xAAAAAAAA;
  88. gpio->GPDUP = 0x0000FFFF;
  89. gpio->GPECON = 0xAAAAAAAA;
  90. gpio->GPEUP = 0x0000FFFF;
  91. gpio->GPFCON = 0x000055AA;
  92. gpio->GPFUP = 0x000000FF;
  93. gpio->GPGCON = 0xFF95FF3A;
  94. gpio->GPGUP = 0x0000FFFF;
  95. gpio->GPHCON = 0x0016FAAA;
  96. gpio->GPHUP = 0x000007FF;
  97. gpio->EXTINT0=0x22222222;
  98. gpio->EXTINT1=0x22222222;
  99. gpio->EXTINT2=0x22222222;
  100. /* arch number of SMDK2410-Board */
  101. gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
  102. /* adress of boot parameters */
  103. gd->bd->bi_boot_params = 0x30000100;
  104. icache_enable();
  105. dcache_enable();
  106. return 0;
  107. }
  108. int dram_init (void)
  109. {
  110. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  111. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  112. return 0;
  113. }
  114. #if defined(CONFIG_CMD_NAND)
  115. extern ulong nand_probe(ulong physadr);
  116. static inline void NF_Reset(void)
  117. {
  118. int i;
  119. NF_SetCE(NFCE_LOW);
  120. NF_Cmd(0xFF); /* reset command */
  121. for(i = 0; i < 10; i++); /* tWB = 100ns. */
  122. NF_WaitRB(); /* wait 200~500us; */
  123. NF_SetCE(NFCE_HIGH);
  124. }
  125. static inline void NF_Init(void)
  126. {
  127. #if 1
  128. #define TACLS 0
  129. #define TWRPH0 3
  130. #define TWRPH1 0
  131. #else
  132. #define TACLS 0
  133. #define TWRPH0 4
  134. #define TWRPH1 2
  135. #endif
  136. NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0));
  137. /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */
  138. /* 1 1 1 1, 1 xxx, r xxx, r xxx */
  139. /* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */
  140. NF_Reset();
  141. }
  142. void nand_init(void)
  143. {
  144. struct s3c2410_nand * const nand = s3c2410_get_base_nand();
  145. NF_Init();
  146. #ifdef DEBUG
  147. printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);
  148. #endif
  149. printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);
  150. }
  151. #endif
  152. #ifdef CONFIG_CMD_NET
  153. int board_eth_init(bd_t *bis)
  154. {
  155. int rc = 0;
  156. #ifdef CONFIG_CS8900
  157. rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
  158. #endif
  159. return rc;
  160. }
  161. #endif