eukrea_mbimx51-baseboard.c 5.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 *
 * Copyright (C) 2010 Eric Bénard <eric@eukrea.com>
 *
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/serial_8250.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/fsl_devices.h>
#include <linux/i2c/tsc2007.h>
#include <linux/leds.h>
#include <linux/input/matrix_keypad.h>

#include <mach/common.h>
#include <mach/hardware.h>
#include <mach/imx-uart.h>
#include <mach/iomux-mx51.h>

#include <asm/mach/arch.h>

33
#include "devices-imx51.h"
34 35
#include "devices.h"

A
Arnaud Patard (Rtp) 已提交
36
#define MBIMX51_TSC2007_GPIO	IMX_GPIO_NR(3, 30)
37
#define MBIMX51_TSC2007_IRQ	(MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
A
Arnaud Patard (Rtp) 已提交
38 39 40 41
#define MBIMX51_LED0		IMX_GPIO_NR(3, 5)
#define MBIMX51_LED1		IMX_GPIO_NR(3, 6)
#define MBIMX51_LED2		IMX_GPIO_NR(3, 7)
#define MBIMX51_LED3		IMX_GPIO_NR(3, 8)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

static struct gpio_led mbimx51_leds[] = {
	{
		.name			= "led0",
		.default_trigger	= "heartbeat",
		.active_low		= 1,
		.gpio			= MBIMX51_LED0,
	},
	{
		.name			= "led1",
		.default_trigger	= "nand-disk",
		.active_low		= 1,
		.gpio			= MBIMX51_LED1,
	},
	{
		.name			= "led2",
		.default_trigger	= "mmc0",
		.active_low		= 1,
		.gpio			= MBIMX51_LED2,
	},
	{
		.name			= "led3",
		.default_trigger	= "default-on",
		.active_low		= 1,
		.gpio			= MBIMX51_LED3,
	},
};

static struct gpio_led_platform_data mbimx51_leds_info = {
	.leds		= mbimx51_leds,
	.num_leds	= ARRAY_SIZE(mbimx51_leds),
};

static struct platform_device mbimx51_leds_gpio = {
	.name	= "leds-gpio",
	.id	= -1,
	.dev	= {
		.platform_data	= &mbimx51_leds_info,
	},
};

static struct platform_device *devices[] __initdata = {
	&mbimx51_leds_gpio,
};

87
static iomux_v3_cfg_t mbimx51_pads[] = {
88 89 90 91 92 93 94 95 96 97 98
	/* UART2 */
	MX51_PAD_UART2_RXD__UART2_RXD,
	MX51_PAD_UART2_TXD__UART2_TXD,

	/* UART3 */
	MX51_PAD_UART3_RXD__UART3_RXD,
	MX51_PAD_UART3_TXD__UART3_TXD,
	MX51_PAD_KEY_COL4__UART3_RTS,
	MX51_PAD_KEY_COL5__UART3_CTS,

	/* TSC2007 IRQ */
S
Sascha Hauer 已提交
99
	MX51_PAD_NANDF_D10__GPIO3_30,
100 101

	/* LEDS */
S
Sascha Hauer 已提交
102 103 104 105
	MX51_PAD_DISPB2_SER_DIN__GPIO3_5,
	MX51_PAD_DISPB2_SER_DIO__GPIO3_6,
	MX51_PAD_DISPB2_SER_CLK__GPIO3_7,
	MX51_PAD_DISPB2_SER_RS__GPIO3_8,
106 107 108 109 110 111 112 113 114 115

	/* KPP */
	MX51_PAD_KEY_ROW0__KEY_ROW0,
	MX51_PAD_KEY_ROW1__KEY_ROW1,
	MX51_PAD_KEY_ROW2__KEY_ROW2,
	MX51_PAD_KEY_ROW3__KEY_ROW3,
	MX51_PAD_KEY_COL0__KEY_COL0,
	MX51_PAD_KEY_COL1__KEY_COL1,
	MX51_PAD_KEY_COL2__KEY_COL2,
	MX51_PAD_KEY_COL3__KEY_COL3,
E
Eric Bénard 已提交
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131

	/* SD 1 */
	MX51_PAD_SD1_CMD__SD1_CMD,
	MX51_PAD_SD1_CLK__SD1_CLK,
	MX51_PAD_SD1_DATA0__SD1_DATA0,
	MX51_PAD_SD1_DATA1__SD1_DATA1,
	MX51_PAD_SD1_DATA2__SD1_DATA2,
	MX51_PAD_SD1_DATA3__SD1_DATA3,

	/* SD 2 */
	MX51_PAD_SD2_CMD__SD2_CMD,
	MX51_PAD_SD2_CLK__SD2_CLK,
	MX51_PAD_SD2_DATA0__SD2_DATA0,
	MX51_PAD_SD2_DATA1__SD2_DATA1,
	MX51_PAD_SD2_DATA2__SD2_DATA2,
	MX51_PAD_SD2_DATA3__SD2_DATA3,
132 133
};

134
static const struct imxuart_platform_data uart_pdata __initconst = {
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
	.flags = IMXUART_HAVE_RTSCTS,
};

static int mbimx51_keymap[] = {
	KEY(0, 0, KEY_1),
	KEY(0, 1, KEY_2),
	KEY(0, 2, KEY_3),
	KEY(0, 3, KEY_UP),

	KEY(1, 0, KEY_4),
	KEY(1, 1, KEY_5),
	KEY(1, 2, KEY_6),
	KEY(1, 3, KEY_LEFT),

	KEY(2, 0, KEY_7),
	KEY(2, 1, KEY_8),
	KEY(2, 2, KEY_9),
	KEY(2, 3, KEY_RIGHT),

	KEY(3, 0, KEY_0),
	KEY(3, 1, KEY_DOWN),
	KEY(3, 2, KEY_ESC),
	KEY(3, 3, KEY_ENTER),
};

static struct matrix_keymap_data mbimx51_map_data = {
	.keymap		= mbimx51_keymap,
	.keymap_size	= ARRAY_SIZE(mbimx51_keymap),
};

static int tsc2007_get_pendown_state(void)
{
	return !gpio_get_value(MBIMX51_TSC2007_GPIO);
}

struct tsc2007_platform_data tsc2007_data = {
	.model = 2007,
	.x_plate_ohms = 180,
	.get_pendown_state = tsc2007_get_pendown_state,
};

static struct i2c_board_info mbimx51_i2c_devices[] = {
	{
E
Eric Bénard 已提交
178
		I2C_BOARD_INFO("tsc2007", 0x49),
179 180
		.irq  = MBIMX51_TSC2007_IRQ,
		.platform_data = &tsc2007_data,
E
Eric Bénard 已提交
181 182
	}, {
		I2C_BOARD_INFO("tlv320aic23", 0x1a),
183 184 185 186 187 188 189 190 191 192 193
	},
};

/*
 * baseboard initialization.
 */
void __init eukrea_mbimx51_baseboard_init(void)
{
	mxc_iomux_v3_setup_multiple_pads(mbimx51_pads,
					ARRAY_SIZE(mbimx51_pads));

194 195
	imx51_add_imx_uart(1, NULL);
	imx51_add_imx_uart(2, &uart_pdata);
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218

	gpio_request(MBIMX51_LED0, "LED0");
	gpio_direction_output(MBIMX51_LED0, 1);
	gpio_free(MBIMX51_LED0);
	gpio_request(MBIMX51_LED1, "LED1");
	gpio_direction_output(MBIMX51_LED1, 1);
	gpio_free(MBIMX51_LED1);
	gpio_request(MBIMX51_LED2, "LED2");
	gpio_direction_output(MBIMX51_LED2, 1);
	gpio_free(MBIMX51_LED2);
	gpio_request(MBIMX51_LED3, "LED3");
	gpio_direction_output(MBIMX51_LED3, 1);
	gpio_free(MBIMX51_LED3);

	platform_add_devices(devices, ARRAY_SIZE(devices));

	mxc_register_device(&mxc_keypad_device, &mbimx51_map_data);

	gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq");
	gpio_direction_input(MBIMX51_TSC2007_GPIO);
	set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING);
	i2c_register_board_info(1, mbimx51_i2c_devices,
				ARRAY_SIZE(mbimx51_i2c_devices));
E
Eric Bénard 已提交
219

220 221
	imx51_add_sdhci_esdhc_imx(0, NULL);
	imx51_add_sdhci_esdhc_imx(1, NULL);
222
}