Commit | Line | Data |
---|---|---|
21744f19 EB |
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 | ||
21744f19 EB |
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> | |
21744f19 | 46 | |
2dcf78c0 | 47 | #include "devices-imx35.h" |
21744f19 EB |
48 | #include "devices.h" |
49 | ||
50 | static const struct fb_videomode fb_modedb[] = { | |
51 | { | |
c0550c4b | 52 | .name = "CMO-QVGA", |
21744f19 EB |
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 | }, | |
c0550c4b EB |
67 | { |
68 | .name = "DVI-VGA", | |
69 | .refresh = 60, | |
70 | .xres = 640, | |
71 | .yres = 480, | |
72 | .pixclock = 32000, | |
73 | .left_margin = 100, | |
74 | .right_margin = 100, | |
75 | .upper_margin = 7, | |
76 | .lower_margin = 100, | |
77 | .hsync_len = 7, | |
78 | .vsync_len = 7, | |
79 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT | | |
80 | FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT, | |
81 | .vmode = FB_VMODE_NONINTERLACED, | |
82 | .flag = 0, | |
83 | }, | |
84 | { | |
85 | .name = "DVI-SVGA", | |
86 | .refresh = 60, | |
87 | .xres = 800, | |
88 | .yres = 600, | |
89 | .pixclock = 25000, | |
90 | .left_margin = 75, | |
91 | .right_margin = 75, | |
92 | .upper_margin = 7, | |
93 | .lower_margin = 75, | |
94 | .hsync_len = 7, | |
95 | .vsync_len = 7, | |
96 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT | | |
97 | FB_SYNC_OE_ACT_HIGH | FB_SYNC_CLK_INVERT, | |
98 | .vmode = FB_VMODE_NONINTERLACED, | |
99 | .flag = 0, | |
100 | }, | |
21744f19 EB |
101 | }; |
102 | ||
103 | static struct ipu_platform_data mx3_ipu_data = { | |
104 | .irq_base = MXC_IPU_IRQ_START, | |
105 | }; | |
106 | ||
107 | static struct mx3fb_platform_data mx3fb_pdata = { | |
108 | .dma_dev = &mx3_ipu.dev, | |
c0550c4b | 109 | .name = "CMO-QVGA", |
21744f19 EB |
110 | .mode = fb_modedb, |
111 | .num_modes = ARRAY_SIZE(fb_modedb), | |
112 | }; | |
113 | ||
8f5260c8 | 114 | static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = { |
21744f19 EB |
115 | /* LCD */ |
116 | MX35_PAD_LD0__IPU_DISPB_DAT_0, | |
117 | MX35_PAD_LD1__IPU_DISPB_DAT_1, | |
118 | MX35_PAD_LD2__IPU_DISPB_DAT_2, | |
119 | MX35_PAD_LD3__IPU_DISPB_DAT_3, | |
120 | MX35_PAD_LD4__IPU_DISPB_DAT_4, | |
121 | MX35_PAD_LD5__IPU_DISPB_DAT_5, | |
122 | MX35_PAD_LD6__IPU_DISPB_DAT_6, | |
123 | MX35_PAD_LD7__IPU_DISPB_DAT_7, | |
124 | MX35_PAD_LD8__IPU_DISPB_DAT_8, | |
125 | MX35_PAD_LD9__IPU_DISPB_DAT_9, | |
126 | MX35_PAD_LD10__IPU_DISPB_DAT_10, | |
127 | MX35_PAD_LD11__IPU_DISPB_DAT_11, | |
128 | MX35_PAD_LD12__IPU_DISPB_DAT_12, | |
129 | MX35_PAD_LD13__IPU_DISPB_DAT_13, | |
130 | MX35_PAD_LD14__IPU_DISPB_DAT_14, | |
131 | MX35_PAD_LD15__IPU_DISPB_DAT_15, | |
132 | MX35_PAD_LD16__IPU_DISPB_DAT_16, | |
133 | MX35_PAD_LD17__IPU_DISPB_DAT_17, | |
134 | MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC, | |
135 | MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK, | |
136 | MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY, | |
137 | MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC, | |
138 | /* Backlight */ | |
139 | MX35_PAD_CONTRAST__IPU_DISPB_CONTR, | |
140 | /* LCD_PWR */ | |
141 | MX35_PAD_D3_CLS__GPIO1_4, | |
142 | /* LED */ | |
143 | MX35_PAD_LD23__GPIO3_29, | |
144 | /* SWITCH */ | |
145 | MX35_PAD_LD19__GPIO3_25, | |
146 | /* UART2 */ | |
147 | MX35_PAD_CTS2__UART2_CTS, | |
148 | MX35_PAD_RTS2__UART2_RTS, | |
149 | MX35_PAD_TXD2__UART2_TXD_MUX, | |
150 | MX35_PAD_RXD2__UART2_RXD_MUX, | |
151 | /* I2S */ | |
152 | MX35_PAD_STXFS4__AUDMUX_AUD4_TXFS, | |
153 | MX35_PAD_STXD4__AUDMUX_AUD4_TXD, | |
154 | MX35_PAD_SRXD4__AUDMUX_AUD4_RXD, | |
155 | MX35_PAD_SCK4__AUDMUX_AUD4_TXC, | |
438a4d66 EB |
156 | /* CAN2 */ |
157 | MX35_PAD_TX5_RX0__CAN2_TXCAN, | |
158 | MX35_PAD_TX4_RX1__CAN2_RXCAN, | |
159 | /* SDCARD */ | |
160 | MX35_PAD_SD1_CMD__ESDHC1_CMD, | |
161 | MX35_PAD_SD1_CLK__ESDHC1_CLK, | |
162 | MX35_PAD_SD1_DATA0__ESDHC1_DAT0, | |
163 | MX35_PAD_SD1_DATA1__ESDHC1_DAT1, | |
164 | MX35_PAD_SD1_DATA2__ESDHC1_DAT2, | |
165 | MX35_PAD_SD1_DATA3__ESDHC1_DAT3, | |
21744f19 EB |
166 | }; |
167 | ||
168 | #define GPIO_LED1 (2 * 32 + 29) | |
169 | #define GPIO_SWITCH1 (2 * 32 + 25) | |
170 | #define GPIO_LCDPWR (4) | |
171 | ||
172 | static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd, | |
173 | unsigned int power) | |
174 | { | |
175 | if (power) | |
176 | gpio_direction_output(GPIO_LCDPWR, 1); | |
177 | else | |
178 | gpio_direction_output(GPIO_LCDPWR, 0); | |
179 | } | |
180 | ||
181 | static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = { | |
182 | .set_power = eukrea_mbimxsd_lcd_power_set, | |
183 | }; | |
184 | ||
185 | static struct platform_device eukrea_mbimxsd_lcd_powerdev = { | |
186 | .name = "platform-lcd", | |
187 | .dev.platform_data = &eukrea_mbimxsd_lcd_power_data, | |
188 | }; | |
189 | ||
190 | static struct gpio_led eukrea_mbimxsd_leds[] = { | |
191 | { | |
192 | .name = "led1", | |
193 | .default_trigger = "heartbeat", | |
194 | .active_low = 1, | |
195 | .gpio = GPIO_LED1, | |
196 | }, | |
197 | }; | |
198 | ||
199 | static struct gpio_led_platform_data eukrea_mbimxsd_led_info = { | |
200 | .leds = eukrea_mbimxsd_leds, | |
201 | .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds), | |
202 | }; | |
203 | ||
204 | static struct platform_device eukrea_mbimxsd_leds_gpio = { | |
205 | .name = "leds-gpio", | |
206 | .id = -1, | |
207 | .dev = { | |
208 | .platform_data = &eukrea_mbimxsd_led_info, | |
209 | }, | |
210 | }; | |
211 | ||
212 | static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = { | |
213 | { | |
214 | .gpio = GPIO_SWITCH1, | |
215 | .code = BTN_0, | |
216 | .desc = "BP1", | |
217 | .active_low = 1, | |
218 | .wakeup = 1, | |
219 | }, | |
220 | }; | |
221 | ||
222 | static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = { | |
223 | .buttons = eukrea_mbimxsd_gpio_buttons, | |
224 | .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons), | |
225 | }; | |
226 | ||
227 | static struct platform_device eukrea_mbimxsd_button_device = { | |
228 | .name = "gpio-keys", | |
229 | .id = -1, | |
230 | .num_resources = 0, | |
231 | .dev = { | |
232 | .platform_data = &eukrea_mbimxsd_button_data, | |
233 | } | |
234 | }; | |
235 | ||
236 | static struct platform_device *platform_devices[] __initdata = { | |
237 | &eukrea_mbimxsd_leds_gpio, | |
238 | &eukrea_mbimxsd_button_device, | |
239 | &eukrea_mbimxsd_lcd_powerdev, | |
240 | }; | |
241 | ||
2dcf78c0 | 242 | static const struct imxuart_platform_data uart_pdata __initconst = { |
21744f19 EB |
243 | .flags = IMXUART_HAVE_RTSCTS, |
244 | }; | |
245 | ||
246 | static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = { | |
247 | { | |
248 | I2C_BOARD_INFO("tlv320aic23", 0x1a), | |
249 | }, | |
250 | }; | |
251 | ||
4697bb92 UKK |
252 | static const |
253 | struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = { | |
21744f19 EB |
254 | .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE, |
255 | }; | |
256 | ||
257 | /* | |
258 | * system init for baseboard usage. Will be called by cpuimx35 init. | |
259 | * | |
260 | * Add platform devices present on this baseboard and init | |
261 | * them from CPU side as far as required to use them later on | |
262 | */ | |
ec53fe3d | 263 | void __init eukrea_mbimxsd35_baseboard_init(void) |
21744f19 EB |
264 | { |
265 | if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads, | |
266 | ARRAY_SIZE(eukrea_mbimxsd_pads))) | |
267 | printk(KERN_ERR "error setting mbimxsd pads !\n"); | |
268 | ||
269 | #if defined(CONFIG_SND_SOC_EUKREA_TLV320) | |
270 | /* SSI unit master I2S codec connected to SSI_AUD4 */ | |
271 | mxc_audmux_v2_configure_port(0, | |
272 | MXC_AUDMUX_V2_PTCR_SYN | | |
273 | MXC_AUDMUX_V2_PTCR_TFSDIR | | |
274 | MXC_AUDMUX_V2_PTCR_TFSEL(3) | | |
275 | MXC_AUDMUX_V2_PTCR_TCLKDIR | | |
276 | MXC_AUDMUX_V2_PTCR_TCSEL(3), | |
277 | MXC_AUDMUX_V2_PDCR_RXDSEL(3) | |
278 | ); | |
279 | mxc_audmux_v2_configure_port(3, | |
280 | MXC_AUDMUX_V2_PTCR_SYN, | |
281 | MXC_AUDMUX_V2_PDCR_RXDSEL(0) | |
282 | ); | |
283 | #endif | |
284 | ||
2dcf78c0 | 285 | imx35_add_imx_uart1(&uart_pdata); |
21744f19 EB |
286 | mxc_register_device(&mx3_ipu, &mx3_ipu_data); |
287 | mxc_register_device(&mx3_fb, &mx3fb_pdata); | |
288 | ||
4697bb92 | 289 | imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata); |
21744f19 | 290 | |
438a4d66 | 291 | imx35_add_flexcan1(NULL); |
124bf94a | 292 | imx35_add_sdhci_esdhc_imx(0, NULL); |
438a4d66 | 293 | |
21744f19 EB |
294 | gpio_request(GPIO_LED1, "LED1"); |
295 | gpio_direction_output(GPIO_LED1, 1); | |
296 | gpio_free(GPIO_LED1); | |
297 | ||
298 | gpio_request(GPIO_SWITCH1, "SWITCH1"); | |
299 | gpio_direction_input(GPIO_SWITCH1); | |
300 | gpio_free(GPIO_SWITCH1); | |
301 | ||
302 | gpio_request(GPIO_LCDPWR, "LCDPWR"); | |
303 | gpio_direction_output(GPIO_LCDPWR, 1); | |
f1de1613 | 304 | gpio_free(GPIO_LCDPWR); |
21744f19 EB |
305 | |
306 | i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices, | |
307 | ARRAY_SIZE(eukrea_mbimxsd_i2c_devices)); | |
308 | ||
309 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); | |
310 | } |