atstk1004.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 <video/atmel_lcdc.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. /* QVGA display */
  52. .modalias = "ltv350qv",
  53. .max_speed_hz = 16000000,
  54. .chip_select = 1,
  55. .mode = SPI_MODE_3,
  56. },
  57. };
  58. #endif
  59. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  60. static struct spi_board_info spi1_board_info[] __initdata = { {
  61. /* patch in custom entries here */
  62. } };
  63. #endif
  64. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  65. static struct mci_platform_data __initdata mci0_data = {
  66. .slot[0] = {
  67. .bus_width = 4,
  68. .detect_pin = -ENODEV,
  69. .wp_pin = -ENODEV,
  70. },
  71. };
  72. #endif
  73. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  74. static void __init atstk1004_setup_extdac(void)
  75. {
  76. struct clk *gclk;
  77. struct clk *pll;
  78. gclk = clk_get(NULL, "gclk0");
  79. if (IS_ERR(gclk))
  80. goto err_gclk;
  81. pll = clk_get(NULL, "pll0");
  82. if (IS_ERR(pll))
  83. goto err_pll;
  84. if (clk_set_parent(gclk, pll)) {
  85. pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
  86. goto err_set_clk;
  87. }
  88. at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
  89. at73c213_data.dac_clk = gclk;
  90. err_set_clk:
  91. clk_put(pll);
  92. err_pll:
  93. clk_put(gclk);
  94. err_gclk:
  95. return;
  96. }
  97. #else
  98. static void __init atstk1004_setup_extdac(void)
  99. {
  100. }
  101. #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
  102. void __init setup_board(void)
  103. {
  104. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  105. at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  106. #else
  107. at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  108. #endif
  109. /* USART 2/unused: expansion connector */
  110. at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  111. at32_setup_serial_console(0);
  112. }
  113. static int __init atstk1004_init(void)
  114. {
  115. at32_add_system_devices();
  116. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  117. at32_add_device_usart(1);
  118. #else
  119. at32_add_device_usart(0);
  120. #endif
  121. at32_add_device_usart(2);
  122. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  123. at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
  124. #endif
  125. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  126. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  127. #endif
  128. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  129. at32_add_device_mci(0, &mci0_data);
  130. #endif
  131. at32_add_device_lcdc(0, &atstk1000_lcdc_data,
  132. fbmem_start, fbmem_size, 0);
  133. at32_add_device_usba(0, NULL);
  134. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  135. at32_add_device_ssc(0, ATMEL_SSC_TX);
  136. #endif
  137. atstk1000_setup_j2_leds();
  138. atstk1004_setup_extdac();
  139. return 0;
  140. }
  141. postcore_initcall(atstk1004_init);