1 /*
2  * Copyright (C) 2010 <LW@KARO-electronics.de>
3  *
4  * based on: mach-mx28_evk.c
5  * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
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  * version 2 as published by the Free Software Foundation
10  */
11 #include <linux/kernel.h>
12 #include <linux/gpio.h>
13 #include <linux/leds.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/spi_gpio.h>
17 #include <linux/i2c.h>
18 
19 #include <asm/mach/arch.h>
20 #include <asm/mach/time.h>
21 
22 #include <mach/common.h>
23 #include <mach/iomux-mx28.h>
24 
25 #include "devices-mx28.h"
26 #include "module-tx28.h"
27 
28 #define TX28_STK5_GPIO_LED		MXS_GPIO_NR(4, 10)
29 
30 static const iomux_cfg_t tx28_stk5v3_pads[] __initconst = {
31 	/* LED */
32 	MX28_PAD_ENET0_RXD3__GPIO_4_10 |
33 		MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_NOPULL,
34 
35 	/* framebuffer */
36 #define LCD_MODE (MXS_PAD_3V3 | MXS_PAD_4MA)
37 	MX28_PAD_LCD_D00__LCD_D0 | LCD_MODE,
38 	MX28_PAD_LCD_D01__LCD_D1 | LCD_MODE,
39 	MX28_PAD_LCD_D02__LCD_D2 | LCD_MODE,
40 	MX28_PAD_LCD_D03__LCD_D3 | LCD_MODE,
41 	MX28_PAD_LCD_D04__LCD_D4 | LCD_MODE,
42 	MX28_PAD_LCD_D05__LCD_D5 | LCD_MODE,
43 	MX28_PAD_LCD_D06__LCD_D6 | LCD_MODE,
44 	MX28_PAD_LCD_D07__LCD_D7 | LCD_MODE,
45 	MX28_PAD_LCD_D08__LCD_D8 | LCD_MODE,
46 	MX28_PAD_LCD_D09__LCD_D9 | LCD_MODE,
47 	MX28_PAD_LCD_D10__LCD_D10 | LCD_MODE,
48 	MX28_PAD_LCD_D11__LCD_D11 | LCD_MODE,
49 	MX28_PAD_LCD_D12__LCD_D12 | LCD_MODE,
50 	MX28_PAD_LCD_D13__LCD_D13 | LCD_MODE,
51 	MX28_PAD_LCD_D14__LCD_D14 | LCD_MODE,
52 	MX28_PAD_LCD_D15__LCD_D15 | LCD_MODE,
53 	MX28_PAD_LCD_D16__LCD_D16 | LCD_MODE,
54 	MX28_PAD_LCD_D17__LCD_D17 | LCD_MODE,
55 	MX28_PAD_LCD_D18__LCD_D18 | LCD_MODE,
56 	MX28_PAD_LCD_D19__LCD_D19 | LCD_MODE,
57 	MX28_PAD_LCD_D20__LCD_D20 | LCD_MODE,
58 	MX28_PAD_LCD_D21__LCD_D21 | LCD_MODE,
59 	MX28_PAD_LCD_D22__LCD_D22 | LCD_MODE,
60 	MX28_PAD_LCD_D23__LCD_D23 | LCD_MODE,
61 	MX28_PAD_LCD_RD_E__LCD_VSYNC | LCD_MODE,
62 	MX28_PAD_LCD_WR_RWN__LCD_HSYNC | LCD_MODE,
63 	MX28_PAD_LCD_RS__LCD_DOTCLK | LCD_MODE,
64 	MX28_PAD_LCD_CS__LCD_CS | LCD_MODE,
65 	MX28_PAD_LCD_VSYNC__LCD_VSYNC | LCD_MODE,
66 	MX28_PAD_LCD_HSYNC__LCD_HSYNC | LCD_MODE,
67 	MX28_PAD_LCD_DOTCLK__LCD_DOTCLK | LCD_MODE,
68 	MX28_PAD_LCD_ENABLE__GPIO_1_31 | LCD_MODE,
69 	MX28_PAD_LCD_RESET__GPIO_3_30 | LCD_MODE,
70 	MX28_PAD_PWM0__PWM_0 | LCD_MODE,
71 
72 	/* UART1 */
73 	MX28_PAD_AUART0_CTS__DUART_RX,
74 	MX28_PAD_AUART0_RTS__DUART_TX,
75 	MX28_PAD_AUART0_TX__DUART_RTS,
76 	MX28_PAD_AUART0_RX__DUART_CTS,
77 
78 	/* UART2 */
79 	MX28_PAD_AUART1_RX__AUART1_RX,
80 	MX28_PAD_AUART1_TX__AUART1_TX,
81 	MX28_PAD_AUART1_RTS__AUART1_RTS,
82 	MX28_PAD_AUART1_CTS__AUART1_CTS,
83 
84 	/* CAN */
85 	MX28_PAD_GPMI_RDY2__CAN0_TX,
86 	MX28_PAD_GPMI_RDY3__CAN0_RX,
87 
88 	/* I2C */
89 	MX28_PAD_I2C0_SCL__I2C0_SCL,
90 	MX28_PAD_I2C0_SDA__I2C0_SDA,
91 
92 	/* TSC2007 */
93 	MX28_PAD_SAIF0_MCLK__GPIO_3_20 | MXS_PAD_3V3 | MXS_PAD_4MA | MXS_PAD_PULLUP,
94 
95 	/* MMC0 */
96 	MX28_PAD_SSP0_DATA0__SSP0_D0 |
97 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
98 	MX28_PAD_SSP0_DATA1__SSP0_D1 |
99 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
100 	MX28_PAD_SSP0_DATA2__SSP0_D2 |
101 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
102 	MX28_PAD_SSP0_DATA3__SSP0_D3 |
103 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
104 	MX28_PAD_SSP0_CMD__SSP0_CMD |
105 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
106 	MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT |
107 		(MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
108 	MX28_PAD_SSP0_SCK__SSP0_SCK |
109 		(MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
110 };
111 
112 static const struct gpio_led tx28_stk5v3_leds[] __initconst = {
113 	{
114 		.name = "GPIO-LED",
115 		.default_trigger = "heartbeat",
116 		.gpio = TX28_STK5_GPIO_LED,
117 	},
118 };
119 
120 static const struct gpio_led_platform_data tx28_stk5v3_led_data __initconst = {
121 	.leds = tx28_stk5v3_leds,
122 	.num_leds = ARRAY_SIZE(tx28_stk5v3_leds),
123 };
124 
125 static struct spi_board_info tx28_spi_board_info[] = {
126 	{
127 		.modalias = "spidev",
128 		.max_speed_hz = 20000000,
129 		.bus_num = 0,
130 		.chip_select = 1,
131 		.controller_data = (void *)SPI_GPIO_NO_CHIPSELECT,
132 		.mode = SPI_MODE_0,
133 	},
134 };
135 
136 static struct i2c_board_info tx28_stk5v3_i2c_boardinfo[] __initdata = {
137 	{
138 		I2C_BOARD_INFO("ds1339", 0x68),
139 	},
140 };
141 
142 static struct mxs_mmc_platform_data tx28_mmc0_pdata __initdata = {
143        .wp_gpio = -EINVAL,
144        .flags = SLOTF_4_BIT_CAPABLE,
145 };
146 
tx28_stk5v3_init(void)147 static void __init tx28_stk5v3_init(void)
148 {
149 	mxs_iomux_setup_multiple_pads(tx28_stk5v3_pads,
150 			ARRAY_SIZE(tx28_stk5v3_pads));
151 
152 	mx28_add_duart(); /* UART1 */
153 	mx28_add_auart(1); /* UART2 */
154 
155 	tx28_add_fec0();
156 	/* spi via ssp will be added when available */
157 	spi_register_board_info(tx28_spi_board_info,
158 			ARRAY_SIZE(tx28_spi_board_info));
159 	gpio_led_register_device(0, &tx28_stk5v3_led_data);
160 	mx28_add_mxs_i2c(0);
161 	i2c_register_board_info(0, tx28_stk5v3_i2c_boardinfo,
162 			ARRAY_SIZE(tx28_stk5v3_i2c_boardinfo));
163 	mx28_add_mxs_mmc(0, &tx28_mmc0_pdata);
164 	mx28_add_rtc_stmp3xxx();
165 }
166 
tx28_timer_init(void)167 static void __init tx28_timer_init(void)
168 {
169 	mx28_clocks_init();
170 }
171 
172 static struct sys_timer tx28_timer = {
173 	.init = tx28_timer_init,
174 };
175 
176 MACHINE_START(TX28, "Ka-Ro electronics TX28 module")
177 	.map_io = mx28_map_io,
178 	.init_irq = mx28_init_irq,
179 	.timer = &tx28_timer,
180 	.init_machine = tx28_stk5v3_init,
181 	.restart	= mxs_restart,
182 MACHINE_END
183