Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
zylonite_pxa300.c
Go to the documentation of this file.
1 /*
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.
8  * 2007-08-21: eric miao <[email protected]>
9  * 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>
19 #include <linux/i2c.h>
20 #include <linux/i2c/pxa-i2c.h>
21 #include <linux/i2c/pca953x.h>
22 #include <linux/gpio.h>
23 
24 #include <mach/pxa300.h>
25 #include <mach/zylonite.h>
26 
27 #include "generic.h"
28 
29 /* PXA300/PXA310 common configurations */
30 static mfp_cfg_t common_mfp_cfg[] __initdata = {
31  /* LCD */
56  GPIO20_PWM3_OUT, /* backlight */
57 
58  /* BTUART */
63 
64  /* STUART */
67 
68  /* AC97 */
75  GPIO17_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */
76 
77  /* SSP3 */
82 
83  /* WM9713 IRQ */
85 
86  /* Keypad */
105 
106  /* MMC1 */
112  GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
113  GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */
114 
115  /* MMC2 */
122 
123  /* USB Host */
126 
127  /* Standard I2C */
130 
131  /* GPIO */
132  GPIO18_GPIO | MFP_PULL_HIGH, /* GPIO Expander #0 INT_N */
133  GPIO19_GPIO | MFP_PULL_HIGH, /* GPIO Expander #1 INT_N */
134 };
135 
136 static mfp_cfg_t pxa300_mfp_cfg[] __initdata = {
137  /* FFUART */
146 
147  /* Ethernet */
148  GPIO2_nCS3,
149  GPIO99_GPIO,
150 };
151 
152 static mfp_cfg_t pxa310_mfp_cfg[] __initdata = {
153  /* FFUART */
158 
159  /* Ethernet */
160  GPIO2_nCS3,
161  GPIO102_GPIO,
162 
163  /* MMC3 */
164  GPIO7_2_MMC3_DAT0,
165  GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH,
166  GPIO9_2_MMC3_DAT2,
167  GPIO10_2_MMC3_DAT3,
168  GPIO103_MMC3_CLK,
169  GPIO105_MMC3_CMD,
170 };
171 
172 #define NUM_LCD_DETECT_PINS 7
173 
174 static int lcd_detect_pins[] __initdata = {
175  MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */
176  MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */
177  MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */
178  MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */
179  MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */
180  MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */
181  MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */
182 };
183 
184 static void __init zylonite_detect_lcd_panel(void)
185 {
186  unsigned long mfpr_save[NUM_LCD_DETECT_PINS];
187  int i, gpio, id = 0;
188 
189  /* save the original MFP settings of these pins and configure
190  * them as GPIO Input, DS01X, Pull Neither, Edge Clear
191  */
192  for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
193  mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
194  pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440);
195  }
196 
197  for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
198  id = id << 1;
199  gpio = mfp_to_gpio(lcd_detect_pins[i]);
200  gpio_request(gpio, "LCD_ID_PINS");
201  gpio_direction_input(gpio);
202 
203  if (gpio_get_value(gpio))
204  id = id | 0x1;
205  gpio_free(gpio);
206  }
207 
208  /* lcd id, flush out bit 1 */
209  lcd_id = id & 0x3d;
210 
211  /* lcd orientation, portrait or landscape */
212  lcd_orientation = (id >> 6) & 0x1;
213 
214  /* restore the original MFP settings */
215  for (i = 0; i < NUM_LCD_DETECT_PINS; i++)
216  pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
217 }
218 
219 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
220 static struct pca953x_platform_data gpio_exp[] = {
221  [0] = {
222  .gpio_base = 128,
223  },
224  [1] = {
225  .gpio_base = 144,
226  },
227 };
228 
229 static struct i2c_board_info zylonite_i2c_board_info[] = {
230  {
231  .type = "pca9539",
232  .addr = 0x74,
233  .platform_data = &gpio_exp[0],
234  .irq = PXA_GPIO_TO_IRQ(18),
235  }, {
236  .type = "pca9539",
237  .addr = 0x75,
238  .platform_data = &gpio_exp[1],
239  .irq = PXA_GPIO_TO_IRQ(19),
240  },
241 };
242 
243 static void __init zylonite_init_i2c(void)
244 {
246  i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info));
247 }
248 #else
249 static inline void zylonite_init_i2c(void) {}
250 #endif
251 
253 {
254  if (cpu_is_pxa300() || cpu_is_pxa310()) {
255  /* initialize MFP */
256  pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg));
257 
258  /* detect LCD panel */
259  zylonite_detect_lcd_panel();
260 
261  /* WM9713 IRQ */
263 
264  zylonite_init_i2c();
265  }
266 
267  if (cpu_is_pxa300()) {
268  pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg));
270  }
271 
272  if (cpu_is_pxa310()) {
273  pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg));
275  }
276 
277  /* GPIOs for Debug LEDs */
280 }