at91sam9260ek.c 2.3 KB

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