blob: 5911281da5f59cef0aed95f3e82e3da30750bdeb [file] [log] [blame]
Eric Benarda961bf32009-07-16 16:26:34 +02001/*
Eric Bénardd2195d52010-05-27 10:58:56 +02002 * Copyright (C) 2009-2010 Eric Benard - eric@eukrea.com
Eric Benarda961bf32009-07-16 16:26:34 +02003 *
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>
Eric Bénardfc04ad02010-05-19 18:45:57 +020027#include <linux/backlight.h>
28#include <video/platform_lcd.h>
Eric Benarda961bf32009-07-16 16:26:34 +020029
30#include <asm/mach/arch.h>
31
32#include <mach/common.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010033#include <mach/iomux-mx27.h>
Eric Benarda961bf32009-07-16 16:26:34 +020034#include <mach/hardware.h>
Eric Bénardd2195d52010-05-27 10:58:56 +020035#include <mach/audmux.h>
Eric Benarda961bf32009-07-16 16:26:34 +020036
Uwe Kleine-König7536cf92010-06-22 09:00:22 +020037#include "devices-imx27.h"
Eric Benarda961bf32009-07-16 16:26:34 +020038
Uwe Kleine-König6c80ee52010-09-28 21:53:31 +020039static const int eukrea_mbimx27_pins[] __initconst = {
Eric Benarda961bf32009-07-16 16:26:34 +020040 /* 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 */
Eric Bénard2d66c782010-05-19 18:45:59 +020051#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benarda961bf32009-07-16 16:26:34 +020052 PB26_AF_UART4_RTS,
53 PB28_AF_UART4_TXD,
54 PB29_AF_UART4_CTS,
55 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020056#endif
Eric Benarda961bf32009-07-16 16:26:34 +020057 /* 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 */
Eric Benarda961bf32009-07-16 16:26:34 +020089 PD29_PF_CSPI1_SCLK,
90 PD30_PF_CSPI1_MISO,
91 PD31_PF_CSPI1_MOSI,
Eric Bénardd2195d52010-05-27 10:58:56 +020092 /* SSI4 */
Eric Bénarde8c74862010-06-20 21:22:54 +020093#if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
94 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
Eric Bénardd2195d52010-05-27 10:58:56 +020095 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
Eric Benarda961bf32009-07-16 16:26:34 +0200100};
101
Eric Bénard5203b992010-05-19 18:46:07 +0200102static 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
Uwe Kleine-König3f880142010-11-10 09:58:56 +0100109static const struct matrix_keymap_data
110eukrea_mbimx27_keymap_data __initconst = {
Eric Bénard5203b992010-05-19 18:46:07 +0200111 .keymap = eukrea_mbimx27_keymap,
112 .keymap_size = ARRAY_SIZE(eukrea_mbimx27_keymap),
113};
114
Eric Benarda961bf32009-07-16 16:26:34 +0200115static struct gpio_led gpio_leds[] = {
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 },
Eric Benarda961bf32009-07-16 16:26:34 +0200128};
129
130static struct gpio_led_platform_data gpio_led_info = {
131 .leds = gpio_leds,
132 .num_leds = ARRAY_SIZE(gpio_leds),
133};
134
135static struct platform_device leds_gpio = {
136 .name = "leds-gpio",
137 .id = -1,
138 .dev = {
139 .platform_data = &gpio_led_info,
140 },
141};
142
143static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
144 {
145 .mode = {
Eric Bénard4eaad662010-05-19 18:45:56 +0200146 .name = "CMO-QVGA",
Eric Benarda961bf32009-07-16 16:26:34 +0200147 .refresh = 60,
148 .xres = 320,
149 .yres = 240,
150 .pixclock = 156000,
151 .hsync_len = 30,
152 .left_margin = 38,
153 .right_margin = 20,
154 .vsync_len = 3,
155 .upper_margin = 15,
156 .lower_margin = 4,
157 },
158 .pcr = 0xFAD08B80,
159 .bpp = 16,
Eric Bénarda4652422010-05-19 18:45:58 +0200160 }, {
161 .mode = {
162 .name = "DVI-VGA",
163 .refresh = 60,
164 .xres = 640,
165 .yres = 480,
166 .pixclock = 32000,
167 .hsync_len = 1,
168 .left_margin = 35,
169 .right_margin = 0,
170 .vsync_len = 1,
171 .upper_margin = 7,
172 .lower_margin = 0,
173 },
174 .pcr = 0xFA208B80,
175 .bpp = 16,
176 }, {
177 .mode = {
178 .name = "DVI-SVGA",
179 .refresh = 60,
180 .xres = 800,
181 .yres = 600,
182 .pixclock = 25000,
183 .hsync_len = 1,
184 .left_margin = 35,
185 .right_margin = 0,
186 .vsync_len = 1,
187 .upper_margin = 7,
188 .lower_margin = 0,
189 },
190 .pcr = 0xFA208B80,
191 .bpp = 16,
Eric Benarda961bf32009-07-16 16:26:34 +0200192 },
193};
194
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100195static const struct imx_fb_platform_data eukrea_mbimx27_fb_data __initconst = {
Eric Benarda961bf32009-07-16 16:26:34 +0200196 .mode = eukrea_mbimx27_modes,
197 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
198
199 .pwmr = 0x00A903FF,
200 .lscr1 = 0x00120300,
201 .dmacr = 0x00040060,
202};
203
Eric Bénardfc04ad02010-05-19 18:45:57 +0200204static void eukrea_mbimx27_bl_set_intensity(int intensity)
205{
206 if (intensity)
207 gpio_direction_output(GPIO_PORTE | 5, 1);
208 else
209 gpio_direction_output(GPIO_PORTE | 5, 0);
210}
211
212static struct generic_bl_info eukrea_mbimx27_bl_info = {
213 .name = "eukrea_mbimx27-bl",
214 .max_intensity = 0xff,
215 .default_intensity = 0xff,
216 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
217};
218
219static struct platform_device eukrea_mbimx27_bl_dev = {
220 .name = "generic-bl",
221 .id = 1,
222 .dev = {
223 .platform_data = &eukrea_mbimx27_bl_info,
224 },
225};
226
227static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
228 unsigned int power)
229{
230 if (power)
231 gpio_direction_output(GPIO_PORTA | 25, 1);
232 else
233 gpio_direction_output(GPIO_PORTA | 25, 0);
234}
235
236static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
237 .set_power = eukrea_mbimx27_lcd_power_set,
238};
239
240static struct platform_device eukrea_mbimx27_lcd_powerdev = {
241 .name = "platform-lcd",
242 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
243};
244
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200245static const struct imxuart_platform_data uart_pdata __initconst = {
246 .flags = IMXUART_HAVE_RTSCTS,
Eric Benarda961bf32009-07-16 16:26:34 +0200247};
248
Eric Benarda961bf32009-07-16 16:26:34 +0200249#define ADS7846_PENDOWN (GPIO_PORTD | 25)
250
Uwe Kleine-König9b1e1ea2011-02-10 11:07:27 +0100251static void __maybe_unused ads7846_dev_init(void)
Eric Benarda961bf32009-07-16 16:26:34 +0200252{
253 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
254 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
255 return;
256 }
Eric Benarda961bf32009-07-16 16:26:34 +0200257 gpio_direction_input(ADS7846_PENDOWN);
258}
259
260static int ads7846_get_pendown_state(void)
261{
262 return !gpio_get_value(ADS7846_PENDOWN);
263}
264
265static struct ads7846_platform_data ads7846_config __initdata = {
266 .get_pendown_state = ads7846_get_pendown_state,
267 .keep_vref_on = 1,
268};
269
Uwe Kleine-König9b1e1ea2011-02-10 11:07:27 +0100270static struct spi_board_info __maybe_unused
271 eukrea_mbimx27_spi_board_info[] __initdata = {
Eric Benarda961bf32009-07-16 16:26:34 +0200272 [0] = {
273 .modalias = "ads7846",
274 .bus_num = 0,
275 .chip_select = 0,
276 .max_speed_hz = 1500000,
277 .irq = IRQ_GPIOD(25),
278 .platform_data = &ads7846_config,
279 .mode = SPI_MODE_2,
280 },
281};
282
283static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
284
Uwe Kleine-König7536cf92010-06-22 09:00:22 +0200285static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst = {
Eric Benarda961bf32009-07-16 16:26:34 +0200286 .chipselect = eukrea_mbimx27_spi_cs,
287 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
288};
Eric Benarda961bf32009-07-16 16:26:34 +0200289
Eric Bénard5055d1e2010-07-19 09:45:17 +0200290static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
291 {
292 I2C_BOARD_INFO("tlv320aic23", 0x1a),
293 },
294};
295
Eric Benarda961bf32009-07-16 16:26:34 +0200296static struct platform_device *platform_devices[] __initdata = {
297 &leds_gpio,
298};
299
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100300static const struct imxmmc_platform_data sdhc_pdata __initconst = {
Eric Bénarde76a17c2010-05-19 18:46:05 +0200301 .dat3_card_detect = 1,
302};
303
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200304static const
305struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata __initconst = {
Eric Bénardd2195d52010-05-27 10:58:56 +0200306 .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
307};
308
Eric Benarda961bf32009-07-16 16:26:34 +0200309/*
310 * system init for baseboard usage. Will be called by cpuimx27 init.
311 *
312 * Add platform devices present on this baseboard and init
313 * them from CPU side as far as required to use them later on
314 */
315void __init eukrea_mbimx27_baseboard_init(void)
316{
317 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
318 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
319
Eric Bénarde8c74862010-06-20 21:22:54 +0200320#if defined(CONFIG_SND_SOC_EUKREA_TLV320) \
321 || defined(CONFIG_SND_SOC_EUKREA_TLV320_MODULE)
Eric Bénardd2195d52010-05-27 10:58:56 +0200322 /* SSI unit master I2S codec connected to SSI_PINS_4*/
323 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
324 MXC_AUDMUX_V1_PCR_SYN |
325 MXC_AUDMUX_V1_PCR_TFSDIR |
326 MXC_AUDMUX_V1_PCR_TCLKDIR |
327 MXC_AUDMUX_V1_PCR_RFSDIR |
328 MXC_AUDMUX_V1_PCR_RCLKDIR |
329 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
330 MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
331 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4)
332 );
333 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4,
334 MXC_AUDMUX_V1_PCR_SYN |
335 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
336 );
337#endif
338
Uwe Kleine-Königd5dac4a2010-06-23 09:36:01 +0200339 imx27_add_imx_uart1(&uart_pdata);
340 imx27_add_imx_uart2(&uart_pdata);
Eric Bénard2d66c782010-05-19 18:45:59 +0200341#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200342 imx27_add_imx_uart3(&uart_pdata);
Eric Bénard2d66c782010-05-19 18:45:59 +0200343#endif
Eric Benarda961bf32009-07-16 16:26:34 +0200344
Uwe Kleine-Königad851bf2010-11-04 17:07:48 +0100345 imx27_add_imx_fb(&eukrea_mbimx27_fb_data);
Uwe Kleine-König9d3d9452010-11-05 17:26:09 +0100346 imx27_add_mxc_mmc(0, &sdhc_pdata);
Eric Benarda961bf32009-07-16 16:26:34 +0200347
Eric Bénardd2195d52010-05-27 10:58:56 +0200348 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
349 ARRAY_SIZE(eukrea_mbimx27_i2c_devices));
350
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200351 imx27_add_imx_ssi(0, &eukrea_mbimx27_ssi_pdata);
Eric Bénardd2195d52010-05-27 10:58:56 +0200352
Eric Bénard62d725b2010-05-20 09:22:28 +0200353#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
Eric Benarda961bf32009-07-16 16:26:34 +0200354 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
Eric Bénard62d725b2010-05-20 09:22:28 +0200355 /* ADS7846 Touchscreen controller init */
Eric Benarda961bf32009-07-16 16:26:34 +0200356 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
Eric Bénard62d725b2010-05-20 09:22:28 +0200357 ads7846_dev_init();
358#endif
359
Eric Bénard62d725b2010-05-20 09:22:28 +0200360 /* SPI_CS0 init */
361 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
Uwe Kleine-König7536cf92010-06-22 09:00:22 +0200362 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data);
Eric Benarda961bf32009-07-16 16:26:34 +0200363 spi_register_board_info(eukrea_mbimx27_spi_board_info,
364 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
Eric Benarda961bf32009-07-16 16:26:34 +0200365
366 /* Leds configuration */
367 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
368 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
369 /* Backlight */
370 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
Eric Bénardfc04ad02010-05-19 18:45:57 +0200371 gpio_request(GPIO_PORTE | 5, "backlight");
372 platform_device_register(&eukrea_mbimx27_bl_dev);
373 /* LCD Reset */
374 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
375 gpio_request(GPIO_PORTA | 25, "lcd_enable");
376 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
Eric Benarda961bf32009-07-16 16:26:34 +0200377
Uwe Kleine-König3f880142010-11-10 09:58:56 +0100378 imx27_add_imx_keypad(&eukrea_mbimx27_keymap_data);
Eric Bénard5203b992010-05-19 18:46:07 +0200379
Eric Benarda961bf32009-07-16 16:26:34 +0200380 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
381}