kmeter1.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. * Dave Liu <daveliu@freescale.com>
  4. *
  5. * Copyright (C) 2007 Logic Product Development, Inc.
  6. * Peter Barada <peterb@logicpd.com>
  7. *
  8. * Copyright (C) 2007 MontaVista Software, Inc.
  9. * Anton Vorontsov <avorontsov@ru.mvista.com>
  10. *
  11. * (C) Copyright 2008
  12. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  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. #include <common.h>
  20. #include <ioports.h>
  21. #include <mpc83xx.h>
  22. #include <i2c.h>
  23. #include <miiphy.h>
  24. #include <asm/io.h>
  25. #include <asm/mmu.h>
  26. #include <asm/processor.h>
  27. #include <pci.h>
  28. #include <libfdt.h>
  29. #include "../common/common.h"
  30. extern void disable_addr_trans (void);
  31. extern void enable_addr_trans (void);
  32. const qe_iop_conf_t qe_iop_conf_tab[] = {
  33. /* port pin dir open_drain assign */
  34. /* MDIO */
  35. {0, 1, 3, 0, 2}, /* MDIO */
  36. {0, 2, 1, 0, 1}, /* MDC */
  37. /* UCC4 - UEC */
  38. {1, 14, 1, 0, 1}, /* TxD0 */
  39. {1, 15, 1, 0, 1}, /* TxD1 */
  40. {1, 20, 2, 0, 1}, /* RxD0 */
  41. {1, 21, 2, 0, 1}, /* RxD1 */
  42. {1, 18, 1, 0, 1}, /* TX_EN */
  43. {1, 26, 2, 0, 1}, /* RX_DV */
  44. {1, 27, 2, 0, 1}, /* RX_ER */
  45. {1, 24, 2, 0, 1}, /* COL */
  46. {1, 25, 2, 0, 1}, /* CRS */
  47. {2, 15, 2, 0, 1}, /* TX_CLK - CLK16 */
  48. {2, 16, 2, 0, 1}, /* RX_CLK - CLK17 */
  49. /* DUART - UART2 */
  50. {5, 0, 1, 0, 2}, /* UART2_SOUT */
  51. {5, 2, 1, 0, 1}, /* UART2_RTS */
  52. {5, 3, 2, 0, 2}, /* UART2_SIN */
  53. {5, 1, 2, 0, 3}, /* UART2_CTS */
  54. /* END of table */
  55. {0, 0, 0, 0, QE_IOP_TAB_END},
  56. };
  57. static int board_init_i2c_busses (void)
  58. {
  59. I2C_MUX_DEVICE *dev = NULL;
  60. uchar *buf;
  61. /* Set up the Bus for the DTTs */
  62. buf = (unsigned char *) getenv ("dtt_bus");
  63. if (buf != NULL)
  64. dev = i2c_mux_ident_muxstring (buf);
  65. if (dev == NULL) {
  66. printf ("Error couldn't add Bus for DTT\n");
  67. printf ("please setup dtt_bus to where your\n");
  68. printf ("DTT is found.\n");
  69. }
  70. return 0;
  71. }
  72. int board_early_init_r (void)
  73. {
  74. unsigned short svid;
  75. /*
  76. * Because of errata in the UCCs, we have to write to the reserved
  77. * registers to slow the clocks down.
  78. */
  79. svid = SVR_REV(mfspr (SVR));
  80. switch (svid) {
  81. case 0x0020:
  82. setbits_be32((void *)(CONFIG_SYS_IMMR + 0x14a8), 0x0c003000);
  83. break;
  84. case 0x0021:
  85. clrsetbits_be32((void *)(CONFIG_SYS_IMMR + 0x14ac),
  86. 0x00000050, 0x000000a0);
  87. break;
  88. }
  89. /* enable the PHY on the PIGGY */
  90. setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x10003), 0x01);
  91. return 0;
  92. }
  93. int misc_init_r (void)
  94. {
  95. /* add board specific i2c busses */
  96. board_init_i2c_busses ();
  97. return 0;
  98. }
  99. int fixed_sdram(void)
  100. {
  101. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  102. u32 msize = 0;
  103. u32 ddr_size;
  104. u32 ddr_size_log2;
  105. im->sysconf.ddrlaw[0].ar = LAWAR_EN | 0x1e;
  106. im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
  107. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
  108. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  109. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  110. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  111. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  112. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  113. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  114. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  115. im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
  116. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  117. im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
  118. udelay (200);
  119. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  120. msize = CONFIG_SYS_DDR_SIZE << 20;
  121. disable_addr_trans ();
  122. msize = get_ram_size (CONFIG_SYS_DDR_BASE, msize);
  123. enable_addr_trans ();
  124. msize /= (1024 * 1024);
  125. if (CONFIG_SYS_DDR_SIZE != msize) {
  126. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  127. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++)
  128. if (ddr_size & 1)
  129. return -1;
  130. im->sysconf.ddrlaw[0].ar =
  131. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  132. im->ddr.csbnds[0].csbnds = (((msize / 16) - 1) & 0xff);
  133. }
  134. return msize;
  135. }
  136. phys_size_t initdram (int board_type)
  137. {
  138. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  139. extern void ddr_enable_ecc (unsigned int dram_size);
  140. #endif
  141. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  142. u32 msize = 0;
  143. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  144. return -1;
  145. /* DDR SDRAM - Main SODIMM */
  146. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
  147. msize = fixed_sdram ();
  148. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  149. /*
  150. * Initialize DDR ECC byte
  151. */
  152. ddr_enable_ecc (msize * 1024 * 1024);
  153. #endif
  154. /* return total bus SDRAM size(bytes) -- DDR */
  155. return (msize * 1024 * 1024);
  156. }
  157. int checkboard (void)
  158. {
  159. puts ("Board: Keymile kmeter1");
  160. if (ethernet_present ())
  161. puts (" with PIGGY.");
  162. puts ("\n");
  163. return 0;
  164. }
  165. #if defined(CONFIG_OF_BOARD_SETUP)
  166. void ft_board_setup (void *blob, bd_t *bd)
  167. {
  168. ft_cpu_setup (blob, bd);
  169. }
  170. #endif
  171. #if defined(CONFIG_HUSH_INIT_VAR)
  172. extern int ivm_read_eeprom (void);
  173. int hush_init_var (void)
  174. {
  175. ivm_read_eeprom ();
  176. return 0;
  177. }
  178. #endif