blob: 2cf603e11c4f36786f06299b00cc8ffd9e7f4125 [file] [log] [blame]
Eric Bénard6f1fa702010-06-08 11:03:01 +02001/*
2 * Copyright (C) 2010 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/leds.h>
24#include <linux/platform_device.h>
Eric Bénard6f1fa702010-06-08 11:03:01 +020025#include <linux/input.h>
26#include <video/platform_lcd.h>
27
Eric Bénard6f1fa702010-06-08 11:03:01 +020028#include <mach/hardware.h>
29#include <mach/iomux-mx25.h>
30#include <mach/common.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <mach/mx25.h>
Eric Bénard6f1fa702010-06-08 11:03:01 +020034
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020035#include "devices-imx25.h"
Eric Bénard6f1fa702010-06-08 11:03:01 +020036
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020037static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
Eric Bénard6f1fa702010-06-08 11:03:01 +020038 /* LCD */
39 MX25_PAD_LD0__LD0,
40 MX25_PAD_LD1__LD1,
41 MX25_PAD_LD2__LD2,
42 MX25_PAD_LD3__LD3,
43 MX25_PAD_LD4__LD4,
44 MX25_PAD_LD5__LD5,
45 MX25_PAD_LD6__LD6,
46 MX25_PAD_LD7__LD7,
47 MX25_PAD_LD8__LD8,
48 MX25_PAD_LD9__LD9,
49 MX25_PAD_LD10__LD10,
50 MX25_PAD_LD11__LD11,
51 MX25_PAD_LD12__LD12,
52 MX25_PAD_LD13__LD13,
53 MX25_PAD_LD14__LD14,
54 MX25_PAD_LD15__LD15,
55 MX25_PAD_GPIO_E__LD16,
56 MX25_PAD_GPIO_F__LD17,
57 MX25_PAD_HSYNC__HSYNC,
58 MX25_PAD_VSYNC__VSYNC,
59 MX25_PAD_LSCLK__LSCLK,
60 MX25_PAD_OE_ACD__OE_ACD,
61 MX25_PAD_CONTRAST__CONTRAST,
62 /* LCD_PWR */
63 MX25_PAD_PWM__GPIO_1_26,
64 /* LED */
65 MX25_PAD_POWER_FAIL__GPIO_3_19,
66 /* SWITCH */
67 MX25_PAD_VSTBY_ACK__GPIO_3_18,
68 /* UART2 */
69 MX25_PAD_UART2_RTS__UART2_RTS,
70 MX25_PAD_UART2_CTS__UART2_CTS,
71 MX25_PAD_UART2_TXD__UART2_TXD,
72 MX25_PAD_UART2_RXD__UART2_RXD,
73 /* SD1 */
74 MX25_PAD_SD1_CMD__SD1_CMD,
75 MX25_PAD_SD1_CLK__SD1_CLK,
76 MX25_PAD_SD1_DATA0__SD1_DATA0,
77 MX25_PAD_SD1_DATA1__SD1_DATA1,
78 MX25_PAD_SD1_DATA2__SD1_DATA2,
79 MX25_PAD_SD1_DATA3__SD1_DATA3,
80 /* SD1 CD */
81 MX25_PAD_DE_B__GPIO_2_20,
82 /* I2S */
83 MX25_PAD_KPP_COL3__AUD5_TXFS,
84 MX25_PAD_KPP_COL2__AUD5_TXC,
85 MX25_PAD_KPP_COL1__AUD5_RXD,
86 MX25_PAD_KPP_COL0__AUD5_TXD,
Eric Bénard6f8460e2010-10-02 17:15:29 +020087 /* CAN */
88 MX25_PAD_GPIO_D__CAN2_RX,
89 MX25_PAD_GPIO_C__CAN2_TX,
Eric Bénard6f1fa702010-06-08 11:03:01 +020090};
91
92#define GPIO_LED1 83
93#define GPIO_SWITCH1 82
94#define GPIO_SD1CD 52
95#define GPIO_LCDPWR 26
96
97static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
98 {
99 .mode = {
100 .name = "CMO-QVGA",
101 .refresh = 60,
102 .xres = 320,
103 .yres = 240,
104 .pixclock = KHZ2PICOS(6500),
105 .left_margin = 30,
106 .right_margin = 38,
107 .upper_margin = 20,
108 .lower_margin = 3,
109 .hsync_len = 15,
110 .vsync_len = 4,
111 },
112 .bpp = 16,
113 .pcr = 0xCAD08B80,
Eric Bénardc0550c42010-10-08 10:56:10 +0200114 }, {
115 .mode = {
116 .name = "DVI-VGA",
117 .refresh = 60,
118 .xres = 640,
119 .yres = 480,
120 .pixclock = 32000,
121 .hsync_len = 7,
122 .left_margin = 100,
123 .right_margin = 100,
124 .vsync_len = 7,
125 .upper_margin = 7,
126 .lower_margin = 100,
127 },
128 .pcr = 0xFA208B80,
129 .bpp = 16,
130 }, {
131 .mode = {
132 .name = "DVI-SVGA",
133 .refresh = 60,
134 .xres = 800,
135 .yres = 600,
136 .pixclock = 25000,
137 .hsync_len = 7,
138 .left_margin = 75,
139 .right_margin = 75,
140 .vsync_len = 7,
141 .upper_margin = 7,
142 .lower_margin = 75,
143 },
144 .pcr = 0xFA208B80,
145 .bpp = 16,
Eric Bénard6f1fa702010-06-08 11:03:01 +0200146 },
147};
148
Uwe Kleine-König194ee8e2010-11-11 15:32:21 +0100149static const struct imx_fb_platform_data eukrea_mximxsd_fb_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200150 .mode = eukrea_mximxsd_modes,
151 .num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
152 .pwmr = 0x00A903FF,
153 .lscr1 = 0x00120300,
154 .dmacr = 0x00040060,
155};
156
157static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
158 unsigned int power)
159{
160 if (power)
161 gpio_direction_output(GPIO_LCDPWR, 1);
162 else
163 gpio_direction_output(GPIO_LCDPWR, 0);
164}
165
166static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
167 .set_power = eukrea_mbimxsd_lcd_power_set,
168};
169
170static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
171 .name = "platform-lcd",
172 .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
173};
174
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200175static const struct gpio_led eukrea_mbimxsd_leds[] __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200176 {
177 .name = "led1",
178 .default_trigger = "heartbeat",
179 .active_low = 1,
180 .gpio = GPIO_LED1,
181 },
182};
183
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200184static const struct gpio_led_platform_data
185 eukrea_mbimxsd_led_info __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200186 .leds = eukrea_mbimxsd_leds,
187 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
188};
189
Eric Bénard6f1fa702010-06-08 11:03:01 +0200190static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
191 {
192 .gpio = GPIO_SWITCH1,
193 .code = BTN_0,
194 .desc = "BP1",
195 .active_low = 1,
196 .wakeup = 1,
197 },
198};
199
Uwe Kleine-König53094982011-02-28 18:04:33 +0100200static const struct gpio_keys_platform_data
201 eukrea_mbimxsd_button_data __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200202 .buttons = eukrea_mbimxsd_gpio_buttons,
203 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
204};
205
Eric Bénard6f1fa702010-06-08 11:03:01 +0200206static struct platform_device *platform_devices[] __initdata = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200207 &eukrea_mbimxsd_lcd_powerdev,
208};
209
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200210static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200211 .flags = IMXUART_HAVE_RTSCTS,
212};
213
214static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
215 {
216 I2C_BOARD_INFO("tlv320aic23", 0x1a),
217 },
218};
219
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200220static const
221struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200222 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
223};
224
Eric Bénard01ea9ae2011-02-25 13:49:14 +0100225static struct esdhc_platform_data sd1_pdata = {
226 .cd_gpio = GPIO_SD1CD,
Shawn Guo913413c2011-06-21 22:41:51 +0800227 .cd_type = ESDHC_CD_GPIO,
228 .wp_type = ESDHC_WP_NONE,
Eric Bénard01ea9ae2011-02-25 13:49:14 +0100229};
230
Eric Bénard6f1fa702010-06-08 11:03:01 +0200231/*
232 * system init for baseboard usage. Will be called by cpuimx25 init.
233 *
234 * Add platform devices present on this baseboard and init
235 * them from CPU side as far as required to use them later on
236 */
Eric Bénardec53fe32010-07-30 22:58:40 +0200237void __init eukrea_mbimxsd25_baseboard_init(void)
Eric Bénard6f1fa702010-06-08 11:03:01 +0200238{
239 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
240 ARRAY_SIZE(eukrea_mbimxsd_pads)))
241 printk(KERN_ERR "error setting mbimxsd pads !\n");
242
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200243 imx25_add_imx_uart1(&uart_pdata);
Uwe Kleine-König194ee8e2010-11-11 15:32:21 +0100244 imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200245 imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
Eric Bénard6f1fa702010-06-08 11:03:01 +0200246
Eric Bénard6f8460e2010-10-02 17:15:29 +0200247 imx25_add_flexcan1(NULL);
Eric Bénard01ea9ae2011-02-25 13:49:14 +0100248 imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
Eric Bénard6f8460e2010-10-02 17:15:29 +0200249
Eric Bénard6f1fa702010-06-08 11:03:01 +0200250 gpio_request(GPIO_LED1, "LED1");
251 gpio_direction_output(GPIO_LED1, 1);
252 gpio_free(GPIO_LED1);
253
254 gpio_request(GPIO_SWITCH1, "SWITCH1");
255 gpio_direction_input(GPIO_SWITCH1);
256 gpio_free(GPIO_SWITCH1);
257
258 gpio_request(GPIO_LCDPWR, "LCDPWR");
259 gpio_direction_output(GPIO_LCDPWR, 1);
260 gpio_free(GPIO_SWITCH1);
261
262 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
263 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
264
265 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200266 gpio_led_register_device(-1, &eukrea_mbimxsd_led_info);
Uwe Kleine-König53094982011-02-28 18:04:33 +0100267 imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
Eric Bénard6f1fa702010-06-08 11:03:01 +0200268}