icontrol.c 4.8 KB

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