blob: 80f6268034012748f51629a277d092e3a79fc5ac [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 Bénard5203b992010-05-19 18:46:07 +020029#include <linux/input/matrix_keypad.h>
Eric Benarda961bf32009-07-16 16:26:34 +020030
31#include <asm/mach/arch.h>
32
33#include <mach/common.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010034#include <mach/iomux-mx27.h>
Eric Benarda961bf32009-07-16 16:26:34 +020035#include <mach/imxfb.h>
36#include <mach/hardware.h>
37#include <mach/mmc.h>
38#include <mach/imx-uart.h>
Eric Bénard62d725b2010-05-20 09:22:28 +020039#include <mach/spi.h>
Eric Bénardd2195d52010-05-27 10:58:56 +020040#include <mach/ssi.h>
41#include <mach/audmux.h>
Eric Benarda961bf32009-07-16 16:26:34 +020042
43#include "devices.h"
44
45static 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 */
Eric Bénard2d66c782010-05-19 18:45:59 +020057#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
Eric Benarda961bf32009-07-16 16:26:34 +020058 PB26_AF_UART4_RTS,
59 PB28_AF_UART4_TXD,
60 PB29_AF_UART4_CTS,
61 PB31_AF_UART4_RXD,
Eric Bénard2d66c782010-05-19 18:45:59 +020062#endif
Eric Benarda961bf32009-07-16 16:26:34 +020063 /* 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 */
Eric Benarda961bf32009-07-16 16:26:34 +020095 PD29_PF_CSPI1_SCLK,
96 PD30_PF_CSPI1_MISO,
97 PD31_PF_CSPI1_MOSI,
Eric Bénardd2195d52010-05-27 10:58:56 +020098 /* SSI4 */
99#if defined(CONFIG_SND_SOC_EUKREA_TLV320)
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
Eric Benarda961bf32009-07-16 16:26:34 +0200105};
106
Eric Bénard5203b992010-05-19 18:46:07 +0200107static 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
114static struct matrix_keymap_data eukrea_mbimx27_keymap_data = {
115 .keymap = eukrea_mbimx27_keymap,
116 .keymap_size = ARRAY_SIZE(eukrea_mbimx27_keymap),
117};
118
Eric Benarda961bf32009-07-16 16:26:34 +0200119static 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 },
Eric Benarda961bf32009-07-16 16:26:34 +0200132};
133
134static struct gpio_led_platform_data gpio_led_info = {
135 .leds = gpio_leds,
136 .num_leds = ARRAY_SIZE(gpio_leds),
137};
138
139static struct platform_device leds_gpio = {
140 .name = "leds-gpio",
141 .id = -1,
142 .dev = {
143 .platform_data = &gpio_led_info,
144 },
145};
146
147static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
148 {
149 .mode = {
Eric Bénard4eaad662010-05-19 18:45:56 +0200150 .name = "CMO-QVGA",
Eric Benarda961bf32009-07-16 16:26:34 +0200151 .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,
163 .bpp = 16,
Eric Bénarda4652422010-05-19 18:45:58 +0200164 }, {
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,
195 .bpp = 16,
Eric Benarda961bf32009-07-16 16:26:34 +0200196 },
197};
198
199static 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
Eric Bénardfc04ad02010-05-19 18:45:57 +0200208static 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
216static 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
223static 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
231static 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
240static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
241 .set_power = eukrea_mbimx27_lcd_power_set,
242};
243
244static struct platform_device eukrea_mbimx27_lcd_powerdev = {
245 .name = "platform-lcd",
246 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
247};
248
Eric Benarda961bf32009-07-16 16:26:34 +0200249static struct imxuart_platform_data uart_pdata[] = {
250 {
251 .flags = IMXUART_HAVE_RTSCTS,
252 },
253 {
254 .flags = IMXUART_HAVE_RTSCTS,
255 },
Eric Bénard2d66c782010-05-19 18:45:59 +0200256 {
257 .flags = IMXUART_HAVE_RTSCTS,
258 },
Eric Benarda961bf32009-07-16 16:26:34 +0200259};
260
Eric Bénard62d725b2010-05-20 09:22:28 +0200261#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
Eric Benarda961bf32009-07-16 16:26:34 +0200262 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
263
264#define ADS7846_PENDOWN (GPIO_PORTD | 25)
265
266static void ads7846_dev_init(void)
267{
268 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
269 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
270 return;
271 }
Eric Benarda961bf32009-07-16 16:26:34 +0200272 gpio_direction_input(ADS7846_PENDOWN);
273}
274
275static int ads7846_get_pendown_state(void)
276{
277 return !gpio_get_value(ADS7846_PENDOWN);
278}
279
280static struct ads7846_platform_data ads7846_config __initdata = {
281 .get_pendown_state = ads7846_get_pendown_state,
282 .keep_vref_on = 1,
283};
Eric Bénard62d725b2010-05-20 09:22:28 +0200284#endif
Eric Benarda961bf32009-07-16 16:26:34 +0200285
Eric Bénard62d725b2010-05-20 09:22:28 +0200286#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
Eric Benarda961bf32009-07-16 16:26:34 +0200287static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
288 [0] = {
289 .modalias = "ads7846",
290 .bus_num = 0,
291 .chip_select = 0,
292 .max_speed_hz = 1500000,
293 .irq = IRQ_GPIOD(25),
294 .platform_data = &ads7846_config,
295 .mode = SPI_MODE_2,
296 },
297};
298
Eric Bénardd2195d52010-05-27 10:58:56 +0200299static struct i2c_board_info eukrea_mbimx27_i2c_devices[] = {
300 {
301 I2C_BOARD_INFO("tlv320aic23", 0x1a),
302 },
303};
304
Eric Benarda961bf32009-07-16 16:26:34 +0200305static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
306
307static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
308 .chipselect = eukrea_mbimx27_spi_cs,
309 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
310};
311#endif
312
313static struct platform_device *platform_devices[] __initdata = {
314 &leds_gpio,
315};
316
Eric Bénarde76a17c2010-05-19 18:46:05 +0200317static struct imxmmc_platform_data sdhc_pdata = {
318 .dat3_card_detect = 1,
319};
320
Eric Bénardd2195d52010-05-27 10:58:56 +0200321struct imx_ssi_platform_data eukrea_mbimx27_ssi_pdata = {
322 .flags = IMX_SSI_DMA | IMX_SSI_USE_I2S_SLAVE,
323};
324
Eric Benarda961bf32009-07-16 16:26:34 +0200325/*
326 * system init for baseboard usage. Will be called by cpuimx27 init.
327 *
328 * Add platform devices present on this baseboard and init
329 * them from CPU side as far as required to use them later on
330 */
331void __init eukrea_mbimx27_baseboard_init(void)
332{
333 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
334 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
335
Eric Bénardd2195d52010-05-27 10:58:56 +0200336#if defined(CONFIG_SND_SOC_EUKREA_TLV320)
337 /* SSI unit master I2S codec connected to SSI_PINS_4*/
338 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR1_SSI0,
339 MXC_AUDMUX_V1_PCR_SYN |
340 MXC_AUDMUX_V1_PCR_TFSDIR |
341 MXC_AUDMUX_V1_PCR_TCLKDIR |
342 MXC_AUDMUX_V1_PCR_RFSDIR |
343 MXC_AUDMUX_V1_PCR_RCLKDIR |
344 MXC_AUDMUX_V1_PCR_TFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
345 MXC_AUDMUX_V1_PCR_RFCSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4) |
346 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR3_SSI_PINS_4)
347 );
348 mxc_audmux_v1_configure_port(MX27_AUDMUX_HPCR3_SSI_PINS_4,
349 MXC_AUDMUX_V1_PCR_SYN |
350 MXC_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0)
351 );
352#endif
353
Eric Benarda961bf32009-07-16 16:26:34 +0200354 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
355 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
Eric Bénard2d66c782010-05-19 18:45:59 +0200356#if !defined(MACH_EUKREA_CPUIMX27_USEUART4)
357 mxc_register_device(&mxc_uart_device3, &uart_pdata[2]);
358#endif
Eric Benarda961bf32009-07-16 16:26:34 +0200359
360 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
Eric Bénarde76a17c2010-05-19 18:46:05 +0200361 mxc_register_device(&mxc_sdhc_device0, &sdhc_pdata);
Eric Benarda961bf32009-07-16 16:26:34 +0200362
Eric Bénardd2195d52010-05-27 10:58:56 +0200363 i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
364 ARRAY_SIZE(eukrea_mbimx27_i2c_devices));
365
366 mxc_register_device(&imx_ssi_device0, &eukrea_mbimx27_ssi_pdata);
367
Eric Bénard62d725b2010-05-20 09:22:28 +0200368#if defined(CONFIG_TOUCHSCREEN_ADS7846) \
Eric Benarda961bf32009-07-16 16:26:34 +0200369 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
Eric Bénard62d725b2010-05-20 09:22:28 +0200370 /* ADS7846 Touchscreen controller init */
Eric Benarda961bf32009-07-16 16:26:34 +0200371 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
Eric Bénard62d725b2010-05-20 09:22:28 +0200372 ads7846_dev_init();
373#endif
374
375#if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE)
376 /* SPI_CS0 init */
377 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
Eric Benarda961bf32009-07-16 16:26:34 +0200378 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
379 spi_register_board_info(eukrea_mbimx27_spi_board_info,
380 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
Eric Benarda961bf32009-07-16 16:26:34 +0200381#endif
382
383 /* Leds configuration */
384 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
385 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
386 /* Backlight */
387 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
Eric Bénardfc04ad02010-05-19 18:45:57 +0200388 gpio_request(GPIO_PORTE | 5, "backlight");
389 platform_device_register(&eukrea_mbimx27_bl_dev);
390 /* LCD Reset */
391 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
392 gpio_request(GPIO_PORTA | 25, "lcd_enable");
393 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
Eric Benarda961bf32009-07-16 16:26:34 +0200394
Eric Bénard5203b992010-05-19 18:46:07 +0200395 mxc_register_device(&imx_kpp_device, &eukrea_mbimx27_keymap_data);
396
Eric Benarda961bf32009-07-16 16:26:34 +0200397 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
398}