Merge git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
[pandora-kernel.git] / arch / arm / mach-imx / mach-mx25_3ds.c
1 /*
2  * Copyright 2009 Sascha Hauer, <kernel@pengutronix.de>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA  02110-1301, USA.
17  */
18
19 /*
20  * This machine is known as:
21  *  - i.MX25 3-Stack Development System
22  *  - i.MX25 Platform Development Kit (i.MX25 PDK)
23  */
24
25 #include <linux/types.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/clk.h>
29 #include <linux/irq.h>
30 #include <linux/gpio.h>
31 #include <linux/platform_device.h>
32 #include <linux/input/matrix_keypad.h>
33 #include <linux/usb/otg.h>
34
35 #include <mach/hardware.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/time.h>
39 #include <asm/memory.h>
40 #include <asm/mach/map.h>
41 #include <mach/common.h>
42 #include <mach/mx25.h>
43 #include <mach/iomux-mx25.h>
44
45 #include "devices-imx25.h"
46
47 static const struct imxuart_platform_data uart_pdata __initconst = {
48         .flags = IMXUART_HAVE_RTSCTS,
49 };
50
51 static iomux_v3_cfg_t mx25pdk_pads[] = {
52         MX25_PAD_FEC_MDC__FEC_MDC,
53         MX25_PAD_FEC_MDIO__FEC_MDIO,
54         MX25_PAD_FEC_TDATA0__FEC_TDATA0,
55         MX25_PAD_FEC_TDATA1__FEC_TDATA1,
56         MX25_PAD_FEC_TX_EN__FEC_TX_EN,
57         MX25_PAD_FEC_RDATA0__FEC_RDATA0,
58         MX25_PAD_FEC_RDATA1__FEC_RDATA1,
59         MX25_PAD_FEC_RX_DV__FEC_RX_DV,
60         MX25_PAD_FEC_TX_CLK__FEC_TX_CLK,
61         MX25_PAD_A17__GPIO_2_3, /* FEC_EN, GPIO 35 */
62         MX25_PAD_D12__GPIO_4_8, /* FEC_RESET_B, GPIO 104 */
63
64         /* LCD */
65         MX25_PAD_LD0__LD0,
66         MX25_PAD_LD1__LD1,
67         MX25_PAD_LD2__LD2,
68         MX25_PAD_LD3__LD3,
69         MX25_PAD_LD4__LD4,
70         MX25_PAD_LD5__LD5,
71         MX25_PAD_LD6__LD6,
72         MX25_PAD_LD7__LD7,
73         MX25_PAD_LD8__LD8,
74         MX25_PAD_LD9__LD9,
75         MX25_PAD_LD10__LD10,
76         MX25_PAD_LD11__LD11,
77         MX25_PAD_LD12__LD12,
78         MX25_PAD_LD13__LD13,
79         MX25_PAD_LD14__LD14,
80         MX25_PAD_LD15__LD15,
81         MX25_PAD_GPIO_E__LD16,
82         MX25_PAD_GPIO_F__LD17,
83         MX25_PAD_HSYNC__HSYNC,
84         MX25_PAD_VSYNC__VSYNC,
85         MX25_PAD_LSCLK__LSCLK,
86         MX25_PAD_OE_ACD__OE_ACD,
87         MX25_PAD_CONTRAST__CONTRAST,
88
89         /* Keypad */
90         MX25_PAD_KPP_ROW0__KPP_ROW0,
91         MX25_PAD_KPP_ROW1__KPP_ROW1,
92         MX25_PAD_KPP_ROW2__KPP_ROW2,
93         MX25_PAD_KPP_ROW3__KPP_ROW3,
94         MX25_PAD_KPP_COL0__KPP_COL0,
95         MX25_PAD_KPP_COL1__KPP_COL1,
96         MX25_PAD_KPP_COL2__KPP_COL2,
97         MX25_PAD_KPP_COL3__KPP_COL3,
98
99         /* SD1 */
100         MX25_PAD_SD1_CMD__SD1_CMD,
101         MX25_PAD_SD1_CLK__SD1_CLK,
102         MX25_PAD_SD1_DATA0__SD1_DATA0,
103         MX25_PAD_SD1_DATA1__SD1_DATA1,
104         MX25_PAD_SD1_DATA2__SD1_DATA2,
105         MX25_PAD_SD1_DATA3__SD1_DATA3,
106
107         /* I2C1 */
108         MX25_PAD_I2C1_CLK__I2C1_CLK,
109         MX25_PAD_I2C1_DAT__I2C1_DAT,
110 };
111
112 static const struct fec_platform_data mx25_fec_pdata __initconst = {
113         .phy    = PHY_INTERFACE_MODE_RMII,
114 };
115
116 #define FEC_ENABLE_GPIO         IMX_GPIO_NR(2, 3)
117 #define FEC_RESET_B_GPIO        IMX_GPIO_NR(4, 8)
118
119 static void __init mx25pdk_fec_reset(void)
120 {
121         gpio_request(FEC_ENABLE_GPIO, "FEC PHY enable");
122         gpio_request(FEC_RESET_B_GPIO, "FEC PHY reset");
123
124         gpio_direction_output(FEC_ENABLE_GPIO, 0);  /* drop PHY power */
125         gpio_direction_output(FEC_RESET_B_GPIO, 0); /* assert reset */
126         udelay(2);
127
128         /* turn on PHY power and lift reset */
129         gpio_set_value(FEC_ENABLE_GPIO, 1);
130         gpio_set_value(FEC_RESET_B_GPIO, 1);
131 }
132
133 static const struct mxc_nand_platform_data
134 mx25pdk_nand_board_info __initconst = {
135         .width          = 1,
136         .hw_ecc         = 1,
137         .flash_bbt      = 1,
138 };
139
140 static struct imx_fb_videomode mx25pdk_modes[] = {
141         {
142                 .mode   = {
143                         .name           = "CRT-VGA",
144                         .refresh        = 60,
145                         .xres           = 640,
146                         .yres           = 480,
147                         .pixclock       = 39683,
148                         .left_margin    = 45,
149                         .right_margin   = 114,
150                         .upper_margin   = 33,
151                         .lower_margin   = 11,
152                         .hsync_len      = 1,
153                         .vsync_len      = 1,
154                 },
155                 .bpp    = 16,
156                 .pcr    = 0xFA208B80,
157         },
158 };
159
160 static const struct imx_fb_platform_data mx25pdk_fb_pdata __initconst = {
161         .mode           = mx25pdk_modes,
162         .num_modes      = ARRAY_SIZE(mx25pdk_modes),
163         .pwmr           = 0x00A903FF,
164         .lscr1          = 0x00120300,
165         .dmacr          = 0x00020010,
166 };
167
168 static const uint32_t mx25pdk_keymap[] = {
169         KEY(0, 0, KEY_UP),
170         KEY(0, 1, KEY_DOWN),
171         KEY(0, 2, KEY_VOLUMEDOWN),
172         KEY(0, 3, KEY_HOME),
173         KEY(1, 0, KEY_RIGHT),
174         KEY(1, 1, KEY_LEFT),
175         KEY(1, 2, KEY_ENTER),
176         KEY(1, 3, KEY_VOLUMEUP),
177         KEY(2, 0, KEY_F6),
178         KEY(2, 1, KEY_F8),
179         KEY(2, 2, KEY_F9),
180         KEY(2, 3, KEY_F10),
181         KEY(3, 0, KEY_F1),
182         KEY(3, 1, KEY_F2),
183         KEY(3, 2, KEY_F3),
184         KEY(3, 3, KEY_POWER),
185 };
186
187 static const struct matrix_keymap_data mx25pdk_keymap_data __initconst = {
188         .keymap         = mx25pdk_keymap,
189         .keymap_size    = ARRAY_SIZE(mx25pdk_keymap),
190 };
191
192 static int mx25pdk_usbh2_init(struct platform_device *pdev)
193 {
194         return mx25_initialize_usb_hw(pdev->id, MXC_EHCI_INTERNAL_PHY);
195 }
196
197 static const struct mxc_usbh_platform_data usbh2_pdata __initconst = {
198         .init   = mx25pdk_usbh2_init,
199         .portsc = MXC_EHCI_MODE_SERIAL,
200 };
201
202 static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
203         .operating_mode = FSL_USB2_DR_DEVICE,
204         .phy_mode       = FSL_USB2_PHY_UTMI,
205 };
206
207 static const struct imxi2c_platform_data mx25_3ds_i2c0_data __initconst = {
208         .bitrate = 100000,
209 };
210
211 static void __init mx25pdk_init(void)
212 {
213         mxc_iomux_v3_setup_multiple_pads(mx25pdk_pads,
214                         ARRAY_SIZE(mx25pdk_pads));
215
216         imx25_add_imx_uart0(&uart_pdata);
217         imx25_add_fsl_usb2_udc(&otg_device_pdata);
218         imx25_add_mxc_ehci_hs(&usbh2_pdata);
219         imx25_add_mxc_nand(&mx25pdk_nand_board_info);
220         imx25_add_imxdi_rtc(NULL);
221         imx25_add_imx_fb(&mx25pdk_fb_pdata);
222         imx25_add_imx2_wdt(NULL);
223
224         mx25pdk_fec_reset();
225         imx25_add_fec(&mx25_fec_pdata);
226         imx25_add_imx_keypad(&mx25pdk_keymap_data);
227
228         imx25_add_sdhci_esdhc_imx(0, NULL);
229         imx25_add_imx_i2c0(&mx25_3ds_i2c0_data);
230 }
231
232 static void __init mx25pdk_timer_init(void)
233 {
234         mx25_clocks_init();
235 }
236
237 static struct sys_timer mx25pdk_timer = {
238         .init   = mx25pdk_timer_init,
239 };
240
241 MACHINE_START(MX25_3DS, "Freescale MX25PDK (3DS)")
242         /* Maintainer: Freescale Semiconductor, Inc. */
243         .boot_params = MX25_PHYS_OFFSET + 0x100,
244         .map_io = mx25_map_io,
245         .init_early = imx25_init_early,
246         .init_irq = mx25_init_irq,
247         .timer = &mx25pdk_timer,
248         .init_machine = mx25pdk_init,
249 MACHINE_END