icontrol.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 <mach/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. .model = CAN_MCP251X_MCP2515,
  65. .board_specific_setup = NULL,
  66. .power_enable = NULL,
  67. .transceiver_enable = NULL
  68. };
  69. static struct spi_board_info mcp251x_board_info[] = {
  70. {
  71. .modalias = "mcp251x",
  72. .max_speed_hz = 6500000,
  73. .bus_num = 3,
  74. .chip_select = 0,
  75. .platform_data = &mcp251x_info,
  76. .controller_data = &mcp251x_chip_info1,
  77. .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1)
  78. },
  79. {
  80. .modalias = "mcp251x",
  81. .max_speed_hz = 6500000,
  82. .bus_num = 3,
  83. .chip_select = 1,
  84. .platform_data = &mcp251x_info,
  85. .controller_data = &mcp251x_chip_info2,
  86. .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2)
  87. },
  88. {
  89. .modalias = "mcp251x",
  90. .max_speed_hz = 6500000,
  91. .bus_num = 4,
  92. .chip_select = 0,
  93. .platform_data = &mcp251x_info,
  94. .controller_data = &mcp251x_chip_info3,
  95. .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3)
  96. },
  97. {
  98. .modalias = "mcp251x",
  99. .max_speed_hz = 6500000,
  100. .bus_num = 4,
  101. .chip_select = 1,
  102. .platform_data = &mcp251x_info,
  103. .controller_data = &mcp251x_chip_info4,
  104. .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ4)
  105. }
  106. };
  107. static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = {
  108. .clock_enable = CKEN_SSP3,
  109. .num_chipselect = 2,
  110. .enable_dma = 1
  111. };
  112. static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = {
  113. .clock_enable = CKEN_SSP4,
  114. .num_chipselect = 2,
  115. .enable_dma = 1
  116. };
  117. struct platform_device pxa_spi_ssp3 = {
  118. .name = "pxa2xx-spi",
  119. .id = 3,
  120. .dev = {
  121. .platform_data = &pxa_ssp3_spi_master_info,
  122. }
  123. };
  124. struct platform_device pxa_spi_ssp4 = {
  125. .name = "pxa2xx-spi",
  126. .id = 4,
  127. .dev = {
  128. .platform_data = &pxa_ssp4_spi_master_info,
  129. }
  130. };
  131. static struct platform_device *icontrol_spi_devices[] __initdata = {
  132. &pxa_spi_ssp3,
  133. &pxa_spi_ssp4,
  134. };
  135. static mfp_cfg_t mfp_can_cfg[] __initdata = {
  136. /* CAN CS lines */
  137. GPIO15_GPIO,
  138. GPIO16_GPIO,
  139. GPIO17_GPIO,
  140. GPIO24_GPIO,
  141. /* SPI (SSP3) lines */
  142. GPIO89_SSP3_SCLK,
  143. GPIO91_SSP3_TXD,
  144. GPIO92_SSP3_RXD,
  145. /* SPI (SSP4) lines */
  146. GPIO93_SSP4_SCLK,
  147. GPIO95_SSP4_TXD,
  148. GPIO96_SSP4_RXD,
  149. /* CAN nIRQ lines */
  150. GPIO74_GPIO | MFP_LPM_EDGE_RISE,
  151. GPIO75_GPIO | MFP_LPM_EDGE_RISE,
  152. GPIO76_GPIO | MFP_LPM_EDGE_RISE,
  153. GPIO77_GPIO | MFP_LPM_EDGE_RISE
  154. };
  155. static void __init icontrol_can_init(void)
  156. {
  157. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
  158. platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
  159. spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
  160. }
  161. static void __init icontrol_init(void)
  162. {
  163. mxm_8x10_barebones_init();
  164. mxm_8x10_usb_host_init();
  165. mxm_8x10_mmc_init();
  166. icontrol_can_init();
  167. }
  168. MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
  169. .phys_io = 0x40000000,
  170. .boot_params = 0xa0000100,
  171. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  172. .map_io = pxa_map_io,
  173. .init_irq = pxa3xx_init_irq,
  174. .timer = &pxa_timer,
  175. .init_machine = icontrol_init
  176. MACHINE_END