atstk1004.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 <asm/arch/at32ap700x.h>
  22. #include <asm/arch/board.h>
  23. #include <asm/arch/init.h>
  24. #include <asm/arch/portmux.h>
  25. #include "atstk1000.h"
  26. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  27. static struct at73c213_board_info at73c213_data = {
  28. .ssc_id = 0,
  29. .shortname = "AVR32 STK1000 external DAC",
  30. };
  31. #endif
  32. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  33. static struct spi_board_info spi0_board_info[] __initdata = {
  34. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  35. {
  36. /* AT73C213 */
  37. .modalias = "at73c213",
  38. .max_speed_hz = 200000,
  39. .chip_select = 0,
  40. .mode = SPI_MODE_1,
  41. .platform_data = &at73c213_data,
  42. },
  43. #endif
  44. {
  45. /* QVGA display */
  46. .modalias = "ltv350qv",
  47. .max_speed_hz = 16000000,
  48. .chip_select = 1,
  49. .mode = SPI_MODE_3,
  50. },
  51. };
  52. #endif
  53. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  54. static struct spi_board_info spi1_board_info[] __initdata = { {
  55. /* patch in custom entries here */
  56. } };
  57. #endif
  58. #ifdef CONFIG_BOARD_ATSTK1000_EXTDAC
  59. static void __init atstk1004_setup_extdac(void)
  60. {
  61. struct clk *gclk;
  62. struct clk *pll;
  63. gclk = clk_get(NULL, "gclk0");
  64. if (IS_ERR(gclk))
  65. goto err_gclk;
  66. pll = clk_get(NULL, "pll0");
  67. if (IS_ERR(pll))
  68. goto err_pll;
  69. if (clk_set_parent(gclk, pll)) {
  70. pr_debug("STK1000: failed to set pll0 as parent for DAC clock\n");
  71. goto err_set_clk;
  72. }
  73. at32_select_periph(GPIO_PIN_PA(30), GPIO_PERIPH_A, 0);
  74. at73c213_data.dac_clk = gclk;
  75. err_set_clk:
  76. clk_put(pll);
  77. err_pll:
  78. clk_put(gclk);
  79. err_gclk:
  80. return;
  81. }
  82. #else
  83. static void __init atstk1004_setup_extdac(void)
  84. {
  85. }
  86. #endif /* CONFIG_BOARD_ATSTK1000_EXTDAC */
  87. void __init setup_board(void)
  88. {
  89. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  90. at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  91. #else
  92. at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  93. #endif
  94. /* USART 2/unused: expansion connector */
  95. at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  96. at32_setup_serial_console(0);
  97. }
  98. static int __init atstk1004_init(void)
  99. {
  100. at32_add_system_devices();
  101. #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  102. at32_add_device_usart(1);
  103. #else
  104. at32_add_device_usart(0);
  105. #endif
  106. at32_add_device_usart(2);
  107. #ifndef CONFIG_BOARD_ATSTK100X_SW1_CUSTOM
  108. at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
  109. #endif
  110. #ifdef CONFIG_BOARD_ATSTK100X_SPI1
  111. at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
  112. #endif
  113. #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
  114. at32_add_device_mci(0);
  115. #endif
  116. at32_add_device_lcdc(0, &atstk1000_lcdc_data,
  117. fbmem_start, fbmem_size);
  118. at32_add_device_usba(0, NULL);
  119. #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM
  120. at32_add_device_ssc(0, ATMEL_SSC_TX);
  121. #endif
  122. atstk1000_setup_j2_leds();
  123. atstk1004_setup_extdac();
  124. return 0;
  125. }
  126. postcore_initcall(atstk1004_init);