atstk1004.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  65. static void __init atstk1004_setup_extdac(void)
  66. {
  67. struct clk *gclk;
  68. struct clk *pll;
  69. gclk = clk_get(NULL, "gclk0");
  70. if (IS_ERR(gclk))
  71. goto err_gclk;
  72. pll = clk_get(NULL, "pll0");
  73. if (IS_ERR(pll))
  74. goto err_pll;
  75. if (clk_set_parent(gclk, pll)) {
  76. pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
  77. goto err_set_clk;
  78. }
  79. at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
  80. at73c213_data.dac_clk = gclk;
  81. err_set_clk:
  82. clk_put(pll);
  83. err_pll:
  84. clk_put(gclk);
  85. err_gclk:
  86. return;
  87. }
  88. #else
  89. static void __init atstk1004_setup_extdac(void)
  90. {
  91. }
  92. #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
  93. void __init setup_board(void)
  94. {
  95. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  96. at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  97. #else
  98. at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  99. #endif
  100. /* USART 2/unused: expansion connector */
  101. at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  102. at32_setup_serial_console(0);
  103. }
  104. static int __init atstk1004_init(void)
  105. {
  106. at32_add_system_devices();
  107. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  108. at32_add_device_usart(1);
  109. #else
  110. at32_add_device_usart(0);
  111. #endif
  112. at32_add_device_usart(2);
  113. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  114. at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
  115. #endif
  116. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  117. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  118. #endif
  119. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  120. at32_add_device_mci(0, NULL);
  121. #endif
  122. at32_add_device_lcdc(0, &atstk1000_lcdc_data,
  123. fbmem_start, fbmem_size, 0);
  124. at32_add_device_usba(0, NULL);
  125. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  126. at32_add_device_ssc(0, ATMEL_SSC_TX);
  127. #endif
  128. atstk1000_setup_j2_leds();
  129. atstk1004_setup_extdac();
  130. return 0;
  131. }
  132. postcore_initcall(atstk1004_init);