1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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>
29
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
34#include "board-mx31lite.h"
35#include "common.h"
36#include "devices-imx31.h"
37#include "hardware.h"
38#include "iomux-mx3.h"
39
40
41
42
43
44
45
46
47static unsigned int litekit_db_board_pins[] __initdata = {
48
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,
55};
56
57
58
59static int gpio_det, gpio_wp;
60
61#define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
62 PAD_CTL_ODE_CMOS)
63
64static int mxc_mmc1_get_ro(struct device *dev)
65{
66 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6));
67}
68
69static int mxc_mmc1_init(struct device *dev,
70 irq_handler_t detect_irq, void *data)
71{
72 int ret;
73
74 gpio_det = IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1);
75 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_GPIO1_6);
76
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);
88
89 ret = gpio_request(gpio_det, "MMC detect");
90 if (ret)
91 return ret;
92
93 ret = gpio_request(gpio_wp, "MMC w/p");
94 if (ret)
95 goto exit_free_det;
96
97 gpio_direction_input(gpio_det);
98 gpio_direction_input(gpio_wp);
99
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;
106
107 return 0;
108
109exit_free_wp:
110 gpio_free(gpio_wp);
111
112exit_free_det:
113 gpio_free(gpio_det);
114
115 return ret;
116}
117
118static void mxc_mmc1_exit(struct device *dev, void *data)
119{
120 gpio_free(gpio_det);
121 gpio_free(gpio_wp);
122 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
123}
124
125static 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,
129};
130
131
132
133static const struct gpio_led litekit_leds[] __initconst = {
134 {
135 .name = "GPIO0",
136 .gpio = IOMUX_TO_GPIO(MX31_PIN_COMPARE),
137 .active_low = 1,
138 .default_state = LEDS_GPIO_DEFSTATE_OFF,
139 },
140 {
141 .name = "GPIO1",
142 .gpio = IOMUX_TO_GPIO(MX31_PIN_CAPTURE),
143 .active_low = 1,
144 .default_state = LEDS_GPIO_DEFSTATE_OFF,
145 }
146};
147
148static const struct gpio_led_platform_data
149 litekit_led_platform_data __initconst = {
150 .leds = litekit_leds,
151 .num_leds = ARRAY_SIZE(litekit_leds),
152};
153
154void __init mx31lite_db_init(void)
155{
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();
163}
164