1 /***************************************************************************/
3 * linux/arch/m68knommu/platform/532x/spi-mcf532x.c
5 * Sub-architcture dependant initialization code for the Freescale
8 * Yaroslav Vinogradov yaroslav.vinogradov@freescale.com
9 * Copyright Freescale Semiconductor, Inc 2006
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 /***************************************************************************/
19 #include <linux/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/param.h>
22 #include <linux/init.h>
23 #include <linux/interrupt.h>
24 #include <linux/device.h>
25 #include <linux/platform_device.h>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/mcfqspi.h>
28 #include <linux/spi/ads7843.h>
31 #include <asm/traps.h>
32 #include <asm/machdep.h>
33 #include <asm/coldfire.h>
34 #include <asm/mcfsim.h>
35 #include <asm/mcfdma.h>
37 #define SPI_NUM_CHIPSELECTS 0x04
38 #define SPI_PAR_VAL 0xFFF0 /* Enable DIN, DOUT, CLK */
40 #define MCF532x_QSPI_IRQ_SOURCE (31)
41 #define MCF532x_QSPI_IRQ_VECTOR (64 + MCF532x_QSPI_IRQ_SOURCE)
43 #define MCF532x_QSPI_PAR (0xFC0A405A)
44 #define MCF532x_QSPI_QMR (0xFC05C000)
45 #define MCF532x_INTC0_ICR (0xFC048040)
46 #define MCF532x_INTC0_IMRL (0xFC04800C)
48 /* on 5329 EVB ADS7843 is connected to IRQ4 */
49 #define ADS784x_IRQ_SOURCE 4
50 #define ADS784x_IRQ_VECTOR (64+ADS784x_IRQ_SOURCE)
51 #define ADS7843_IRQ_LEVEL 2
54 void coldfire_qspi_cs_control(u8 cs
, u8 command
)
58 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
59 static struct coldfire_spi_chip ads784x_chip_info
= {
67 static struct ads7843_platform_data ads784x_platform_data
= {
69 .vref_delay_usecs
= 0,
76 static struct spi_board_info spi_board_info
[] = {
77 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
79 .modalias
= "ads7843",
80 .max_speed_hz
= 125000 * 16,
83 .irq
= ADS784x_IRQ_VECTOR
,
84 .platform_data
= &ads784x_platform_data
,
85 .controller_data
= &ads784x_chip_info
90 static struct coldfire_spi_master coldfire_master_info
= {
92 .num_chipselect
= SPI_NUM_CHIPSELECTS
,
93 .irq_source
= MCF532x_QSPI_IRQ_SOURCE
,
94 .irq_vector
= MCF532x_QSPI_IRQ_VECTOR
,
95 .irq_mask
= (0x01 << MCF532x_QSPI_IRQ_SOURCE
),
96 .irq_lp
= 0x5, /* Level */
97 .par_val
= 0, /* not used on 532x */
98 .par_val16
= SPI_PAR_VAL
,
99 .cs_control
= coldfire_qspi_cs_control
,
102 static struct resource coldfire_spi_resources
[] = {
105 .start
= MCF532x_QSPI_PAR
,
106 .end
= MCF532x_QSPI_PAR
,
107 .flags
= IORESOURCE_MEM
111 .name
= "qspi-module",
112 .start
= MCF532x_QSPI_QMR
,
113 .end
= MCF532x_QSPI_QMR
+ 0x18,
114 .flags
= IORESOURCE_MEM
118 .name
= "qspi-int-level",
119 .start
= MCF532x_INTC0_ICR
+ MCF532x_QSPI_IRQ_SOURCE
,
120 .end
= MCF532x_INTC0_ICR
+ MCF532x_QSPI_IRQ_SOURCE
,
121 .flags
= IORESOURCE_MEM
125 .name
= "qspi-int-mask",
126 .start
= MCF532x_INTC0_IMRL
,
127 .end
= MCF532x_INTC0_IMRL
,
128 .flags
= IORESOURCE_MEM
132 static struct platform_device coldfire_spi
= {
133 .name
= "coldfire-qspi",
135 .resource
= coldfire_spi_resources
,
136 .num_resources
= ARRAY_SIZE(coldfire_spi_resources
),
138 .platform_data
= &coldfire_master_info
,
142 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
143 static int __init
init_ads7843(void)
145 /* GPIO initiaalization */
146 MCF_GPIO_PAR_IRQ
= MCF_GPIO_PAR_IRQ_PAR_IRQ4(0);
147 /* EPORT initialization */
148 MCF_EPORT_EPPAR
= MCF_EPORT_EPPAR_EPPA4(MCF_EPORT_EPPAR_FALLING
);
150 MCF_EPORT_EPIER
= MCF_EPORT_EPIER_EPIE4
;
151 /* enable interrupt source */
152 MCF_INTC0_ICR4
= ADS7843_IRQ_LEVEL
;
153 MCF_INTC0_CIMR
= ADS784x_IRQ_SOURCE
;
157 static int __init
spi_dev_init(void)
160 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
164 retval
= platform_device_register(&coldfire_spi
);
168 if (ARRAY_SIZE(spi_board_info
))
169 retval
= spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
176 arch_initcall(spi_dev_init
);