Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/arm/mach-imx/eukrea_mbimxsd25-baseboard.c
10819 views
1
/*
2
* Copyright (C) 2010 Eric Benard - [email protected]
3
*
4
* Based on pcm970-baseboard.c which is :
5
* Copyright (C) 2008 Juergen Beisert ([email protected])
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/input.h>
26
#include <video/platform_lcd.h>
27
28
#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/audmux.h>
35
36
#include "devices-imx25.h"
37
38
static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
39
/* LCD */
40
MX25_PAD_LD0__LD0,
41
MX25_PAD_LD1__LD1,
42
MX25_PAD_LD2__LD2,
43
MX25_PAD_LD3__LD3,
44
MX25_PAD_LD4__LD4,
45
MX25_PAD_LD5__LD5,
46
MX25_PAD_LD6__LD6,
47
MX25_PAD_LD7__LD7,
48
MX25_PAD_LD8__LD8,
49
MX25_PAD_LD9__LD9,
50
MX25_PAD_LD10__LD10,
51
MX25_PAD_LD11__LD11,
52
MX25_PAD_LD12__LD12,
53
MX25_PAD_LD13__LD13,
54
MX25_PAD_LD14__LD14,
55
MX25_PAD_LD15__LD15,
56
MX25_PAD_GPIO_E__LD16,
57
MX25_PAD_GPIO_F__LD17,
58
MX25_PAD_HSYNC__HSYNC,
59
MX25_PAD_VSYNC__VSYNC,
60
MX25_PAD_LSCLK__LSCLK,
61
MX25_PAD_OE_ACD__OE_ACD,
62
MX25_PAD_CONTRAST__CONTRAST,
63
/* LCD_PWR */
64
MX25_PAD_PWM__GPIO_1_26,
65
/* LED */
66
MX25_PAD_POWER_FAIL__GPIO_3_19,
67
/* SWITCH */
68
MX25_PAD_VSTBY_ACK__GPIO_3_18,
69
/* UART2 */
70
MX25_PAD_UART2_RTS__UART2_RTS,
71
MX25_PAD_UART2_CTS__UART2_CTS,
72
MX25_PAD_UART2_TXD__UART2_TXD,
73
MX25_PAD_UART2_RXD__UART2_RXD,
74
/* SD1 */
75
MX25_PAD_SD1_CMD__SD1_CMD,
76
MX25_PAD_SD1_CLK__SD1_CLK,
77
MX25_PAD_SD1_DATA0__SD1_DATA0,
78
MX25_PAD_SD1_DATA1__SD1_DATA1,
79
MX25_PAD_SD1_DATA2__SD1_DATA2,
80
MX25_PAD_SD1_DATA3__SD1_DATA3,
81
/* SD1 CD */
82
MX25_PAD_DE_B__GPIO_2_20,
83
/* I2S */
84
MX25_PAD_KPP_COL3__AUD5_TXFS,
85
MX25_PAD_KPP_COL2__AUD5_TXC,
86
MX25_PAD_KPP_COL1__AUD5_RXD,
87
MX25_PAD_KPP_COL0__AUD5_TXD,
88
/* CAN */
89
MX25_PAD_GPIO_D__CAN2_RX,
90
MX25_PAD_GPIO_C__CAN2_TX,
91
};
92
93
#define GPIO_LED1 83
94
#define GPIO_SWITCH1 82
95
#define GPIO_SD1CD 52
96
#define GPIO_LCDPWR 26
97
98
static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
99
{
100
.mode = {
101
.name = "CMO-QVGA",
102
.refresh = 60,
103
.xres = 320,
104
.yres = 240,
105
.pixclock = KHZ2PICOS(6500),
106
.left_margin = 30,
107
.right_margin = 38,
108
.upper_margin = 20,
109
.lower_margin = 3,
110
.hsync_len = 15,
111
.vsync_len = 4,
112
},
113
.bpp = 16,
114
.pcr = 0xCAD08B80,
115
}, {
116
.mode = {
117
.name = "DVI-VGA",
118
.refresh = 60,
119
.xres = 640,
120
.yres = 480,
121
.pixclock = 32000,
122
.hsync_len = 7,
123
.left_margin = 100,
124
.right_margin = 100,
125
.vsync_len = 7,
126
.upper_margin = 7,
127
.lower_margin = 100,
128
},
129
.pcr = 0xFA208B80,
130
.bpp = 16,
131
}, {
132
.mode = {
133
.name = "DVI-SVGA",
134
.refresh = 60,
135
.xres = 800,
136
.yres = 600,
137
.pixclock = 25000,
138
.hsync_len = 7,
139
.left_margin = 75,
140
.right_margin = 75,
141
.vsync_len = 7,
142
.upper_margin = 7,
143
.lower_margin = 75,
144
},
145
.pcr = 0xFA208B80,
146
.bpp = 16,
147
},
148
};
149
150
static const struct imx_fb_platform_data eukrea_mximxsd_fb_pdata __initconst = {
151
.mode = eukrea_mximxsd_modes,
152
.num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
153
.pwmr = 0x00A903FF,
154
.lscr1 = 0x00120300,
155
.dmacr = 0x00040060,
156
};
157
158
static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
159
unsigned int power)
160
{
161
if (power)
162
gpio_direction_output(GPIO_LCDPWR, 1);
163
else
164
gpio_direction_output(GPIO_LCDPWR, 0);
165
}
166
167
static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
168
.set_power = eukrea_mbimxsd_lcd_power_set,
169
};
170
171
static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
172
.name = "platform-lcd",
173
.dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
174
};
175
176
static struct gpio_led eukrea_mbimxsd_leds[] = {
177
{
178
.name = "led1",
179
.default_trigger = "heartbeat",
180
.active_low = 1,
181
.gpio = GPIO_LED1,
182
},
183
};
184
185
static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
186
.leds = eukrea_mbimxsd_leds,
187
.num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
188
};
189
190
static struct platform_device eukrea_mbimxsd_leds_gpio = {
191
.name = "leds-gpio",
192
.id = -1,
193
.dev = {
194
.platform_data = &eukrea_mbimxsd_led_info,
195
},
196
};
197
198
static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
199
{
200
.gpio = GPIO_SWITCH1,
201
.code = BTN_0,
202
.desc = "BP1",
203
.active_low = 1,
204
.wakeup = 1,
205
},
206
};
207
208
static const struct gpio_keys_platform_data
209
eukrea_mbimxsd_button_data __initconst = {
210
.buttons = eukrea_mbimxsd_gpio_buttons,
211
.nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
212
};
213
214
static struct platform_device *platform_devices[] __initdata = {
215
&eukrea_mbimxsd_leds_gpio,
216
&eukrea_mbimxsd_lcd_powerdev,
217
};
218
219
static const struct imxuart_platform_data uart_pdata __initconst = {
220
.flags = IMXUART_HAVE_RTSCTS,
221
};
222
223
static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
224
{
225
I2C_BOARD_INFO("tlv320aic23", 0x1a),
226
},
227
};
228
229
static const
230
struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
231
.flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE,
232
};
233
234
static struct esdhc_platform_data sd1_pdata = {
235
.cd_gpio = GPIO_SD1CD,
236
.wp_gpio = -EINVAL,
237
};
238
239
/*
240
* system init for baseboard usage. Will be called by cpuimx25 init.
241
*
242
* Add platform devices present on this baseboard and init
243
* them from CPU side as far as required to use them later on
244
*/
245
void __init eukrea_mbimxsd25_baseboard_init(void)
246
{
247
if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
248
ARRAY_SIZE(eukrea_mbimxsd_pads)))
249
printk(KERN_ERR "error setting mbimxsd pads !\n");
250
251
#if defined(CONFIG_SND_SOC_EUKREA_TLV320)
252
/* SSI unit master I2S codec connected to SSI_AUD5*/
253
mxc_audmux_v2_configure_port(0,
254
MXC_AUDMUX_V2_PTCR_SYN |
255
MXC_AUDMUX_V2_PTCR_TFSDIR |
256
MXC_AUDMUX_V2_PTCR_TFSEL(4) |
257
MXC_AUDMUX_V2_PTCR_TCLKDIR |
258
MXC_AUDMUX_V2_PTCR_TCSEL(4),
259
MXC_AUDMUX_V2_PDCR_RXDSEL(4)
260
);
261
mxc_audmux_v2_configure_port(4,
262
MXC_AUDMUX_V2_PTCR_SYN,
263
MXC_AUDMUX_V2_PDCR_RXDSEL(0)
264
);
265
#endif
266
267
imx25_add_imx_uart1(&uart_pdata);
268
imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
269
imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
270
271
imx25_add_flexcan1(NULL);
272
imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
273
274
gpio_request(GPIO_LED1, "LED1");
275
gpio_direction_output(GPIO_LED1, 1);
276
gpio_free(GPIO_LED1);
277
278
gpio_request(GPIO_SWITCH1, "SWITCH1");
279
gpio_direction_input(GPIO_SWITCH1);
280
gpio_free(GPIO_SWITCH1);
281
282
gpio_request(GPIO_LCDPWR, "LCDPWR");
283
gpio_direction_output(GPIO_LCDPWR, 1);
284
gpio_free(GPIO_SWITCH1);
285
286
i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
287
ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
288
289
platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
290
imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
291
}
292
293