at91sam9260ek.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Stelian Pop <stelian@popies.net>
  4. * Lead Tech Design <www.leadtechdesign.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <debug_uart.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/at91sam9260_matrix.h>
  12. #include <asm/arch/at91sam9_smc.h>
  13. #include <asm/arch/at91_common.h>
  14. #include <asm/arch/clk.h>
  15. #include <asm/arch/gpio.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. /* ------------------------------------------------------------------------- */
  18. /*
  19. * Miscelaneous platform dependent initialisations
  20. */
  21. #ifdef CONFIG_CMD_NAND
  22. static void at91sam9260ek_nand_hw_init(void)
  23. {
  24. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  25. struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
  26. unsigned long csa;
  27. /* Assign CS3 to NAND/SmartMedia Interface */
  28. csa = readl(&matrix->ebicsa);
  29. csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
  30. writel(csa, &matrix->ebicsa);
  31. /* Configure SMC CS3 for NAND/SmartMedia */
  32. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  33. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  34. &smc->cs[3].setup);
  35. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  36. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  37. &smc->cs[3].pulse);
  38. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  39. &smc->cs[3].cycle);
  40. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  41. AT91_SMC_MODE_EXNW_DISABLE |
  42. #ifdef CONFIG_SYS_NAND_DBW_16
  43. AT91_SMC_MODE_DBW_16 |
  44. #else /* CONFIG_SYS_NAND_DBW_8 */
  45. AT91_SMC_MODE_DBW_8 |
  46. #endif
  47. AT91_SMC_MODE_TDF_CYCLE(2),
  48. &smc->cs[3].mode);
  49. /* Configure RDY/BSY */
  50. at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
  51. /* Enable NandFlash */
  52. at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
  53. }
  54. #endif
  55. #ifdef CONFIG_DEBUG_UART_BOARD_INIT
  56. void board_debug_uart_init(void)
  57. {
  58. at91_seriald_hw_init();
  59. }
  60. #endif
  61. #ifdef CONFIG_BOARD_EARLY_INIT_F
  62. int board_early_init_f(void)
  63. {
  64. #ifdef CONFIG_DEBUG_UART
  65. debug_uart_init();
  66. #endif
  67. return 0;
  68. }
  69. #endif
  70. int board_init(void)
  71. {
  72. /* adress of boot parameters */
  73. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  74. #ifdef CONFIG_CMD_NAND
  75. at91sam9260ek_nand_hw_init();
  76. #endif
  77. return 0;
  78. }
  79. int dram_init(void)
  80. {
  81. gd->ram_size = get_ram_size(
  82. (void *)CONFIG_SYS_SDRAM_BASE,
  83. CONFIG_SYS_SDRAM_SIZE);
  84. return 0;
  85. }
  86. #ifdef CONFIG_RESET_PHY_R
  87. void reset_phy(void)
  88. {
  89. }
  90. #endif