blob: 13da7325c32b30f43caee0f9b1c678b901d6724b [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Daniel Mackb7d91a62009-11-19 12:02:06 +01002/*
3 * LogicPD i.MX31 SOM-LV development board support
4 *
5 * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
6 *
7 * based on code for other MX31 boards,
8 *
9 * Copyright 2005-2007 Freescale Semiconductor
10 * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
11 * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
Daniel Mackb7d91a62009-11-19 12:02:06 +010012 */
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/init.h>
17#include <linux/gpio.h>
Daniel Mack81057f32009-11-19 12:02:10 +010018#include <linux/leds.h>
19#include <linux/platform_device.h>
Daniel Mackb7d91a62009-11-19 12:02:06 +010020
21#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23#include <asm/mach/map.h>
24
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080025#include "board-mx31lite.h"
Shawn Guoe3372472012-09-13 21:01:00 +080026#include "common.h"
Uwe Kleine-König06606ff2010-06-22 10:09:14 +020027#include "devices-imx31.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080028#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080029#include "iomux-mx3.h"
Daniel Mackb7d91a62009-11-19 12:02:06 +010030
31/*
32 * This file contains board-specific initialization routines for the
33 * LogicPD i.MX31 SOM-LV development board, aka 'LiteKit'.
34 * If you design an own baseboard for the module, use this file as base
35 * for support code.
36 */
37
38static unsigned int litekit_db_board_pins[] __initdata = {
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030039 /* SDHC1 */
40 MX31_PIN_SD1_DATA0__SD1_DATA0,
41 MX31_PIN_SD1_DATA1__SD1_DATA1,
42 MX31_PIN_SD1_DATA2__SD1_DATA2,
43 MX31_PIN_SD1_DATA3__SD1_DATA3,
44 MX31_PIN_SD1_CLK__SD1_CLK,
45 MX31_PIN_SD1_CMD__SD1_CMD,
Daniel Mackb7d91a62009-11-19 12:02:06 +010046};
47
Daniel Mack364cd542009-11-19 12:02:07 +010048/* MMC */
49
50static int gpio_det, gpio_wp;
51
52#define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030053 PAD_CTL_ODE_CMOS)
Daniel Mack364cd542009-11-19 12:02:07 +010054
55static int mxc_mmc1_get_ro(struct device *dev)
56{
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030057 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_GPIO1_6));
Daniel Mack364cd542009-11-19 12:02:07 +010058}
59
60static int mxc_mmc1_init(struct device *dev,
61 irq_handler_t detect_irq, void *data)
62{
63 int ret;
64
65 gpio_det = IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1);
66 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_GPIO1_6);
67
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030068 mxc_iomux_set_pad(MX31_PIN_SD1_DATA0,
69 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
70 mxc_iomux_set_pad(MX31_PIN_SD1_DATA1,
71 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
72 mxc_iomux_set_pad(MX31_PIN_SD1_DATA2,
73 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
74 mxc_iomux_set_pad(MX31_PIN_SD1_DATA3,
75 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
76 mxc_iomux_set_pad(MX31_PIN_SD1_CMD,
77 MMC_PAD_CFG | PAD_CTL_PUE_PUD | PAD_CTL_100K_PU);
Daniel Mack364cd542009-11-19 12:02:07 +010078 mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
Daniel Mack364cd542009-11-19 12:02:07 +010079
80 ret = gpio_request(gpio_det, "MMC detect");
81 if (ret)
82 return ret;
83
84 ret = gpio_request(gpio_wp, "MMC w/p");
85 if (ret)
86 goto exit_free_det;
87
88 gpio_direction_input(gpio_det);
89 gpio_direction_input(gpio_wp);
90
Shawn Guoed175342011-12-02 20:00:33 +080091 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)),
92 detect_irq,
Vladimir Zapolskiy70c91a32010-01-26 14:00:40 +030093 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Daniel Mack364cd542009-11-19 12:02:07 +010094 "MMC detect", data);
95 if (ret)
96 goto exit_free_wp;
97
98 return 0;
99
100exit_free_wp:
101 gpio_free(gpio_wp);
102
103exit_free_det:
104 gpio_free(gpio_det);
105
106 return ret;
107}
108
109static void mxc_mmc1_exit(struct device *dev, void *data)
110{
111 gpio_free(gpio_det);
112 gpio_free(gpio_wp);
Shawn Guoed175342011-12-02 20:00:33 +0800113 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_DCD_DCE1)), data);
Daniel Mack364cd542009-11-19 12:02:07 +0100114}
115
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100116static const struct imxmmc_platform_data mmc_pdata __initconst = {
Daniel Mack364cd542009-11-19 12:02:07 +0100117 .get_ro = mxc_mmc1_get_ro,
118 .init = mxc_mmc1_init,
119 .exit = mxc_mmc1_exit,
120};
121
Daniel Mack81057f32009-11-19 12:02:10 +0100122/* GPIO LEDs */
123
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200124static const struct gpio_led litekit_leds[] __initconst = {
Daniel Mack81057f32009-11-19 12:02:10 +0100125 {
126 .name = "GPIO0",
127 .gpio = IOMUX_TO_GPIO(MX31_PIN_COMPARE),
128 .active_low = 1,
129 .default_state = LEDS_GPIO_DEFSTATE_OFF,
130 },
131 {
132 .name = "GPIO1",
133 .gpio = IOMUX_TO_GPIO(MX31_PIN_CAPTURE),
134 .active_low = 1,
135 .default_state = LEDS_GPIO_DEFSTATE_OFF,
136 }
137};
138
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200139static const struct gpio_led_platform_data
140 litekit_led_platform_data __initconst = {
Daniel Mack81057f32009-11-19 12:02:10 +0100141 .leds = litekit_leds,
142 .num_leds = ARRAY_SIZE(litekit_leds),
143};
144
Daniel Mackb7d91a62009-11-19 12:02:06 +0100145void __init mx31lite_db_init(void)
146{
147 mxc_iomux_setup_multiple_pins(litekit_db_board_pins,
148 ARRAY_SIZE(litekit_db_board_pins),
149 "development board pins");
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100150 imx31_add_mxc_mmc(0, &mmc_pdata);
Uwe Kleine-König47e837b2011-05-28 21:05:01 +0200151 gpio_led_register_device(-1, &litekit_led_platform_data);
Benoît Thébaudeaubec31a82012-07-04 16:35:54 +0200152 imx31_add_imx2_wdt();
153 imx31_add_mxc_rtc();
Daniel Mackb7d91a62009-11-19 12:02:06 +0100154}