tny_a9260.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Stelian Pop <stelian@popies.net>
  4. * Lead Tech Design <www.leadtechdesign.com>
  5. *
  6. * Copyright (C) 2009
  7. * Albin Tonnerre, Free Electrons <albin.tonnerre@free-electrons.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <asm/arch/at91sam9_matrix.h>
  29. #include <asm/arch/at91sam9_smc.h>
  30. #include <asm/arch/at91_common.h>
  31. #include <asm/arch/at91_pmc.h>
  32. #include <asm/arch/at91_rstc.h>
  33. #include <asm/arch/gpio.h>
  34. #include <asm/arch/hardware.h>
  35. DECLARE_GLOBAL_DATA_PTR;
  36. /* ------------------------------------------------------------------------- */
  37. /*
  38. * Miscelaneous platform dependent initialisations
  39. */
  40. static void tny_a9260_nand_hw_init(void)
  41. {
  42. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  43. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  44. struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
  45. unsigned long csa;
  46. /* Assign CS3 to NAND/SmartMedia Interface */
  47. csa = readl(&matrix->ebicsa);
  48. csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
  49. writel(csa, &matrix->ebicsa);
  50. /* Configure SMC CS3 for NAND/SmartMedia */
  51. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  52. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  53. &smc->cs[3].setup);
  54. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  55. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  56. &smc->cs[3].pulse);
  57. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  58. &smc->cs[3].cycle);
  59. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  60. AT91_SMC_MODE_EXNW_DISABLE |
  61. #ifdef CONFIG_SYS_NAND_DBW_16
  62. AT91_SMC_MODE_DBW_16 |
  63. #else /* CONFIG_SYS_NAND_DBW_8 */
  64. AT91_SMC_MODE_DBW_8 |
  65. #endif
  66. AT91_SMC_MODE_TDF_CYCLE(2),
  67. &smc->cs[3].mode);
  68. writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
  69. /* Configure RDY/BSY */
  70. at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
  71. /* Enable NandFlash */
  72. at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
  73. }
  74. int board_init(void)
  75. {
  76. /* Enable Ctrlc */
  77. console_init_f();
  78. #if defined(CONFIG_TNY_A9260)
  79. gd->bd->bi_arch_number = MACH_TYPE_TNY_A9260;
  80. #elif defined(CONFIG_TNY_A9G20)
  81. gd->bd->bi_arch_number = MACH_TYPE_TNY_A9G20;
  82. #endif
  83. /* adress of boot parameters */
  84. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  85. at91_seriald_hw_init();
  86. tny_a9260_nand_hw_init();
  87. at91_spi0_hw_init(1 << 5);
  88. return 0;
  89. }
  90. int dram_init(void)
  91. {
  92. gd->ram_size = get_ram_size(
  93. (void *)CONFIG_SYS_SDRAM_BASE,
  94. CONFIG_SYS_SDRAM_SIZE);
  95. return 0;
  96. }