blob: eed8143712470c15f8451b51529e8370ddb813ef [file] [log] [blame]
Eric Benarda961bf32009-07-16 16:26:34 +02001/*
2 * Copyright (C) 2009 Eric Benard - eric@eukrea.com
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>
27
28#include <asm/mach/arch.h>
29
30#include <mach/common.h>
Uwe Kleine-Könige835d882010-02-16 11:07:49 +010031#include <mach/iomux-mx27.h>
Eric Benarda961bf32009-07-16 16:26:34 +020032#include <mach/imxfb.h>
33#include <mach/hardware.h>
34#include <mach/mmc.h>
35#include <mach/imx-uart.h>
36
Uwe Kleine-König7536cf92010-06-22 09:00:22 +020037#include "devices-imx27.h"
Eric Benarda961bf32009-07-16 16:26:34 +020038#include "devices.h"
39
40static int eukrea_mbimx27_pins[] = {
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 */
52 PB26_AF_UART4_RTS,
53 PB28_AF_UART4_TXD,
54 PB29_AF_UART4_CTS,
55 PB31_AF_UART4_RXD,
56 /* SDHC1*/
57 PE18_PF_SD1_D0,
58 PE19_PF_SD1_D1,
59 PE20_PF_SD1_D2,
60 PE21_PF_SD1_D3,
61 PE22_PF_SD1_CMD,
62 PE23_PF_SD1_CLK,
63 /* display */
64 PA5_PF_LSCLK,
65 PA6_PF_LD0,
66 PA7_PF_LD1,
67 PA8_PF_LD2,
68 PA9_PF_LD3,
69 PA10_PF_LD4,
70 PA11_PF_LD5,
71 PA12_PF_LD6,
72 PA13_PF_LD7,
73 PA14_PF_LD8,
74 PA15_PF_LD9,
75 PA16_PF_LD10,
76 PA17_PF_LD11,
77 PA18_PF_LD12,
78 PA19_PF_LD13,
79 PA20_PF_LD14,
80 PA21_PF_LD15,
81 PA22_PF_LD16,
82 PA23_PF_LD17,
83 PA28_PF_HSYNC,
84 PA29_PF_VSYNC,
85 PA30_PF_CONTRAST,
86 PA31_PF_OE_ACD,
87 /* SPI1 */
88 PD28_PF_CSPI1_SS0,
89 PD29_PF_CSPI1_SCLK,
90 PD30_PF_CSPI1_MISO,
91 PD31_PF_CSPI1_MOSI,
92};
93
94static struct gpio_led gpio_leds[] = {
95 {
96 .name = "led1",
97 .default_trigger = "heartbeat",
98 .active_low = 1,
99 .gpio = GPIO_PORTF | 16,
100 },
101 {
102 .name = "led2",
103 .default_trigger = "none",
104 .active_low = 1,
105 .gpio = GPIO_PORTF | 19,
106 },
107 {
108 .name = "backlight",
109 .default_trigger = "backlight",
110 .active_low = 0,
111 .gpio = GPIO_PORTE | 5,
112 },
113};
114
115static struct gpio_led_platform_data gpio_led_info = {
116 .leds = gpio_leds,
117 .num_leds = ARRAY_SIZE(gpio_leds),
118};
119
120static struct platform_device leds_gpio = {
121 .name = "leds-gpio",
122 .id = -1,
123 .dev = {
124 .platform_data = &gpio_led_info,
125 },
126};
127
128static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
129 {
130 .mode = {
131 .name = "CMO-QGVA",
132 .refresh = 60,
133 .xres = 320,
134 .yres = 240,
135 .pixclock = 156000,
136 .hsync_len = 30,
137 .left_margin = 38,
138 .right_margin = 20,
139 .vsync_len = 3,
140 .upper_margin = 15,
141 .lower_margin = 4,
142 },
143 .pcr = 0xFAD08B80,
144 .bpp = 16,
145 },
146};
147
148static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
149 .mode = eukrea_mbimx27_modes,
150 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
151
152 .pwmr = 0x00A903FF,
153 .lscr1 = 0x00120300,
154 .dmacr = 0x00040060,
155};
156
157static struct imxuart_platform_data uart_pdata[] = {
158 {
159 .flags = IMXUART_HAVE_RTSCTS,
160 },
161 {
162 .flags = IMXUART_HAVE_RTSCTS,
163 },
164};
165
166#if defined(CONFIG_TOUCHSCREEN_ADS7846)
167 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
168
169#define ADS7846_PENDOWN (GPIO_PORTD | 25)
170
171static void ads7846_dev_init(void)
172{
173 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
174 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
175 return;
176 }
177
178 gpio_direction_input(ADS7846_PENDOWN);
179}
180
181static int ads7846_get_pendown_state(void)
182{
183 return !gpio_get_value(ADS7846_PENDOWN);
184}
185
186static struct ads7846_platform_data ads7846_config __initdata = {
187 .get_pendown_state = ads7846_get_pendown_state,
188 .keep_vref_on = 1,
189};
190
191static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
192 [0] = {
193 .modalias = "ads7846",
194 .bus_num = 0,
195 .chip_select = 0,
196 .max_speed_hz = 1500000,
197 .irq = IRQ_GPIOD(25),
198 .platform_data = &ads7846_config,
199 .mode = SPI_MODE_2,
200 },
201};
202
203static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
204
Uwe Kleine-König7536cf92010-06-22 09:00:22 +0200205static const struct spi_imx_master eukrea_mbimx27_spi0_data __initconst = {
Eric Benarda961bf32009-07-16 16:26:34 +0200206 .chipselect = eukrea_mbimx27_spi_cs,
207 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
208};
209#endif
210
211static struct platform_device *platform_devices[] __initdata = {
212 &leds_gpio,
213};
214
215/*
216 * system init for baseboard usage. Will be called by cpuimx27 init.
217 *
218 * Add platform devices present on this baseboard and init
219 * them from CPU side as far as required to use them later on
220 */
221void __init eukrea_mbimx27_baseboard_init(void)
222{
223 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
224 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
225
Uwe Kleine-König551823e2010-06-11 09:08:02 +0200226 mxc_register_device(&imx2x_uart_device1, &uart_pdata[0]);
227 mxc_register_device(&imx2x_uart_device2, &uart_pdata[1]);
Eric Benarda961bf32009-07-16 16:26:34 +0200228
229 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
230 mxc_register_device(&mxc_sdhc_device0, NULL);
231
232#if defined(CONFIG_TOUCHSCREEN_ADS7846)
233 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
234 /* SPI and ADS7846 Touchscreen controler init */
235 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
236 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
Uwe Kleine-König7536cf92010-06-22 09:00:22 +0200237 imx27_add_spi_imx0(&eukrea_mbimx27_spi0_data);
Eric Benarda961bf32009-07-16 16:26:34 +0200238 spi_register_board_info(eukrea_mbimx27_spi_board_info,
239 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
240 ads7846_dev_init();
241#endif
242
243 /* Leds configuration */
244 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
245 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
246 /* Backlight */
247 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
248
249 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
250}