atstk1004.c 3.7 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 <linux/atmel-mci.h>
  20. #include <video/atmel_lcdc.h>
  21. #include <asm/setup.h>
  22. #include <mach/at32ap700x.h>
  23. #include <mach/board.h>
  24. #include <mach/init.h>
  25. #include <mach/portmux.h>
  26. #include "atstk1000.h"
  27. /* Oscillator frequencies. These are board specific */
  28. unsigned long at32_board_osc_rates[3] = {
  29. [0] = 32768, /* 32.768 kHz on RTC osc */
  30. [1] = 20000000, /* 20 MHz on osc0 */
  31. [2] = 12000000, /* 12 MHz on osc1 */
  32. };
  33. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  34. static struct at73c213_board_info at73c213_data = {
  35. .ssc_id = 0,
  36. .shortname = "AVR32 STK1000 external DAC",
  37. };
  38. #endif
  39. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  40. static struct spi_board_info spi0_board_info[] __initdata = {
  41. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  42. {
  43. /* AT73C213 */
  44. .modalias = "at73c213",
  45. .max_speed_hz = 200000,
  46. .chip_select = 0,
  47. .mode = SPI_MODE_1,
  48. .platform_data = &at73c213_data,
  49. },
  50. #endif
  51. {
  52. /* QVGA display */
  53. .modalias = "ltv350qv",
  54. .max_speed_hz = 16000000,
  55. .chip_select = 1,
  56. .mode = SPI_MODE_3,
  57. },
  58. };
  59. #endif
  60. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  61. static struct spi_board_info spi1_board_info[] __initdata = { {
  62. /* patch in custom entries here */
  63. } };
  64. #endif
  65. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  66. static struct mci_platform_data __initdata mci0_data = {
  67. .slot[0] = {
  68. .bus_width = 4,
  69. .detect_pin = -ENODEV,
  70. .wp_pin = -ENODEV,
  71. },
  72. };
  73. #endif
  74. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  75. static void __init atstk1004_setup_extdac(void)
  76. {
  77. struct clk *gclk;
  78. struct clk *pll;
  79. gclk = clk_get(NULL, "gclk0");
  80. if (IS_ERR(gclk))
  81. goto err_gclk;
  82. pll = clk_get(NULL, "pll0");
  83. if (IS_ERR(pll))
  84. goto err_pll;
  85. if (clk_set_parent(gclk, pll)) {
  86. pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
  87. goto err_set_clk;
  88. }
  89. at32_select_periph(GPIO_PIOA_BASE, (1 << 30), GPIO_PERIPH_A, 0);
  90. at73c213_data.dac_clk = gclk;
  91. err_set_clk:
  92. clk_put(pll);
  93. err_pll:
  94. clk_put(gclk);
  95. err_gclk:
  96. return;
  97. }
  98. #else
  99. static void __init atstk1004_setup_extdac(void)
  100. {
  101. }
  102. #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
  103. void __init setup_board(void)
  104. {
  105. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  106. at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */
  107. #else
  108. at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  109. #endif
  110. /* USART 2/unused: expansion connector */
  111. at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */
  112. at32_setup_serial_console(0);
  113. }
  114. static int __init atstk1004_init(void)
  115. {
  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,
  133. ATMEL_LCDC_PRI_24BIT | ATMEL_LCDC_PRI_CONTROL);
  134. at32_add_device_usba(0, NULL);
  135. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  136. at32_add_device_ssc(0, ATMEL_SSC_TX);
  137. #endif
  138. atstk1000_setup_j2_leds();
  139. atstk1004_setup_extdac();
  140. return 0;
  141. }
  142. postcore_initcall(atstk1004_init);