blob: 0f201c56fccf3397cabc495c445f4c75d146ca3c [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>
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/imxfb.h>
35#include <mach/hardware.h>
36#include <mach/mmc.h>
37#include <mach/imx-uart.h>
38
39#include "devices.h"
40
41static int eukrea_mbimx27_pins[] = {
42 /* UART2 */
43 PE3_PF_UART2_CTS,
44 PE4_PF_UART2_RTS,
45 PE6_PF_UART2_TXD,
46 PE7_PF_UART2_RXD,
47 /* UART3 */
48 PE8_PF_UART3_TXD,
49 PE9_PF_UART3_RXD,
50 PE10_PF_UART3_CTS,
51 PE11_PF_UART3_RTS,
52 /* UART4 */
53 PB26_AF_UART4_RTS,
54 PB28_AF_UART4_TXD,
55 PB29_AF_UART4_CTS,
56 PB31_AF_UART4_RXD,
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 */
89 PD28_PF_CSPI1_SS0,
90 PD29_PF_CSPI1_SCLK,
91 PD30_PF_CSPI1_MISO,
92 PD31_PF_CSPI1_MOSI,
93};
94
95static struct gpio_led gpio_leds[] = {
96 {
97 .name = "led1",
98 .default_trigger = "heartbeat",
99 .active_low = 1,
100 .gpio = GPIO_PORTF | 16,
101 },
102 {
103 .name = "led2",
104 .default_trigger = "none",
105 .active_low = 1,
106 .gpio = GPIO_PORTF | 19,
107 },
Eric Benarda961bf32009-07-16 16:26:34 +0200108};
109
110static struct gpio_led_platform_data gpio_led_info = {
111 .leds = gpio_leds,
112 .num_leds = ARRAY_SIZE(gpio_leds),
113};
114
115static struct platform_device leds_gpio = {
116 .name = "leds-gpio",
117 .id = -1,
118 .dev = {
119 .platform_data = &gpio_led_info,
120 },
121};
122
123static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
124 {
125 .mode = {
Eric Bénard4eaad662010-05-19 18:45:56 +0200126 .name = "CMO-QVGA",
Eric Benarda961bf32009-07-16 16:26:34 +0200127 .refresh = 60,
128 .xres = 320,
129 .yres = 240,
130 .pixclock = 156000,
131 .hsync_len = 30,
132 .left_margin = 38,
133 .right_margin = 20,
134 .vsync_len = 3,
135 .upper_margin = 15,
136 .lower_margin = 4,
137 },
138 .pcr = 0xFAD08B80,
139 .bpp = 16,
140 },
141};
142
143static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
144 .mode = eukrea_mbimx27_modes,
145 .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
146
147 .pwmr = 0x00A903FF,
148 .lscr1 = 0x00120300,
149 .dmacr = 0x00040060,
150};
151
Eric Bénardfc04ad02010-05-19 18:45:57 +0200152static void eukrea_mbimx27_bl_set_intensity(int intensity)
153{
154 if (intensity)
155 gpio_direction_output(GPIO_PORTE | 5, 1);
156 else
157 gpio_direction_output(GPIO_PORTE | 5, 0);
158}
159
160static struct generic_bl_info eukrea_mbimx27_bl_info = {
161 .name = "eukrea_mbimx27-bl",
162 .max_intensity = 0xff,
163 .default_intensity = 0xff,
164 .set_bl_intensity = eukrea_mbimx27_bl_set_intensity,
165};
166
167static struct platform_device eukrea_mbimx27_bl_dev = {
168 .name = "generic-bl",
169 .id = 1,
170 .dev = {
171 .platform_data = &eukrea_mbimx27_bl_info,
172 },
173};
174
175static void eukrea_mbimx27_lcd_power_set(struct plat_lcd_data *pd,
176 unsigned int power)
177{
178 if (power)
179 gpio_direction_output(GPIO_PORTA | 25, 1);
180 else
181 gpio_direction_output(GPIO_PORTA | 25, 0);
182}
183
184static struct plat_lcd_data eukrea_mbimx27_lcd_power_data = {
185 .set_power = eukrea_mbimx27_lcd_power_set,
186};
187
188static struct platform_device eukrea_mbimx27_lcd_powerdev = {
189 .name = "platform-lcd",
190 .dev.platform_data = &eukrea_mbimx27_lcd_power_data,
191};
192
Eric Benarda961bf32009-07-16 16:26:34 +0200193static struct imxuart_platform_data uart_pdata[] = {
194 {
195 .flags = IMXUART_HAVE_RTSCTS,
196 },
197 {
198 .flags = IMXUART_HAVE_RTSCTS,
199 },
200};
201
202#if defined(CONFIG_TOUCHSCREEN_ADS7846)
203 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
204
205#define ADS7846_PENDOWN (GPIO_PORTD | 25)
206
207static void ads7846_dev_init(void)
208{
209 if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) {
210 printk(KERN_ERR "can't get ads746 pen down GPIO\n");
211 return;
212 }
213
214 gpio_direction_input(ADS7846_PENDOWN);
215}
216
217static int ads7846_get_pendown_state(void)
218{
219 return !gpio_get_value(ADS7846_PENDOWN);
220}
221
222static struct ads7846_platform_data ads7846_config __initdata = {
223 .get_pendown_state = ads7846_get_pendown_state,
224 .keep_vref_on = 1,
225};
226
227static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = {
228 [0] = {
229 .modalias = "ads7846",
230 .bus_num = 0,
231 .chip_select = 0,
232 .max_speed_hz = 1500000,
233 .irq = IRQ_GPIOD(25),
234 .platform_data = &ads7846_config,
235 .mode = SPI_MODE_2,
236 },
237};
238
239static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28};
240
241static struct spi_imx_master eukrea_mbimx27_spi_0_data = {
242 .chipselect = eukrea_mbimx27_spi_cs,
243 .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs),
244};
245#endif
246
247static struct platform_device *platform_devices[] __initdata = {
248 &leds_gpio,
249};
250
251/*
252 * system init for baseboard usage. Will be called by cpuimx27 init.
253 *
254 * Add platform devices present on this baseboard and init
255 * them from CPU side as far as required to use them later on
256 */
257void __init eukrea_mbimx27_baseboard_init(void)
258{
259 mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins,
260 ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27");
261
262 mxc_register_device(&mxc_uart_device1, &uart_pdata[0]);
263 mxc_register_device(&mxc_uart_device2, &uart_pdata[1]);
264
265 mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
266 mxc_register_device(&mxc_sdhc_device0, NULL);
267
268#if defined(CONFIG_TOUCHSCREEN_ADS7846)
269 || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
270 /* SPI and ADS7846 Touchscreen controler init */
271 mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT);
272 mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN);
273 mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data);
274 spi_register_board_info(eukrea_mbimx27_spi_board_info,
275 ARRAY_SIZE(eukrea_mbimx27_spi_board_info));
276 ads7846_dev_init();
277#endif
278
279 /* Leds configuration */
280 mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT);
281 mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT);
282 /* Backlight */
283 mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT);
Eric Bénardfc04ad02010-05-19 18:45:57 +0200284 gpio_request(GPIO_PORTE | 5, "backlight");
285 platform_device_register(&eukrea_mbimx27_bl_dev);
286 /* LCD Reset */
287 mxc_gpio_mode(GPIO_PORTA | 25 | GPIO_GPIO | GPIO_OUT);
288 gpio_request(GPIO_PORTA | 25, "lcd_enable");
289 platform_device_register(&eukrea_mbimx27_lcd_powerdev);
Eric Benarda961bf32009-07-16 16:26:34 +0200290
291 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
292}