Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
eukrea_mbimxsd35-baseboard.c
Go to the documentation of this file.
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/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/input.h>
30 #include <linux/spi/spi.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/iomux-mx35.h>
42 
43 #include "devices-imx35.h"
44 
45 static const struct fb_videomode fb_modedb[] = {
46  {
47  .name = "CMO-QVGA",
48  .refresh = 60,
49  .xres = 320,
50  .yres = 240,
51  .pixclock = KHZ2PICOS(6500),
52  .left_margin = 68,
53  .right_margin = 20,
54  .upper_margin = 15,
55  .lower_margin = 4,
56  .hsync_len = 30,
57  .vsync_len = 3,
58  .sync = 0,
59  .vmode = FB_VMODE_NONINTERLACED,
60  .flag = 0,
61  },
62  {
63  .name = "DVI-VGA",
64  .refresh = 60,
65  .xres = 640,
66  .yres = 480,
67  .pixclock = 32000,
68  .left_margin = 100,
69  .right_margin = 100,
70  .upper_margin = 7,
71  .lower_margin = 100,
72  .hsync_len = 7,
73  .vsync_len = 7,
76  .vmode = FB_VMODE_NONINTERLACED,
77  .flag = 0,
78  },
79  {
80  .name = "DVI-SVGA",
81  .refresh = 60,
82  .xres = 800,
83  .yres = 600,
84  .pixclock = 25000,
85  .left_margin = 75,
86  .right_margin = 75,
87  .upper_margin = 7,
88  .lower_margin = 75,
89  .hsync_len = 7,
90  .vsync_len = 7,
93  .vmode = FB_VMODE_NONINTERLACED,
94  .flag = 0,
95  },
96 };
97 
98 static struct mx3fb_platform_data mx3fb_pdata __initdata = {
99  .name = "CMO-QVGA",
100  .mode = fb_modedb,
101  .num_modes = ARRAY_SIZE(fb_modedb),
102 };
103 
104 static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
105  /* LCD */
128  /* Backlight */
130  /* LCD_PWR */
132  /* LED */
134  /* SWITCH */
136  /* UART2 */
141  /* I2S */
146  /* CAN2 */
149  /* SDCARD */
156  /* SD1 CD */
158  /* SPI */
165 };
166 
167 #define GPIO_LED1 IMX_GPIO_NR(3, 29)
168 #define GPIO_SWITCH1 IMX_GPIO_NR(3, 25)
169 #define GPIO_LCDPWR IMX_GPIO_NR(1, 4)
170 #define GPIO_SD1CD IMX_GPIO_NR(3, 24)
171 #define GPIO_SPI1_SS0 IMX_GPIO_NR(1, 18)
172 #define GPIO_SPI1_SS1 IMX_GPIO_NR(1, 19)
173 #define GPIO_SPI1_IRQ IMX_GPIO_NR(3, 5)
174 
175 static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
176  unsigned int power)
177 {
178  if (power)
180  else
182 }
183 
184 static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
185  .set_power = eukrea_mbimxsd_lcd_power_set,
186 };
187 
188 static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
189  .name = "platform-lcd",
190  .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
191 };
192 
193 static struct gpio_led eukrea_mbimxsd_leds[] = {
194  {
195  .name = "led1",
196  .default_trigger = "heartbeat",
197  .active_low = 1,
198  .gpio = GPIO_LED1,
199  },
200 };
201 
202 static const struct gpio_led_platform_data
203  eukrea_mbimxsd_led_info __initconst = {
204  .leds = eukrea_mbimxsd_leds,
205  .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
206 };
207 
208 static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
209  {
210  .gpio = GPIO_SWITCH1,
211  .code = BTN_0,
212  .desc = "BP1",
213  .active_low = 1,
214  .wakeup = 1,
215  },
216 };
217 
218 static const struct gpio_keys_platform_data
219  eukrea_mbimxsd_button_data __initconst = {
220  .buttons = eukrea_mbimxsd_gpio_buttons,
221  .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
222 };
223 
224 static struct platform_device *platform_devices[] __initdata = {
225  &eukrea_mbimxsd_lcd_powerdev,
226 };
227 
228 static const struct imxuart_platform_data uart_pdata __initconst = {
229  .flags = IMXUART_HAVE_RTSCTS,
230 };
231 
232 static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
233  {
234  I2C_BOARD_INFO("tlv320aic23", 0x1a),
235  },
236 };
237 
238 static const
239 struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
241 };
242 
243 static struct esdhc_platform_data sd1_pdata = {
244  .cd_gpio = GPIO_SD1CD,
245  .cd_type = ESDHC_CD_GPIO,
246  .wp_type = ESDHC_WP_NONE,
247 };
248 
249 static struct spi_board_info eukrea_mbimxsd35_spi_board_info[] __initdata = {
250  {
251  .modalias = "spidev",
252  .max_speed_hz = 20000000,
253  .bus_num = 0,
254  .chip_select = 0,
255  .mode = SPI_MODE_0,
256  },
257  {
258  .modalias = "spidev",
259  .max_speed_hz = 20000000,
260  .bus_num = 0,
261  .chip_select = 1,
262  .mode = SPI_MODE_0,
263  },
264 };
265 
266 static int eukrea_mbimxsd35_spi_cs[] = {GPIO_SPI1_SS0, GPIO_SPI1_SS1};
267 
268 static const struct spi_imx_master eukrea_mbimxsd35_spi0_data __initconst = {
269  .chipselect = eukrea_mbimxsd35_spi_cs,
270  .num_chipselect = ARRAY_SIZE(eukrea_mbimxsd35_spi_cs),
271 };
272 
273 /*
274  * system init for baseboard usage. Will be called by cpuimx35 init.
275  *
276  * Add platform devices present on this baseboard and init
277  * them from CPU side as far as required to use them later on
278  */
280 {
281  if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
282  ARRAY_SIZE(eukrea_mbimxsd_pads)))
283  printk(KERN_ERR "error setting mbimxsd pads !\n");
284 
285  imx35_add_imx_uart1(&uart_pdata);
287  imx35_add_mx3_sdc_fb(&mx3fb_pdata);
288 
289  imx35_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
290 
292  imx35_add_sdhci_esdhc_imx(0, &sd1_pdata);
293 
294  gpio_request(GPIO_LED1, "LED1");
297 
298  gpio_request(GPIO_SWITCH1, "SWITCH1");
301 
302  gpio_request(GPIO_LCDPWR, "LCDPWR");
304 
305  i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
306  ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
307 
308  gpio_request(GPIO_SPI1_IRQ, "SPI1_IRQ");
311  imx35_add_spi_imx0(&eukrea_mbimxsd35_spi0_data);
312  spi_register_board_info(eukrea_mbimxsd35_spi_board_info,
313  ARRAY_SIZE(eukrea_mbimxsd35_spi_board_info));
314 
315  platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
316  gpio_led_register_device(-1, &eukrea_mbimxsd_led_info);
317  imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
318  imx_add_platform_device("eukrea_tlv320", 0, NULL, 0, NULL, 0);
319 }