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