icontrol.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/icontrol.c
  4. *
  5. * Support for the iControl and SafeTcam platforms from TMT Services
  6. * using the Embedian MXM-8x10 Computer on Module
  7. *
  8. * Copyright (C) 2009 TMT Services & Supplies (Pty) Ltd.
  9. *
  10. * 2010-01-21 Hennie van der Merve <[email protected]>
  11. */
  12. #include <linux/irq.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/property.h>
  15. #include <linux/gpio/machine.h>
  16. #include <asm/mach-types.h>
  17. #include <asm/mach/arch.h>
  18. #include "pxa320.h"
  19. #include "mxm8x10.h"
  20. #include <linux/spi/spi.h>
  21. #include <linux/spi/pxa2xx_spi.h>
  22. #include <linux/regulator/machine.h>
  23. #include "generic.h"
  24. #define ICONTROL_MCP251x_nCS1 (15)
  25. #define ICONTROL_MCP251x_nCS2 (16)
  26. #define ICONTROL_MCP251x_nCS3 (17)
  27. #define ICONTROL_MCP251x_nCS4 (24)
  28. #define ICONTROL_MCP251x_nIRQ1 (74)
  29. #define ICONTROL_MCP251x_nIRQ2 (75)
  30. #define ICONTROL_MCP251x_nIRQ3 (76)
  31. #define ICONTROL_MCP251x_nIRQ4 (77)
  32. static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
  33. .tx_threshold = 8,
  34. .rx_threshold = 128,
  35. .dma_burst_size = 8,
  36. .timeout = 235,
  37. };
  38. static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
  39. .tx_threshold = 8,
  40. .rx_threshold = 128,
  41. .dma_burst_size = 8,
  42. .timeout = 235,
  43. };
  44. static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
  45. .tx_threshold = 8,
  46. .rx_threshold = 128,
  47. .dma_burst_size = 8,
  48. .timeout = 235,
  49. };
  50. static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
  51. .tx_threshold = 8,
  52. .rx_threshold = 128,
  53. .dma_burst_size = 8,
  54. .timeout = 235,
  55. };
  56. static const struct property_entry mcp251x_properties[] = {
  57. PROPERTY_ENTRY_U32("clock-frequency", 16000000),
  58. {}
  59. };
  60. static const struct software_node mcp251x_node = {
  61. .properties = mcp251x_properties,
  62. };
  63. static struct spi_board_info mcp251x_board_info[] = {
  64. {
  65. .modalias = "mcp2515",
  66. .max_speed_hz = 6500000,
  67. .bus_num = 3,
  68. .chip_select = 0,
  69. .swnode = &mcp251x_node,
  70. .controller_data = &mcp251x_chip_info1,
  71. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
  72. },
  73. {
  74. .modalias = "mcp2515",
  75. .max_speed_hz = 6500000,
  76. .bus_num = 3,
  77. .chip_select = 1,
  78. .swnode = &mcp251x_node,
  79. .controller_data = &mcp251x_chip_info2,
  80. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
  81. },
  82. {
  83. .modalias = "mcp2515",
  84. .max_speed_hz = 6500000,
  85. .bus_num = 4,
  86. .chip_select = 0,
  87. .swnode = &mcp251x_node,
  88. .controller_data = &mcp251x_chip_info3,
  89. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
  90. },
  91. {
  92. .modalias = "mcp2515",
  93. .max_speed_hz = 6500000,
  94. .bus_num = 4,
  95. .chip_select = 1,
  96. .swnode = &mcp251x_node,
  97. .controller_data = &mcp251x_chip_info4,
  98. .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
  99. }
  100. };
  101. static struct pxa2xx_spi_controller pxa_ssp3_spi_master_info = {
  102. .num_chipselect = 2,
  103. .enable_dma = 1
  104. };
  105. static struct pxa2xx_spi_controller pxa_ssp4_spi_master_info = {
  106. .num_chipselect = 2,
  107. .enable_dma = 1
  108. };
  109. struct platform_device pxa_spi_ssp3 = {
  110. .name = "pxa2xx-spi",
  111. .id = 3,
  112. .dev = {
  113. .platform_data = &pxa_ssp3_spi_master_info,
  114. }
  115. };
  116. struct platform_device pxa_spi_ssp4 = {
  117. .name = "pxa2xx-spi",
  118. .id = 4,
  119. .dev = {
  120. .platform_data = &pxa_ssp4_spi_master_info,
  121. }
  122. };
  123. static struct gpiod_lookup_table pxa_ssp3_gpio_table = {
  124. .dev_id = "spi3",
  125. .table = {
  126. GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS1, "cs", 0, GPIO_ACTIVE_LOW),
  127. GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS2, "cs", 1, GPIO_ACTIVE_LOW),
  128. { },
  129. },
  130. };
  131. static struct gpiod_lookup_table pxa_ssp4_gpio_table = {
  132. .dev_id = "spi4",
  133. .table = {
  134. GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS3, "cs", 0, GPIO_ACTIVE_LOW),
  135. GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS4, "cs", 1, GPIO_ACTIVE_LOW),
  136. { },
  137. },
  138. };
  139. static struct platform_device *icontrol_spi_devices[] __initdata = {
  140. &pxa_spi_ssp3,
  141. &pxa_spi_ssp4,
  142. };
  143. static mfp_cfg_t mfp_can_cfg[] __initdata = {
  144. /* CAN CS lines */
  145. GPIO15_GPIO,
  146. GPIO16_GPIO,
  147. GPIO17_GPIO,
  148. GPIO24_GPIO,
  149. /* SPI (SSP3) lines */
  150. GPIO89_SSP3_SCLK,
  151. GPIO91_SSP3_TXD,
  152. GPIO92_SSP3_RXD,
  153. /* SPI (SSP4) lines */
  154. GPIO93_SSP4_SCLK,
  155. GPIO95_SSP4_TXD,
  156. GPIO96_SSP4_RXD,
  157. /* CAN nIRQ lines */
  158. GPIO74_GPIO | MFP_LPM_EDGE_RISE,
  159. GPIO75_GPIO | MFP_LPM_EDGE_RISE,
  160. GPIO76_GPIO | MFP_LPM_EDGE_RISE,
  161. GPIO77_GPIO | MFP_LPM_EDGE_RISE
  162. };
  163. static void __init icontrol_can_init(void)
  164. {
  165. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
  166. gpiod_add_lookup_table(&pxa_ssp3_gpio_table);
  167. gpiod_add_lookup_table(&pxa_ssp4_gpio_table);
  168. platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
  169. spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
  170. }
  171. static void __init icontrol_init(void)
  172. {
  173. mxm_8x10_barebones_init();
  174. mxm_8x10_usb_host_init();
  175. mxm_8x10_mmc_init();
  176. icontrol_can_init();
  177. regulator_has_full_constraints();
  178. }
  179. MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
  180. .atag_offset = 0x100,
  181. .map_io = pxa3xx_map_io,
  182. .nr_irqs = PXA_NR_IRQS,
  183. .init_irq = pxa3xx_init_irq,
  184. .handle_irq = pxa3xx_handle_irq,
  185. .init_time = pxa_timer_init,
  186. .init_machine = icontrol_init,
  187. .restart = pxa_restart,
  188. MACHINE_END