blob: 00a5ee30d5dda68e26d1aaa35c8ad02f1f9a3adf [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Daniel Mack1bc34f72009-05-20 19:54:34 +02002/*
3 * LILLY-1131 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 Mack1bc34f72009-05-20 19:54:34 +020012 */
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/init.h>
Daniel Mackd0b1eab2009-05-20 19:54:36 +020017#include <linux/gpio.h>
Daniel Mackb99238722009-05-20 19:54:37 +020018#include <linux/platform_device.h>
Daniel Mack1bc34f72009-05-20 19:54:34 +020019
20#include <asm/mach-types.h>
21#include <asm/mach/arch.h>
22#include <asm/mach/map.h>
23
Shawn Guo3ed0bcb2012-09-13 09:37:49 +080024#include "board-mx31lilly.h"
Shawn Guoe3372472012-09-13 21:01:00 +080025#include "common.h"
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +020026#include "devices-imx31.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080027#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080028#include "iomux-mx3.h"
Daniel Mack1bc34f72009-05-20 19:54:34 +020029
30/*
31 * This file contains board-specific initialization routines for the
32 * LILLY-1131 development board. If you design an own baseboard for the
33 * module, use this file as base for support code.
34 */
35
36static unsigned int lilly_db_board_pins[] __initdata = {
Daniel Mackd0b1eab2009-05-20 19:54:36 +020037 MX31_PIN_SD1_DATA3__SD1_DATA3,
38 MX31_PIN_SD1_DATA2__SD1_DATA2,
39 MX31_PIN_SD1_DATA1__SD1_DATA1,
40 MX31_PIN_SD1_DATA0__SD1_DATA0,
41 MX31_PIN_SD1_CLK__SD1_CLK,
42 MX31_PIN_SD1_CMD__SD1_CMD,
Daniel Mackb99238722009-05-20 19:54:37 +020043 MX31_PIN_LD0__LD0,
44 MX31_PIN_LD1__LD1,
45 MX31_PIN_LD2__LD2,
46 MX31_PIN_LD3__LD3,
47 MX31_PIN_LD4__LD4,
48 MX31_PIN_LD5__LD5,
49 MX31_PIN_LD6__LD6,
50 MX31_PIN_LD7__LD7,
51 MX31_PIN_LD8__LD8,
52 MX31_PIN_LD9__LD9,
53 MX31_PIN_LD10__LD10,
54 MX31_PIN_LD11__LD11,
55 MX31_PIN_LD12__LD12,
56 MX31_PIN_LD13__LD13,
57 MX31_PIN_LD14__LD14,
58 MX31_PIN_LD15__LD15,
59 MX31_PIN_LD16__LD16,
60 MX31_PIN_LD17__LD17,
61 MX31_PIN_VSYNC3__VSYNC3,
62 MX31_PIN_HSYNC__HSYNC,
63 MX31_PIN_FPSHIFT__FPSHIFT,
64 MX31_PIN_DRDY0__DRDY0,
65 MX31_PIN_CONTRAST__CONTRAST,
Daniel Mack1bc34f72009-05-20 19:54:34 +020066};
67
Daniel Mackd0b1eab2009-05-20 19:54:36 +020068/* MMC support */
69
70static int mxc_mmc1_get_ro(struct device *dev)
71{
72 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_LCS0));
73}
74
75static int gpio_det, gpio_wp;
76
Daniel Mack24fb8422009-10-26 11:55:58 +010077#define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
78 PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
79
Daniel Mackd0b1eab2009-05-20 19:54:36 +020080static int mxc_mmc1_init(struct device *dev,
81 irq_handler_t detect_irq, void *data)
82{
83 int ret;
84
85 gpio_det = IOMUX_TO_GPIO(MX31_PIN_GPIO1_1);
86 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_LCS0);
87
Daniel Mack24fb8422009-10-26 11:55:58 +010088 mxc_iomux_set_pad(MX31_PIN_SD1_DATA0, MMC_PAD_CFG);
89 mxc_iomux_set_pad(MX31_PIN_SD1_DATA1, MMC_PAD_CFG);
90 mxc_iomux_set_pad(MX31_PIN_SD1_DATA2, MMC_PAD_CFG);
91 mxc_iomux_set_pad(MX31_PIN_SD1_DATA3, MMC_PAD_CFG);
92 mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG);
93 mxc_iomux_set_pad(MX31_PIN_SD1_CMD, MMC_PAD_CFG);
94
Daniel Mackd0b1eab2009-05-20 19:54:36 +020095 ret = gpio_request(gpio_det, "MMC detect");
96 if (ret)
97 return ret;
98
99 ret = gpio_request(gpio_wp, "MMC w/p");
100 if (ret)
101 goto exit_free_det;
102
103 gpio_direction_input(gpio_det);
104 gpio_direction_input(gpio_wp);
105
Shawn Guoed175342011-12-02 20:00:33 +0800106 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)),
Michael Opdenacker4c1dd3e2013-09-04 07:04:39 +0200107 detect_irq, IRQF_TRIGGER_FALLING,
Daniel Mackd0b1eab2009-05-20 19:54:36 +0200108 "MMC detect", data);
109 if (ret)
110 goto exit_free_wp;
111
112 return 0;
113
114exit_free_wp:
115 gpio_free(gpio_wp);
116
117exit_free_det:
118 gpio_free(gpio_det);
119
120 return ret;
121}
122
123static void mxc_mmc1_exit(struct device *dev, void *data)
124{
125 gpio_free(gpio_det);
126 gpio_free(gpio_wp);
Shawn Guoed175342011-12-02 20:00:33 +0800127 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1)), data);
Daniel Mackd0b1eab2009-05-20 19:54:36 +0200128}
129
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100130static const struct imxmmc_platform_data mmc_pdata __initconst = {
Daniel Mackd0b1eab2009-05-20 19:54:36 +0200131 .get_ro = mxc_mmc1_get_ro,
132 .init = mxc_mmc1_init,
133 .exit = mxc_mmc1_exit,
134};
135
Daniel Mackb99238722009-05-20 19:54:37 +0200136/* Framebuffer support */
Daniel Mackb99238722009-05-20 19:54:37 +0200137static const struct fb_videomode fb_modedb = {
138 /* 640x480 TFT panel (IPS-056T) */
Uwe Kleine-König27ad4bf2011-03-17 09:40:29 +0100139 .name = "CRT-VGA",
Daniel Mackb99238722009-05-20 19:54:37 +0200140 .refresh = 64,
141 .xres = 640,
142 .yres = 480,
143 .pixclock = 30000,
144 .left_margin = 200,
145 .right_margin = 2,
146 .upper_margin = 2,
147 .lower_margin = 2,
148 .hsync_len = 3,
149 .vsync_len = 1,
150 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH,
151 .vmode = FB_VMODE_NONINTERLACED,
152 .flag = 0,
153};
154
155static struct mx3fb_platform_data fb_pdata __initdata = {
Daniel Mackb99238722009-05-20 19:54:37 +0200156 .name = "CRT-VGA",
157 .mode = &fb_modedb,
158 .num_modes = 1,
159};
160
161#define LCD_VCC_EN_GPIO (7)
162
163static void __init mx31lilly_init_fb(void)
164{
165 if (gpio_request(LCD_VCC_EN_GPIO, "LCD enable") != 0) {
166 printk(KERN_WARNING "unable to request LCD_VCC_EN pin.\n");
167 return;
168 }
169
Shawn Guo88289c82012-06-13 14:07:31 +0800170 imx31_add_ipu_core();
Uwe Kleine-Königafa77ef2011-03-03 21:32:02 +0100171 imx31_add_mx3_sdc_fb(&fb_pdata);
Daniel Mackb99238722009-05-20 19:54:37 +0200172 gpio_direction_output(LCD_VCC_EN_GPIO, 1);
173}
174
Daniel Mack1bc34f72009-05-20 19:54:34 +0200175void __init mx31lilly_db_init(void)
176{
177 mxc_iomux_setup_multiple_pins(lilly_db_board_pins,
178 ARRAY_SIZE(lilly_db_board_pins),
179 "development board pins");
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100180 imx31_add_mxc_mmc(0, &mmc_pdata);
Daniel Mackb99238722009-05-20 19:54:37 +0200181 mx31lilly_init_fb();
Daniel Mack1bc34f72009-05-20 19:54:34 +0200182}