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