diff options
Diffstat (limited to 'arch/m68k/platform/532x/config.c')
-rw-r--r-- | arch/m68k/platform/532x/config.c | 117 |
1 files changed, 3 insertions, 114 deletions
diff --git a/arch/m68k/platform/532x/config.c b/arch/m68k/platform/532x/config.c index c8e1395e9344..8c0dd5caae97 100644 --- a/arch/m68k/platform/532x/config.c +++ b/arch/m68k/platform/532x/config.c | |||
@@ -21,134 +21,24 @@ | |||
21 | #include <linux/param.h> | 21 | #include <linux/param.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/spi/spi.h> | ||
25 | #include <linux/gpio.h> | ||
26 | #include <asm/machdep.h> | 24 | #include <asm/machdep.h> |
27 | #include <asm/coldfire.h> | 25 | #include <asm/coldfire.h> |
28 | #include <asm/mcfsim.h> | 26 | #include <asm/mcfsim.h> |
29 | #include <asm/mcfuart.h> | 27 | #include <asm/mcfuart.h> |
30 | #include <asm/mcfdma.h> | 28 | #include <asm/mcfdma.h> |
31 | #include <asm/mcfwdebug.h> | 29 | #include <asm/mcfwdebug.h> |
32 | #include <asm/mcfqspi.h> | ||
33 | 30 | ||
34 | /***************************************************************************/ | 31 | /***************************************************************************/ |
35 | 32 | ||
36 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | 33 | #ifdef CONFIG_SPI_COLDFIRE_QSPI |
37 | static struct resource m532x_qspi_resources[] = { | ||
38 | { | ||
39 | .start = MCFQSPI_BASE, | ||
40 | .end = MCFQSPI_BASE + MCFQSPI_SIZE - 1, | ||
41 | .flags = IORESOURCE_MEM, | ||
42 | }, | ||
43 | { | ||
44 | .start = MCF_IRQ_QSPI, | ||
45 | .end = MCF_IRQ_QSPI, | ||
46 | .flags = IORESOURCE_IRQ, | ||
47 | }, | ||
48 | }; | ||
49 | |||
50 | static int m532x_cs_setup(struct mcfqspi_cs_control *cs_control) | ||
51 | { | ||
52 | int status; | ||
53 | |||
54 | status = gpio_request(MCFQSPI_CS0, "MCFQSPI_CS0"); | ||
55 | if (status) { | ||
56 | pr_debug("gpio_request for MCFQSPI_CS0 failed\n"); | ||
57 | goto fail0; | ||
58 | } | ||
59 | status = gpio_direction_output(MCFQSPI_CS0, 1); | ||
60 | if (status) { | ||
61 | pr_debug("gpio_direction_output for MCFQSPI_CS0 failed\n"); | ||
62 | goto fail1; | ||
63 | } | ||
64 | |||
65 | status = gpio_request(MCFQSPI_CS1, "MCFQSPI_CS1"); | ||
66 | if (status) { | ||
67 | pr_debug("gpio_request for MCFQSPI_CS1 failed\n"); | ||
68 | goto fail1; | ||
69 | } | ||
70 | status = gpio_direction_output(MCFQSPI_CS1, 1); | ||
71 | if (status) { | ||
72 | pr_debug("gpio_direction_output for MCFQSPI_CS1 failed\n"); | ||
73 | goto fail2; | ||
74 | } | ||
75 | |||
76 | status = gpio_request(MCFQSPI_CS2, "MCFQSPI_CS2"); | ||
77 | if (status) { | ||
78 | pr_debug("gpio_request for MCFQSPI_CS2 failed\n"); | ||
79 | goto fail2; | ||
80 | } | ||
81 | status = gpio_direction_output(MCFQSPI_CS2, 1); | ||
82 | if (status) { | ||
83 | pr_debug("gpio_direction_output for MCFQSPI_CS2 failed\n"); | ||
84 | goto fail3; | ||
85 | } | ||
86 | |||
87 | return 0; | ||
88 | |||
89 | fail3: | ||
90 | gpio_free(MCFQSPI_CS2); | ||
91 | fail2: | ||
92 | gpio_free(MCFQSPI_CS1); | ||
93 | fail1: | ||
94 | gpio_free(MCFQSPI_CS0); | ||
95 | fail0: | ||
96 | return status; | ||
97 | } | ||
98 | |||
99 | static void m532x_cs_teardown(struct mcfqspi_cs_control *cs_control) | ||
100 | { | ||
101 | gpio_free(MCFQSPI_CS2); | ||
102 | gpio_free(MCFQSPI_CS1); | ||
103 | gpio_free(MCFQSPI_CS0); | ||
104 | } | ||
105 | |||
106 | static void m532x_cs_select(struct mcfqspi_cs_control *cs_control, | ||
107 | u8 chip_select, bool cs_high) | ||
108 | { | ||
109 | gpio_set_value(MCFQSPI_CS0 + chip_select, cs_high); | ||
110 | } | ||
111 | |||
112 | static void m532x_cs_deselect(struct mcfqspi_cs_control *cs_control, | ||
113 | u8 chip_select, bool cs_high) | ||
114 | { | ||
115 | gpio_set_value(MCFQSPI_CS0 + chip_select, !cs_high); | ||
116 | } | ||
117 | |||
118 | static struct mcfqspi_cs_control m532x_cs_control = { | ||
119 | .setup = m532x_cs_setup, | ||
120 | .teardown = m532x_cs_teardown, | ||
121 | .select = m532x_cs_select, | ||
122 | .deselect = m532x_cs_deselect, | ||
123 | }; | ||
124 | |||
125 | static struct mcfqspi_platform_data m532x_qspi_data = { | ||
126 | .bus_num = 0, | ||
127 | .num_chipselect = 3, | ||
128 | .cs_control = &m532x_cs_control, | ||
129 | }; | ||
130 | |||
131 | static struct platform_device m532x_qspi = { | ||
132 | .name = "mcfqspi", | ||
133 | .id = 0, | ||
134 | .num_resources = ARRAY_SIZE(m532x_qspi_resources), | ||
135 | .resource = m532x_qspi_resources, | ||
136 | .dev.platform_data = &m532x_qspi_data, | ||
137 | }; | ||
138 | 34 | ||
139 | static void __init m532x_qspi_init(void) | 35 | static void __init m532x_qspi_init(void) |
140 | { | 36 | { |
141 | /* setup QSPS pins for QSPI with gpio CS control */ | 37 | /* setup QSPS pins for QSPI with gpio CS control */ |
142 | writew(0x01f0, MCF_GPIO_PAR_QSPI); | 38 | writew(0x01f0, MCF_GPIO_PAR_QSPI); |
143 | } | 39 | } |
144 | #endif /* defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) */ | ||
145 | |||
146 | 40 | ||
147 | static struct platform_device *m532x_devices[] __initdata = { | 41 | #endif /* CONFIG_SPI_COLDFIRE_QSPI */ |
148 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
149 | &m532x_qspi, | ||
150 | #endif | ||
151 | }; | ||
152 | 42 | ||
153 | /***************************************************************************/ | 43 | /***************************************************************************/ |
154 | 44 | ||
@@ -210,10 +100,9 @@ static int __init init_BSP(void) | |||
210 | { | 100 | { |
211 | m532x_uarts_init(); | 101 | m532x_uarts_init(); |
212 | m532x_fec_init(); | 102 | m532x_fec_init(); |
213 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | 103 | #ifdef CONFIG_SPI_COLDFIRE_QSPI |
214 | m532x_qspi_init(); | 104 | m532x_qspi_init(); |
215 | #endif | 105 | #endif |
216 | platform_add_devices(m532x_devices, ARRAY_SIZE(m532x_devices)); | ||
217 | return 0; | 106 | return 0; |
218 | } | 107 | } |
219 | 108 | ||