Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux...
[deliverable/linux.git] / arch / arm / mach-mx3 / eukrea_mbimxsd-baseboard.c
1 /*
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/types.h>
23 #include <linux/init.h>
24
25 #include <linux/gpio.h>
26 #include <linux/interrupt.h>
27 #include <linux/leds.h>
28 #include <linux/platform_device.h>
29 #include <linux/gpio_keys.h>
30 #include <linux/input.h>
31 #include <video/platform_lcd.h>
32 #include <linux/i2c.h>
33
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/time.h>
37 #include <asm/mach/map.h>
38
39 #include <mach/hardware.h>
40 #include <mach/common.h>
41 #include <mach/imx-uart.h>
42 #include <mach/iomux-mx35.h>
43 #include <mach/ipu.h>
44 #include <mach/mx3fb.h>
45 #include <mach/audmux.h>
46
47 #include "devices-imx35.h"
48 #include "devices.h"
49
50 static const struct fb_videomode fb_modedb[] = {
51 {
52 .name = "CMO_QVGA",
53 .refresh = 60,
54 .xres = 320,
55 .yres = 240,
56 .pixclock = KHZ2PICOS(6500),
57 .left_margin = 68,
58 .right_margin = 20,
59 .upper_margin = 15,
60 .lower_margin = 4,
61 .hsync_len = 30,
62 .vsync_len = 3,
63 .sync = 0,
64 .vmode = FB_VMODE_NONINTERLACED,
65 .flag = 0,
66 },
67 };
68
69 static struct ipu_platform_data mx3_ipu_data = {
70 .irq_base = MXC_IPU_IRQ_START,
71 };
72
73 static struct mx3fb_platform_data mx3fb_pdata = {
74 .dma_dev = &mx3_ipu.dev,
75 .name = "CMO_QVGA",
76 .mode = fb_modedb,
77 .num_modes = ARRAY_SIZE(fb_modedb),
78 };
79
80 static struct pad_desc eukrea_mbimxsd_pads[] = {
81 /* LCD */
82 MX35_PAD_LD0__IPU_DISPB_DAT_0,
83 MX35_PAD_LD1__IPU_DISPB_DAT_1,
84 MX35_PAD_LD2__IPU_DISPB_DAT_2,
85 MX35_PAD_LD3__IPU_DISPB_DAT_3,
86 MX35_PAD_LD4__IPU_DISPB_DAT_4,
87 MX35_PAD_LD5__IPU_DISPB_DAT_5,
88 MX35_PAD_LD6__IPU_DISPB_DAT_6,
89 MX35_PAD_LD7__IPU_DISPB_DAT_7,
90 MX35_PAD_LD8__IPU_DISPB_DAT_8,
91 MX35_PAD_LD9__IPU_DISPB_DAT_9,
92 MX35_PAD_LD10__IPU_DISPB_DAT_10,
93 MX35_PAD_LD11__IPU_DISPB_DAT_11,
94 MX35_PAD_LD12__IPU_DISPB_DAT_12,
95 MX35_PAD_LD13__IPU_DISPB_DAT_13,
96 MX35_PAD_LD14__IPU_DISPB_DAT_14,
97 MX35_PAD_LD15__IPU_DISPB_DAT_15,
98 MX35_PAD_LD16__IPU_DISPB_DAT_16,
99 MX35_PAD_LD17__IPU_DISPB_DAT_17,
100 MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
101 MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
102 MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
103 MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
104 /* Backlight */
105 MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
106 /* LCD_PWR */
107 MX35_PAD_D3_CLS__GPIO1_4,
108 /* LED */
109 MX35_PAD_LD23__GPIO3_29,
110 /* SWITCH */
111 MX35_PAD_LD19__GPIO3_25,
112 /* UART2 */
113 MX35_PAD_CTS2__UART2_CTS,
114 MX35_PAD_RTS2__UART2_RTS,
115 MX35_PAD_TXD2__UART2_TXD_MUX,
116 MX35_PAD_RXD2__UART2_RXD_MUX,
117 /* I2S */
118 MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS,
119 MX35_PAD_STXD4__AUDMUX_AUD4_TXD,
120 MX35_PAD_SRXD4__AUDMUX_AUD4_RXD,
121 MX35_PAD_SCK4__AUDMUX_AUD4_TXC,
122 /* CAN2 */
123 MX35_PAD_TX5_RX0__CAN2_TXCAN,
124 MX35_PAD_TX4_RX1__CAN2_RXCAN,
125 /* SDCARD */
126 MX35_PAD_SD1_CMD__ESDHC1_CMD,
127 MX35_PAD_SD1_CLK__ESDHC1_CLK,
128 MX35_PAD_SD1_DATA0__ESDHC1_DAT0,
129 MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
130 MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
131 MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
132 };
133
134 #define GPIO_LED1 (2 * 32 + 29)
135 #define GPIO_SWITCH1 (2 * 32 + 25)
136 #define GPIO_LCDPWR (4)
137
138 static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
139 unsigned int power)
140 {
141 if (power)
142 gpio_direction_output(GPIO_LCDPWR, 1);
143 else
144 gpio_direction_output(GPIO_LCDPWR, 0);
145 }
146
147 static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
148 .set_power = eukrea_mbimxsd_lcd_power_set,
149 };
150
151 static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
152 .name = "platform-lcd",
153 .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
154 };
155
156 static struct gpio_led eukrea_mbimxsd_leds[] = {
157 {
158 .name = "led1",
159 .default_trigger = "heartbeat",
160 .active_low = 1,
161 .gpio = GPIO_LED1,
162 },
163 };
164
165 static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
166 .leds = eukrea_mbimxsd_leds,
167 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
168 };
169
170 static struct platform_device eukrea_mbimxsd_leds_gpio = {
171 .name = "leds-gpio",
172 .id = -1,
173 .dev = {
174 .platform_data = &eukrea_mbimxsd_led_info,
175 },
176 };
177
178 static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
179 {
180 .gpio = GPIO_SWITCH1,
181 .code = BTN_0,
182 .desc = "BP1",
183 .active_low = 1,
184 .wakeup = 1,
185 },
186 };
187
188 static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = {
189 .buttons = eukrea_mbimxsd_gpio_buttons,
190 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
191 };
192
193 static struct platform_device eukrea_mbimxsd_button_device = {
194 .name = "gpio-keys",
195 .id = -1,
196 .num_resources = 0,
197 .dev = {
198 .platform_data = &eukrea_mbimxsd_button_data,
199 }
200 };
201
202 static struct platform_device *platform_devices[] __initdata = {
203 &eukrea_mbimxsd_leds_gpio,
204 &eukrea_mbimxsd_button_device,
205 &eukrea_mbimxsd_lcd_powerdev,
206 };
207
208 static const struct imxuart_platform_data uart_pdata __initconst = {
209 .flags = IMXUART_HAVE_RTSCTS,
210 };
211
212 static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
213 {
214 I2C_BOARD_INFO("tlv320aic23", 0x1a),
215 },
216 };
217
218 static const
219 struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
220 .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
221 };
222
223 /*
224 * system init for baseboard usage. Will be called by cpuimx35 init.
225 *
226 * Add platform devices present on this baseboard and init
227 * them from CPU side as far as required to use them later on
228 */
229 void __init eukrea_mbimxsd35_baseboard_init(void)
230 {
231 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
232 ARRAY_SIZE(eukrea_mbimxsd_pads)))
233 printk(KERN_ERR "error setting mbimxsd pads !\n");
234
235 #if defined(CONFIG_SND_SOC_EUKREA_TLV320)
236 /* SSI unit master I2S codec connected to SSI_AUD4 */
237 mxc_audmux_v2_configure_port(0,
238 MXC_AUDMUX_V2_PTCR_SYN |
239 MXC_AUDMUX_V2_PTCR_TFSDIR |
240 MXC_AUDMUX_V2_PTCR_TFSEL(3) |
241 MXC_AUDMUX_V2_PTCR_TCLKDIR |
242 MXC_AUDMUX_V2_PTCR_TCSEL(3),
243 MXC_AUDMUX_V2_PDCR_RXDSEL(3)
244 );
245 mxc_audmux_v2_configure_port(3,
246 MXC_AUDMUX_V2_PTCR_SYN,
247 MXC_AUDMUX_V2_PDCR_RXDSEL(0)
248 );
249 #endif
250
251 imx35_add_imx_uart1(&uart_pdata);
252 mxc_register_device(&mx3_ipu, &mx3_ipu_data);
253 mxc_register_device(&mx3_fb, &mx3fb_pdata);
254
255 imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
256
257 imx35_add_flexcan1(NULL);
258 imx35_add_esdhc0(NULL);
259
260 gpio_request(GPIO_LED1, "LED1");
261 gpio_direction_output(GPIO_LED1, 1);
262 gpio_free(GPIO_LED1);
263
264 gpio_request(GPIO_SWITCH1, "SWITCH1");
265 gpio_direction_input(GPIO_SWITCH1);
266 gpio_free(GPIO_SWITCH1);
267
268 gpio_request(GPIO_LCDPWR, "LCDPWR");
269 gpio_direction_output(GPIO_LCDPWR, 1);
270 gpio_free(GPIO_SWITCH1);
271
272 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
273 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
274
275 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
276 }
This page took 0.034892 seconds and 5 git commands to generate.