Linux Audio

Check our new training course

Loading...
v3.15
 
  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>
 27#include <linux/spi/pxa2xx_spi.h>
 28#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,
 
 
 
 
 
 76};
 77
 78static struct spi_board_info mcp251x_board_info[] = {
 79	{
 80		.modalias        = "mcp2515",
 81		.max_speed_hz    = 6500000,
 82		.bus_num         = 3,
 83		.chip_select     = 0,
 84		.platform_data   = &mcp251x_info,
 85		.controller_data = &mcp251x_chip_info1,
 86		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
 87	},
 88	{
 89		.modalias        = "mcp2515",
 90		.max_speed_hz    = 6500000,
 91		.bus_num         = 3,
 92		.chip_select     = 1,
 93		.platform_data   = &mcp251x_info,
 94		.controller_data = &mcp251x_chip_info2,
 95		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
 96	},
 97	{
 98		.modalias        = "mcp2515",
 99		.max_speed_hz    = 6500000,
100		.bus_num         = 4,
101		.chip_select     = 0,
102		.platform_data   = &mcp251x_info,
103		.controller_data = &mcp251x_chip_info3,
104		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
105	},
106	{
107		.modalias        = "mcp2515",
108		.max_speed_hz    = 6500000,
109		.bus_num         = 4,
110		.chip_select     = 1,
111		.platform_data   = &mcp251x_info,
112		.controller_data = &mcp251x_chip_info4,
113		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
114	}
115};
116
117static struct pxa2xx_spi_master pxa_ssp3_spi_master_info = {
118	.clock_enable   = CKEN_SSP3,
119	.num_chipselect = 2,
120	.enable_dma     = 1
121};
122
123static struct pxa2xx_spi_master pxa_ssp4_spi_master_info = {
124	.clock_enable   = CKEN_SSP4,
125	.num_chipselect = 2,
126	.enable_dma     = 1
127};
128
129struct platform_device pxa_spi_ssp3 = {
130	.name          = "pxa2xx-spi",
131	.id            = 3,
132	.dev           = {
133		.platform_data = &pxa_ssp3_spi_master_info,
134	}
135};
136
137struct platform_device pxa_spi_ssp4 = {
138	.name          = "pxa2xx-spi",
139	.id            = 4,
140	.dev           = {
141		.platform_data = &pxa_ssp4_spi_master_info,
142	}
143};
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145static struct platform_device *icontrol_spi_devices[] __initdata = {
146	&pxa_spi_ssp3,
147	&pxa_spi_ssp4,
148};
149
150static mfp_cfg_t mfp_can_cfg[] __initdata = {
151	/* CAN CS lines */
152	GPIO15_GPIO,
153	GPIO16_GPIO,
154	GPIO17_GPIO,
155	GPIO24_GPIO,
156
157	/* SPI (SSP3) lines */
158	GPIO89_SSP3_SCLK,
159	GPIO91_SSP3_TXD,
160	GPIO92_SSP3_RXD,
161
162	/* SPI (SSP4) lines */
163	GPIO93_SSP4_SCLK,
164	GPIO95_SSP4_TXD,
165	GPIO96_SSP4_RXD,
166
167	/* CAN nIRQ lines */
168	GPIO74_GPIO | MFP_LPM_EDGE_RISE,
169	GPIO75_GPIO | MFP_LPM_EDGE_RISE,
170	GPIO76_GPIO | MFP_LPM_EDGE_RISE,
171	GPIO77_GPIO | MFP_LPM_EDGE_RISE
172};
173
174static void __init icontrol_can_init(void)
175{
176	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
 
 
177	platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
178	spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
179}
180
181static void __init icontrol_init(void)
182{
183	mxm_8x10_barebones_init();
184	mxm_8x10_usb_host_init();
185	mxm_8x10_mmc_init();
186
187	icontrol_can_init();
 
 
188}
189
190MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
191	.atag_offset	= 0x100,
192	.map_io		= pxa3xx_map_io,
193	.nr_irqs	= PXA_NR_IRQS,
194	.init_irq	= pxa3xx_init_irq,
195	.handle_irq	= pxa3xx_handle_irq,
196	.init_time	= pxa_timer_init,
197	.init_machine	= icontrol_init,
198	.restart	= pxa_restart,
199MACHINE_END
v6.2
  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 <hvdmerwe@tmtservies.co.za>
 
 
 
 
 11 */
 12
 13#include <linux/irq.h>
 14#include <linux/platform_device.h>
 15#include <linux/property.h>
 16#include <linux/gpio/machine.h>
 17
 18#include <asm/mach-types.h>
 19#include <asm/mach/arch.h>
 20
 21#include "pxa320.h"
 22#include "mxm8x10.h"
 23
 24#include <linux/spi/spi.h>
 25#include <linux/spi/pxa2xx_spi.h>
 26#include <linux/regulator/machine.h>
 27
 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};
 46
 47static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
 48	.tx_threshold   = 8,
 49	.rx_threshold   = 128,
 50	.dma_burst_size = 8,
 51	.timeout        = 235,
 
 52};
 53
 54static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
 55	.tx_threshold   = 8,
 56	.rx_threshold   = 128,
 57	.dma_burst_size = 8,
 58	.timeout        = 235,
 
 59};
 60
 61static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
 62	.tx_threshold   = 8,
 63	.rx_threshold   = 128,
 64	.dma_burst_size = 8,
 65	.timeout        = 235,
 
 66};
 67
 68static const struct property_entry mcp251x_properties[] = {
 69	PROPERTY_ENTRY_U32("clock-frequency", 16000000),
 70	{}
 71};
 72
 73static const struct software_node mcp251x_node = {
 74	.properties = mcp251x_properties,
 75};
 76
 77static struct spi_board_info mcp251x_board_info[] = {
 78	{
 79		.modalias        = "mcp2515",
 80		.max_speed_hz    = 6500000,
 81		.bus_num         = 3,
 82		.chip_select     = 0,
 83		.swnode		 = &mcp251x_node,
 84		.controller_data = &mcp251x_chip_info1,
 85		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
 86	},
 87	{
 88		.modalias        = "mcp2515",
 89		.max_speed_hz    = 6500000,
 90		.bus_num         = 3,
 91		.chip_select     = 1,
 92		.swnode		 = &mcp251x_node,
 93		.controller_data = &mcp251x_chip_info2,
 94		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
 95	},
 96	{
 97		.modalias        = "mcp2515",
 98		.max_speed_hz    = 6500000,
 99		.bus_num         = 4,
100		.chip_select     = 0,
101		.swnode		 = &mcp251x_node,
102		.controller_data = &mcp251x_chip_info3,
103		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
104	},
105	{
106		.modalias        = "mcp2515",
107		.max_speed_hz    = 6500000,
108		.bus_num         = 4,
109		.chip_select     = 1,
110		.swnode		 = &mcp251x_node,
111		.controller_data = &mcp251x_chip_info4,
112		.irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
113	}
114};
115
116static struct pxa2xx_spi_controller pxa_ssp3_spi_master_info = {
 
117	.num_chipselect = 2,
118	.enable_dma     = 1
119};
120
121static struct pxa2xx_spi_controller pxa_ssp4_spi_master_info = {
 
122	.num_chipselect = 2,
123	.enable_dma     = 1
124};
125
126struct platform_device pxa_spi_ssp3 = {
127	.name          = "pxa2xx-spi",
128	.id            = 3,
129	.dev           = {
130		.platform_data = &pxa_ssp3_spi_master_info,
131	}
132};
133
134struct platform_device pxa_spi_ssp4 = {
135	.name          = "pxa2xx-spi",
136	.id            = 4,
137	.dev           = {
138		.platform_data = &pxa_ssp4_spi_master_info,
139	}
140};
141
142static struct gpiod_lookup_table pxa_ssp3_gpio_table = {
143	.dev_id = "spi3",
144	.table = {
145		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS1, "cs", 0, GPIO_ACTIVE_LOW),
146		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS2, "cs", 1, GPIO_ACTIVE_LOW),
147		{ },
148	},
149};
150
151static struct gpiod_lookup_table pxa_ssp4_gpio_table = {
152	.dev_id = "spi4",
153	.table = {
154		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS3, "cs", 0, GPIO_ACTIVE_LOW),
155		GPIO_LOOKUP_IDX("gpio-pxa", ICONTROL_MCP251x_nCS4, "cs", 1, GPIO_ACTIVE_LOW),
156		{ },
157	},
158};
159
160static struct platform_device *icontrol_spi_devices[] __initdata = {
161	&pxa_spi_ssp3,
162	&pxa_spi_ssp4,
163};
164
165static mfp_cfg_t mfp_can_cfg[] __initdata = {
166	/* CAN CS lines */
167	GPIO15_GPIO,
168	GPIO16_GPIO,
169	GPIO17_GPIO,
170	GPIO24_GPIO,
171
172	/* SPI (SSP3) lines */
173	GPIO89_SSP3_SCLK,
174	GPIO91_SSP3_TXD,
175	GPIO92_SSP3_RXD,
176
177	/* SPI (SSP4) lines */
178	GPIO93_SSP4_SCLK,
179	GPIO95_SSP4_TXD,
180	GPIO96_SSP4_RXD,
181
182	/* CAN nIRQ lines */
183	GPIO74_GPIO | MFP_LPM_EDGE_RISE,
184	GPIO75_GPIO | MFP_LPM_EDGE_RISE,
185	GPIO76_GPIO | MFP_LPM_EDGE_RISE,
186	GPIO77_GPIO | MFP_LPM_EDGE_RISE
187};
188
189static void __init icontrol_can_init(void)
190{
191	pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
192	gpiod_add_lookup_table(&pxa_ssp3_gpio_table);
193	gpiod_add_lookup_table(&pxa_ssp4_gpio_table);
194	platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
195	spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
196}
197
198static void __init icontrol_init(void)
199{
200	mxm_8x10_barebones_init();
201	mxm_8x10_usb_host_init();
202	mxm_8x10_mmc_init();
203
204	icontrol_can_init();
205
206	regulator_has_full_constraints();
207}
208
209MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
210	.atag_offset	= 0x100,
211	.map_io		= pxa3xx_map_io,
212	.nr_irqs	= PXA_NR_IRQS,
213	.init_irq	= pxa3xx_init_irq,
214	.handle_irq	= pxa3xx_handle_irq,
215	.init_time	= pxa_timer_init,
216	.init_machine	= icontrol_init,
217	.restart	= pxa_restart,
218MACHINE_END