blob: 1d02eabc9c654bb18751a9b802c2f3cdbc8c83a5 [file] [log] [blame]
Edwin Peer1f3b5362010-02-05 18:31:48 +02001/*
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
16#include <linux/irq.h>
17#include <linux/platform_device.h>
18#include <linux/gpio.h>
19
20#include <asm/mach-types.h>
21#include <asm/mach/arch.h>
22
23#include <mach/pxa320.h>
24#include <mach/mxm8x10.h>
25
26#include <linux/spi/spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080027#include <linux/spi/pxa2xx_spi.h>
Edwin Peer1f3b5362010-02-05 18:31:48 +020028#include <linux/can/platform/mcp251x.h>
29
30#include "generic.h"
31
32#define ICONTROL_MCP251x_nCS1 (15)
33#define ICONTROL_MCP251x_nCS2 (16)
34#define ICONTROL_MCP251x_nCS3 (17)
35#define ICONTROL_MCP251x_nCS4 (24)
36
37#define ICONTROL_MCP251x_nIRQ1 (74)
38#define ICONTROL_MCP251x_nIRQ2 (75)
39#define ICONTROL_MCP251x_nIRQ3 (76)
40#define ICONTROL_MCP251x_nIRQ4 (77)
41
42static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
43 .tx_threshold = 8,
44 .rx_threshold = 128,
45 .dma_burst_size = 8,
46 .timeout = 235,
47 .gpio_cs = ICONTROL_MCP251x_nCS1
48};
49
50static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
51 .tx_threshold = 8,
52 .rx_threshold = 128,
53 .dma_burst_size = 8,
54 .timeout = 235,
55 .gpio_cs = ICONTROL_MCP251x_nCS2
56};
57
58static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
59 .tx_threshold = 8,
60 .rx_threshold = 128,
61 .dma_burst_size = 8,
62 .timeout = 235,
63 .gpio_cs = ICONTROL_MCP251x_nCS3
64};
65
66static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
67 .tx_threshold = 8,
68 .rx_threshold = 128,
69 .dma_burst_size = 8,
70 .timeout = 235,
71 .gpio_cs = ICONTROL_MCP251x_nCS4
72};
73
74static struct mcp251x_platform_data mcp251x_info = {
75 .oscillator_frequency = 16E6,
Edwin Peer1f3b5362010-02-05 18:31:48 +020076 .board_specific_setup = NULL,
77 .power_enable = NULL,
78 .transceiver_enable = NULL
79};
80
81static 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,
87 .platform_data = &mcp251x_info,
88 .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,
96 .platform_data = &mcp251x_info,
97 .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,
105 .platform_data = &mcp251x_info,
106 .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,
114 .platform_data = &mcp251x_info,
115 .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
120static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = {
121 .clock_enable = CKEN_SSP3,
122 .num_chipselect = 2,
123 .enable_dma = 1
124};
125
126static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = {
127 .clock_enable = CKEN_SSP4,
128 .num_chipselect = 2,
129 .enable_dma = 1
130};
131
132struct platform_device pxa_spi_ssp3 = {
133 .name = "pxa2xx-spi",
134 .id = 3,
135 .dev = {
136 .platform_data = &pxa_ssp3_spi_master_info,
137 }
138};
139
140struct platform_device pxa_spi_ssp4 = {
141 .name = "pxa2xx-spi",
142 .id = 4,
143 .dev = {
144 .platform_data = &pxa_ssp4_spi_master_info,
145 }
146};
147
148static struct platform_device *icontrol_spi_devices[] __initdata = {
149 &pxa_spi_ssp3,
150 &pxa_spi_ssp4,
151};
152
153static mfp_cfg_t mfp_can_cfg[] __initdata = {
154 /* CAN CS lines */
155 GPIO15_GPIO,
156 GPIO16_GPIO,
157 GPIO17_GPIO,
158 GPIO24_GPIO,
159
160 /* SPI (SSP3) lines */
161 GPIO89_SSP3_SCLK,
162 GPIO91_SSP3_TXD,
163 GPIO92_SSP3_RXD,
164
165 /* SPI (SSP4) lines */
166 GPIO93_SSP4_SCLK,
167 GPIO95_SSP4_TXD,
168 GPIO96_SSP4_RXD,
169
170 /* CAN nIRQ lines */
171 GPIO74_GPIO | MFP_LPM_EDGE_RISE,
172 GPIO75_GPIO | MFP_LPM_EDGE_RISE,
173 GPIO76_GPIO | MFP_LPM_EDGE_RISE,
174 GPIO77_GPIO | MFP_LPM_EDGE_RISE
175};
176
177static void __init icontrol_can_init(void)
178{
179 pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
180 platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
181 spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
182}
183
184static void __init icontrol_init(void)
185{
186 mxm_8x10_barebones_init();
187 mxm_8x10_usb_host_init();
188 mxm_8x10_mmc_init();
189
190 icontrol_can_init();
191}
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,
Edwin Peer1f3b5362010-02-05 18:31:48 +0200199 .timer = &pxa_timer,
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