blob: 46538885a58aad46e5a2d0543d582971eee89cf1 [file] [log] [blame]
eric miao2c8086a2007-09-11 19:13:17 -07001/*
2 * linux/arch/arm/mach-pxa/zylonite_pxa300.c
3 *
4 * PXA300/PXA310 specific support code for the
5 * PXA3xx Development Platform (aka Zylonite)
6 *
7 * Copyright (C) 2007 Marvell Internation Ltd.
eric miaoe9bba8e2007-10-30 08:01:38 +01008 * 2007-08-21: eric miao <eric.miao@marvell.com>
eric miao2c8086a2007-09-11 19:13:17 -07009 * initial version
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
Eric Miaoa1f7fc42008-05-28 10:44:16 +080019#include <linux/i2c.h>
20#include <linux/i2c/pca953x.h>
eric miao2c8086a2007-09-11 19:13:17 -070021
22#include <asm/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/mfp-pxa300.h>
24#include <mach/i2c.h>
25#include <mach/zylonite.h>
eric miao2c8086a2007-09-11 19:13:17 -070026
eric miao3d3934c2008-02-03 15:49:09 +080027#include "generic.h"
eric miao2c8086a2007-09-11 19:13:17 -070028
29/* PXA300/PXA310 common configurations */
30static mfp_cfg_t common_mfp_cfg[] __initdata = {
31 /* LCD */
32 GPIO54_LCD_LDD_0,
33 GPIO55_LCD_LDD_1,
34 GPIO56_LCD_LDD_2,
35 GPIO57_LCD_LDD_3,
36 GPIO58_LCD_LDD_4,
37 GPIO59_LCD_LDD_5,
38 GPIO60_LCD_LDD_6,
39 GPIO61_LCD_LDD_7,
40 GPIO62_LCD_LDD_8,
41 GPIO63_LCD_LDD_9,
42 GPIO64_LCD_LDD_10,
43 GPIO65_LCD_LDD_11,
44 GPIO66_LCD_LDD_12,
45 GPIO67_LCD_LDD_13,
46 GPIO68_LCD_LDD_14,
47 GPIO69_LCD_LDD_15,
48 GPIO70_LCD_LDD_16,
49 GPIO71_LCD_LDD_17,
50 GPIO72_LCD_FCLK,
51 GPIO73_LCD_LCLK,
52 GPIO74_LCD_PCLK,
53 GPIO75_LCD_BIAS,
54 GPIO76_LCD_VSYNC,
55 GPIO127_LCD_CS_N,
eric miao5cca9142008-04-13 21:46:34 +010056 GPIO20_PWM3_OUT, /* backlight */
eric miao2c8086a2007-09-11 19:13:17 -070057
58 /* BTUART */
59 GPIO111_UART2_RTS,
Russell Kinga10476d2008-01-08 15:25:01 +000060 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -070061 GPIO113_UART2_TXD,
Russell Kinga10476d2008-01-08 15:25:01 +000062 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
eric miao2c8086a2007-09-11 19:13:17 -070063
64 /* STUART */
65 GPIO109_UART3_TXD,
Russell Kinga10476d2008-01-08 15:25:01 +000066 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -070067
68 /* AC97 */
69 GPIO23_AC97_nACRESET,
70 GPIO24_AC97_SYSCLK,
71 GPIO29_AC97_BITCLK,
72 GPIO25_AC97_SDATA_IN_0,
73 GPIO27_AC97_SDATA_OUT,
74 GPIO28_AC97_SYNC,
75
Mark Brown58d27fc2008-07-10 17:52:10 +010076 /* SSP3 */
77 GPIO91_SSP3_SCLK,
78 GPIO92_SSP3_FRM,
79 GPIO93_SSP3_TXD,
80 GPIO94_SSP3_RXD,
81
Mark Brown768dec42008-04-15 15:50:49 +010082 /* WM9713 IRQ */
83 GPIO26_GPIO,
84
eric miao2c8086a2007-09-11 19:13:17 -070085 /* Keypad */
Russell Kinga10476d2008-01-08 15:25:01 +000086 GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
87 GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
88 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
89 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
90 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
91 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
92 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
93 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
94 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
95 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
eric miao2c8086a2007-09-11 19:13:17 -070096 GPIO121_KP_MKOUT_0,
97 GPIO122_KP_MKOUT_1,
98 GPIO123_KP_MKOUT_2,
99 GPIO124_KP_MKOUT_3,
100 GPIO125_KP_MKOUT_4,
101 GPIO4_2_KP_MKOUT_5,
102 GPIO5_2_KP_MKOUT_6,
103 GPIO6_2_KP_MKOUT_7,
Bridge Wufafc9d32007-12-21 19:00:13 +0800104
105 /* MMC1 */
106 GPIO3_MMC1_DAT0,
Russell Kinga10476d2008-01-08 15:25:01 +0000107 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
Bridge Wufafc9d32007-12-21 19:00:13 +0800108 GPIO5_MMC1_DAT2,
109 GPIO6_MMC1_DAT3,
110 GPIO7_MMC1_CLK,
111 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
112 GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
Bridge Wu8d33b052007-12-21 19:15:36 +0800113
114 /* MMC2 */
115 GPIO9_MMC2_DAT0,
Russell Kinga10476d2008-01-08 15:25:01 +0000116 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
Bridge Wu8d33b052007-12-21 19:15:36 +0800117 GPIO11_MMC2_DAT2,
118 GPIO12_MMC2_DAT3,
119 GPIO13_MMC2_CLK,
120 GPIO14_MMC2_CMD,
Eric Miaoa1f7fc42008-05-28 10:44:16 +0800121
Eric Miao7ff43532008-09-27 18:05:49 +0800122 /* USB Host */
123 GPIO0_2_USBH_PEN,
124 GPIO1_2_USBH_PWR,
125
Eric Miaoa1f7fc42008-05-28 10:44:16 +0800126 /* Standard I2C */
127 GPIO21_I2C_SCL,
128 GPIO22_I2C_SDA,
eric miao2c8086a2007-09-11 19:13:17 -0700129};
130
131static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
132 /* FFUART */
Russell Kinga10476d2008-01-08 15:25:01 +0000133 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700134 GPIO31_UART1_TXD,
135 GPIO32_UART1_CTS,
136 GPIO37_UART1_RTS,
137 GPIO33_UART1_DCD,
Russell Kinga10476d2008-01-08 15:25:01 +0000138 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700139 GPIO35_UART1_RI,
140 GPIO36_UART1_DTR,
141
142 /* Ethernet */
143 GPIO2_nCS3,
144 GPIO99_GPIO,
145};
146
147static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
148 /* FFUART */
Russell Kinga10476d2008-01-08 15:25:01 +0000149 GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700150 GPIO100_UART1_TXD,
151 GPIO101_UART1_CTS,
152 GPIO106_UART1_RTS,
153
154 /* Ethernet */
155 GPIO2_nCS3,
156 GPIO102_GPIO,
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800157
158 /* MMC3 */
159 GPIO7_2_MMC3_DAT0,
Russell Kinga10476d2008-01-08 15:25:01 +0000160 GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800161 GPIO9_2_MMC3_DAT2,
162 GPIO10_2_MMC3_DAT3,
163 GPIO103_MMC3_CLK,
164 GPIO105_MMC3_CMD,
eric miao2c8086a2007-09-11 19:13:17 -0700165};
166
167#define NUM_LCD_DETECT_PINS 7
168
169static int lcd_detect_pins[] __initdata = {
170 MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
171 MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
172 MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
173 MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
174 MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
175 MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
176 MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
177};
178
179static void __init zylonite_detect_lcd_panel(void)
180{
181 unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
182 int i, gpio, id = 0;
183
184 /* save the original MFP settings of these pins and configure
185 * them as GPIO Input, DS01X, Pull Neither, Edge Clear
186 */
187 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
188 mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
189 pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
190 }
191
192 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
193 id = id << 1;
194 gpio = mfp_to_gpio(lcd_detect_pins[i]);
195 gpio_direction_input(gpio);
196
197 if (gpio_get_value(gpio))
198 id = id | 0x1;
199 }
200
201 /* lcd id, flush out bit 1 */
202 lcd_id = id & 0x3d;
203
204 /* lcd orientation, portrait or landscape */
205 lcd_orientation = (id >> 6) & 0x1;
206
207 /* restore the original MFP settings */
208 for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
209 pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
210}
211
Eric Miaoa1f7fc42008-05-28 10:44:16 +0800212#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
213static struct pca953x_platform_data gpio_exp[] = {
214 [0] = {
215 .gpio_base = 128,
216 },
217 [1] = {
218 .gpio_base = 144,
219 },
220};
221
Mark Browna461a8d2008-08-26 10:58:54 +0100222static struct i2c_board_info zylonite_i2c_board_info[] = {
Eric Miaoa1f7fc42008-05-28 10:44:16 +0800223 {
224 .type = "pca9539",
225 .addr = 0x74,
226 .platform_data = &gpio_exp[0],
227 .irq = IRQ_GPIO(18),
228 }, {
229 .type = "pca9539",
230 .addr = 0x75,
231 .platform_data = &gpio_exp[1],
232 .irq = IRQ_GPIO(19),
233 },
234};
235
236static void __init zylonite_init_i2c(void)
237{
238 pxa_set_i2c_info(NULL);
239 i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
240}
241#else
242static inline void zylonite_init_i2c(void) {}
243#endif
244
eric miao2c8086a2007-09-11 19:13:17 -0700245void __init zylonite_pxa300_init(void)
246{
247 if (cpu_is_pxa300() || cpu_is_pxa310()) {
248 /* initialize MFP */
249 pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
250
251 /* detect LCD panel */
252 zylonite_detect_lcd_panel();
253
Bridge Wufafc9d32007-12-21 19:00:13 +0800254 /* MMC card detect & write protect for controller 0 */
255 zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0);
256 zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2);
Mark Brown768dec42008-04-15 15:50:49 +0100257
258 /* WM9713 IRQ */
259 wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26);
Eric Miaoa1f7fc42008-05-28 10:44:16 +0800260
261 zylonite_init_i2c();
eric miao2c8086a2007-09-11 19:13:17 -0700262 }
263
264 if (cpu_is_pxa300()) {
265 pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
266 gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99);
267 }
268
269 if (cpu_is_pxa310()) {
270 pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
271 gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102);
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800272
273 /* MMC card detect & write protect for controller 2 */
274 zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30);
275 zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31);
eric miao2c8086a2007-09-11 19:13:17 -0700276 }
Eric Miao5c9f50e2008-06-17 19:03:54 +0800277
278 /* GPIOs for Debug LEDs */
279 gpio_debug_led1 = EXT_GPIO(25);
280 gpio_debug_led2 = EXT_GPIO(26);
eric miao2c8086a2007-09-11 19:13:17 -0700281}