blob: c1fe048c445ed3a3ff5ec81a2a35bffd6728ee8d [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>
25#include <linux/gpio_keys.h>
26#include <linux/input.h>
27#include <video/platform_lcd.h>
28
Eric Bénard6f1fa702010-06-08 11:03:01 +020029#include <mach/hardware.h>
30#include <mach/iomux-mx25.h>
31#include <mach/common.h>
32#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <mach/mx25.h>
35#include <mach/imx-uart.h>
36#include <mach/imxfb.h>
Eric Bénard6f1fa702010-06-08 11:03:01 +020037#include <mach/audmux.h>
38
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +020039#include "devices-imx25.h"
Eric Bénard6f1fa702010-06-08 11:03:01 +020040#include "devices.h"
41
42static struct pad_desc eukrea_mbimxsd_pads[] = {
43 /* LCD */
44 MX25_PAD_LD0__LD0,
45 MX25_PAD_LD1__LD1,
46 MX25_PAD_LD2__LD2,
47 MX25_PAD_LD3__LD3,
48 MX25_PAD_LD4__LD4,
49 MX25_PAD_LD5__LD5,
50 MX25_PAD_LD6__LD6,
51 MX25_PAD_LD7__LD7,
52 MX25_PAD_LD8__LD8,
53 MX25_PAD_LD9__LD9,
54 MX25_PAD_LD10__LD10,
55 MX25_PAD_LD11__LD11,
56 MX25_PAD_LD12__LD12,
57 MX25_PAD_LD13__LD13,
58 MX25_PAD_LD14__LD14,
59 MX25_PAD_LD15__LD15,
60 MX25_PAD_GPIO_E__LD16,
61 MX25_PAD_GPIO_F__LD17,
62 MX25_PAD_HSYNC__HSYNC,
63 MX25_PAD_VSYNC__VSYNC,
64 MX25_PAD_LSCLK__LSCLK,
65 MX25_PAD_OE_ACD__OE_ACD,
66 MX25_PAD_CONTRAST__CONTRAST,
67 /* LCD_PWR */
68 MX25_PAD_PWM__GPIO_1_26,
69 /* LED */
70 MX25_PAD_POWER_FAIL__GPIO_3_19,
71 /* SWITCH */
72 MX25_PAD_VSTBY_ACK__GPIO_3_18,
73 /* UART2 */
74 MX25_PAD_UART2_RTS__UART2_RTS,
75 MX25_PAD_UART2_CTS__UART2_CTS,
76 MX25_PAD_UART2_TXD__UART2_TXD,
77 MX25_PAD_UART2_RXD__UART2_RXD,
78 /* SD1 */
79 MX25_PAD_SD1_CMD__SD1_CMD,
80 MX25_PAD_SD1_CLK__SD1_CLK,
81 MX25_PAD_SD1_DATA0__SD1_DATA0,
82 MX25_PAD_SD1_DATA1__SD1_DATA1,
83 MX25_PAD_SD1_DATA2__SD1_DATA2,
84 MX25_PAD_SD1_DATA3__SD1_DATA3,
85 /* SD1 CD */
86 MX25_PAD_DE_B__GPIO_2_20,
87 /* I2S */
88 MX25_PAD_KPP_COL3__AUD5_TXFS,
89 MX25_PAD_KPP_COL2__AUD5_TXC,
90 MX25_PAD_KPP_COL1__AUD5_RXD,
91 MX25_PAD_KPP_COL0__AUD5_TXD,
Eric Bénard6f8460e2010-10-02 17:15:29 +020092 /* CAN */
93 MX25_PAD_GPIO_D__CAN2_RX,
94 MX25_PAD_GPIO_C__CAN2_TX,
Eric Bénard6f1fa702010-06-08 11:03:01 +020095};
96
97#define GPIO_LED1 83
98#define GPIO_SWITCH1 82
99#define GPIO_SD1CD 52
100#define GPIO_LCDPWR 26
101
102static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
103 {
104 .mode = {
105 .name = "CMO-QVGA",
106 .refresh = 60,
107 .xres = 320,
108 .yres = 240,
109 .pixclock = KHZ2PICOS(6500),
110 .left_margin = 30,
111 .right_margin = 38,
112 .upper_margin = 20,
113 .lower_margin = 3,
114 .hsync_len = 15,
115 .vsync_len = 4,
116 },
117 .bpp = 16,
118 .pcr = 0xCAD08B80,
119 },
120};
121
122static struct imx_fb_platform_data eukrea_mximxsd_fb_pdata = {
123 .mode = eukrea_mximxsd_modes,
124 .num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
125 .pwmr = 0x00A903FF,
126 .lscr1 = 0x00120300,
127 .dmacr = 0x00040060,
128};
129
130static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
131 unsigned int power)
132{
133 if (power)
134 gpio_direction_output(GPIO_LCDPWR, 1);
135 else
136 gpio_direction_output(GPIO_LCDPWR, 0);
137}
138
139static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
140 .set_power = eukrea_mbimxsd_lcd_power_set,
141};
142
143static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
144 .name = "platform-lcd",
145 .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
146};
147
148static struct gpio_led eukrea_mbimxsd_leds[] = {
149 {
150 .name = "led1",
151 .default_trigger = "heartbeat",
152 .active_low = 1,
153 .gpio = GPIO_LED1,
154 },
155};
156
157static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
158 .leds = eukrea_mbimxsd_leds,
159 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
160};
161
162static struct platform_device eukrea_mbimxsd_leds_gpio = {
163 .name = "leds-gpio",
164 .id = -1,
165 .dev = {
166 .platform_data = &eukrea_mbimxsd_led_info,
167 },
168};
169
170static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
171 {
172 .gpio = GPIO_SWITCH1,
173 .code = BTN_0,
174 .desc = "BP1",
175 .active_low = 1,
176 .wakeup = 1,
177 },
178};
179
180static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = {
181 .buttons = eukrea_mbimxsd_gpio_buttons,
182 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
183};
184
185static struct platform_device eukrea_mbimxsd_button_device = {
186 .name = "gpio-keys",
187 .id = -1,
188 .num_resources = 0,
189 .dev = {
190 .platform_data = &eukrea_mbimxsd_button_data,
191 }
192};
193
194static struct platform_device *platform_devices[] __initdata = {
195 &eukrea_mbimxsd_leds_gpio,
196 &eukrea_mbimxsd_button_device,
197 &eukrea_mbimxsd_lcd_powerdev,
198};
199
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200200static const struct imxuart_platform_data uart_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200201 .flags = IMXUART_HAVE_RTSCTS,
202};
203
204static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
205 {
206 I2C_BOARD_INFO("tlv320aic23", 0x1a),
207 },
208};
209
Uwe Kleine-König4697bb92010-08-25 17:37:45 +0200210static const
211struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
Eric Bénard6f1fa702010-06-08 11:03:01 +0200212 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
213};
214
215/*
216 * system init for baseboard usage. Will be called by cpuimx25 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 */
Eric Bénardec53fe32010-07-30 22:58:40 +0200221void __init eukrea_mbimxsd25_baseboard_init(void)
Eric Bénard6f1fa702010-06-08 11:03:01 +0200222{
223 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
224 ARRAY_SIZE(eukrea_mbimxsd_pads)))
225 printk(KERN_ERR "error setting mbimxsd pads !\n");
226
227#if defined(CONFIG_SND_SOC_EUKREA_TLV320)
228 /* SSI unit master I2S codec connected to SSI_AUD5*/
229 mxc_audmux_v2_configure_port(0,
230 MXC_AUDMUX_V2_PTCR_SYN |
231 MXC_AUDMUX_V2_PTCR_TFSDIR |
232 MXC_AUDMUX_V2_PTCR_TFSEL(4) |
233 MXC_AUDMUX_V2_PTCR_TCLKDIR |
234 MXC_AUDMUX_V2_PTCR_TCSEL(4),
235 MXC_AUDMUX_V2_PDCR_RXDSEL(4)
236 );
237 mxc_audmux_v2_configure_port(4,
238 MXC_AUDMUX_V2_PTCR_SYN,
239 MXC_AUDMUX_V2_PDCR_RXDSEL(0)
240 );
241#endif
242
Uwe Kleine-König2dcf78c2010-06-30 12:16:24 +0200243 imx25_add_imx_uart1(&uart_pdata);
Eric Bénard6f1fa702010-06-08 11:03:01 +0200244 mxc_register_device(&mx25_fb_device, &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);
248 imx25_add_esdhc0(NULL);
249
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));
266}