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