blob: 176e61bf44b6dc8099c37a951a03105b3e8d33b3 [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>
34#include <mach/imx-uart.h>
Eric Bénard6f1fa702010-06-08 11:03:01 +020035#include <mach/audmux.h>
Eric Bénard01ea9ae2011-02-25 13:49:14 +010036#include <mach/esdhc.h>
Eric Bénard6f1fa702010-06-08 11:03:01 +020037
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020038#include "devices-imx25.h"
Eric Bénard6f1fa702010-06-08 11:03:01 +020039
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020040static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
Eric Bénard6f1fa702010-06-08 11:03:01 +020041 /* LCD */
42 MX25_PAD_LD0__LD0,
43 MX25_PAD_LD1__LD1,
44 MX25_PAD_LD2__LD2,
45 MX25_PAD_LD3__LD3,
46 MX25_PAD_LD4__LD4,
47 MX25_PAD_LD5__LD5,
48 MX25_PAD_LD6__LD6,
49 MX25_PAD_LD7__LD7,
50 MX25_PAD_LD8__LD8,
51 MX25_PAD_LD9__LD9,
52 MX25_PAD_LD10__LD10,
53 MX25_PAD_LD11__LD11,
54 MX25_PAD_LD12__LD12,
55 MX25_PAD_LD13__LD13,
56 MX25_PAD_LD14__LD14,
57 MX25_PAD_LD15__LD15,
58 MX25_PAD_GPIO_E__LD16,
59 MX25_PAD_GPIO_F__LD17,
60 MX25_PAD_HSYNC__HSYNC,
61 MX25_PAD_VSYNC__VSYNC,
62 MX25_PAD_LSCLK__LSCLK,
63 MX25_PAD_OE_ACD__OE_ACD,
64 MX25_PAD_CONTRAST__CONTRAST,
65 /* LCD_PWR */
66 MX25_PAD_PWM__GPIO_1_26,
67 /* LED */
68 MX25_PAD_POWER_FAIL__GPIO_3_19,
69 /* SWITCH */
70 MX25_PAD_VSTBY_ACK__GPIO_3_18,
71 /* UART2 */
72 MX25_PAD_UART2_RTS__UART2_RTS,
73 MX25_PAD_UART2_CTS__UART2_CTS,
74 MX25_PAD_UART2_TXD__UART2_TXD,
75 MX25_PAD_UART2_RXD__UART2_RXD,
76 /* SD1 */
77 MX25_PAD_SD1_CMD__SD1_CMD,
78 MX25_PAD_SD1_CLK__SD1_CLK,
79 MX25_PAD_SD1_DATA0__SD1_DATA0,
80 MX25_PAD_SD1_DATA1__SD1_DATA1,
81 MX25_PAD_SD1_DATA2__SD1_DATA2,
82 MX25_PAD_SD1_DATA3__SD1_DATA3,
83 /* SD1 CD */
84 MX25_PAD_DE_B__GPIO_2_20,
85 /* I2S */
86 MX25_PAD_KPP_COL3__AUD5_TXFS,
87 MX25_PAD_KPP_COL2__AUD5_TXC,
88 MX25_PAD_KPP_COL1__AUD5_RXD,
89 MX25_PAD_KPP_COL0__AUD5_TXD,
Eric Bénard6f8460e2010-10-02 17:15:29 +020090 /* CAN */
91 MX25_PAD_GPIO_D__CAN2_RX,
92 MX25_PAD_GPIO_C__CAN2_TX,
Eric Bénard6f1fa702010-06-08 11:03:01 +020093};
94
95#define GPIO_LED1 83
96#define GPIO_SWITCH1 82
97#define GPIO_SD1CD 52
98#define GPIO_LCDPWR 26
99
100static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
101 {
102 .mode = {
103 .name = "CMO-QVGA",
104 .refresh = 60,
105 .xres = 320,
106 .yres = 240,
107 .pixclock = KHZ2PICOS(6500),
108 .left_margin = 30,
109 .right_margin = 38,
110 .upper_margin = 20,
111 .lower_margin = 3,
112 .hsync_len = 15,
113 .vsync_len = 4,
114 },
115 .bpp = 16,
116 .pcr = 0xCAD08B80,
Eric Bénardc0550c42010-10-08 10:56:10 +0200117 }, {
118 .mode = {
119 .name = "DVI-VGA",
120 .refresh = 60,
121 .xres = 640,
122 .yres = 480,
123 .pixclock = 32000,
124 .hsync_len = 7,
125 .left_margin = 100,
126 .right_margin = 100,
127 .vsync_len = 7,
128 .upper_margin = 7,
129 .lower_margin = 100,
130 },
131 .pcr = 0xFA208B80,
132 .bpp = 16,
133 }, {
134 .mode = {
135 .name = "DVI-SVGA",
136 .refresh = 60,
137 .xres = 800,
138 .yres = 600,
139 .pixclock = 25000,
140 .hsync_len = 7,
141 .left_margin = 75,
142 .right_margin = 75,
143 .vsync_len = 7,
144 .upper_margin = 7,
145 .lower_margin = 75,
146 },
147 .pcr = 0xFA208B80,
148 .bpp = 16,
Eric Bénard6f1fa702010-06-08 11:03:01 +0200149 },
150};
151
Uwe Kleine-König194ee8e2010-11-11 15:32:21 +0100152static const struct imx_fb_platform_data eukrea_mximxsd_fb_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200153 .mode = eukrea_mximxsd_modes,
154 .num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
155 .pwmr = 0x00A903FF,
156 .lscr1 = 0x00120300,
157 .dmacr = 0x00040060,
158};
159
160static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
161 unsigned int power)
162{
163 if (power)
164 gpio_direction_output(GPIO_LCDPWR, 1);
165 else
166 gpio_direction_output(GPIO_LCDPWR, 0);
167}
168
169static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
170 .set_power = eukrea_mbimxsd_lcd_power_set,
171};
172
173static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
174 .name = "platform-lcd",
175 .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
176};
177
178static struct gpio_led eukrea_mbimxsd_leds[] = {
179 {
180 .name = "led1",
181 .default_trigger = "heartbeat",
182 .active_low = 1,
183 .gpio = GPIO_LED1,
184 },
185};
186
187static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
188 .leds = eukrea_mbimxsd_leds,
189 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
190};
191
192static struct platform_device eukrea_mbimxsd_leds_gpio = {
193 .name = "leds-gpio",
194 .id = -1,
195 .dev = {
196 .platform_data = &eukrea_mbimxsd_led_info,
197 },
198};
199
200static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
201 {
202 .gpio = GPIO_SWITCH1,
203 .code = BTN_0,
204 .desc = "BP1",
205 .active_low = 1,
206 .wakeup = 1,
207 },
208};
209
Uwe Kleine-König53094982011-02-28 18:04:33 +0100210static const struct gpio_keys_platform_data
211 eukrea_mbimxsd_button_data __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200212 .buttons = eukrea_mbimxsd_gpio_buttons,
213 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
214};
215
Eric Bénard6f1fa702010-06-08 11:03:01 +0200216static struct platform_device *platform_devices[] __initdata = {
217 &eukrea_mbimxsd_leds_gpio,
Eric Bénard6f1fa702010-06-08 11:03:01 +0200218 &eukrea_mbimxsd_lcd_powerdev,
219};
220
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200221static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200222 .flags = IMXUART_HAVE_RTSCTS,
223};
224
225static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
226 {
227 I2C_BOARD_INFO("tlv320aic23", 0x1a),
228 },
229};
230
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200231static const
232struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200233 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
234};
235
Eric Bénard01ea9ae2011-02-25 13:49:14 +0100236static struct esdhc_platform_data sd1_pdata = {
237 .cd_gpio = GPIO_SD1CD,
238 .wp_gpio = -EINVAL,
239};
240
Eric Bénard6f1fa702010-06-08 11:03:01 +0200241/*
242 * system init for baseboard usage. Will be called by cpuimx25 init.
243 *
244 * Add platform devices present on this baseboard and init
245 * them from CPU side as far as required to use them later on
246 */
Eric Bénardec53fe32010-07-30 22:58:40 +0200247void __init eukrea_mbimxsd25_baseboard_init(void)
Eric Bénard6f1fa702010-06-08 11:03:01 +0200248{
249 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
250 ARRAY_SIZE(eukrea_mbimxsd_pads)))
251 printk(KERN_ERR "error setting mbimxsd pads !\n");
252
253#if defined(CONFIG_SND_SOC_EUKREA_TLV320)
254 /* SSI unit master I2S codec connected to SSI_AUD5*/
255 mxc_audmux_v2_configure_port(0,
256 MXC_AUDMUX_V2_PTCR_SYN |
257 MXC_AUDMUX_V2_PTCR_TFSDIR |
258 MXC_AUDMUX_V2_PTCR_TFSEL(4) |
259 MXC_AUDMUX_V2_PTCR_TCLKDIR |
260 MXC_AUDMUX_V2_PTCR_TCSEL(4),
261 MXC_AUDMUX_V2_PDCR_RXDSEL(4)
262 );
263 mxc_audmux_v2_configure_port(4,
264 MXC_AUDMUX_V2_PTCR_SYN,
265 MXC_AUDMUX_V2_PDCR_RXDSEL(0)
266 );
267#endif
268
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200269 imx25_add_imx_uart1(&uart_pdata);
Uwe Kleine-König194ee8e2010-11-11 15:32:21 +0100270 imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200271 imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
Eric Bénard6f1fa702010-06-08 11:03:01 +0200272
Eric Bénard6f8460e2010-10-02 17:15:29 +0200273 imx25_add_flexcan1(NULL);
Eric Bénard01ea9ae2011-02-25 13:49:14 +0100274 imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
Eric Bénard6f8460e2010-10-02 17:15:29 +0200275
Eric Bénard6f1fa702010-06-08 11:03:01 +0200276 gpio_request(GPIO_LED1, "LED1");
277 gpio_direction_output(GPIO_LED1, 1);
278 gpio_free(GPIO_LED1);
279
280 gpio_request(GPIO_SWITCH1, "SWITCH1");
281 gpio_direction_input(GPIO_SWITCH1);
282 gpio_free(GPIO_SWITCH1);
283
284 gpio_request(GPIO_LCDPWR, "LCDPWR");
285 gpio_direction_output(GPIO_LCDPWR, 1);
286 gpio_free(GPIO_SWITCH1);
287
288 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
289 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
290
291 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Uwe Kleine-König53094982011-02-28 18:04:33 +0100292 imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
Eric Bénard6f1fa702010-06-08 11:03:01 +0200293}