Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / mach-imx / mx31lite-db.c
blobc66a006bf2fd0ad8cb44679911e784d5014eae45
1 /*
2 * LogicPD i.MX31 SOM-LV development board support
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6 * based on code for other MX31 boards,
8 * Copyright 2005-2007 Freescale Semiconductor
9 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
10 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
23 #include <linux/kernel.h>
24 #include <linux/types.h>
25 #include <linux/init.h>
26 #include <linux/gpio.h>
27 #include <linux/leds.h>
28 #include <linux/platform_device.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include "board-mx31lite.h"
35 #include "common.h"
36 #include "devices-imx31.h"
37 #include "hardware.h"
38 #include "iomux-mx3.h"
41 * This file contains board-specific initialization routines for the
42 * LogicPD i.MX31 SOM-LV development board, aka 'LiteKit'.
43 * If you design an own baseboard for the module, use this file as base
44 * for support code.
47 static unsigned int litekit_db_board_pins[] __initdata = {
48 /* SDHC1 */
49 MX31_PIN_SD1_DATA0__SD1_DATA0,
50 MX31_PIN_SD1_DATA1__SD1_DATA1,
51 MX31_PIN_SD1_DATA2__SD1_DATA2,
52 MX31_PIN_SD1_DATA3__SD1_DATA3,
53 MX31_PIN_SD1_CLK__SD1_CLK,
54 MX31_PIN_SD1_CMD__SD1_CMD,
57 /* MMC */
59 static int gpio_det, gpio_wp;
61 #define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
62 PAD_CTL_ODE_CMOS)
64 static int mxc_mmc1_get_ro(struct device *dev)
66 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6));
69 static int mxc_mmc1_init(struct device *dev,
70 irq_handler_t detect_irq, void *data)
72 int ret;
74 gpio_det = IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1);
75 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_GPIO1_6);
77 mxc_iomux_set_pad(MX31_PIN_SD1_DATA0,
78 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
79 mxc_iomux_set_pad(MX31_PIN_SD1_DATA1,
80 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
81 mxc_iomux_set_pad(MX31_PIN_SD1_DATA2,
82 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
83 mxc_iomux_set_pad(MX31_PIN_SD1_DATA3,
84 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
85 mxc_iomux_set_pad(MX31_PIN_SD1_CMD,
86 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
87 mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
89 ret = gpio_request(gpio_det, "MMC detect");
90 if (ret)
91 return ret;
93 ret = gpio_request(gpio_wp, "MMC w/p");
94 if (ret)
95 goto exit_free_det;
97 gpio_direction_input(gpio_det);
98 gpio_direction_input(gpio_wp);
100 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)),
101 detect_irq,
102 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
103 "MMC detect", data);
104 if (ret)
105 goto exit_free_wp;
107 return 0;
109 exit_free_wp:
110 gpio_free(gpio_wp);
112 exit_free_det:
113 gpio_free(gpio_det);
115 return ret;
118 static void mxc_mmc1_exit(struct device *dev, void *data)
120 gpio_free(gpio_det);
121 gpio_free(gpio_wp);
122 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
125 static const struct imxmmc_platform_data mmc_pdata __initconst = {
126 .get_ro = mxc_mmc1_get_ro,
127 .init = mxc_mmc1_init,
128 .exit = mxc_mmc1_exit,
131 /* GPIO LEDs */
133 static const struct gpio_led litekit_leds[] __initconst = {
135 .name = "GPIO0",
136 .gpio = IOMUX_TO_GPIO(MX31_PIN_COMPARE),
137 .active_low = 1,
138 .default_state = LEDS_GPIO_DEFSTATE_OFF,
141 .name = "GPIO1",
142 .gpio = IOMUX_TO_GPIO(MX31_PIN_CAPTURE),
143 .active_low = 1,
144 .default_state = LEDS_GPIO_DEFSTATE_OFF,
148 static const struct gpio_led_platform_data
149 litekit_led_platform_data __initconst = {
150 .leds = litekit_leds,
151 .num_leds = ARRAY_SIZE(litekit_leds),
154 void __init mx31lite_db_init(void)
156 mxc_iomux_setup_multiple_pins(litekit_db_board_pins,
157 ARRAY_SIZE(litekit_db_board_pins),
158 "development board pins");
159 imx31_add_mxc_mmc(0, &mmc_pdata);
160 gpio_led_register_device(-1, &litekit_led_platform_data);
161 imx31_add_imx2_wdt();
162 imx31_add_mxc_rtc();