blob: c66a006bf2fd0ad8cb44679911e784d5014eae45 [file] [log] [blame]
Daniel Mackb7d91a62009-11-19 12:02:06 +01001/*
2 * LogicPD i.MX31 SOM-LV development board support
3 *
4 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
5 *
6 * based on code for other MX31 boards,
7 *
8 * Copyright 2005-2007 Freescale Semiconductor
9 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
10 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
11 *
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.
16 *
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.
Daniel Mackb7d91a62009-11-19 12:02:06 +010021 */
22
23#include <linux/kernel.h>
24#include <linux/types.h>
25#include <linux/init.h>
26#include <linux/gpio.h>
Daniel Mack81057f32009-11-19 12:02:10 +010027#include <linux/leds.h>
28#include <linux/platform_device.h>
Daniel Mackb7d91a62009-11-19 12:02:06 +010029
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080034#include "board-mx31lite.h"
Shawn Guoe3372472012-09-13 21:01:00 +080035#include "common.h"
Uwe Kleine-König06606ff2010-06-22 10:09:14 +020036#include "devices-imx31.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080037#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080038#include "iomux-mx3.h"
Daniel Mackb7d91a62009-11-19 12:02:06 +010039
40/*
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.
45 */
46
47static unsigned int litekit_db_board_pins[] __initdata = {
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030048 /* 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,
Daniel Mackb7d91a62009-11-19 12:02:06 +010055};
56
Daniel Mack364cd542009-11-19 12:02:07 +010057/* MMC */
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 | \
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030062 PAD_CTL_ODE_CMOS)
Daniel Mack364cd542009-11-19 12:02:07 +010063
64static int mxc_mmc1_get_ro(struct device *dev)
65{
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030066 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6));
Daniel Mack364cd542009-11-19 12:02:07 +010067}
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
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030077 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);
Daniel Mack364cd542009-11-19 12:02:07 +010087 mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
Daniel Mack364cd542009-11-19 12:02:07 +010088
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
Shawn Guoed175342011-12-02 20:00:33 +0800100 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)),
101 detect_irq,
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +0300102 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Daniel Mack364cd542009-11-19 12:02:07 +0100103 "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);
Shawn Guoed175342011-12-02 20:00:33 +0800122 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
Daniel Mack364cd542009-11-19 12:02:07 +0100123}
124
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100125static const struct imxmmc_platform_data mmc_pdata __initconst = {
Daniel Mack364cd542009-11-19 12:02:07 +0100126 .get_ro = mxc_mmc1_get_ro,
127 .init = mxc_mmc1_init,
128 .exit = mxc_mmc1_exit,
129};
130
Daniel Mack81057f32009-11-19 12:02:10 +0100131/* GPIO LEDs */
132
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200133static const struct gpio_led litekit_leds[] __initconst = {
Daniel Mack81057f32009-11-19 12:02:10 +0100134 {
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
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200148static const struct gpio_led_platform_data
149 litekit_led_platform_data __initconst = {
Daniel Mack81057f32009-11-19 12:02:10 +0100150 .leds = litekit_leds,
151 .num_leds = ARRAY_SIZE(litekit_leds),
152};
153
Daniel Mackb7d91a62009-11-19 12:02:06 +0100154void __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");
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100159 imx31_add_mxc_mmc(0, &mmc_pdata);
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200160 gpio_led_register_device(-1, &litekit_led_platform_data);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200161 imx31_add_imx2_wdt();
162 imx31_add_mxc_rtc();
Daniel Mackb7d91a62009-11-19 12:02:06 +0100163}