MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / m68knommu / platform / 532x / spi-mcf532x.c
blob9fc5615de14a59fe12d47825e8d7e597ea9c472f
1 /***************************************************************************/
2 /*
3 * linux/arch/m68knommu/platform/532x/spi-mcf532x.c
5 * Sub-architcture dependant initialization code for the Freescale
6 * 532x SPI module
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>
30 #include <asm/dma.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 = {
60 .mode = SPI_MODE_0,
61 .bits_per_word = 8,
62 .del_cs_to_clk = 17,
63 .del_after_trans = 1,
64 .void_write_data = 0
67 static struct ads7843_platform_data ads784x_platform_data = {
68 .model = 7843,
69 .vref_delay_usecs = 0,
70 .x_plate_ohms = 580,
71 .y_plate_ohms = 410
73 #endif
76 static struct spi_board_info spi_board_info[] = {
77 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
79 .modalias = "ads7843",
80 .max_speed_hz = 125000 * 16,
81 .bus_num = 1,
82 .chip_select = 1,
83 .irq = ADS784x_IRQ_VECTOR,
84 .platform_data = &ads784x_platform_data,
85 .controller_data = &ads784x_chip_info
87 #endif
90 static struct coldfire_spi_master coldfire_master_info = {
91 .bus_num = 1,
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[] = {
103 [0] = {
104 .name = "qspi-par",
105 .start = MCF532x_QSPI_PAR,
106 .end = MCF532x_QSPI_PAR,
107 .flags = IORESOURCE_MEM
110 [1] = {
111 .name = "qspi-module",
112 .start = MCF532x_QSPI_QMR,
113 .end = MCF532x_QSPI_QMR + 0x18,
114 .flags = IORESOURCE_MEM
117 [2] = {
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
124 [3] = {
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",
134 .id = -1,
135 .resource = coldfire_spi_resources,
136 .num_resources = ARRAY_SIZE(coldfire_spi_resources),
137 .dev = {
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);
149 MCF_EPORT_EPDDR = 0;
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;
155 #endif
157 static int __init spi_dev_init(void)
159 int retval = 0;
160 #if defined(CONFIG_TOUCHSCREEN_ADS7843)
161 init_ads7843();
162 #endif
164 retval = platform_device_register(&coldfire_spi);
165 if (retval < 0)
166 goto out;
168 if (ARRAY_SIZE(spi_board_info))
169 retval = spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
172 out:
173 return retval;
176 arch_initcall(spi_dev_init);