Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
zylonite_pxa320.c
Go to the documentation of this file.
1 /*
2  * linux/arch/arm/mach-pxa/zylonite_pxa320.c
3  *
4  * PXA320 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/gpio.h>
20 
21 #include <mach/pxa320.h>
22 #include <mach/zylonite.h>
23 
24 #include "generic.h"
25 
26 static mfp_cfg_t mfp_cfg[] __initdata = {
27  /* LCD */
52  GPIO14_PWM3_OUT, /* backlight */
53 
54  /* FFUART */
63 
64  /* AC97 */
71  GPIO36_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */
72 
73  /* SSP3 */
78 
79  /* WM9713 IRQ */
81 
82  /* I2C */
85 
86  /* Keypad */
105 
106  /* Ethernet */
107  GPIO4_nCS3,
108  GPIO90_GPIO,
109 
110  /* MMC1 */
116  GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
117  GPIO31_GPIO, /* CMD1 default as GPIO for slot 0 */
118 
119  /* MMC2 */
126 
127  /* USB Host */
130 
131  /* Debug LEDs */
134 };
135 
136 #define NUM_LCD_DETECT_PINS 7
137 
138 static int lcd_detect_pins[] __initdata = {
139  MFP_PIN_GPIO72, /* LCD_LDD_17 - ORIENT */
140  MFP_PIN_GPIO71, /* LCD_LDD_16 - LCDID[5] */
141  MFP_PIN_GPIO17_2, /* LCD_BIAS - LCDID[4] */
142  MFP_PIN_GPIO15_2, /* LCD_LCLK - LCDID[3] */
143  MFP_PIN_GPIO14_2, /* LCD_FCLK - LCDID[2] */
144  MFP_PIN_GPIO73, /* LCD_CS_N - LCDID[1] */
145  MFP_PIN_GPIO74, /* LCD_VSYNC - LCDID[0] */
146  /*
147  * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
148  * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
149  */
153 };
154 
155 static int lcd_detect_mfpr[] __initdata = {
156  /* AF0, DS 1X, Pull Neither, Edge Clear */
157  0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
158  0xc442, /* Backlight, Pull-Up, AF2 */
159  0x8445, /* AF5 */
160  0x8445, /* AF5 */
161 };
162 
163 static void __init zylonite_detect_lcd_panel(void)
164 {
165  unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
166  int i, gpio, id = 0;
167 
168  /* save the original MFP settings of these pins and configure them
169  * as GPIO Input, DS01X, Pull Neither, Edge Clear
170  */
171  for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
172  mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
173  pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
174  }
175 
176  for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
177  id = id << 1;
178  gpio = mfp_to_gpio(lcd_detect_pins[i]);
179  gpio_request(gpio, "LCD_ID_PINS");
180  gpio_direction_input(gpio);
181 
182  if (gpio_get_value(gpio))
183  id = id | 0x1;
184  gpio_free(gpio);
185  }
186 
187  /* lcd id, flush out bit 1 */
188  lcd_id = id & 0x3d;
189 
190  /* lcd orientation, portrait or landscape */
191  lcd_orientation = (id >> 6) & 0x1;
192 
193  /* restore the original MFP settings */
194  for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
195  pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
196 }
197 
199 {
200  if (cpu_is_pxa320()) {
201  /* initialize MFP */
202  pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
203 
204  /* detect LCD panel */
205  zylonite_detect_lcd_panel();
206 
207  /* GPIO pin assignment */
211 
212  /* WM9713 IRQ */
214  }
215 }