atstk1003.c 4.2 KB

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