mini2440.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 2009
  10. * Michel Pollet <buserror@gmail.com>
  11. *
  12. * (C) Copyright 2012
  13. * Gabriel Huau <contact@huau-gabriel.fr>
  14. *
  15. * See file CREDITS for list of people who contributed to this
  16. * project.
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License as
  20. * published by the Free Software Foundation; either version 2 of
  21. * the License, or (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program; if not, write to the Free Software
  30. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  31. * MA 02111-1307 USA
  32. */
  33. #include <common.h>
  34. #include <asm/arch/s3c2440.h>
  35. #include <asm/arch/iomux.h>
  36. #include <asm/arch/gpio.h>
  37. #include <asm/io.h>
  38. #include <asm/gpio.h>
  39. #include <netdev.h>
  40. #include "mini2440.h"
  41. DECLARE_GLOBAL_DATA_PTR;
  42. static inline void pll_delay(unsigned long loops)
  43. {
  44. __asm__ volatile ("1:\n"
  45. "subs %0, %1, #1\n"
  46. "bne 1b" : "=r" (loops) : "0" (loops));
  47. }
  48. int board_early_init_f(void)
  49. {
  50. struct s3c24x0_clock_power * const clk_power =
  51. s3c24x0_get_base_clock_power();
  52. /* to reduce PLL lock time, adjust the LOCKTIME register */
  53. clk_power->locktime = 0xFFFFFF; /* Max PLL Lock time count */
  54. clk_power->clkdivn = CLKDIVN_VAL;
  55. /* configure UPLL */
  56. clk_power->upllcon = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);
  57. /* some delay between MPLL and UPLL */
  58. pll_delay(100);
  59. /* configure MPLL */
  60. clk_power->mpllcon = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);
  61. /* some delay between MPLL and UPLL */
  62. pll_delay(10000);
  63. return 0;
  64. }
  65. /*
  66. * Miscellaneous platform dependent initialisations
  67. */
  68. int board_init(void)
  69. {
  70. struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();
  71. /* IOMUX Port H : UART Configuration */
  72. gpio->gphcon = IOMUXH_nCTS0 | IOMUXH_nRTS0 | IOMUXH_TXD0 | IOMUXH_RXD0 |
  73. IOMUXH_TXD1 | IOMUXH_RXD1 | IOMUXH_TXD2 | IOMUXH_RXD2;
  74. gpio_direction_output(GPH8, 0);
  75. gpio_direction_output(GPH9, 0);
  76. gpio_direction_output(GPH10, 0);
  77. /* adress of boot parameters */
  78. gd->bd->bi_boot_params = CONFIG_BOOT_PARAM_ADDR;
  79. return 0;
  80. }
  81. int dram_init(void)
  82. {
  83. struct s3c24x0_memctl *memctl = s3c24x0_get_base_memctl();
  84. /*
  85. * Configuring bus width and timing
  86. * Initialize clocks for each bank 0..5
  87. * Bank 3 and 4 are used for DM9000
  88. */
  89. writel(BANK_CONF, &memctl->bwscon);
  90. writel(B0_CONF, &memctl->bankcon[0]);
  91. writel(B1_CONF, &memctl->bankcon[1]);
  92. writel(B2_CONF, &memctl->bankcon[2]);
  93. writel(B3_CONF, &memctl->bankcon[3]);
  94. writel(B4_CONF, &memctl->bankcon[4]);
  95. writel(B5_CONF, &memctl->bankcon[5]);
  96. /* Bank 6 and 7 are used for DRAM */
  97. writel(SDRAM_64MB, &memctl->bankcon[6]);
  98. writel(SDRAM_64MB, &memctl->bankcon[7]);
  99. writel(MEM_TIMING, &memctl->refresh);
  100. writel(BANKSIZE_CONF, &memctl->banksize);
  101. writel(B6_MRSR, &memctl->mrsrb6);
  102. writel(B7_MRSR, &memctl->mrsrb7);
  103. gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
  104. PHYS_SDRAM_SIZE);
  105. return 0;
  106. }
  107. int board_eth_init(bd_t *bis)
  108. {
  109. #ifdef CONFIG_DRIVER_DM9000
  110. return dm9000_initialize(bis);
  111. #else
  112. return 0;
  113. #endif
  114. }