at91sam9260ek.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <asm/io.h>
  10. #include <asm/arch/at91sam9260_matrix.h>
  11. #include <asm/arch/at91sam9_smc.h>
  12. #include <asm/arch/at91_common.h>
  13. #include <asm/arch/clk.h>
  14. #include <asm/arch/gpio.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. /* ------------------------------------------------------------------------- */
  17. /*
  18. * Miscelaneous platform dependent initialisations
  19. */
  20. #ifdef CONFIG_CMD_NAND
  21. static void at91sam9260ek_nand_hw_init(void)
  22. {
  23. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  24. struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
  25. unsigned long csa;
  26. /* Assign CS3 to NAND/SmartMedia Interface */
  27. csa = readl(&matrix->ebicsa);
  28. csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
  29. writel(csa, &matrix->ebicsa);
  30. /* Configure SMC CS3 for NAND/SmartMedia */
  31. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  32. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  33. &smc->cs[3].setup);
  34. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  35. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  36. &smc->cs[3].pulse);
  37. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  38. &smc->cs[3].cycle);
  39. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  40. AT91_SMC_MODE_EXNW_DISABLE |
  41. #ifdef CONFIG_SYS_NAND_DBW_16
  42. AT91_SMC_MODE_DBW_16 |
  43. #else /* CONFIG_SYS_NAND_DBW_8 */
  44. AT91_SMC_MODE_DBW_8 |
  45. #endif
  46. AT91_SMC_MODE_TDF_CYCLE(2),
  47. &smc->cs[3].mode);
  48. /* Configure RDY/BSY */
  49. at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
  50. /* Enable NandFlash */
  51. at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
  52. }
  53. #endif
  54. int board_early_init_f(void)
  55. {
  56. return 0;
  57. }
  58. int board_init(void)
  59. {
  60. /* adress of boot parameters */
  61. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  62. #ifdef CONFIG_CMD_NAND
  63. at91sam9260ek_nand_hw_init();
  64. #endif
  65. #ifdef CONFIG_HAS_DATAFLASH
  66. at91_spi0_hw_init((1 << 0) | (1 << 1));
  67. #endif
  68. return 0;
  69. }
  70. int dram_init(void)
  71. {
  72. gd->ram_size = get_ram_size(
  73. (void *)CONFIG_SYS_SDRAM_BASE,
  74. CONFIG_SYS_SDRAM_SIZE);
  75. return 0;
  76. }
  77. #ifdef CONFIG_RESET_PHY_R
  78. void reset_phy(void)
  79. {
  80. }
  81. #endif