]>
Commit | Line | Data |
---|---|---|
a961bf38 | 1 | /* |
d2195d52 | 2 | * Copyright (C) 2009-2010 Eric Benard - eric@eukrea.com |
a961bf38 EB |
3 | * |
4 | * Based on pcm970-baseboard.c which is : | |
5 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License | |
9 | * as published by the Free Software Foundation; either version 2 | |
10 | * of the License, or (at your option) any later version. | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
19 | * MA 02110-1301, USA. | |
20 | */ | |
21 | ||
22 | #include <linux/gpio.h> | |
23 | #include <linux/irq.h> | |
24 | #include <linux/platform_device.h> | |
25 | #include <linux/spi/spi.h> | |
26 | #include <linux/spi/ads7846.h> | |
fc04ad0e EB |
27 | #include <linux/backlight.h> |
28 | #include <video/platform_lcd.h> | |
5203b99c | 29 | #include <linux/input/matrix_keypad.h> |
a961bf38 EB |
30 | |
31 | #include <asm/mach/arch.h> | |
32 | ||
33 | #include <mach/common.h> | |
e835d88e | 34 | #include <mach/iomux-mx27.h> |
a961bf38 EB |
35 | #include <mach/imxfb.h> |
36 | #include <mach/hardware.h> | |
37 | #include <mach/mmc.h> | |
62d725b1 | 38 | #include <mach/spi.h> |
d2195d52 EB |
39 | #include <mach/ssi.h> |
40 | #include <mach/audmux.h> | |
a961bf38 | 41 | |
7536cf99 | 42 | #include "devices-imx27.h" |
a961bf38 EB |
43 | #include "devices.h" |
44 | ||
45 | static int eukrea_mbimx27_pins[] = { | |
46 | /* UART2 */ | |
47 | PE3_PF_UART2_CTS, | |
48 | PE4_PF_UART2_RTS, | |
49 | PE6_PF_UART2_TXD, | |
50 | PE7_PF_UART2_RXD, | |
51 | /* UART3 */ | |
52 | PE8_PF_UART3_TXD, | |
53 | PE9_PF_UART3_RXD, | |
54 | PE10_PF_UART3_CTS, | |
55 | PE11_PF_UART3_RTS, | |
56 | /* UART4 */ | |
2d66c780 | 57 | #if !defined(MACH_EUKREA_CPUIMX27_USEUART4) |
a961bf38 EB |
58 | PB26_AF_UART4_RTS, |
59 | PB28_AF_UART4_TXD, | |
60 | PB29_AF_UART4_CTS, | |
61 | PB31_AF_UART4_RXD, | |
2d66c780 | 62 | #endif |
a961bf38 EB |
63 | /* SDHC1*/ |
64 | PE18_PF_SD1_D0, | |
65 | PE19_PF_SD1_D1, | |
66 | PE20_PF_SD1_D2, | |
67 | PE21_PF_SD1_D3, | |
68 | PE22_PF_SD1_CMD, | |
69 | PE23_PF_SD1_CLK, | |
70 | /* display */ | |
71 | PA5_PF_LSCLK, | |
72 | PA6_PF_LD0, | |
73 | PA7_PF_LD1, | |
74 | PA8_PF_LD2, | |
75 | PA9_PF_LD3, | |
76 | PA10_PF_LD4, | |
77 | PA11_PF_LD5, | |
78 | PA12_PF_LD6, | |
79 | PA13_PF_LD7, | |
80 | PA14_PF_LD8, | |
81 | PA15_PF_LD9, | |
82 | PA16_PF_LD10, | |
83 | PA17_PF_LD11, | |
84 | PA18_PF_LD12, | |
85 | PA19_PF_LD13, | |
86 | PA20_PF_LD14, | |
87 | PA21_PF_LD15, | |
88 | PA22_PF_LD16, | |
89 | PA23_PF_LD17, | |
90 | PA28_PF_HSYNC, | |
91 | PA29_PF_VSYNC, | |
92 | PA30_PF_CONTRAST, | |
93 | PA31_PF_OE_ACD, | |
94 | /* SPI1 */ | |
a961bf38 EB |
95 | PD29_PF_CSPI1_SCLK, |
96 | PD30_PF_CSPI1_MISO, | |
97 | PD31_PF_CSPI1_MOSI, | |
d2195d52 | 98 | /* SSI4 */ |
e8c74860 EB |
99 | #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \ |
100 | || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE) | |
d2195d52 EB |
101 | PC16_PF_SSI4_FS, |
102 | PC17_PF_SSI4_RXD | GPIO_PUEN, | |
103 | PC18_PF_SSI4_TXD | GPIO_PUEN, | |
104 | PC19_PF_SSI4_CLK, | |
105 | #endif | |
a961bf38 EB |
106 | }; |
107 | ||
5203b99c EB |
108 | static const uint32_t eukrea_mbimx27_keymap[] = { |
109 | KEY(0, 0, KEY_UP), | |
110 | KEY(0, 1, KEY_DOWN), | |
111 | KEY(1, 0, KEY_RIGHT), | |
112 | KEY(1, 1, KEY_LEFT), | |
113 | }; | |
114 | ||
115 | static struct matrix_keymap_data eukrea_mbimx27_keymap_data = { | |
116 | .keymap = eukrea_mbimx27_keymap, | |
117 | .keymap_size = ARRAY_SIZE(eukrea_mbimx27_keymap), | |
118 | }; | |
119 | ||
a961bf38 EB |
120 | static struct gpio_led gpio_leds[] = { |
121 | { | |
122 | .name = "led1", | |
123 | .default_trigger = "heartbeat", | |
124 | .active_low = 1, | |
125 | .gpio = GPIO_PORTF | 16, | |
126 | }, | |
127 | { | |
128 | .name = "led2", | |
129 | .default_trigger = "none", | |
130 | .active_low = 1, | |
131 | .gpio = GPIO_PORTF | 19, | |
132 | }, | |
a961bf38 EB |
133 | }; |
134 | ||
135 | static struct gpio_led_platform_data gpio_led_info = { | |
136 | .leds = gpio_leds, | |
137 | .num_leds = ARRAY_SIZE(gpio_leds), | |
138 | }; | |
139 | ||
140 | static struct platform_device leds_gpio = { | |
141 | .name = "leds-gpio", | |
142 | .id = -1, | |
143 | .dev = { | |
144 | .platform_data = &gpio_led_info, | |
145 | }, | |
146 | }; | |
147 | ||
148 | static struct imx_fb_videomode eukrea_mbimx27_modes[] = { | |
149 | { | |
150 | .mode = { | |
4eaad66a | 151 | .name = "CMO-QVGA", |
a961bf38 EB |
152 | .refresh = 60, |
153 | .xres = 320, | |
154 | .yres = 240, | |
155 | .pixclock = 156000, | |
156 | .hsync_len = 30, | |
157 | .left_margin = 38, | |
158 | .right_margin = 20, | |
159 | .vsync_len = 3, | |
160 | .upper_margin = 15, | |
161 | .lower_margin = 4, | |
162 | }, | |
163 | .pcr = 0xFAD08B80, | |
a465242e EB |
164 | .bpp = 16, |
165 | }, { | |
166 | .mode = { | |
167 | .name = "DVI-VGA", | |
168 | .refresh = 60, | |
169 | .xres = 640, | |
170 | .yres = 480, | |
171 | .pixclock = 32000, | |
172 | .hsync_len = 1, | |
173 | .left_margin = 35, | |
174 | .right_margin = 0, | |
175 | .vsync_len = 1, | |
176 | .upper_margin = 7, | |
177 | .lower_margin = 0, | |
178 | }, | |
179 | .pcr = 0xFA208B80, | |
180 | .bpp = 16, | |
181 | }, { | |
182 | .mode = { | |
183 | .name = "DVI-SVGA", | |
184 | .refresh = 60, | |
185 | .xres = 800, | |
186 | .yres = 600, | |
187 | .pixclock = 25000, | |
188 | .hsync_len = 1, | |
189 | .left_margin = 35, | |
190 | .right_margin = 0, | |
191 | .vsync_len = 1, | |
192 | .upper_margin = 7, | |
193 | .lower_margin = 0, | |
194 | }, | |
195 | .pcr = 0xFA208B80, | |
a961bf38 EB |
196 | .bpp = 16, |
197 | }, | |
198 | }; | |
199 | ||
200 | static struct imx_fb_platform_data eukrea_mbimx27_fb_data = { | |
201 | .mode = eukrea_mbimx27_modes, | |
202 | .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes), | |
203 | ||
204 | .pwmr = 0x00A903FF, | |
205 | .lscr1 = 0x00120300, | |
206 | .dmacr = 0x00040060, | |
207 | }; | |
208 | ||
fc04ad0e EB |
209 | static void eukrea_mbimx27_bl_set_intensity(int intensity) |
210 | { | |
211 | if (intensity) | |
212 | gpio_direction_output(GPIO_PORTE | 5, 1); | |
213 | else | |
214 | gpio_direction_output(GPIO_PORTE | 5, 0); | |
215 | } | |
216 | ||
217 | static struct generic_bl_info eukrea_mbimx27_bl_info = { | |
218 | .name = "eukrea_mbimx27-bl", | |
219 | .max_intensity = 0xff, | |
220 | .default_intensity = 0xff, | |
221 | .set_bl_intensity = eukrea_mbimx27_bl_set_intensity, | |
222 | }; | |
223 | ||
224 | static struct platform_device eukrea_mbimx27_bl_dev = { | |
225 | .name = "generic-bl", | |
226 | .id = 1, | |
227 | .dev = { | |
228 | .platform_data = &eukrea_mbimx27_bl_info, | |
229 | }, | |
230 | }; | |
231 | ||
232 | static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd, | |
233 | unsigned int power) | |
234 | { | |
235 | if (power) | |
236 | gpio_direction_output(GPIO_PORTA | 25, 1); | |
237 | else | |
238 | gpio_direction_output(GPIO_PORTA | 25, 0); | |
239 | } | |
240 | ||
241 | static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = { | |
242 | .set_power = eukrea_mbimx27_lcd_power_set, | |
243 | }; | |
244 | ||
245 | static struct platform_device eukrea_mbimx27_lcd_powerdev = { | |
246 | .name = "platform-lcd", | |
247 | .dev.platform_data = &eukrea_mbimx27_lcd_power_data, | |
248 | }; | |
249 | ||
d5dac4a6 UKK |
250 | static const struct imxuart_platform_data uart_pdata __initconst = { |
251 | .flags = IMXUART_HAVE_RTSCTS, | |
a961bf38 EB |
252 | }; |
253 | ||
62d725b1 | 254 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) \ |
a961bf38 EB |
255 | || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) |
256 | ||
257 | #define ADS7846_PENDOWN (GPIO_PORTD | 25) | |
258 | ||
259 | static void ads7846_dev_init(void) | |
260 | { | |
261 | if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) { | |
262 | printk(KERN_ERR "can't get ads746 pen down GPIO\n"); | |
263 | return; | |
264 | } | |
a961bf38 EB |
265 | gpio_direction_input(ADS7846_PENDOWN); |
266 | } | |
267 | ||
268 | static int ads7846_get_pendown_state(void) | |
269 | { | |
270 | return !gpio_get_value(ADS7846_PENDOWN); | |
271 | } | |
272 | ||
273 | static struct ads7846_platform_data ads7846_config __initdata = { | |
274 | .get_pendown_state = ads7846_get_pendown_state, | |
275 | .keep_vref_on = 1, | |
276 | }; | |
62d725b1 | 277 | #endif |
a961bf38 | 278 | |
62d725b1 | 279 | #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) |
a961bf38 EB |
280 | static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = { |
281 | [0] = { | |
282 | .modalias = "ads7846", | |
283 | .bus_num = 0, | |
284 | .chip_select = 0, | |
285 | .max_speed_hz = 1500000, | |
286 | .irq = IRQ_GPIOD(25), | |
287 | .platform_data = &ads7846_config, | |
288 | .mode = SPI_MODE_2, | |
289 | }, | |
290 | }; | |
291 | ||
d2195d52 EB |
292 | static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = { |
293 | { | |
294 | I2C_BOARD_INFO("tlv320aic23", 0x1a), | |
295 | }, | |
296 | }; | |
297 | ||
a961bf38 EB |
298 | static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28}; |
299 | ||
7536cf99 | 300 | static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst = { |
a961bf38 EB |
301 | .chipselect = eukrea_mbimx27_spi_cs, |
302 | .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs), | |
303 | }; | |
304 | #endif | |
305 | ||
306 | static struct platform_device *platform_devices[] __initdata = { | |
307 | &leds_gpio, | |
308 | }; | |
309 | ||
e76a17c2 EB |
310 | static struct imxmmc_platform_data sdhc_pdata = { |
311 | .dat3_card_detect = 1, | |
312 | }; | |
313 | ||
d2195d52 EB |
314 | struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata = { |
315 | .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE, | |
316 | }; | |
317 | ||
a961bf38 EB |
318 | /* |
319 | * system init for baseboard usage. Will be called by cpuimx27 init. | |
320 | * | |
321 | * Add platform devices present on this baseboard and init | |
322 | * them from CPU side as far as required to use them later on | |
323 | */ | |
324 | void __init eukrea_mbimx27_baseboard_init(void) | |
325 | { | |
326 | mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins, | |
327 | ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27"); | |
328 | ||
e8c74860 EB |
329 | #if defined(CONFIG_SND_SOC_EUKREA_TLV320) \ |
330 | || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE) | |
d2195d52 EB |
331 | /* SSI unit master I2S codec connected to SSI_PINS_4*/ |
332 | mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0, | |
333 | MXC_AUDMUX_V1_PCR_SYN | | |
334 | MXC_AUDMUX_V1_PCR_TFSDIR | | |
335 | MXC_AUDMUX_V1_PCR_TCLKDIR | | |
336 | MXC_AUDMUX_V1_PCR_RFSDIR | | |
337 | MXC_AUDMUX_V1_PCR_RCLKDIR | | |
338 | MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | | |
339 | MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | | |
340 | MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) | |
341 | ); | |
342 | mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4, | |
343 | MXC_AUDMUX_V1_PCR_SYN | | |
344 | MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) | |
345 | ); | |
346 | #endif | |
347 | ||
d5dac4a6 UKK |
348 | imx27_add_imx_uart1(&uart_pdata); |
349 | imx27_add_imx_uart2(&uart_pdata); | |
2d66c780 | 350 | #if !defined(MACH_EUKREA_CPUIMX27_USEUART4) |
2dcf78c0 | 351 | imx27_add_imx_uart3(&uart_pdata); |
2d66c780 | 352 | #endif |
a961bf38 EB |
353 | |
354 | mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data); | |
e76a17c2 | 355 | mxc_register_device(&mxc_sdhc_device0, &sdhc_pdata); |
a961bf38 | 356 | |
d2195d52 EB |
357 | i2c_register_board_info(0, eukrea_mbimx27_i2c_devices, |
358 | ARRAY_SIZE(eukrea_mbimx27_i2c_devices)); | |
359 | ||
360 | mxc_register_device(&imx_ssi_device0, &eukrea_mbimx27_ssi_pdata); | |
361 | ||
62d725b1 | 362 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) \ |
a961bf38 | 363 | || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) |
62d725b1 | 364 | /* ADS7846 Touchscreen controller init */ |
a961bf38 | 365 | mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN); |
62d725b1 EB |
366 | ads7846_dev_init(); |
367 | #endif | |
368 | ||
369 | #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) | |
370 | /* SPI_CS0 init */ | |
371 | mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT); | |
7536cf99 | 372 | imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data); |
a961bf38 EB |
373 | spi_register_board_info(eukrea_mbimx27_spi_board_info, |
374 | ARRAY_SIZE(eukrea_mbimx27_spi_board_info)); | |
a961bf38 EB |
375 | #endif |
376 | ||
377 | /* Leds configuration */ | |
378 | mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT); | |
379 | mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT); | |
380 | /* Backlight */ | |
381 | mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT); | |
fc04ad0e EB |
382 | gpio_request(GPIO_PORTE | 5, "backlight"); |
383 | platform_device_register(&eukrea_mbimx27_bl_dev); | |
384 | /* LCD Reset */ | |
385 | mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT); | |
386 | gpio_request(GPIO_PORTA | 25, "lcd_enable"); | |
387 | platform_device_register(&eukrea_mbimx27_lcd_powerdev); | |
a961bf38 | 388 | |
5203b99c EB |
389 | mxc_register_device(&imx_kpp_device, &eukrea_mbimx27_keymap_data); |
390 | ||
a961bf38 EB |
391 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
392 | } |