atstk1003.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * ATSTK1003 daughterboard-specific init code
  3. *
  4. * Copyright (C) 2007 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/clk.h>
  11. #include <linux/err.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/string.h>
  16. #include <linux/types.h>
  17. #include <linux/spi/at73c213.h>
  18. #include <linux/spi/spi.h>
  19. #include <linux/atmel-mci.h>
  20. #include <asm/setup.h>
  21. #include <mach/at32ap700x.h>
  22. #include <mach/board.h>
  23. #include <mach/init.h>
  24. #include <mach/portmux.h>
  25. #include "atstk1000.h"
  26. /* Oscillator frequencies. These are board specific */
  27. unsigned long at32_board_osc_rates[3] = {
  28. [0] = 32768, /* 32.768 kHz on RTC osc */
  29. [1] = 20000000, /* 20 MHz on osc0 */
  30. [2] = 12000000, /* 12 MHz on osc1 */
  31. };
  32. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  33. static struct at73c213_board_info at73c213_data = {
  34. .ssc_id = 0,
  35. .shortname = "AVR32 STK1000 external DAC",
  36. };
  37. #endif
  38. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  39. static struct spi_board_info spi0_board_info[] __initdata = {
  40. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  41. {
  42. /* AT73C213 */
  43. .modalias = "at73c213",
  44. .max_speed_hz = 200000,
  45. .chip_select = 0,
  46. .mode = SPI_MODE_1,
  47. .platform_data = &at73c213_data,
  48. },
  49. #endif
  50. /*
  51. * We can control the LTV350QV LCD panel, but it isn't much
  52. * point since we don't have an LCD controller...
  53. */
  54. };
  55. #endif
  56. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  57. static struct spi_board_info spi1_board_info[] __initdata = { {
  58. /* patch in custom entries here */
  59. } };
  60. #endif
  61. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  62. static struct mci_platform_data __initdata mci0_data = {
  63. .slot[0] = {
  64. .bus_width = 4,
  65. .detect_pin = -ENODEV,
  66. .wp_pin = -ENODEV,
  67. },
  68. };
  69. #endif
  70. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  71. static void __init atstk1003_setup_extdac(void)
  72. {
  73. struct clk *gclk;
  74. struct clk *pll;
  75. gclk = clk_get(NULL, "gclk0");
  76. if (IS_ERR(gclk))
  77. goto err_gclk;
  78. pll = clk_get(NULL, "pll0");
  79. if (IS_ERR(pll))
  80. goto err_pll;
  81. if (clk_set_parent(gclk, pll)) {
  82. pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
  83. goto err_set_clk;
  84. }
  85. at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);
  86. at73c213_data.dac_clk = gclk;
  87. err_set_clk:
  88. clk_put(pll);
  89. err_pll:
  90. clk_put(gclk);
  91. err_gclk:
  92. return;
  93. }
  94. #else
  95. static void __init atstk1003_setup_extdac(void)
  96. {
  97. }
  98. #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
  99. void __init setup_board(void)
  100. {
  101. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  102. at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */
  103. #else
  104. at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  105. #endif
  106. /* USART 2/unused: expansion connector */
  107. at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */
  108. at32_setup_serial_console(0);
  109. }
  110. static int __init atstk1003_init(void)
  111. {
  112. /*
  113. * ATSTK1000 uses 32-bit SDRAM interface. Reserve the
  114. * SDRAM-specific pins so that nobody messes with them.
  115. */
  116. at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL);
  117. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  118. at32_add_device_usart(1);
  119. #else
  120. at32_add_device_usart(0);
  121. #endif
  122. at32_add_device_usart(2);
  123. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  124. at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
  125. #endif
  126. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  127. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  128. #endif
  129. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  130. at32_add_device_mci(0, &mci0_data);
  131. #endif
  132. at32_add_device_usba(0, NULL);
  133. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  134. at32_add_device_ssc(0, ATMEL_SSC_TX);
  135. #endif
  136. atstk1000_setup_j2_leds();
  137. atstk1003_setup_extdac();
  138. return 0;
  139. }
  140. postcore_initcall(atstk1003_init);