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