1297f1b0dcb712fb66eb833121c6b523c46cfe74
[deliverable/linux.git] / arch / arm / mach-imx / pcm970-baseboard.c
1 /*
2 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
16 * MA 02110-1301, USA.
17 */
18
19 #include <linux/gpio.h>
20 #include <linux/irq.h>
21 #include <linux/platform_device.h>
22 #include <linux/can/platform/sja1000.h>
23
24 #include <asm/mach/arch.h>
25
26 #include <mach/common.h>
27 #include <mach/iomux-mx27.h>
28 #include <mach/hardware.h>
29
30 #include "devices-imx27.h"
31 #include "devices.h"
32
33 static const int pcm970_pins[] __initconst = {
34 /* SDHC */
35 PB4_PF_SD2_D0,
36 PB5_PF_SD2_D1,
37 PB6_PF_SD2_D2,
38 PB7_PF_SD2_D3,
39 PB8_PF_SD2_CMD,
40 PB9_PF_SD2_CLK,
41 /* display */
42 PA5_PF_LSCLK,
43 PA6_PF_LD0,
44 PA7_PF_LD1,
45 PA8_PF_LD2,
46 PA9_PF_LD3,
47 PA10_PF_LD4,
48 PA11_PF_LD5,
49 PA12_PF_LD6,
50 PA13_PF_LD7,
51 PA14_PF_LD8,
52 PA15_PF_LD9,
53 PA16_PF_LD10,
54 PA17_PF_LD11,
55 PA18_PF_LD12,
56 PA19_PF_LD13,
57 PA20_PF_LD14,
58 PA21_PF_LD15,
59 PA22_PF_LD16,
60 PA23_PF_LD17,
61 PA24_PF_REV,
62 PA25_PF_CLS,
63 PA26_PF_PS,
64 PA27_PF_SPL_SPR,
65 PA28_PF_HSYNC,
66 PA29_PF_VSYNC,
67 PA30_PF_CONTRAST,
68 PA31_PF_OE_ACD,
69 /*
70 * it seems the data line misses a pullup, so we must enable
71 * the internal pullup as a local workaround
72 */
73 PD17_PF_I2C_DATA | GPIO_PUEN,
74 PD18_PF_I2C_CLK,
75 /* Camera */
76 PB10_PF_CSI_D0,
77 PB11_PF_CSI_D1,
78 PB12_PF_CSI_D2,
79 PB13_PF_CSI_D3,
80 PB14_PF_CSI_D4,
81 PB15_PF_CSI_MCLK,
82 PB16_PF_CSI_PIXCLK,
83 PB17_PF_CSI_D5,
84 PB18_PF_CSI_D6,
85 PB19_PF_CSI_D7,
86 PB20_PF_CSI_VSYNC,
87 PB21_PF_CSI_HSYNC,
88 };
89
90 static int pcm970_sdhc2_get_ro(struct device *dev)
91 {
92 return gpio_get_value(GPIO_PORTC + 28);
93 }
94
95 static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
96 {
97 int ret;
98
99 ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING,
100 "imx-mmc-detect", data);
101 if (ret)
102 return ret;
103
104 ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
105 if (ret) {
106 free_irq(IRQ_GPIOC(29), data);
107 return ret;
108 }
109
110 gpio_direction_input(GPIO_PORTC + 28);
111
112 return 0;
113 }
114
115 static void pcm970_sdhc2_exit(struct device *dev, void *data)
116 {
117 free_irq(IRQ_GPIOC(29), data);
118 gpio_free(GPIO_PORTC + 28);
119 }
120
121 static const struct imxmmc_platform_data sdhc_pdata __initconst = {
122 .get_ro = pcm970_sdhc2_get_ro,
123 .init = pcm970_sdhc2_init,
124 .exit = pcm970_sdhc2_exit,
125 };
126
127 static struct imx_fb_videomode pcm970_modes[] = {
128 {
129 .mode = {
130 .name = "Sharp-LQ035Q7",
131 .refresh = 60,
132 .xres = 240,
133 .yres = 320,
134 .pixclock = 188679, /* in ps (5.3MHz) */
135 .hsync_len = 7,
136 .left_margin = 5,
137 .right_margin = 16,
138 .vsync_len = 1,
139 .upper_margin = 7,
140 .lower_margin = 9,
141 },
142 /*
143 * - HSYNC active high
144 * - VSYNC active high
145 * - clk notenabled while idle
146 * - clock not inverted
147 * - data not inverted
148 * - data enable low active
149 * - enable sharp mode
150 */
151 .pcr = 0xF00080C0,
152 .bpp = 16,
153 }, {
154 .mode = {
155 .name = "TX090",
156 .refresh = 60,
157 .xres = 240,
158 .yres = 320,
159 .pixclock = 38255,
160 .left_margin = 144,
161 .right_margin = 0,
162 .upper_margin = 7,
163 .lower_margin = 40,
164 .hsync_len = 96,
165 .vsync_len = 1,
166 },
167 /*
168 * - HSYNC active low (1 << 22)
169 * - VSYNC active low (1 << 23)
170 * - clk notenabled while idle
171 * - clock not inverted
172 * - data not inverted
173 * - data enable low active
174 * - enable sharp mode
175 */
176 .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19),
177 .bpp = 32,
178 },
179 };
180
181 static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
182 .mode = pcm970_modes,
183 .num_modes = ARRAY_SIZE(pcm970_modes),
184
185 .pwmr = 0x00A903FF,
186 .lscr1 = 0x00120300,
187 .dmacr = 0x00020010,
188 };
189
190 static struct resource pcm970_sja1000_resources[] = {
191 {
192 .start = MX27_CS4_BASE_ADDR,
193 .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
194 .flags = IORESOURCE_MEM,
195 }, {
196 .start = IRQ_GPIOE(19),
197 .end = IRQ_GPIOE(19),
198 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
199 },
200 };
201
202 static struct sja1000_platform_data pcm970_sja1000_platform_data = {
203 .osc_freq = 16000000,
204 .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
205 .cdr = CDR_CBP,
206 };
207
208 static struct platform_device pcm970_sja1000 = {
209 .name = "sja1000_platform",
210 .dev = {
211 .platform_data = &pcm970_sja1000_platform_data,
212 },
213 .resource = pcm970_sja1000_resources,
214 .num_resources = ARRAY_SIZE(pcm970_sja1000_resources),
215 };
216
217 /*
218 * system init for baseboard usage. Will be called by pcm038 init.
219 *
220 * Add platform devices present on this baseboard and init
221 * them from CPU side as far as required to use them later on
222 */
223 void __init pcm970_baseboard_init(void)
224 {
225 mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
226 "PCM970");
227
228 imx27_add_imx_fb(&pcm038_fb_data);
229 mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
230 imx27_add_mxc_mmc(1, &sdhc_pdata);
231 platform_device_register(&pcm970_sja1000);
232 }
This page took 0.034274 seconds and 4 git commands to generate.