board-dt.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Setup code for AT91SAM Evaluation Kits with Device Tree support
  3. *
  4. * Covers: * AT91SAM9G45-EKES board
  5. * * AT91SAM9M10-EKES board
  6. * * AT91SAM9M10G45-EK board
  7. *
  8. * Copyright (C) 2011 Atmel,
  9. * 2011 Nicolas Ferre <nicolas.ferre@atmel.com>
  10. *
  11. * Licensed under GPLv2 or later.
  12. */
  13. #include <linux/types.h>
  14. #include <linux/init.h>
  15. #include <linux/module.h>
  16. #include <linux/gpio.h>
  17. #include <linux/irqdomain.h>
  18. #include <linux/of_irq.h>
  19. #include <linux/of_platform.h>
  20. #include <mach/hardware.h>
  21. #include <mach/board.h>
  22. #include <mach/system_rev.h>
  23. #include <mach/at91sam9_smc.h>
  24. #include <asm/setup.h>
  25. #include <asm/irq.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <asm/mach/irq.h>
  29. #include "sam9_smc.h"
  30. #include "generic.h"
  31. static void __init ek_init_early(void)
  32. {
  33. /* Initialize processor: 12.000 MHz crystal */
  34. at91_initialize(12000000);
  35. /* DGBU on ttyS0. (Rx & Tx only) */
  36. at91_register_uart(0, 0, 0);
  37. /* set serial console to ttyS0 (ie, DBGU) */
  38. at91_set_serial_console(0);
  39. }
  40. /* det_pin is not connected */
  41. static struct atmel_nand_data __initdata ek_nand_data = {
  42. .ale = 21,
  43. .cle = 22,
  44. .rdy_pin = AT91_PIN_PC8,
  45. .enable_pin = AT91_PIN_PC14,
  46. };
  47. static struct sam9_smc_config __initdata ek_nand_smc_config = {
  48. .ncs_read_setup = 0,
  49. .nrd_setup = 2,
  50. .ncs_write_setup = 0,
  51. .nwe_setup = 2,
  52. .ncs_read_pulse = 4,
  53. .nrd_pulse = 4,
  54. .ncs_write_pulse = 4,
  55. .nwe_pulse = 4,
  56. .read_cycle = 7,
  57. .write_cycle = 7,
  58. .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
  59. .tdf_cycles = 3,
  60. };
  61. static void __init ek_add_device_nand(void)
  62. {
  63. ek_nand_data.bus_width_16 = board_have_nand_16bit();
  64. /* setup bus-width (8 or 16) */
  65. if (ek_nand_data.bus_width_16)
  66. ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
  67. else
  68. ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
  69. /* configure chip-select 3 (NAND) */
  70. sam9_smc_configure(3, &ek_nand_smc_config);
  71. at91_add_device_nand(&ek_nand_data);
  72. }
  73. static const struct of_device_id aic_of_match[] __initconst = {
  74. { .compatible = "atmel,at91rm9200-aic", },
  75. {},
  76. };
  77. static void __init at91_dt_init_irq(void)
  78. {
  79. irq_domain_generate_simple(aic_of_match, 0xfffff000, 0);
  80. at91_init_irq_default();
  81. }
  82. static void __init at91_dt_device_init(void)
  83. {
  84. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  85. /* NAND */
  86. ek_add_device_nand();
  87. }
  88. static const char *at91_dt_board_compat[] __initdata = {
  89. "atmel,at91sam9m10g45ek",
  90. "calao,usb-a9g20",
  91. NULL
  92. };
  93. DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
  94. /* Maintainer: Atmel */
  95. .timer = &at91sam926x_timer,
  96. .map_io = at91_map_io,
  97. .init_early = ek_init_early,
  98. .init_irq = at91_dt_init_irq,
  99. .init_machine = at91_dt_device_init,
  100. .dt_compat = at91_dt_board_compat,
  101. MACHINE_END