blob: 04a12523cdee0418e764027cb0cbc732fd594c20 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Edwin Peer1f3b5362010-02-05 18:31:48 +02002/*
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 <hvdmerwe@tmtservies.co.za>
Edwin Peer1f3b5362010-02-05 18:31:48 +020011 */
12
13#include <linux/irq.h>
14#include <linux/platform_device.h>
Andy Shevchenko50ec8812019-10-08 19:20:39 +030015#include <linux/property.h>
Edwin Peer1f3b5362010-02-05 18:31:48 +020016#include <linux/gpio.h>
17
18#include <asm/mach-types.h>
19#include <asm/mach/arch.h>
20
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010021#include "pxa320.h"
22#include "mxm8x10.h"
Edwin Peer1f3b5362010-02-05 18:31:48 +020023
24#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080025#include <linux/spi/pxa2xx_spi.h>
Robert Jarzmika927ef82015-07-11 21:33:06 +020026#include <linux/regulator/machine.h>
Edwin Peer1f3b5362010-02-05 18:31:48 +020027
28#include "generic.h"
29
30#define ICONTROL_MCP251x_nCS1 (15)
31#define ICONTROL_MCP251x_nCS2 (16)
32#define ICONTROL_MCP251x_nCS3 (17)
33#define ICONTROL_MCP251x_nCS4 (24)
34
35#define ICONTROL_MCP251x_nIRQ1 (74)
36#define ICONTROL_MCP251x_nIRQ2 (75)
37#define ICONTROL_MCP251x_nIRQ3 (76)
38#define ICONTROL_MCP251x_nIRQ4 (77)
39
40static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
41 .tx_threshold = 8,
42 .rx_threshold = 128,
43 .dma_burst_size = 8,
44 .timeout = 235,
45 .gpio_cs = ICONTROL_MCP251x_nCS1
46};
47
48static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
49 .tx_threshold = 8,
50 .rx_threshold = 128,
51 .dma_burst_size = 8,
52 .timeout = 235,
53 .gpio_cs = ICONTROL_MCP251x_nCS2
54};
55
56static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
57 .tx_threshold = 8,
58 .rx_threshold = 128,
59 .dma_burst_size = 8,
60 .timeout = 235,
61 .gpio_cs = ICONTROL_MCP251x_nCS3
62};
63
64static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
65 .tx_threshold = 8,
66 .rx_threshold = 128,
67 .dma_burst_size = 8,
68 .timeout = 235,
69 .gpio_cs = ICONTROL_MCP251x_nCS4
70};
71
Andy Shevchenko50ec8812019-10-08 19:20:39 +030072static const struct property_entry mcp251x_properties[] = {
73 PROPERTY_ENTRY_U32("clock-frequency", 16000000),
74 {}
Edwin Peer1f3b5362010-02-05 18:31:48 +020075};
76
Heikki Krogerus2df0c4a2021-03-03 18:28:12 +030077static const struct software_node mcp251x_node = {
78 .properties = mcp251x_properties,
79};
80
Edwin Peer1f3b5362010-02-05 18:31:48 +020081static struct spi_board_info mcp251x_board_info[] = {
82 {
Marc Zyngiere4466302010-03-29 08:57:56 +000083 .modalias = "mcp2515",
Edwin Peer1f3b5362010-02-05 18:31:48 +020084 .max_speed_hz = 6500000,
85 .bus_num = 3,
86 .chip_select = 0,
Heikki Krogerus2df0c4a2021-03-03 18:28:12 +030087 .swnode = &mcp251x_node,
Edwin Peer1f3b5362010-02-05 18:31:48 +020088 .controller_data = &mcp251x_chip_info1,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +080089 .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
Edwin Peer1f3b5362010-02-05 18:31:48 +020090 },
91 {
Marc Zyngiere4466302010-03-29 08:57:56 +000092 .modalias = "mcp2515",
Edwin Peer1f3b5362010-02-05 18:31:48 +020093 .max_speed_hz = 6500000,
94 .bus_num = 3,
95 .chip_select = 1,
Heikki Krogerus2df0c4a2021-03-03 18:28:12 +030096 .swnode = &mcp251x_node,
Edwin Peer1f3b5362010-02-05 18:31:48 +020097 .controller_data = &mcp251x_chip_info2,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +080098 .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
Edwin Peer1f3b5362010-02-05 18:31:48 +020099 },
100 {
Marc Zyngiere4466302010-03-29 08:57:56 +0000101 .modalias = "mcp2515",
Edwin Peer1f3b5362010-02-05 18:31:48 +0200102 .max_speed_hz = 6500000,
103 .bus_num = 4,
104 .chip_select = 0,
Heikki Krogerus2df0c4a2021-03-03 18:28:12 +0300105 .swnode = &mcp251x_node,
Edwin Peer1f3b5362010-02-05 18:31:48 +0200106 .controller_data = &mcp251x_chip_info3,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800107 .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
Edwin Peer1f3b5362010-02-05 18:31:48 +0200108 },
109 {
Marc Zyngiere4466302010-03-29 08:57:56 +0000110 .modalias = "mcp2515",
Edwin Peer1f3b5362010-02-05 18:31:48 +0200111 .max_speed_hz = 6500000,
112 .bus_num = 4,
113 .chip_select = 1,
Heikki Krogerus2df0c4a2021-03-03 18:28:12 +0300114 .swnode = &mcp251x_node,
Edwin Peer1f3b5362010-02-05 18:31:48 +0200115 .controller_data = &mcp251x_chip_info4,
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800116 .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
Edwin Peer1f3b5362010-02-05 18:31:48 +0200117 }
118};
119
Lubomir Rintel51eea522019-01-16 16:13:31 +0100120static struct pxa2xx_spi_controller pxa_ssp3_spi_master_info = {
Edwin Peer1f3b5362010-02-05 18:31:48 +0200121 .num_chipselect = 2,
122 .enable_dma = 1
123};
124
Lubomir Rintel51eea522019-01-16 16:13:31 +0100125static struct pxa2xx_spi_controller pxa_ssp4_spi_master_info = {
Edwin Peer1f3b5362010-02-05 18:31:48 +0200126 .num_chipselect = 2,
127 .enable_dma = 1
128};
129
130struct platform_device pxa_spi_ssp3 = {
131 .name = "pxa2xx-spi",
132 .id = 3,
133 .dev = {
134 .platform_data = &pxa_ssp3_spi_master_info,
135 }
136};
137
138struct platform_device pxa_spi_ssp4 = {
139 .name = "pxa2xx-spi",
140 .id = 4,
141 .dev = {
142 .platform_data = &pxa_ssp4_spi_master_info,
143 }
144};
145
146static struct platform_device *icontrol_spi_devices[] __initdata = {
147 &pxa_spi_ssp3,
148 &pxa_spi_ssp4,
149};
150
151static mfp_cfg_t mfp_can_cfg[] __initdata = {
152 /* CAN CS lines */
153 GPIO15_GPIO,
154 GPIO16_GPIO,
155 GPIO17_GPIO,
156 GPIO24_GPIO,
157
158 /* SPI (SSP3) lines */
159 GPIO89_SSP3_SCLK,
160 GPIO91_SSP3_TXD,
161 GPIO92_SSP3_RXD,
162
163 /* SPI (SSP4) lines */
164 GPIO93_SSP4_SCLK,
165 GPIO95_SSP4_TXD,
166 GPIO96_SSP4_RXD,
167
168 /* CAN nIRQ lines */
169 GPIO74_GPIO | MFP_LPM_EDGE_RISE,
170 GPIO75_GPIO | MFP_LPM_EDGE_RISE,
171 GPIO76_GPIO | MFP_LPM_EDGE_RISE,
172 GPIO77_GPIO | MFP_LPM_EDGE_RISE
173};
174
175static void __init icontrol_can_init(void)
176{
177 pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
178 platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
179 spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
180}
181
182static void __init icontrol_init(void)
183{
184 mxm_8x10_barebones_init();
185 mxm_8x10_usb_host_init();
186 mxm_8x10_mmc_init();
187
188 icontrol_can_init();
Robert Jarzmika927ef82015-07-11 21:33:06 +0200189
190 regulator_has_full_constraints();
Edwin Peer1f3b5362010-02-05 18:31:48 +0200191}
192
193MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400194 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200195 .map_io = pxa3xx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600196 .nr_irqs = PXA_NR_IRQS,
Edwin Peer1f3b5362010-02-05 18:31:48 +0200197 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800198 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700199 .init_time = pxa_timer_init,
Russell King271a74f2011-11-04 14:15:53 +0000200 .init_machine = icontrol_init,
201 .restart = pxa_restart,
Edwin Peer1f3b5362010-02-05 18:31:48 +0200202MACHINE_END