icontrol.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 "pxa320.h"
  21. #include "mxm8x10.h"
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/pxa2xx_spi.h>
  24. #include <linux/can/platform/mcp251x.h>
  25. #include <linux/regulator/machine.h>
  26. #include "generic.h"
  27. #define ICONTROL_MCP251x_nCS1 (15)
  28. #define ICONTROL_MCP251x_nCS2 (16)
  29. #define ICONTROL_MCP251x_nCS3 (17)
  30. #define ICONTROL_MCP251x_nCS4 (24)
  31. #define ICONTROL_MCP251x_nIRQ1 (74)
  32. #define ICONTROL_MCP251x_nIRQ2 (75)
  33. #define ICONTROL_MCP251x_nIRQ3 (76)
  34. #define ICONTROL_MCP251x_nIRQ4 (77)
  35. static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
  36. .tx_threshold = 8,
  37. .rx_threshold = 128,
  38. .dma_burst_size = 8,
  39. .timeout = 235,
  40. .gpio_cs = ICONTROL_MCP251x_nCS1
  41. };
  42. static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
  43. .tx_threshold = 8,
  44. .rx_threshold = 128,
  45. .dma_burst_size = 8,
  46. .timeout = 235,
  47. .gpio_cs = ICONTROL_MCP251x_nCS2
  48. };
  49. static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
  50. .tx_threshold = 8,
  51. .rx_threshold = 128,
  52. .dma_burst_size = 8,
  53. .timeout = 235,
  54. .gpio_cs = ICONTROL_MCP251x_nCS3
  55. };
  56. static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
  57. .tx_threshold = 8,
  58. .rx_threshold = 128,
  59. .dma_burst_size = 8,
  60. .timeout = 235,
  61. .gpio_cs = ICONTROL_MCP251x_nCS4
  62. };
  63. static struct mcp251x_platform_data mcp251x_info = {
  64. .oscillator_frequency = 16E6,
  65. };
  66. static struct spi_board_info mcp251x_board_info[] = {
  67. {
  68. .modalias = "mcp2515",
  69. .max_speed_hz = 6500000,
  70. .bus_num = 3,
  71. .chip_select = 0,
  72. .platform_data = &mcp251x_info,
  73. .controller_data = &mcp251x_chip_info1,
  74. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
  75. },
  76. {
  77. .modalias = "mcp2515",
  78. .max_speed_hz = 6500000,
  79. .bus_num = 3,
  80. .chip_select = 1,
  81. .platform_data = &mcp251x_info,
  82. .controller_data = &mcp251x_chip_info2,
  83. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
  84. },
  85. {
  86. .modalias = "mcp2515",
  87. .max_speed_hz = 6500000,
  88. .bus_num = 4,
  89. .chip_select = 0,
  90. .platform_data = &mcp251x_info,
  91. .controller_data = &mcp251x_chip_info3,
  92. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
  93. },
  94. {
  95. .modalias = "mcp2515",
  96. .max_speed_hz = 6500000,
  97. .bus_num = 4,
  98. .chip_select = 1,
  99. .platform_data = &mcp251x_info,
  100. .controller_data = &mcp251x_chip_info4,
  101. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
  102. }
  103. };
  104. static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = {
  105. .num_chipselect = 2,
  106. .enable_dma = 1
  107. };
  108. static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = {
  109. .num_chipselect = 2,
  110. .enable_dma = 1
  111. };
  112. struct platform_device pxa_spi_ssp3 = {
  113. .name = "pxa2xx-spi",
  114. .id = 3,
  115. .dev = {
  116. .platform_data = &pxa_ssp3_spi_master_info,
  117. }
  118. };
  119. struct platform_device pxa_spi_ssp4 = {
  120. .name = "pxa2xx-spi",
  121. .id = 4,
  122. .dev = {
  123. .platform_data = &pxa_ssp4_spi_master_info,
  124. }
  125. };
  126. static struct platform_device *icontrol_spi_devices[] __initdata = {
  127. &pxa_spi_ssp3,
  128. &pxa_spi_ssp4,
  129. };
  130. static mfp_cfg_t mfp_can_cfg[] __initdata = {
  131. /* CAN CS lines */
  132. GPIO15_GPIO,
  133. GPIO16_GPIO,
  134. GPIO17_GPIO,
  135. GPIO24_GPIO,
  136. /* SPI (SSP3) lines */
  137. GPIO89_SSP3_SCLK,
  138. GPIO91_SSP3_TXD,
  139. GPIO92_SSP3_RXD,
  140. /* SPI (SSP4) lines */
  141. GPIO93_SSP4_SCLK,
  142. GPIO95_SSP4_TXD,
  143. GPIO96_SSP4_RXD,
  144. /* CAN nIRQ lines */
  145. GPIO74_GPIO | MFP_LPM_EDGE_RISE,
  146. GPIO75_GPIO | MFP_LPM_EDGE_RISE,
  147. GPIO76_GPIO | MFP_LPM_EDGE_RISE,
  148. GPIO77_GPIO | MFP_LPM_EDGE_RISE
  149. };
  150. static void __init icontrol_can_init(void)
  151. {
  152. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
  153. platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
  154. spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
  155. }
  156. static void __init icontrol_init(void)
  157. {
  158. mxm_8x10_barebones_init();
  159. mxm_8x10_usb_host_init();
  160. mxm_8x10_mmc_init();
  161. icontrol_can_init();
  162. regulator_has_full_constraints();
  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