Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
eukrea_mbimxsd25-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/gpio.h>
23 #include <linux/leds.h>
24 #include <linux/platform_device.h>
25 #include <linux/input.h>
26 #include <linux/spi/spi.h>
27 #include <video/platform_lcd.h>
28 
29 #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 
36 #include "devices-imx25.h"
37 
38 static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
39  /* LCD */
63  /* LCD_PWR */
65  /* LED */
67  /* SWITCH */
69  /* UART2 */
74  /* SD1 */
81  /* SD1 CD */
83  /* I2S */
88  /* CAN */
91  /* SPI1 */
98 };
99 
100 #define GPIO_LED1 IMX_GPIO_NR(3, 19)
101 #define GPIO_SWITCH1 IMX_GPIO_NR(3, 18)
102 #define GPIO_SD1CD IMX_GPIO_NR(2, 20)
103 #define GPIO_LCDPWR IMX_GPIO_NR(1, 26)
104 #define GPIO_SPI1_SS0 IMX_GPIO_NR(1, 16)
105 #define GPIO_SPI1_SS1 IMX_GPIO_NR(1, 17)
106 #define GPIO_SPI1_IRQ IMX_GPIO_NR(2, 22)
107 
108 static struct imx_fb_videomode eukrea_mximxsd_modes[] = {
109  {
110  .mode = {
111  .name = "CMO-QVGA",
112  .refresh = 60,
113  .xres = 320,
114  .yres = 240,
115  .pixclock = KHZ2PICOS(6500),
116  .left_margin = 30,
117  .right_margin = 38,
118  .upper_margin = 20,
119  .lower_margin = 3,
120  .hsync_len = 15,
121  .vsync_len = 4,
122  },
123  .bpp = 16,
124  .pcr = 0xCAD08B80,
125  }, {
126  .mode = {
127  .name = "DVI-VGA",
128  .refresh = 60,
129  .xres = 640,
130  .yres = 480,
131  .pixclock = 32000,
132  .hsync_len = 7,
133  .left_margin = 100,
134  .right_margin = 100,
135  .vsync_len = 7,
136  .upper_margin = 7,
137  .lower_margin = 100,
138  },
139  .pcr = 0xFA208B80,
140  .bpp = 16,
141  }, {
142  .mode = {
143  .name = "DVI-SVGA",
144  .refresh = 60,
145  .xres = 800,
146  .yres = 600,
147  .pixclock = 25000,
148  .hsync_len = 7,
149  .left_margin = 75,
150  .right_margin = 75,
151  .vsync_len = 7,
152  .upper_margin = 7,
153  .lower_margin = 75,
154  },
155  .pcr = 0xFA208B80,
156  .bpp = 16,
157  },
158 };
159 
160 static const struct imx_fb_platform_data eukrea_mximxsd_fb_pdata __initconst = {
161  .mode = eukrea_mximxsd_modes,
162  .num_modes = ARRAY_SIZE(eukrea_mximxsd_modes),
163  .pwmr = 0x00A903FF,
164  .lscr1 = 0x00120300,
165  .dmacr = 0x00040060,
166 };
167 
168 static void eukrea_mbimxsd_lcd_power_set(struct plat_lcd_data *pd,
169  unsigned int power)
170 {
171  if (power)
173  else
175 }
176 
177 static struct plat_lcd_data eukrea_mbimxsd_lcd_power_data = {
178  .set_power = eukrea_mbimxsd_lcd_power_set,
179 };
180 
181 static struct platform_device eukrea_mbimxsd_lcd_powerdev = {
182  .name = "platform-lcd",
183  .dev.platform_data = &eukrea_mbimxsd_lcd_power_data,
184 };
185 
186 static const struct gpio_led eukrea_mbimxsd_leds[] __initconst = {
187  {
188  .name = "led1",
189  .default_trigger = "heartbeat",
190  .active_low = 1,
191  .gpio = GPIO_LED1,
192  },
193 };
194 
195 static const struct gpio_led_platform_data
196  eukrea_mbimxsd_led_info __initconst = {
197  .leds = eukrea_mbimxsd_leds,
198  .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
199 };
200 
201 static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
202  {
203  .gpio = GPIO_SWITCH1,
204  .code = BTN_0,
205  .desc = "BP1",
206  .active_low = 1,
207  .wakeup = 1,
208  },
209 };
210 
211 static const struct gpio_keys_platform_data
212  eukrea_mbimxsd_button_data __initconst = {
213  .buttons = eukrea_mbimxsd_gpio_buttons,
214  .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
215 };
216 
217 static struct platform_device *platform_devices[] __initdata = {
218  &eukrea_mbimxsd_lcd_powerdev,
219 };
220 
221 static const struct imxuart_platform_data uart_pdata __initconst = {
222  .flags = IMXUART_HAVE_RTSCTS,
223 };
224 
225 static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
226  {
227  I2C_BOARD_INFO("tlv320aic23", 0x1a),
228  },
229 };
230 
231 static const
232 struct imx_ssi_platform_data eukrea_mbimxsd_ssi_pdata __initconst = {
234 };
235 
236 static struct esdhc_platform_data sd1_pdata = {
237  .cd_gpio = GPIO_SD1CD,
238  .cd_type = ESDHC_CD_GPIO,
239  .wp_type = ESDHC_WP_NONE,
240 };
241 
242 static struct spi_board_info eukrea_mbimxsd25_spi_board_info[] __initdata = {
243  {
244  .modalias = "spidev",
245  .max_speed_hz = 20000000,
246  .bus_num = 0,
247  .chip_select = 0,
248  .mode = SPI_MODE_0,
249  },
250  {
251  .modalias = "spidev",
252  .max_speed_hz = 20000000,
253  .bus_num = 0,
254  .chip_select = 1,
255  .mode = SPI_MODE_0,
256  },
257 };
258 
259 static int eukrea_mbimxsd25_spi_cs[] = {GPIO_SPI1_SS0, GPIO_SPI1_SS1};
260 
261 static const struct spi_imx_master eukrea_mbimxsd25_spi0_data __initconst = {
262  .chipselect = eukrea_mbimxsd25_spi_cs,
263  .num_chipselect = ARRAY_SIZE(eukrea_mbimxsd25_spi_cs),
264 };
265 
266 /*
267  * system init for baseboard usage. Will be called by cpuimx25 init.
268  *
269  * Add platform devices present on this baseboard and init
270  * them from CPU side as far as required to use them later on
271  */
273 {
274  if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
275  ARRAY_SIZE(eukrea_mbimxsd_pads)))
276  printk(KERN_ERR "error setting mbimxsd pads !\n");
277 
278  imx25_add_imx_uart1(&uart_pdata);
279  imx25_add_imx_fb(&eukrea_mximxsd_fb_pdata);
280  imx25_add_imx_ssi(0, &eukrea_mbimxsd_ssi_pdata);
281 
283  imx25_add_sdhci_esdhc_imx(0, &sd1_pdata);
284 
285  gpio_request(GPIO_LED1, "LED1");
288 
289  gpio_request(GPIO_SWITCH1, "SWITCH1");
292 
293  gpio_request(GPIO_LCDPWR, "LCDPWR");
295 
296  i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
297  ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
298 
299  gpio_request(GPIO_SPI1_IRQ, "SPI1_IRQ");
302  imx25_add_spi_imx0(&eukrea_mbimxsd25_spi0_data);
303  spi_register_board_info(eukrea_mbimxsd25_spi_board_info,
304  ARRAY_SIZE(eukrea_mbimxsd25_spi_board_info));
305 
306  platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
307  gpio_led_register_device(-1, &eukrea_mbimxsd_led_info);
308  imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
309  imx_add_platform_device("eukrea_tlv320", 0, NULL, 0, NULL, 0);
310 }