grasshopper.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2011
  3. * Corscience GmbH & Co.KG, Andreas Bießmann <biessmann@corscience.de>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/sdram.h>
  10. #include <asm/arch/clk.h>
  11. #include <asm/arch/hmatrix.h>
  12. #include <asm/arch/mmu.h>
  13. #include <asm/arch/portmux.h>
  14. #include <netdev.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
  17. {
  18. .virt_pgno = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
  19. .nr_pages = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
  20. .phys = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
  21. | MMU_VMR_CACHE_NONE,
  22. }, {
  23. .virt_pgno = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
  24. .nr_pages = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
  25. .phys = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
  26. | MMU_VMR_CACHE_WRBACK,
  27. },
  28. };
  29. static const struct sdram_config sdram_config = {
  30. /* Dual MT48LC16M16A2-7E (or equal) */
  31. .data_bits = SDRAM_DATA_32BIT,
  32. .row_bits = 13,
  33. .col_bits = 9,
  34. .bank_bits = 2,
  35. .cas = 2,
  36. .twr = 2,
  37. .trc = 7,
  38. .trp = 2,
  39. .trcd = 2,
  40. .tras = 4,
  41. .txsr = 7,
  42. /* 7.81 us */
  43. .refresh_period = (781 * (SDRAMC_BUS_HZ / 1000)) / 100000,
  44. };
  45. int board_early_init_f(void)
  46. {
  47. /* Enable SDRAM in the EBI mux */
  48. hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
  49. portmux_enable_ebi(SDRAM_DATA_32BIT, 23, 0, PORTMUX_DRIVE_HIGH);
  50. sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
  51. portmux_enable_usart0(PORTMUX_DRIVE_MIN);
  52. portmux_enable_usart1(PORTMUX_DRIVE_MIN);
  53. #if defined(CONFIG_MACB)
  54. /* set PHY reset and pwrdown to low */
  55. portmux_select_gpio(PORTMUX_PORT_B, (1 << 29) | (1 << 30),
  56. PORTMUX_DIR_OUTPUT | PORTMUX_INIT_LOW);
  57. udelay(100);
  58. /* release PHYs reset */
  59. gpio_set_value(GPIO_PIN_PB(29), 1);
  60. portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW);
  61. #endif
  62. return 0;
  63. }
  64. int board_early_init_r(void)
  65. {
  66. gd->bd->bi_phy_id[0] = 0x00;
  67. return 0;
  68. }
  69. #ifdef CONFIG_CMD_NET
  70. int board_eth_init(bd_t *bi)
  71. {
  72. macb_eth_initialize(0, (void *)ATMEL_BASE_MACB0, bi->bi_phy_id[0]);
  73. return 0;
  74. }
  75. #endif
  76. /* vim: set noet ts=8: */