tt01.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * (C) Copyright 2011 HALE electronic <helmut.raiger@hale.at>
  3. * (C) Copyright 2009 Magnus Lilja <lilja.magnus@gmail.com>
  4. * (c) 2007 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <netdev.h>
  26. #include <command.h>
  27. #include <pmic.h>
  28. #include <asm/arch/clock.h>
  29. #include <asm/arch/sys_proto.h>
  30. #include <asm/io.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. #define BOARD_STRING "Board: HALE TT-01"
  33. /* Clock configuration */
  34. #define CCM_CCMR_SETUP 0x074B0BF5
  35. static void board_setup_clocks(void)
  36. {
  37. struct clock_control_regs *ccm = (struct clock_control_regs *) CCM_BASE;
  38. volatile int wait = 0x10000;
  39. writel(CCM_CCMR_SETUP, &ccm->ccmr);
  40. while (wait--)
  41. ;
  42. writel(CCM_CCMR_SETUP | CCMR_MPE, &ccm->ccmr);
  43. writel((CCM_CCMR_SETUP | CCMR_MPE) & ~CCMR_MDS, &ccm->ccmr);
  44. /* Set up clock to 532MHz */
  45. writel(PDR0_CSI_PODF(0x1ff) | PDR0_PER_PODF(7) |
  46. PDR0_HSP_PODF(3) | PDR0_NFC_PODF(5) |
  47. PDR0_IPG_PODF(1) | PDR0_MAX_PODF(3) |
  48. PDR0_MCU_PODF(0), &ccm->pdr0);
  49. writel(PLL_PD(0) | PLL_MFD(51) | PLL_MFI(10) | PLL_MFN(12),
  50. &ccm->mpctl);
  51. writel(PLL_PD(1) | PLL_MFD(4) | PLL_MFI(12) | PLL_MFN(1),
  52. &ccm->spctl);
  53. }
  54. /* DRAM configuration */
  55. #define ESDMISC_MDDR_SETUP 0x00000004
  56. #define ESDMISC_MDDR_RESET_DL 0x0000000c
  57. /*
  58. * decoding magic 0x6ac73a = 0b 0110 1010 1100 0111 0011 1010 below:
  59. * tXP = 11, tWTR = 0, tRP = 10, tMRD = 10
  60. * tWR = 1, tRAS = 100, tRRD = 01, tCAS = 11
  61. * tRCD = 011, tRC = 010
  62. * note: all but tWTR (1), tRC (111) are reset defaults,
  63. * the same values work in the jtag configuration
  64. *
  65. * Bluetechnix setup has 0x75e73a (for 128MB) =
  66. * 0b 0111 0101 1110 0111 0011 1010
  67. * tXP = 11, tWTR = 1, tRP = 01, tMRD = 01
  68. * tWR = 1, tRAS = 110, tRRD = 01, tCAS = 11
  69. * tRCD = 011, tRC = 010
  70. */
  71. #define ESDCFG0_MDDR_SETUP 0x006ac73a
  72. #define ESDCTL_ROW_COL (ESDCTL_SDE | ESDCTL_ROW(2) | ESDCTL_COL(2))
  73. #define ESDCTL_SETTINGS (ESDCTL_ROW_COL | ESDCTL_SREFR(3) | \
  74. ESDCTL_DSIZ(2) | ESDCTL_BL(1))
  75. #define ESDCTL_PRECHARGE (ESDCTL_ROW_COL | ESDCTL_CMD_PRECHARGE)
  76. #define ESDCTL_AUTOREFRESH (ESDCTL_ROW_COL | ESDCTL_CMD_AUTOREFRESH)
  77. #define ESDCTL_LOADMODEREG (ESDCTL_ROW_COL | ESDCTL_CMD_LOADMODEREG)
  78. #define ESDCTL_RW ESDCTL_SETTINGS
  79. static void board_setup_sdram(void)
  80. {
  81. u32 *pad;
  82. struct esdc_regs *esdc = (struct esdc_regs *)ESDCTL_BASE_ADDR;
  83. /*
  84. * setup pad control for the controller pins
  85. * no loopback, no pull, no keeper, no open drain,
  86. * standard input, standard drive, slow slew rate
  87. */
  88. for (pad = (u32 *) IOMUXC_SW_PAD_CTL_SDCKE1_SDCLK_SDCLK_B;
  89. pad <= (u32 *) IOMUXC_SW_PAD_CTL_VPG0_VPG1_A0; pad++)
  90. *pad = 0;
  91. /* set up MX31 DDR Memory Controller */
  92. writel(ESDMISC_MDDR_SETUP, &esdc->misc);
  93. writel(ESDCFG0_MDDR_SETUP, &esdc->cfg0);
  94. /* perform DDR init sequence for CSD0 */
  95. writel(ESDCTL_PRECHARGE, &esdc->ctl0);
  96. writel(0x12344321, CSD0_BASE+0x0f00);
  97. writel(ESDCTL_AUTOREFRESH, &esdc->ctl0);
  98. writel(0x12344321, CSD0_BASE);
  99. writel(0x12344321, CSD0_BASE);
  100. writel(ESDCTL_LOADMODEREG, &esdc->ctl0);
  101. writeb(0xda, CSD0_BASE+0x33);
  102. writeb(0xff, CSD0_BASE+0x1000000);
  103. writel(ESDCTL_RW, &esdc->ctl0);
  104. writel(0xDEADBEEF, CSD0_BASE);
  105. writel(ESDMISC_MDDR_RESET_DL, &esdc->misc);
  106. }
  107. static void tt01_spi3_hw_init(void)
  108. {
  109. /* CSPI3 */
  110. mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_MISO, MUX_CTL_FUNC));
  111. mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_MOSI, MUX_CTL_FUNC));
  112. mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI3_SCLK, MUX_CTL_FUNC));
  113. /* CSPI3, SS0 = Atlas */
  114. mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CSPI2_SS0, MUX_CTL_ALT1));
  115. /* start CSPI3 clock (3 = always on except if PLL off) */
  116. setbits_le32(CCM_CGR0, 3 << 16);
  117. }
  118. int dram_init(void)
  119. {
  120. /* dram_init must store complete ramsize in gd->ram_size */
  121. gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE,
  122. PHYS_SDRAM_1_SIZE);
  123. return 0;
  124. }
  125. int board_early_init_f(void)
  126. {
  127. /* CS4: FPGA incl. network controller */
  128. struct mxc_weimcs cs4 = {
  129. /* sp wp bcd bcs psz pme sync dol cnc wsc ew wws edc */
  130. CSCR_U(0, 0, 0, 0, 0, 0, 0, 0, 3, 28, 1, 7, 6),
  131. /* oea oen ebwa ebwn csa ebc dsz csn psr cre wrap csen */
  132. CSCR_L(4, 4, 4, 10, 4, 0, 5, 4, 0, 0, 0, 1),
  133. /* ebra ebrn rwa rwn mum lah lbn lba dww dct wwu age cnc2 fce*/
  134. CSCR_A(4, 4, 4, 4, 0, 1, 4, 3, 0, 0, 0, 0, 1, 0)
  135. };
  136. /* this seems essential, won't start without, but why? */
  137. writel(IPU_CONF_DI_EN, (u32 *) IPU_CONF);
  138. board_setup_clocks();
  139. board_setup_sdram();
  140. mxc_setup_weimcs(4, &cs4);
  141. /* Setup UART2 and SPI3 pins */
  142. mx31_uart2_hw_init();
  143. tt01_spi3_hw_init();
  144. return 0;
  145. }
  146. int board_init(void)
  147. {
  148. /* address of boot parameters */
  149. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  150. return 0;
  151. }
  152. int board_late_init(void)
  153. {
  154. pmic_init();
  155. #ifdef CONFIG_HW_WATCHDOG
  156. mxc_hw_watchdog_enable();
  157. #endif
  158. return 0;
  159. }
  160. int checkboard(void)
  161. {
  162. puts(BOARD_STRING "\n");
  163. return 0;
  164. }
  165. int board_eth_init(bd_t *bis)
  166. {
  167. int rc = 0;
  168. #ifdef CONFIG_SMC911X
  169. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  170. #endif
  171. return rc;
  172. }