icontrol.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. * linux/arch/arm/mach-pxa/icontrol.c
  3. *
  4. * Support for the iControl and SafeTcam platforms from TMT Services
  5. * using the Embedian MXM-8x10 Computer on Module
  6. *
  7. * Copyright (C) 2009 TMT Services & Supplies (Pty) Ltd.
  8. *
  9. * 2010-01-21 Hennie van der Merve <hvdmerwe@tmtservies.co.za>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/irq.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/gpio.h>
  18. #include <asm/mach-types.h>
  19. #include <asm/mach/arch.h>
  20. #include <mach/pxa320.h>
  21. #include <mach/mxm8x10.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/pxa2xx_spi.h>
  24. #include <linux/can/platform/mcp251x.h>
  25. #include "generic.h"
  26. #define ICONTROL_MCP251x_nCS1 (15)
  27. #define ICONTROL_MCP251x_nCS2 (16)
  28. #define ICONTROL_MCP251x_nCS3 (17)
  29. #define ICONTROL_MCP251x_nCS4 (24)
  30. #define ICONTROL_MCP251x_nIRQ1 (74)
  31. #define ICONTROL_MCP251x_nIRQ2 (75)
  32. #define ICONTROL_MCP251x_nIRQ3 (76)
  33. #define ICONTROL_MCP251x_nIRQ4 (77)
  34. static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
  35. .tx_threshold = 8,
  36. .rx_threshold = 128,
  37. .dma_burst_size = 8,
  38. .timeout = 235,
  39. .gpio_cs = ICONTROL_MCP251x_nCS1
  40. };
  41. static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
  42. .tx_threshold = 8,
  43. .rx_threshold = 128,
  44. .dma_burst_size = 8,
  45. .timeout = 235,
  46. .gpio_cs = ICONTROL_MCP251x_nCS2
  47. };
  48. static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
  49. .tx_threshold = 8,
  50. .rx_threshold = 128,
  51. .dma_burst_size = 8,
  52. .timeout = 235,
  53. .gpio_cs = ICONTROL_MCP251x_nCS3
  54. };
  55. static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
  56. .tx_threshold = 8,
  57. .rx_threshold = 128,
  58. .dma_burst_size = 8,
  59. .timeout = 235,
  60. .gpio_cs = ICONTROL_MCP251x_nCS4
  61. };
  62. static struct mcp251x_platform_data mcp251x_info = {
  63. .oscillator_frequency = 16E6,
  64. };
  65. static struct spi_board_info mcp251x_board_info[] = {
  66. {
  67. .modalias = "mcp2515",
  68. .max_speed_hz = 6500000,
  69. .bus_num = 3,
  70. .chip_select = 0,
  71. .platform_data = &mcp251x_info,
  72. .controller_data = &mcp251x_chip_info1,
  73. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
  74. },
  75. {
  76. .modalias = "mcp2515",
  77. .max_speed_hz = 6500000,
  78. .bus_num = 3,
  79. .chip_select = 1,
  80. .platform_data = &mcp251x_info,
  81. .controller_data = &mcp251x_chip_info2,
  82. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
  83. },
  84. {
  85. .modalias = "mcp2515",
  86. .max_speed_hz = 6500000,
  87. .bus_num = 4,
  88. .chip_select = 0,
  89. .platform_data = &mcp251x_info,
  90. .controller_data = &mcp251x_chip_info3,
  91. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
  92. },
  93. {
  94. .modalias = "mcp2515",
  95. .max_speed_hz = 6500000,
  96. .bus_num = 4,
  97. .chip_select = 1,
  98. .platform_data = &mcp251x_info,
  99. .controller_data = &mcp251x_chip_info4,
  100. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
  101. }
  102. };
  103. static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = {
  104. .clock_enable = CKEN_SSP3,
  105. .num_chipselect = 2,
  106. .enable_dma = 1
  107. };
  108. static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = {
  109. .clock_enable = CKEN_SSP4,
  110. .num_chipselect = 2,
  111. .enable_dma = 1
  112. };
  113. struct platform_device pxa_spi_ssp3 = {
  114. .name = "pxa2xx-spi",
  115. .id = 3,
  116. .dev = {
  117. .platform_data = &pxa_ssp3_spi_master_info,
  118. }
  119. };
  120. struct platform_device pxa_spi_ssp4 = {
  121. .name = "pxa2xx-spi",
  122. .id = 4,
  123. .dev = {
  124. .platform_data = &pxa_ssp4_spi_master_info,
  125. }
  126. };
  127. static struct platform_device *icontrol_spi_devices[] __initdata = {
  128. &pxa_spi_ssp3,
  129. &pxa_spi_ssp4,
  130. };
  131. static mfp_cfg_t mfp_can_cfg[] __initdata = {
  132. /* CAN CS lines */
  133. GPIO15_GPIO,
  134. GPIO16_GPIO,
  135. GPIO17_GPIO,
  136. GPIO24_GPIO,
  137. /* SPI (SSP3) lines */
  138. GPIO89_SSP3_SCLK,
  139. GPIO91_SSP3_TXD,
  140. GPIO92_SSP3_RXD,
  141. /* SPI (SSP4) lines */
  142. GPIO93_SSP4_SCLK,
  143. GPIO95_SSP4_TXD,
  144. GPIO96_SSP4_RXD,
  145. /* CAN nIRQ lines */
  146. GPIO74_GPIO | MFP_LPM_EDGE_RISE,
  147. GPIO75_GPIO | MFP_LPM_EDGE_RISE,
  148. GPIO76_GPIO | MFP_LPM_EDGE_RISE,
  149. GPIO77_GPIO | MFP_LPM_EDGE_RISE
  150. };
  151. static void __init icontrol_can_init(void)
  152. {
  153. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
  154. platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
  155. spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
  156. }
  157. static void __init icontrol_init(void)
  158. {
  159. mxm_8x10_barebones_init();
  160. mxm_8x10_usb_host_init();
  161. mxm_8x10_mmc_init();
  162. icontrol_can_init();
  163. }
  164. MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
  165. .atag_offset = 0x100,
  166. .map_io = pxa3xx_map_io,
  167. .nr_irqs = PXA_NR_IRQS,
  168. .init_irq = pxa3xx_init_irq,
  169. .handle_irq = pxa3xx_handle_irq,
  170. .init_time = pxa_timer_init,
  171. .init_machine = icontrol_init,
  172. .restart = pxa_restart,
  173. MACHINE_END