Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 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 | |
| 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 Siewior | 8348c25 | 2010-11-22 17:12:15 -0800 | [diff] [blame] | 27 | #include <linux/spi/pxa2xx_spi.h> |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 28 | #include <linux/can/platform/mcp251x.h> |
Robert Jarzmik | a927ef8 | 2015-07-11 21:33:06 +0200 | [diff] [blame] | 29 | #include <linux/regulator/machine.h> |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 30 | |
| 31 | #include "generic.h" |
| 32 | |
| 33 | #define ICONTROL_MCP251x_nCS1 (15) |
| 34 | #define ICONTROL_MCP251x_nCS2 (16) |
| 35 | #define ICONTROL_MCP251x_nCS3 (17) |
| 36 | #define ICONTROL_MCP251x_nCS4 (24) |
| 37 | |
| 38 | #define ICONTROL_MCP251x_nIRQ1 (74) |
| 39 | #define ICONTROL_MCP251x_nIRQ2 (75) |
| 40 | #define ICONTROL_MCP251x_nIRQ3 (76) |
| 41 | #define ICONTROL_MCP251x_nIRQ4 (77) |
| 42 | |
| 43 | static struct pxa2xx_spi_chip mcp251x_chip_info1 = { |
| 44 | .tx_threshold = 8, |
| 45 | .rx_threshold = 128, |
| 46 | .dma_burst_size = 8, |
| 47 | .timeout = 235, |
| 48 | .gpio_cs = ICONTROL_MCP251x_nCS1 |
| 49 | }; |
| 50 | |
| 51 | static struct pxa2xx_spi_chip mcp251x_chip_info2 = { |
| 52 | .tx_threshold = 8, |
| 53 | .rx_threshold = 128, |
| 54 | .dma_burst_size = 8, |
| 55 | .timeout = 235, |
| 56 | .gpio_cs = ICONTROL_MCP251x_nCS2 |
| 57 | }; |
| 58 | |
| 59 | static struct pxa2xx_spi_chip mcp251x_chip_info3 = { |
| 60 | .tx_threshold = 8, |
| 61 | .rx_threshold = 128, |
| 62 | .dma_burst_size = 8, |
| 63 | .timeout = 235, |
| 64 | .gpio_cs = ICONTROL_MCP251x_nCS3 |
| 65 | }; |
| 66 | |
| 67 | static struct pxa2xx_spi_chip mcp251x_chip_info4 = { |
| 68 | .tx_threshold = 8, |
| 69 | .rx_threshold = 128, |
| 70 | .dma_burst_size = 8, |
| 71 | .timeout = 235, |
| 72 | .gpio_cs = ICONTROL_MCP251x_nCS4 |
| 73 | }; |
| 74 | |
| 75 | static struct mcp251x_platform_data mcp251x_info = { |
| 76 | .oscillator_frequency = 16E6, |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static struct spi_board_info mcp251x_board_info[] = { |
| 80 | { |
Marc Zyngier | e446630 | 2010-03-29 08:57:56 +0000 | [diff] [blame] | 81 | .modalias = "mcp2515", |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 82 | .max_speed_hz = 6500000, |
| 83 | .bus_num = 3, |
| 84 | .chip_select = 0, |
| 85 | .platform_data = &mcp251x_info, |
| 86 | .controller_data = &mcp251x_chip_info1, |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 87 | .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1) |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 88 | }, |
| 89 | { |
Marc Zyngier | e446630 | 2010-03-29 08:57:56 +0000 | [diff] [blame] | 90 | .modalias = "mcp2515", |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 91 | .max_speed_hz = 6500000, |
| 92 | .bus_num = 3, |
| 93 | .chip_select = 1, |
| 94 | .platform_data = &mcp251x_info, |
| 95 | .controller_data = &mcp251x_chip_info2, |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 96 | .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2) |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 97 | }, |
| 98 | { |
Marc Zyngier | e446630 | 2010-03-29 08:57:56 +0000 | [diff] [blame] | 99 | .modalias = "mcp2515", |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 100 | .max_speed_hz = 6500000, |
| 101 | .bus_num = 4, |
| 102 | .chip_select = 0, |
| 103 | .platform_data = &mcp251x_info, |
| 104 | .controller_data = &mcp251x_chip_info3, |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 105 | .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3) |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 106 | }, |
| 107 | { |
Marc Zyngier | e446630 | 2010-03-29 08:57:56 +0000 | [diff] [blame] | 108 | .modalias = "mcp2515", |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 109 | .max_speed_hz = 6500000, |
| 110 | .bus_num = 4, |
| 111 | .chip_select = 1, |
| 112 | .platform_data = &mcp251x_info, |
| 113 | .controller_data = &mcp251x_chip_info4, |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 114 | .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4) |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 115 | } |
| 116 | }; |
| 117 | |
| 118 | static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = { |
| 119 | .clock_enable = CKEN_SSP3, |
| 120 | .num_chipselect = 2, |
| 121 | .enable_dma = 1 |
| 122 | }; |
| 123 | |
| 124 | static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = { |
| 125 | .clock_enable = CKEN_SSP4, |
| 126 | .num_chipselect = 2, |
| 127 | .enable_dma = 1 |
| 128 | }; |
| 129 | |
| 130 | struct 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 | |
| 138 | struct 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 | |
| 146 | static struct platform_device *icontrol_spi_devices[] __initdata = { |
| 147 | &pxa_spi_ssp3, |
| 148 | &pxa_spi_ssp4, |
| 149 | }; |
| 150 | |
| 151 | static 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 | |
| 175 | static 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 | |
| 182 | static 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 Jarzmik | a927ef8 | 2015-07-11 21:33:06 +0200 | [diff] [blame] | 189 | |
| 190 | regulator_has_full_constraints(); |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 194 | .atag_offset = 0x100, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 195 | .map_io = pxa3xx_map_io, |
Rob Herring | 4e61109 | 2012-01-03 16:53:48 -0600 | [diff] [blame] | 196 | .nr_irqs = PXA_NR_IRQS, |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 197 | .init_irq = pxa3xx_init_irq, |
Eric Miao | 8a97ae2 | 2011-05-18 21:30:04 +0800 | [diff] [blame] | 198 | .handle_irq = pxa3xx_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 199 | .init_time = pxa_timer_init, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 200 | .init_machine = icontrol_init, |
| 201 | .restart = pxa_restart, |
Edwin Peer | 1f3b536 | 2010-02-05 18:31:48 +0200 | [diff] [blame] | 202 | MACHINE_END |