blob: 0c80b62ed7861d3a84db8abc59f26b493a4a497e [file] [log] [blame]
Eric Bénard70b17262010-10-12 16:12:36 +02001/*
2 * Copyright (C) 2010 Eric Benard - eric@eukrea.com
3 *
4 * Based on pcm970-baseboard.c which is :
5 * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 */
21
22#include <linux/types.h>
23#include <linux/init.h>
24
25#include <linux/gpio.h>
26#include <linux/interrupt.h>
27#include <linux/irq.h>
28#include <linux/leds.h>
29#include <linux/platform_device.h>
Eric Bénard70b17262010-10-12 16:12:36 +020030#include <linux/input.h>
31#include <linux/i2c.h>
32
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/time.h>
36#include <asm/mach/map.h>
37
38#include <mach/hardware.h>
39#include <mach/common.h>
40#include <mach/imx-uart.h>
41#include <mach/iomux-mx51.h>
42#include <mach/audmux.h>
43
44#include "devices-imx51.h"
45#include "devices.h"
46
Lothar Waßmann8f5260c2010-10-26 14:28:31 +020047static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
Eric Bénard70b17262010-10-12 16:12:36 +020048 /* LED */
Sascha Haueree1ae4d2010-12-15 09:56:35 +010049 MX51_PAD_NANDF_D10__GPIO3_30,
Eric Bénard70b17262010-10-12 16:12:36 +020050 /* SWITCH */
Sascha Haueree1ae4d2010-12-15 09:56:35 +010051 _MX51_PAD_NANDF_D9__GPIO3_31 | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
52 PAD_CTL_PKE | PAD_CTL_SRE_FAST |
53 PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),
Eric Bénard70b17262010-10-12 16:12:36 +020054 /* UART2 */
55 MX51_PAD_UART2_RXD__UART2_RXD,
56 MX51_PAD_UART2_TXD__UART2_TXD,
57 /* UART 3 */
58 MX51_PAD_UART3_RXD__UART3_RXD,
59 MX51_PAD_UART3_TXD__UART3_TXD,
60 MX51_PAD_KEY_COL4__UART3_RTS,
61 MX51_PAD_KEY_COL5__UART3_CTS,
62 /* SD */
63 MX51_PAD_SD1_CMD__SD1_CMD,
64 MX51_PAD_SD1_CLK__SD1_CLK,
65 MX51_PAD_SD1_DATA0__SD1_DATA0,
66 MX51_PAD_SD1_DATA1__SD1_DATA1,
67 MX51_PAD_SD1_DATA2__SD1_DATA2,
68 MX51_PAD_SD1_DATA3__SD1_DATA3,
Eric Bénardef560bf2011-02-25 14:38:31 +010069 /* SD1 CD */
70 _MX51_PAD_GPIO1_0__SD1_CD | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
71 PAD_CTL_PKE | PAD_CTL_SRE_FAST |
72 PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),
Eric Bénard70b17262010-10-12 16:12:36 +020073};
74
Arnaud Patard (Rtp)96886c42010-11-26 15:20:52 +010075#define GPIO_LED1 IMX_GPIO_NR(3, 30)
76#define GPIO_SWITCH1 IMX_GPIO_NR(3, 31)
Eric Bénard70b17262010-10-12 16:12:36 +020077
78static struct gpio_led eukrea_mbimxsd_leds[] = {
79 {
80 .name = "led1",
81 .default_trigger = "heartbeat",
82 .active_low = 1,
83 .gpio = GPIO_LED1,
84 },
85};
86
87static struct gpio_led_platform_data eukrea_mbimxsd_led_info = {
88 .leds = eukrea_mbimxsd_leds,
89 .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds),
90};
91
92static struct platform_device eukrea_mbimxsd_leds_gpio = {
93 .name = "leds-gpio",
94 .id = -1,
95 .dev = {
96 .platform_data = &eukrea_mbimxsd_led_info,
97 },
98};
99
100static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = {
101 {
102 .gpio = GPIO_SWITCH1,
103 .code = BTN_0,
104 .desc = "BP1",
105 .active_low = 1,
106 .wakeup = 1,
107 },
108};
109
Uwe Kleine-König53094982011-02-28 18:04:33 +0100110static const struct gpio_keys_platform_data
111 eukrea_mbimxsd_button_data __initconst = {
Eric Bénard70b17262010-10-12 16:12:36 +0200112 .buttons = eukrea_mbimxsd_gpio_buttons,
113 .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons),
114};
115
Eric Bénard70b17262010-10-12 16:12:36 +0200116static struct platform_device *platform_devices[] __initdata = {
117 &eukrea_mbimxsd_leds_gpio,
Eric Bénard70b17262010-10-12 16:12:36 +0200118};
119
120static const struct imxuart_platform_data uart_pdata __initconst = {
121 .flags = IMXUART_HAVE_RTSCTS,
122};
123
124static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = {
125 {
126 I2C_BOARD_INFO("tlv320aic23", 0x1a),
127 },
128};
129
130/*
131 * system init for baseboard usage. Will be called by cpuimx51sd init.
132 *
133 * Add platform devices present on this baseboard and init
134 * them from CPU side as far as required to use them later on
135 */
136void __init eukrea_mbimxsd51_baseboard_init(void)
137{
138 if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads,
139 ARRAY_SIZE(eukrea_mbimxsd_pads)))
140 printk(KERN_ERR "error setting mbimxsd pads !\n");
141
142 imx51_add_imx_uart(1, NULL);
143 imx51_add_imx_uart(2, &uart_pdata);
144
Uwe Kleine-König124bf942010-11-19 21:03:33 +0100145 imx51_add_sdhci_esdhc_imx(0, NULL);
Eric Bénard70b17262010-10-12 16:12:36 +0200146
147 gpio_request(GPIO_LED1, "LED1");
148 gpio_direction_output(GPIO_LED1, 1);
149 gpio_free(GPIO_LED1);
150
151 gpio_request(GPIO_SWITCH1, "SWITCH1");
152 gpio_direction_input(GPIO_SWITCH1);
153 gpio_free(GPIO_SWITCH1);
154
155 i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices,
156 ARRAY_SIZE(eukrea_mbimxsd_i2c_devices));
157
158 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
Uwe Kleine-König53094982011-02-28 18:04:33 +0100159 imx_add_gpio_keys(&eukrea_mbimxsd_button_data);
Eric Bénard70b17262010-10-12 16:12:36 +0200160}